fix: ensure no overlap for localCIDRs

This commit is contained in:
SunBK201 2025-12-11 18:57:51 +08:00
parent 241cc6a743
commit bcee4f2c8b

View File

@ -380,13 +380,31 @@ func initLanCidrs() {
}
}
LAN_CIDRS = updatedCIDRs
// Add local CIDRs if not already covered by existing CIDRs
localCIDRs, err := getLocalIPv4CIDRs()
if err == nil {
for _, localCIDR := range localCIDRs {
localIP, _, err := net.ParseCIDR(localCIDR)
if err != nil {
return
continue
}
LAN_CIDRS = append(LAN_CIDRS, localCIDRs...)
covered := false
for i, lanNet := range lanRanges {
if _, ok := remove[i]; ok {
continue
}
if lanNet.Contains(localIP) {
covered = true
break
}
}
if !covered {
updatedCIDRs = append(updatedCIDRs, localCIDR)
}
}
}
LAN_CIDRS = updatedCIDRs
}
func GetLanDevice() (string, error) {