1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-28 06:40:26 +08:00

fix route

This commit is contained in:
fumiama
2021-12-30 17:24:51 +08:00
parent cd060c7b92
commit f2d80f5f4d
3 changed files with 9 additions and 9 deletions

View File

@@ -23,12 +23,7 @@ func (m *Me) AddPeer(peerip string, pubicKey *[32]byte, endPoint string, allowed
peerip: net.ParseIP(peerip),
allowtrans: allowTrans,
me: m,
router: &Router{
list: make([]*net.IPNet, 1, 16),
table: make(map[string]*Link, 16),
},
}
l.router.SetDefault(l)
if !nopipe {
l.pipe = make(chan *head.Packet, 32)
@@ -54,12 +49,12 @@ 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.router.SetItem(cidr, l)
} 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()