Merge from remote branch

This commit is contained in:
yaling888
2021-09-01 00:38:43 +08:00
38 changed files with 583 additions and 272 deletions

View File

@ -16,11 +16,13 @@ type fallbackIPFilter interface {
Match(net.IP) bool
}
type geoipFilter struct{}
type geoipFilter struct {
code string
}
func (gf *geoipFilter) Match(ip net.IP) bool {
if multiGeoIPMatcher == nil {
countryCodeCN := "cn"
countryCodeCN := gf.code
countryCodePrivate := "private"
geoLoader, err := geodata.GetGeoDataLoader("standard")
if err != nil {

View File

@ -302,9 +302,10 @@ type NameServer struct {
}
type FallbackFilter struct {
GeoIP bool
IPCIDR []*net.IPNet
Domain []string
GeoIP bool
GeoIPCode string
IPCIDR []*net.IPNet
Domain []string
}
type Config struct {
@ -344,7 +345,9 @@ func NewResolver(config Config) *Resolver {
fallbackIPFilters := []fallbackIPFilter{}
if config.FallbackFilter.GeoIP {
fallbackIPFilters = append(fallbackIPFilters, &geoipFilter{})
fallbackIPFilters = append(fallbackIPFilters, &geoipFilter{
code: config.FallbackFilter.GeoIPCode,
})
}
for _, ipnet := range config.FallbackFilter.IPCIDR {
fallbackIPFilters = append(fallbackIPFilters, &ipnetFilter{ipnet: ipnet})