mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 12:42:27 +08:00
Chore: make geoip match case-insensitive (#1574)
This commit is contained in:
parent
e0d3f926b7
commit
a20b9a3960
@ -2,6 +2,7 @@ package dns
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/Dreamacro/clash/component/mmdb"
|
"github.com/Dreamacro/clash/component/mmdb"
|
||||||
"github.com/Dreamacro/clash/component/trie"
|
"github.com/Dreamacro/clash/component/trie"
|
||||||
@ -17,7 +18,7 @@ type geoipFilter struct {
|
|||||||
|
|
||||||
func (gf *geoipFilter) Match(ip net.IP) bool {
|
func (gf *geoipFilter) Match(ip net.IP) bool {
|
||||||
record, _ := mmdb.Instance().Country(ip)
|
record, _ := mmdb.Instance().Country(ip)
|
||||||
return record.Country.IsoCode != gf.code && !ip.IsPrivate()
|
return !strings.EqualFold(record.Country.IsoCode, gf.code) && !ip.IsPrivate()
|
||||||
}
|
}
|
||||||
|
|
||||||
type ipnetFilter struct {
|
type ipnetFilter struct {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package rules
|
package rules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/Dreamacro/clash/component/mmdb"
|
"github.com/Dreamacro/clash/component/mmdb"
|
||||||
C "github.com/Dreamacro/clash/constant"
|
C "github.com/Dreamacro/clash/constant"
|
||||||
)
|
)
|
||||||
@ -21,11 +23,11 @@ func (g *GEOIP) Match(metadata *C.Metadata) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if g.country == "LAN" {
|
if strings.EqualFold(g.country, "LAN") {
|
||||||
return ip.IsPrivate()
|
return ip.IsPrivate()
|
||||||
}
|
}
|
||||||
record, _ := mmdb.Instance().Country(ip)
|
record, _ := mmdb.Instance().Country(ip)
|
||||||
return record.Country.IsoCode == g.country
|
return strings.EqualFold(record.Country.IsoCode, g.country)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GEOIP) Adapter() string {
|
func (g *GEOIP) Adapter() string {
|
||||||
|
Loading…
Reference in New Issue
Block a user