Avoid sending unnecessairy udp key packets, and try config peers less often

This commit is contained in:
Arceliar 2018-01-02 18:45:09 -06:00
parent c3e236b7fb
commit 82fd435211
2 changed files with 8 additions and 4 deletions

View file

@ -262,9 +262,12 @@ func (c *Core) DEBUG_getGlobalUDPAddr() net.Addr {
return c.udp.sock.LocalAddr()
}
func (c *Core) DEBUG_sendUDPKeys(saddr string) {
func (c *Core) DEBUG_maybeSendUDPKeys(saddr string) {
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) }
}
////////////////////////////////////////////////////////////////////////////////