Feature: add no-resolve for ip rules (#375)

This commit is contained in:
Fndroid
2019-10-28 00:02:23 +08:00
committed by Dreamacro
parent 207371aeae
commit 82a8c03953
12 changed files with 137 additions and 50 deletions

View File

@ -19,7 +19,7 @@ func (p *Port) RuleType() C.RuleType {
return C.DstPort
}
func (p *Port) IsMatch(metadata *C.Metadata) bool {
func (p *Port) Match(metadata *C.Metadata) bool {
if p.isSource {
return metadata.SrcPort == p.port
}
@ -34,14 +34,18 @@ func (p *Port) Payload() string {
return p.port
}
func NewPort(port string, adapter string, isSource bool) *Port {
func (p *Port) NoResolveIP() bool {
return false
}
func NewPort(port string, adapter string, isSource bool) (*Port, error) {
_, err := strconv.Atoi(port)
if err != nil {
return nil
return nil, errPayload
}
return &Port{
adapter: adapter,
port: port,
isSource: isSource,
}
}, nil
}