update to latest phony, adjust interface use accordingly

This commit is contained in:
Arceliar 2019-08-27 19:43:54 -05:00
parent 4d9c6342a7
commit 3845f81357
14 changed files with 80 additions and 76 deletions

View file

@ -27,7 +27,7 @@ type tunConn struct {
}
func (s *tunConn) close() {
s.tun.RecvFrom(s, s._close_from_tun)
s.tun.Act(s, s._close_from_tun)
}
func (s *tunConn) _close_from_tun() {
@ -117,7 +117,7 @@ func (s *tunConn) _read(bs []byte) (err error) {
}
func (s *tunConn) writeFrom(from phony.Actor, bs []byte) {
s.RecvFrom(from, func() {
s.Act(from, func() {
s._write(bs)
})
}
@ -197,7 +197,7 @@ func (s *tunConn) _write(bs []byte) (err error) {
// No point in wasting resources to send back an error if there was none
return
}
s.RecvFrom(s.conn, func() {
s.Act(s.conn, func() {
if e, eok := err.(yggdrasil.ConnError); !eok {
if e.Closed() {
s.tun.log.Debugln(s.conn.String(), "TUN/TAP generic write debug:", err)

View file

@ -19,7 +19,7 @@ type tunWriter struct {
}
func (w *tunWriter) writeFrom(from phony.Actor, b []byte) {
w.RecvFrom(from, func() {
w.Act(from, func() {
w._write(b)
})
}
@ -90,7 +90,7 @@ func (w *tunWriter) _write(b []byte) {
util.PutBytes(b)
}
if err != nil {
w.tun.RecvFrom(w, func() {
w.tun.Act(w, func() {
if !w.tun.isOpen {
w.tun.log.Errorln("TUN/TAP iface write error:", err)
}
@ -118,12 +118,12 @@ func (r *tunReader) _read() {
}
if err == nil {
// Now read again
r.RecvFrom(nil, r._read)
r.Act(nil, r._read)
}
}
func (tun *TunAdapter) handlePacketFrom(from phony.Actor, packet []byte, err error) {
tun.RecvFrom(from, func() {
tun.Act(from, func() {
tun._handlePacket(packet, err)
})
}
@ -248,7 +248,7 @@ func (tun *TunAdapter) _handlePacket(recvd []byte, err error) {
if !known {
go func() {
conn, err := tun.dialer.DialByNodeIDandMask(dstNodeID, dstNodeIDMask)
tun.RecvFrom(nil, func() {
tun.Act(nil, func() {
packets := tun.dials[*dstNodeID]
delete(tun.dials, *dstNodeID)
if err != nil {

View file

@ -125,7 +125,7 @@ func (tun *TunAdapter) Init(config *config.NodeState, log *log.Logger, listener
// reader actor to handle packets on that interface.
func (tun *TunAdapter) Start() error {
var err error
<-tun.SyncExec(func() {
phony.Block(tun, func() {
err = tun._start()
})
return err
@ -167,7 +167,7 @@ func (tun *TunAdapter) _start() error {
}
}()
go tun.handler()
tun.reader.RecvFrom(nil, tun.reader._read) // Start the reader
tun.reader.Act(nil, tun.reader._read) // Start the reader
tun.icmpv6.Init(tun)
if iftapmode {
go tun.icmpv6.Solicit(tun.addr)
@ -180,7 +180,7 @@ func (tun *TunAdapter) _start() error {
// read/write goroutines to handle packets on that interface.
func (tun *TunAdapter) Stop() error {
var err error
<-tun.SyncExec(func() {
phony.Block(tun, func() {
err = tun._stop()
})
return err
@ -233,7 +233,7 @@ func (tun *TunAdapter) handler() error {
tun.log.Errorln("TUN/TAP connection accept error:", err)
return err
}
<-tun.SyncExec(func() {
phony.Block(tun, func() {
if _, err := tun._wrap(conn); err != nil {
// Something went wrong when storing the connection, typically that
// something already exists for this address or subnet
@ -273,11 +273,11 @@ func (tun *TunAdapter) _wrap(conn *yggdrasil.Conn) (c *tunConn, err error) {
tun.subnetToConn[s.snet] = &s
// Set the read callback and start the timeout
conn.SetReadCallback(func(bs []byte) {
s.RecvFrom(conn, func() {
s.Act(conn, func() {
s._read(bs)
})
})
s.RecvFrom(nil, s.stillAlive)
s.Act(nil, s.stillAlive)
// Return
return c, err
}