This commit is contained in:
MetaCubeX
2022-03-17 23:24:07 +08:00
parent 30f1b29257
commit 435bee0ca2
37 changed files with 329 additions and 727 deletions

View File

@ -30,6 +30,10 @@ func (b *Base) ShouldFindProcess() bool {
return false
}
func (b *Base) ShouldResolveIP() bool {
return false
}
func HasNoResolve(params []string) bool {
for _, p := range params {
if p == noResolve {

View File

@ -31,14 +31,6 @@ func (d *Domain) Payload() string {
return d.domain
}
func (d *Domain) ShouldResolveIP() bool {
return false
}
func (d *Domain) ShouldFindProcess() bool {
return false
}
func NewDomain(domain string, adapter string) *Domain {
return &Domain{
Base: &Base{},

View File

@ -32,14 +32,6 @@ func (dk *DomainKeyword) Payload() string {
return dk.keyword
}
func (dk *DomainKeyword) ShouldResolveIP() bool {
return false
}
func (dk *DomainKeyword) ShouldFindProcess() bool {
return false
}
func NewDomainKeyword(keyword string, adapter string) *DomainKeyword {
return &DomainKeyword{
Base: &Base{},

View File

@ -32,14 +32,6 @@ func (ds *DomainSuffix) Payload() string {
return ds.suffix
}
func (ds *DomainSuffix) ShouldResolveIP() bool {
return false
}
func (ds *DomainSuffix) ShouldFindProcess() bool {
return false
}
func NewDomainSuffix(suffix string, adapter string) *DomainSuffix {
return &DomainSuffix{
Base: &Base{},

View File

@ -25,14 +25,6 @@ func (f *Match) Payload() string {
return ""
}
func (f *Match) ShouldResolveIP() bool {
return false
}
func (f *Match) ShouldFindProcess() bool {
return false
}
func NewMatch(adapter string) *Match {
return &Match{
Base: &Base{},

View File

@ -14,16 +14,12 @@ import (
type GEOIP struct {
*Base
country string
adapter string
noResolveIP bool
country string
adapter string
noResolveIP bool
geoIPMatcher *router.GeoIPMatcher
}
func (g *GEOIP) ShouldFindProcess() bool {
return false
}
func (g *GEOIP) RuleType() C.RuleType {
return C.GEOIP
}
@ -87,7 +83,7 @@ func NewGEOIP(country string, adapter string, noResolveIP bool) (*GEOIP, error)
log.Infoln("Start initial GeoIP rule %s => %s, records: %d", country, adapter, recordsCount)
geoip := &GEOIP{
Base: &Base{},
Base: &Base{},
country: country,
adapter: adapter,
noResolveIP: noResolveIP,

View File

@ -40,19 +40,11 @@ func (gs *GEOSITE) Payload() string {
return gs.country
}
func (gs *GEOSITE) ShouldResolveIP() bool {
return false
}
func (gs *GEOSITE) ShouldFindProcess() bool {
return false
}
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())

View File

@ -55,10 +55,6 @@ func (i *IPCIDR) ShouldResolveIP() bool {
return !i.noResolveIP
}
func (i *IPCIDR) ShouldFindProcess() bool {
return false
}
func NewIPCIDR(s string, adapter string, opts ...IPCIDROption) (*IPCIDR, error) {
_, ipnet, err := net.ParseCIDR(s)
if err != nil {

View File

@ -7,14 +7,11 @@ import (
)
type NetworkType struct {
*Base
network C.NetWork
adapter string
}
func (n *NetworkType) ShouldFindProcess() bool {
return false
}
func NewNetworkType(network, adapter string) (*NetworkType, error) {
ntType := new(NetworkType)
ntType.adapter = adapter
@ -47,11 +44,3 @@ func (n *NetworkType) Adapter() string {
func (n *NetworkType) Payload() string {
return n.network.String()
}
func (n *NetworkType) ShouldResolveIP() bool {
return false
}
func (n *NetworkType) RuleExtra() *C.RuleExtra {
return nil
}

View File

@ -21,10 +21,6 @@ type Port struct {
portList []portReal
}
func (p *Port) ShouldFindProcess() bool {
return false
}
func (p *Port) RuleType() C.RuleType {
if p.isSource {
return C.SrcPort
@ -47,10 +43,6 @@ func (p *Port) Payload() string {
return p.port
}
func (p *Port) ShouldResolveIP() bool {
return false
}
func (p *Port) matchPortReal(portRef string) bool {
port, _ := strconv.Atoi(portRef)
var rs bool

View File

@ -14,14 +14,10 @@ import (
var processCache = cache.NewLRUCache(cache.WithAge(2), cache.WithSize(64))
type Process struct {
adapter string
process string
nameOnly bool
ruleExtra *C.RuleExtra
}
func (ps *Process) ShouldFindProcess() bool {
return false
*Base
adapter string
process string
nameOnly bool
}
func (ps *Process) RuleType() C.RuleType {
@ -67,19 +63,11 @@ func (ps *Process) Payload() string {
return ps.process
}
func (ps *Process) ShouldResolveIP() bool {
return false
}
func (ps *Process) RuleExtra() *C.RuleExtra {
return ps.ruleExtra
}
func NewProcess(process string, adapter string, nameOnly bool, ruleExtra *C.RuleExtra) (*Process, error) {
func NewProcess(process string, adapter string, nameOnly bool) (*Process, error) {
return &Process{
adapter: adapter,
process: process,
nameOnly: nameOnly,
ruleExtra: ruleExtra,
Base: &Base{},
adapter: adapter,
process: process,
nameOnly: nameOnly,
}, nil
}