chore: using uint16 for ports in Metadata
This commit is contained in:
@ -2,7 +2,6 @@ package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/Dreamacro/clash/common/utils"
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
@ -28,7 +27,7 @@ func (p *Port) Match(metadata *C.Metadata) (bool, string) {
|
||||
case C.SrcPort:
|
||||
targetPort = metadata.SrcPort
|
||||
}
|
||||
return p.matchPortReal(targetPort), p.adapter
|
||||
return p.portRanges.Check(targetPort), p.adapter
|
||||
}
|
||||
|
||||
func (p *Port) Adapter() string {
|
||||
@ -39,12 +38,6 @@ func (p *Port) Payload() string {
|
||||
return p.port
|
||||
}
|
||||
|
||||
func (p *Port) matchPortReal(portRef string) bool {
|
||||
port, _ := strconv.Atoi(portRef)
|
||||
|
||||
return p.portRanges.Check(uint16(port))
|
||||
}
|
||||
|
||||
func NewPort(port string, adapter string, ruleType C.RuleType) (*Port, error) {
|
||||
portRanges, err := utils.NewIntRanges[uint16](port)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user