Skip to content

Commit

Permalink
Fix for GeodataMode
Browse files Browse the repository at this point in the history
  • Loading branch information
hamjin committed Feb 26, 2024
1 parent 088fdb2 commit ca36080
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion dns/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type geoipFilter struct {
}

var geoIPMatcher *router.GeoIPMatcher
var geoIPMatcherPrivate *router.GeoIPMatcher

func (gf *geoipFilter) Match(ip netip.Addr) bool {
if !C.GeodataMode {
Expand All @@ -42,7 +43,15 @@ func (gf *geoipFilter) Match(ip netip.Addr) bool {
return false
}
}
return !geoIPMatcher.Match(ip)

if geoIPMatcherPrivate == nil {
var err error
geoIPMatcherPrivate, _, err = geodata.LoadGeoIPMatcher("private")
if err != nil {
return false
}
}
return !geoIPMatcher.Match(ip) && !geoIPMatcherPrivate.Match(ip)
}

type ipnetFilter struct {
Expand Down

0 comments on commit ca36080

Please sign in to comment.