Revert "Merge branch 'main' into hosts"

This reverts commit e329d6e249, reversing
changes made to 253cd99122.
This commit is contained in:
patterniha 2025-05-07 23:30:31 +03:30
parent e329d6e249
commit 43fec0dcd3
13 changed files with 288 additions and 892 deletions

View file

@ -116,29 +116,3 @@ func (c *GeoIPMatcherContainer) Add(geoip *GeoIP) (*GeoIPMatcher, error) {
}
var GlobalGeoIPContainer GeoIPMatcherContainer
func MatchIPs(matchers []*GeoIPMatcher, ips []net.IP, reverse bool) []net.IP {
if len(matchers) == 0 {
panic("GeoIP matchers should not be empty to avoid ambiguity")
}
newIPs := make([]net.IP, 0, len(ips))
var isFound bool
for _, ip := range ips {
isFound = false
for _, matcher := range matchers {
if matcher.Match(ip) {
isFound = true
break
}
}
if isFound && !reverse {
newIPs = append(newIPs, ip)
continue
}
if !isFound && reverse {
newIPs = append(newIPs, ip)
continue
}
}
return newIPs
}