mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 03:32:33 +08:00
fix: GeoIP side-load
This commit is contained in:
parent
a551d7ebd9
commit
ebe33cff18
|
@ -54,7 +54,7 @@ func Verify() bool {
|
||||||
return err == nil
|
return err == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DefaultInstance() Reader {
|
func Instance() Reader {
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
mmdbPath := C.Path.MMDB()
|
mmdbPath := C.Path.MMDB()
|
||||||
log.Debugln("Load MMDB file: %s", mmdbPath)
|
log.Debugln("Load MMDB file: %s", mmdbPath)
|
||||||
|
|
|
@ -2,30 +2,19 @@ package mmdb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
C "github.com/Dreamacro/clash/constant"
|
C "github.com/Dreamacro/clash/constant"
|
||||||
"github.com/Dreamacro/clash/log"
|
|
||||||
"github.com/oschwald/geoip2-golang"
|
|
||||||
"github.com/oschwald/maxminddb-golang"
|
"github.com/oschwald/maxminddb-golang"
|
||||||
)
|
)
|
||||||
|
|
||||||
var overrideMmdb *geoip2.Reader
|
func InstallOverride(override *maxminddb.Reader) {
|
||||||
|
newReader := Reader{Reader: override}
|
||||||
func InstallOverride(override *geoip2.Reader) {
|
switch override.Metadata.DatabaseType {
|
||||||
overrideMmdb = overrideMmdb
|
case "sing-geoip":
|
||||||
}
|
|
||||||
|
|
||||||
func Instance() Reader {
|
|
||||||
once.Do(func() {
|
|
||||||
mmdb, err := maxminddb.Open(C.Path.MMDB())
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalln("Can't load mmdb: %s", err.Error())
|
|
||||||
}
|
|
||||||
reader = Reader{Reader: mmdb}
|
|
||||||
if mmdb.Metadata.DatabaseType == "sing-geoip" {
|
|
||||||
reader.databaseType = typeSing
|
reader.databaseType = typeSing
|
||||||
} else {
|
case "Meta-geoip0":
|
||||||
|
reader.databaseType = typeMetaV0
|
||||||
|
default:
|
||||||
reader.databaseType = typeMaxmind
|
reader.databaseType = typeMaxmind
|
||||||
}
|
}
|
||||||
})
|
reader = newReader
|
||||||
|
|
||||||
return reader
|
|
||||||
}
|
}
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -29,7 +29,6 @@ require (
|
||||||
github.com/miekg/dns v1.1.56
|
github.com/miekg/dns v1.1.56
|
||||||
github.com/mroth/weightedrand/v2 v2.1.0
|
github.com/mroth/weightedrand/v2 v2.1.0
|
||||||
github.com/openacid/low v0.1.21
|
github.com/openacid/low v0.1.21
|
||||||
github.com/oschwald/geoip2-golang v1.9.0
|
|
||||||
github.com/oschwald/maxminddb-golang v1.12.0
|
github.com/oschwald/maxminddb-golang v1.12.0
|
||||||
github.com/puzpuzpuz/xsync/v2 v2.5.1
|
github.com/puzpuzpuz/xsync/v2 v2.5.1
|
||||||
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97
|
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -127,8 +127,6 @@ github.com/openacid/low v0.1.21 h1:Tr2GNu4N/+rGRYdOsEHOE89cxUIaDViZbVmKz29uKGo=
|
||||||
github.com/openacid/low v0.1.21/go.mod h1:q+MsKI6Pz2xsCkzV4BLj7NR5M4EX0sGz5AqotpZDVh0=
|
github.com/openacid/low v0.1.21/go.mod h1:q+MsKI6Pz2xsCkzV4BLj7NR5M4EX0sGz5AqotpZDVh0=
|
||||||
github.com/openacid/must v0.1.3/go.mod h1:luPiXCuJlEo3UUFQngVQokV0MPGryeYvtCbQPs3U1+I=
|
github.com/openacid/must v0.1.3/go.mod h1:luPiXCuJlEo3UUFQngVQokV0MPGryeYvtCbQPs3U1+I=
|
||||||
github.com/openacid/testkeys v0.1.6/go.mod h1:MfA7cACzBpbiwekivj8StqX0WIRmqlMsci1c37CA3Do=
|
github.com/openacid/testkeys v0.1.6/go.mod h1:MfA7cACzBpbiwekivj8StqX0WIRmqlMsci1c37CA3Do=
|
||||||
github.com/oschwald/geoip2-golang v1.9.0 h1:uvD3O6fXAXs+usU+UGExshpdP13GAqp4GBrzN7IgKZc=
|
|
||||||
github.com/oschwald/geoip2-golang v1.9.0/go.mod h1:BHK6TvDyATVQhKNbQBdrj9eAvuwOMi2zSFXizL3K81Y=
|
|
||||||
github.com/oschwald/maxminddb-golang v1.12.0 h1:9FnTOD0YOhP7DGxGsq4glzpGy5+w7pq50AS6wALUMYs=
|
github.com/oschwald/maxminddb-golang v1.12.0 h1:9FnTOD0YOhP7DGxGsq4glzpGy5+w7pq50AS6wALUMYs=
|
||||||
github.com/oschwald/maxminddb-golang v1.12.0/go.mod h1:q0Nob5lTCqyQ8WT6FYgS1L7PXKVVbgiymefNwIjPzgY=
|
github.com/oschwald/maxminddb-golang v1.12.0/go.mod h1:q0Nob5lTCqyQ8WT6FYgS1L7PXKVVbgiymefNwIjPzgY=
|
||||||
github.com/pierrec/lz4/v4 v4.1.14 h1:+fL8AQEZtz/ijeNnpduH0bROTu0O3NZAlPjQxGn8LwE=
|
github.com/pierrec/lz4/v4 v4.1.14 h1:+fL8AQEZtz/ijeNnpduH0bROTu0O3NZAlPjQxGn8LwE=
|
||||||
|
|
Loading…
Reference in New Issue
Block a user