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

move router into link

This commit is contained in:
fumiama
2021-12-30 16:50:12 +08:00
parent 54303f8ab2
commit 0c3aa357d0
4 changed files with 12 additions and 12 deletions

View File

@@ -23,7 +23,13 @@ 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)
}
@@ -48,7 +54,7 @@ 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.router.SetItem(cidr, l)
} else {
panic(err)
}