diff --git a/src/tuntap/conn.go b/src/tuntap/conn.go index ae8fcc0b..50860f36 100644 --- a/src/tuntap/conn.go +++ b/src/tuntap/conn.go @@ -41,7 +41,12 @@ func (s *tunConn) reader() error { select { case <-read: if n > 0 { - s.tun.send <- append(util.GetBytes(), b[:n]...) + bs := append(util.GetBytes(), b[:n]...) + select { + case s.tun.send <- bs: + default: + util.PutBytes(bs) + } } case <-s.stop: s.tun.log.Debugln("Stopping conn reader for", s) diff --git a/src/tuntap/iface.go b/src/tuntap/iface.go index 5b8e77bb..efccd071 100644 --- a/src/tuntap/iface.go +++ b/src/tuntap/iface.go @@ -190,7 +190,11 @@ func (tun *TunAdapter) reader() error { if !isIn || session == nil { // Neither an address nor a subnet mapping matched, therefore populate // the node ID and mask to commence a search - dstNodeID, dstNodeIDMask = dstAddr.GetNodeIDandMask() + if dstAddr.IsValid() { + dstNodeID, dstNodeIDMask = dstAddr.GetNodeIDandMask() + } else { + dstNodeID, dstNodeIDMask = dstSnet.GetNodeIDandMask() + } } } tun.mutex.RUnlock() diff --git a/src/yggdrasil/debug.go b/src/yggdrasil/debug.go index e575b72d..c4eed639 100644 --- a/src/yggdrasil/debug.go +++ b/src/yggdrasil/debug.go @@ -59,13 +59,17 @@ func (c *Core) Init() { hbpriv := hex.EncodeToString(bpriv[:]) hspub := hex.EncodeToString(spub[:]) hspriv := hex.EncodeToString(spriv[:]) - c.config = config.NodeConfig{ + cfg := config.NodeConfig{ EncryptionPublicKey: hbpub, EncryptionPrivateKey: hbpriv, SigningPublicKey: hspub, SigningPrivateKey: hspriv, } - c.init( /*bpub, bpriv, spub, spriv*/ ) + c.config = config.NodeState{ + Current: cfg, + Previous: cfg, + } + c.init() c.switchTable.start() c.router.start() } @@ -82,6 +86,7 @@ func (c *Core) DEBUG_getEncryptionPublicKey() crypto.BoxPubKey { return (crypto.BoxPubKey)(c.boxPub) } +/* func (c *Core) DEBUG_getSend() chan<- []byte { return c.router.tun.send } @@ -89,6 +94,7 @@ func (c *Core) DEBUG_getSend() chan<- []byte { func (c *Core) DEBUG_getRecv() <-chan []byte { return c.router.tun.recv } +*/ // Peer @@ -317,6 +323,7 @@ func (c *Core) DEBUG_getAddr() *address.Address { return address.AddrForNodeID(&c.dht.nodeID) } +/* func (c *Core) DEBUG_startTun(ifname string, iftapmode bool) { c.DEBUG_startTunWithMTU(ifname, iftapmode, 1280) } @@ -338,6 +345,7 @@ func (c *Core) DEBUG_startTunWithMTU(ifname string, iftapmode bool, mtu int) { func (c *Core) DEBUG_stopTun() { c.router.tun.close() } +*/ //////////////////////////////////////////////////////////////////////////////// @@ -382,13 +390,17 @@ func (c *Core) DEBUG_init(bpub []byte, hbpriv := hex.EncodeToString(bpriv[:]) hspub := hex.EncodeToString(spub[:]) hspriv := hex.EncodeToString(spriv[:]) - c.config = config.NodeConfig{ + cfg := config.NodeConfig{ EncryptionPublicKey: hbpub, EncryptionPrivateKey: hbpriv, SigningPublicKey: hspub, SigningPrivateKey: hspriv, } - c.init( /*bpub, bpriv, spub, spriv*/ ) + c.config = config.NodeState{ + Current: cfg, + Previous: cfg, + } + c.init() if err := c.router.start(); err != nil { panic(err) @@ -455,7 +467,7 @@ func (c *Core) DEBUG_addSOCKSConn(socksaddr, peeraddr string) { } */ -//* +/* func (c *Core) DEBUG_setupAndStartGlobalTCPInterface(addrport string) { c.config.Listen = []string{addrport} if err := c.link.init(c); err != nil { @@ -503,10 +515,11 @@ func (c *Core) DEBUG_addKCPConn(saddr string) { //////////////////////////////////////////////////////////////////////////////// +/* func (c *Core) DEBUG_setupAndStartAdminInterface(addrport string) { a := admin{} c.config.AdminListen = addrport - a.init(c /*, addrport*/) + a.init() c.admin = a } @@ -516,6 +529,7 @@ func (c *Core) DEBUG_setupAndStartMulticastInterface() { c.multicast = m m.start() } +*/ //////////////////////////////////////////////////////////////////////////////// @@ -579,9 +593,11 @@ func DEBUG_simLinkPeers(p, q *peer) { q.core.switchTable.idleIn <- q.port } +/* func (c *Core) DEBUG_simFixMTU() { c.router.tun.mtu = 65535 } +*/ ////////////////////////////////////////////////////////////////////////////////