Chore: embed the RuleExtra into Base

This commit is contained in:
yaling888
2022-03-13 01:21:23 +08:00
parent 8fbf93ccc8
commit 46b9a1092d
47 changed files with 1995 additions and 471 deletions

View File

@ -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)