mirror of
https://github.com/SunBK201/UA3F.git
synced 2025-12-16 16:57:08 +00:00
fix: ensure no overlap for localCIDRs
This commit is contained in:
parent
241cc6a743
commit
bcee4f2c8b
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user