1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-27 14:20:27 +08:00

fix router

This commit is contained in:
fumiama
2022-01-01 15:45:18 +08:00
parent 08d5d74fb5
commit 96d1720c1f
5 changed files with 30 additions and 31 deletions

View File

@@ -49,15 +49,15 @@ func (m *Me) AddPeer(peerip string, pubicKey *[32]byte, endPoint string, allowed
_, cidr, err := net.ParseCIDR(ipnet)
if err == nil {
l.allowedips = append(l.allowedips, cidr)
l.me.router.SetItem(cidr, l)
l.me.connmapmu.Lock()
l.me.connections[peerip] = l
l.me.connmapmu.Unlock()
} else {
panic(err)
}
}
}
l.me.router.SetItem(&net.IPNet{IP: l.peerip, Mask: net.IPMask(net.IPv4bcast)}, l)
l.me.connmapmu.Lock()
l.me.connections[peerip] = l
l.me.connmapmu.Unlock()
logrus.Infoln("[peer] add peer:", peerip, "allow:", allowedIPs)
go l.keepAlive()
return