chore: remove AddrType on Metadata

This commit is contained in:
wwqgtxx
2022-11-11 09:19:28 +08:00
parent 698d8ca701
commit 6dadc2357a
16 changed files with 60 additions and 116 deletions

View File

@ -19,9 +19,6 @@ func (d *Domain) RuleType() C.RuleType {
}
func (d *Domain) Match(metadata *C.Metadata) (bool, string) {
if metadata.AddrType != C.AtypDomainName {
return false, ""
}
return metadata.Host == d.domain, d.adapter
}

View File

@ -19,9 +19,6 @@ func (dk *DomainKeyword) RuleType() C.RuleType {
}
func (dk *DomainKeyword) Match(metadata *C.Metadata) (bool, string) {
if metadata.AddrType != C.AtypDomainName {
return false, ""
}
domain := metadata.Host
return strings.Contains(domain, dk.keyword), dk.adapter
}

View File

@ -19,9 +19,6 @@ func (ds *DomainSuffix) RuleType() C.RuleType {
}
func (ds *DomainSuffix) Match(metadata *C.Metadata) (bool, string) {
if metadata.AddrType != C.AtypDomainName {
return false, ""
}
domain := metadata.Host
return strings.HasSuffix(domain, "."+ds.suffix) || domain == ds.suffix, ds.adapter
}

View File

@ -24,10 +24,6 @@ func (gs *GEOSITE) RuleType() C.RuleType {
}
func (gs *GEOSITE) Match(metadata *C.Metadata) (bool, string) {
if metadata.AddrType != C.AtypDomainName {
return false, ""
}
domain := metadata.Host
return gs.matcher.ApplyDomain(domain), gs.adapter
}

View File

@ -73,10 +73,9 @@ func TestAND(t *testing.T) {
assert.Equal(t, "DIRECT", and.adapter)
assert.Equal(t, false, and.ShouldResolveIP())
m, _ := and.Match(&C.Metadata{
Host: "baidu.com",
AddrType: C.AtypDomainName,
NetWork: C.TCP,
DstPort: "20000",
Host: "baidu.com",
NetWork: C.TCP,
DstPort: "20000",
})
assert.Equal(t, true, m)