fix: geoip mmdb/geodata init
This commit is contained in:
@ -6,7 +6,6 @@ import (
|
||||
|
||||
var (
|
||||
errPayload = errors.New("payloadRule error")
|
||||
initFlag bool
|
||||
noResolve = "no-resolve"
|
||||
)
|
||||
|
||||
|
@ -71,6 +71,11 @@ func (g *GEOIP) GetRecodeSize() int {
|
||||
}
|
||||
|
||||
func NewGEOIP(country string, adapter string, noResolveIP bool) (*GEOIP, error) {
|
||||
if err := geodata.InitGeoIP(); err != nil {
|
||||
log.Errorln("can't initial GeoIP: %s", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !C.GeodataMode || strings.EqualFold(country, "LAN") {
|
||||
geoip := &GEOIP{
|
||||
Base: &Base{},
|
||||
|
@ -50,12 +50,9 @@ func (gs *GEOSITE) GetRecodeSize() int {
|
||||
}
|
||||
|
||||
func NewGEOSITE(country string, adapter string) (*GEOSITE, error) {
|
||||
if !initFlag {
|
||||
if err := geodata.InitGeoSite(); err != nil {
|
||||
log.Errorln("can't initial GeoSite: %s", err)
|
||||
return nil, err
|
||||
}
|
||||
initFlag = true
|
||||
if err := geodata.InitGeoSite(); err != nil {
|
||||
log.Errorln("can't initial GeoSite: %s", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
matcher, size, err := geodata.LoadGeoSiteMatcher(country)
|
||||
@ -76,4 +73,4 @@ func NewGEOSITE(country string, adapter string) (*GEOSITE, error) {
|
||||
return geoSite, nil
|
||||
}
|
||||
|
||||
//var _ C.Rule = (*GEOSITE)(nil)
|
||||
var _ C.Rule = (*GEOSITE)(nil)
|
||||
|
Reference in New Issue
Block a user