mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-01 00:16:26 +00:00
simplify port range
This commit is contained in:
@@ -82,7 +82,7 @@ type FieldRule struct {
|
||||
Rule
|
||||
Domain []DomainMatcher
|
||||
IP []*net.IPNet
|
||||
Port v2net.PortRange
|
||||
Port *v2net.PortRange
|
||||
Network v2net.NetworkList
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ func (this *FieldRule) Apply(dest v2net.Destination) bool {
|
||||
|
||||
if this.Port != nil {
|
||||
port := dest.Port()
|
||||
if port.Value() < this.Port.From().Value() || port.Value() > this.Port.To().Value() {
|
||||
if port.Value() < this.Port.From.Value() || port.Value() > this.Port.To.Value() {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ func (this *FieldRule) UnmarshalJSON(data []byte) error {
|
||||
Rule
|
||||
Domain *StringList `json:"domain"`
|
||||
IP *StringList `json:"ip"`
|
||||
Port *v2netjson.PortRange `json:"port"`
|
||||
Port *v2net.PortRange `json:"port"`
|
||||
Network *v2netjson.NetworkList `json:"network"`
|
||||
}
|
||||
rawFieldRule := RawFieldRule{}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"testing"
|
||||
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
v2nettesting "github.com/v2ray/v2ray-core/common/net/testing"
|
||||
v2testing "github.com/v2ray/v2ray-core/testing"
|
||||
"github.com/v2ray/v2ray-core/testing/assert"
|
||||
)
|
||||
@@ -47,9 +46,9 @@ func TestPortMatching(t *testing.T) {
|
||||
v2testing.Current(t)
|
||||
|
||||
rule := &FieldRule{
|
||||
Port: &v2nettesting.PortRange{
|
||||
FromValue: 0,
|
||||
ToValue: 100,
|
||||
Port: &v2net.PortRange{
|
||||
From: 0,
|
||||
To: 100,
|
||||
},
|
||||
}
|
||||
dest := v2net.TCPDestination(v2net.DomainAddress("www.v2ray.com"), 80)
|
||||
|
||||
Reference in New Issue
Block a user