mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-26 20:01:38 +00:00
use the subnet derived ID/mask when creating a connection based on a subnet address, fix a potential blocking channel send in tuntap/conn.go, and get debug.go compiling well enough to profile things (the sim is currently still broken)
This commit is contained in:
parent
efdaea1b5e
commit
522ed147b1
@ -41,7 +41,12 @@ func (s *tunConn) reader() error {
|
|||||||
select {
|
select {
|
||||||
case <-read:
|
case <-read:
|
||||||
if n > 0 {
|
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:
|
case <-s.stop:
|
||||||
s.tun.log.Debugln("Stopping conn reader for", s)
|
s.tun.log.Debugln("Stopping conn reader for", s)
|
||||||
|
@ -190,7 +190,11 @@ func (tun *TunAdapter) reader() error {
|
|||||||
if !isIn || session == nil {
|
if !isIn || session == nil {
|
||||||
// Neither an address nor a subnet mapping matched, therefore populate
|
// Neither an address nor a subnet mapping matched, therefore populate
|
||||||
// the node ID and mask to commence a search
|
// 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()
|
tun.mutex.RUnlock()
|
||||||
|
@ -59,13 +59,17 @@ func (c *Core) Init() {
|
|||||||
hbpriv := hex.EncodeToString(bpriv[:])
|
hbpriv := hex.EncodeToString(bpriv[:])
|
||||||
hspub := hex.EncodeToString(spub[:])
|
hspub := hex.EncodeToString(spub[:])
|
||||||
hspriv := hex.EncodeToString(spriv[:])
|
hspriv := hex.EncodeToString(spriv[:])
|
||||||
c.config = config.NodeConfig{
|
cfg := config.NodeConfig{
|
||||||
EncryptionPublicKey: hbpub,
|
EncryptionPublicKey: hbpub,
|
||||||
EncryptionPrivateKey: hbpriv,
|
EncryptionPrivateKey: hbpriv,
|
||||||
SigningPublicKey: hspub,
|
SigningPublicKey: hspub,
|
||||||
SigningPrivateKey: hspriv,
|
SigningPrivateKey: hspriv,
|
||||||
}
|
}
|
||||||
c.init( /*bpub, bpriv, spub, spriv*/ )
|
c.config = config.NodeState{
|
||||||
|
Current: cfg,
|
||||||
|
Previous: cfg,
|
||||||
|
}
|
||||||
|
c.init()
|
||||||
c.switchTable.start()
|
c.switchTable.start()
|
||||||
c.router.start()
|
c.router.start()
|
||||||
}
|
}
|
||||||
@ -82,6 +86,7 @@ func (c *Core) DEBUG_getEncryptionPublicKey() crypto.BoxPubKey {
|
|||||||
return (crypto.BoxPubKey)(c.boxPub)
|
return (crypto.BoxPubKey)(c.boxPub)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func (c *Core) DEBUG_getSend() chan<- []byte {
|
func (c *Core) DEBUG_getSend() chan<- []byte {
|
||||||
return c.router.tun.send
|
return c.router.tun.send
|
||||||
}
|
}
|
||||||
@ -89,6 +94,7 @@ func (c *Core) DEBUG_getSend() chan<- []byte {
|
|||||||
func (c *Core) DEBUG_getRecv() <-chan []byte {
|
func (c *Core) DEBUG_getRecv() <-chan []byte {
|
||||||
return c.router.tun.recv
|
return c.router.tun.recv
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Peer
|
// Peer
|
||||||
|
|
||||||
@ -317,6 +323,7 @@ func (c *Core) DEBUG_getAddr() *address.Address {
|
|||||||
return address.AddrForNodeID(&c.dht.nodeID)
|
return address.AddrForNodeID(&c.dht.nodeID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func (c *Core) DEBUG_startTun(ifname string, iftapmode bool) {
|
func (c *Core) DEBUG_startTun(ifname string, iftapmode bool) {
|
||||||
c.DEBUG_startTunWithMTU(ifname, iftapmode, 1280)
|
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() {
|
func (c *Core) DEBUG_stopTun() {
|
||||||
c.router.tun.close()
|
c.router.tun.close()
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -382,13 +390,17 @@ func (c *Core) DEBUG_init(bpub []byte,
|
|||||||
hbpriv := hex.EncodeToString(bpriv[:])
|
hbpriv := hex.EncodeToString(bpriv[:])
|
||||||
hspub := hex.EncodeToString(spub[:])
|
hspub := hex.EncodeToString(spub[:])
|
||||||
hspriv := hex.EncodeToString(spriv[:])
|
hspriv := hex.EncodeToString(spriv[:])
|
||||||
c.config = config.NodeConfig{
|
cfg := config.NodeConfig{
|
||||||
EncryptionPublicKey: hbpub,
|
EncryptionPublicKey: hbpub,
|
||||||
EncryptionPrivateKey: hbpriv,
|
EncryptionPrivateKey: hbpriv,
|
||||||
SigningPublicKey: hspub,
|
SigningPublicKey: hspub,
|
||||||
SigningPrivateKey: hspriv,
|
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 {
|
if err := c.router.start(); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -455,7 +467,7 @@ func (c *Core) DEBUG_addSOCKSConn(socksaddr, peeraddr string) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//*
|
/*
|
||||||
func (c *Core) DEBUG_setupAndStartGlobalTCPInterface(addrport string) {
|
func (c *Core) DEBUG_setupAndStartGlobalTCPInterface(addrport string) {
|
||||||
c.config.Listen = []string{addrport}
|
c.config.Listen = []string{addrport}
|
||||||
if err := c.link.init(c); err != nil {
|
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) {
|
func (c *Core) DEBUG_setupAndStartAdminInterface(addrport string) {
|
||||||
a := admin{}
|
a := admin{}
|
||||||
c.config.AdminListen = addrport
|
c.config.AdminListen = addrport
|
||||||
a.init(c /*, addrport*/)
|
a.init()
|
||||||
c.admin = a
|
c.admin = a
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -516,6 +529,7 @@ func (c *Core) DEBUG_setupAndStartMulticastInterface() {
|
|||||||
c.multicast = m
|
c.multicast = m
|
||||||
m.start()
|
m.start()
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -579,9 +593,11 @@ func DEBUG_simLinkPeers(p, q *peer) {
|
|||||||
q.core.switchTable.idleIn <- q.port
|
q.core.switchTable.idleIn <- q.port
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func (c *Core) DEBUG_simFixMTU() {
|
func (c *Core) DEBUG_simFixMTU() {
|
||||||
c.router.tun.mtu = 65535
|
c.router.tun.mtu = 65535
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user