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

feat(route): support x grammar

This commit is contained in:
源文雨
2024-07-13 01:56:02 +09:00
parent 03021e5d69
commit af3aa02105
3 changed files with 35 additions and 24 deletions

View File

@@ -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)