Feature: add geoip-code option

This commit is contained in:
Dreamacro
2021-08-25 15:15:13 +08:00
parent 121bc910f6
commit e0d3f926b7
4 changed files with 27 additions and 17 deletions

View File

@ -11,11 +11,13 @@ type fallbackIPFilter interface {
Match(net.IP) bool
}
type geoipFilter struct{}
type geoipFilter struct {
code string
}
func (gf *geoipFilter) Match(ip net.IP) bool {
record, _ := mmdb.Instance().Country(ip)
return record.Country.IsoCode != "CN" && !ip.IsPrivate()
return record.Country.IsoCode != gf.code && !ip.IsPrivate()
}
type ipnetFilter struct {