1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-08 09:36:24 +08:00

fix allowed ips error

This commit is contained in:
fumiama
2021-12-30 15:36:27 +08:00
parent f91507fe6a
commit 561392dc0d
2 changed files with 5 additions and 2 deletions

View File

@@ -77,13 +77,16 @@ func (l *Link) Write(p *head.Packet) (n int, err error) {
p.Data = l.Encode(p.Data)
d := p.Marshal(l.me.me)
if d == nil {
return 0, errors.New("ttl exceeded")
return 0, errors.New("[link] ttl exceeded")
}
logrus.Debugln("[link] write", len(d), "bytes data")
if err == nil {
peerlink := l.me.router.NextHop(l.peerip.String() + "/32")
if peerlink != nil {
peerep := peerlink.endpoint
if peerep == nil {
return 0, errors.New("[link] nil endpoint of " + l.peerip.String())
}
logrus.Infoln("[link] write data from ep", l.me.myconn.LocalAddr(), "to", peerep)
n, err = l.me.myconn.WriteToUDP(d, peerep)
} else {

View File

@@ -43,7 +43,7 @@ func (m *Me) AddPeer(peerip string, pubicKey *[32]byte, endPoint string, allowed
l.endpoint = e
}
if allowedIPs != nil {
l.allowedips = make([]*net.IPNet, len(allowedIPs))
l.allowedips = make([]*net.IPNet, 0, len(allowedIPs))
for _, ipnet := range allowedIPs {
_, cidr, err := net.ParseCIDR(ipnet)
if err == nil {