mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-09 23:20:28 +00:00
Avoid sending unnecessairy udp key packets, and try config peers less often
This commit is contained in:
parent
c3e236b7fb
commit
82fd435211
@ -262,9 +262,12 @@ func (c *Core) DEBUG_getGlobalUDPAddr() net.Addr {
|
|||||||
return c.udp.sock.LocalAddr()
|
return c.udp.sock.LocalAddr()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Core) DEBUG_sendUDPKeys(saddr string) {
|
func (c *Core) DEBUG_maybeSendUDPKeys(saddr string) {
|
||||||
addr := connAddr(saddr)
|
addr := connAddr(saddr)
|
||||||
c.udp.sendKeys(addr)
|
c.udp.mutex.RLock()
|
||||||
|
_, isIn := c.udp.conns[connAddr(addr)]
|
||||||
|
c.udp.mutex.RUnlock()
|
||||||
|
if !isIn { c.udp.sendKeys(addr) }
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -60,9 +60,10 @@ func (n *node) init(cfg *nodeConfig, logger *log.Logger) {
|
|||||||
if len(cfg.Peers) == 0 { return }
|
if len(cfg.Peers) == 0 { return }
|
||||||
for {
|
for {
|
||||||
for _, p := range cfg.Peers {
|
for _, p := range cfg.Peers {
|
||||||
n.core.DEBUG_sendUDPKeys(p)
|
n.core.DEBUG_maybeSendUDPKeys(p)
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
}
|
}
|
||||||
|
time.Sleep(time.Minute)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
@ -112,7 +113,7 @@ func (n *node) listen() {
|
|||||||
saddr := addr.String()
|
saddr := addr.String()
|
||||||
//if _, isIn := n.peers[saddr]; isIn { continue }
|
//if _, isIn := n.peers[saddr]; isIn { continue }
|
||||||
//n.peers[saddr] = struct{}{}
|
//n.peers[saddr] = struct{}{}
|
||||||
n.core.DEBUG_sendUDPKeys(saddr)
|
n.core.DEBUG_maybeSendUDPKeys(saddr)
|
||||||
//fmt.Println("DEBUG:", "added multicast peer:", saddr)
|
//fmt.Println("DEBUG:", "added multicast peer:", saddr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user