mirror of
https://github.com/fumiama/WireGold.git
synced 2026-06-20 02:16:17 +08:00
feat(route): support x grammar
This commit is contained in:
@@ -81,6 +81,16 @@ func (m *Me) AddPeer(cfg *PeerConfig) (l *Link) {
|
||||
if cfg.AllowedIPs != nil {
|
||||
l.allowedips = make([]*net.IPNet, 0, len(cfg.AllowedIPs))
|
||||
for _, ipnet := range cfg.AllowedIPs {
|
||||
if len(ipnet) == 0 {
|
||||
continue
|
||||
}
|
||||
noroute := ipnet[0] == 'x'
|
||||
if noroute {
|
||||
ipnet = ipnet[1:]
|
||||
if len(ipnet) == 0 {
|
||||
continue
|
||||
}
|
||||
}
|
||||
_, cidr, err := net.ParseCIDR(ipnet)
|
||||
if err == nil {
|
||||
l.allowedips = append(l.allowedips, cidr)
|
||||
|
||||
@@ -81,7 +81,7 @@ func (r *Router) SetItem(ip *net.IPNet, l *Link) {
|
||||
if r.list[i].Contains(ip.IP) {
|
||||
// 是同一个网络
|
||||
if ip.Mask.String() == r.list[i].Mask.String() {
|
||||
logrus.Infoln("[router] change link of item", r.list[i], "from", r.table[r.list[i].String()], "to", l)
|
||||
logrus.Warnln("[router] change link of item", r.list[i], "from", r.table[r.list[i].String()], "to", l)
|
||||
r.table[r.list[i].String()] = l
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user