Chore: embed the RuleExtra into Base
This commit is contained in:
@ -11,10 +11,10 @@ import (
|
||||
)
|
||||
|
||||
type GEOSITE struct {
|
||||
country string
|
||||
adapter string
|
||||
ruleExtra *C.RuleExtra
|
||||
matcher *router.DomainMatcher
|
||||
*Base
|
||||
country string
|
||||
adapter string
|
||||
matcher *router.DomainMatcher
|
||||
}
|
||||
|
||||
func (gs *GEOSITE) RuleType() C.RuleType {
|
||||
@ -42,15 +42,11 @@ func (gs *GEOSITE) ShouldResolveIP() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (gs *GEOSITE) RuleExtra() *C.RuleExtra {
|
||||
return gs.ruleExtra
|
||||
}
|
||||
|
||||
func (gs *GEOSITE) GetDomainMatcher() *router.DomainMatcher {
|
||||
return gs.matcher
|
||||
}
|
||||
|
||||
func NewGEOSITE(country string, adapter string, ruleExtra *C.RuleExtra) (*GEOSITE, error) {
|
||||
func NewGEOSITE(country string, adapter string) (*GEOSITE, error) {
|
||||
matcher, recordsCount, err := geodata.LoadGeoSiteMatcher(country)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("load GeoSite data error, %s", err.Error())
|
||||
@ -59,11 +55,13 @@ func NewGEOSITE(country string, adapter string, ruleExtra *C.RuleExtra) (*GEOSIT
|
||||
log.Infoln("Start initial GeoSite rule %s => %s, records: %d", country, adapter, recordsCount)
|
||||
|
||||
geoSite := &GEOSITE{
|
||||
country: country,
|
||||
adapter: adapter,
|
||||
ruleExtra: ruleExtra,
|
||||
matcher: matcher,
|
||||
Base: &Base{},
|
||||
country: country,
|
||||
adapter: adapter,
|
||||
matcher: matcher,
|
||||
}
|
||||
|
||||
return geoSite, nil
|
||||
}
|
||||
|
||||
var _ C.Rule = (*GEOSITE)(nil)
|
||||
|
Reference in New Issue
Block a user