mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-01 16:18:24 +00:00
move port out of address
This commit is contained in:
@@ -24,7 +24,7 @@ func TestRouter(t *testing.T) {
|
||||
router, err := CreateRouter(pointConfig.RouterConfig().Strategy(), pointConfig.RouterConfig().Settings())
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
dest := v2net.NewTCPDestination(v2net.IPAddress(net.ParseIP("120.135.126.1"), 80))
|
||||
dest := v2net.TCPDestination(v2net.IPAddress(net.ParseIP("120.135.126.1")), 80)
|
||||
tag, err := router.TakeDetour(dest)
|
||||
assert.Error(err).IsNil()
|
||||
assert.StringLiteral(tag).Equals("direct")
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func makeDestination(ip string) v2net.Destination {
|
||||
return v2net.NewTCPDestination(v2net.IPAddress(net.ParseIP(ip), 80))
|
||||
return v2net.TCPDestination(v2net.IPAddress(net.ParseIP(ip)), 80)
|
||||
}
|
||||
|
||||
func TestChinaIP(t *testing.T) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func makeDomainDestination(domain string) v2net.Destination {
|
||||
return v2net.NewTCPDestination(v2net.DomainAddress(domain, 80))
|
||||
return v2net.TCPDestination(v2net.DomainAddress(domain), 80)
|
||||
}
|
||||
|
||||
func TestChinaSites(t *testing.T) {
|
||||
|
||||
@@ -121,7 +121,7 @@ func (this *FieldRule) Apply(dest v2net.Destination) bool {
|
||||
}
|
||||
|
||||
if this.Port != nil {
|
||||
port := address.Port()
|
||||
port := dest.Port()
|
||||
if port.Value() < this.Port.From().Value() || port.Value() > this.Port.To().Value() {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func TestDomainMatching(t *testing.T) {
|
||||
"tag": "test"
|
||||
}`
|
||||
rule := parseRule([]byte(rawJson))
|
||||
dest := v2net.NewTCPDestination(v2net.DomainAddress("www.v2ray.com", 80))
|
||||
dest := v2net.TCPDestination(v2net.DomainAddress("www.v2ray.com"), 80)
|
||||
assert.Bool(rule.Apply(dest)).IsTrue()
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func TestPortMatching(t *testing.T) {
|
||||
ToValue: 100,
|
||||
},
|
||||
}
|
||||
dest := v2net.NewTCPDestination(v2net.DomainAddress("www.v2ray.com", 80))
|
||||
dest := v2net.TCPDestination(v2net.DomainAddress("www.v2ray.com"), 80)
|
||||
assert.Bool(rule.Apply(dest)).IsTrue()
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func TestIPMatching(t *testing.T) {
|
||||
"tag": "test"
|
||||
}`
|
||||
rule := parseRule([]byte(rawJson))
|
||||
dest := v2net.NewTCPDestination(v2net.IPAddress([]byte{10, 0, 0, 1}, 80))
|
||||
dest := v2net.TCPDestination(v2net.IPAddress([]byte{10, 0, 0, 1}), 80)
|
||||
assert.Bool(rule.Apply(dest)).IsTrue()
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ func TestIPListMatching(t *testing.T) {
|
||||
"tag": "test"
|
||||
}`
|
||||
rule := parseRule([]byte(rawJson))
|
||||
dest := v2net.NewTCPDestination(v2net.IPAddress([]byte{192, 168, 1, 1}, 80))
|
||||
dest := v2net.TCPDestination(v2net.IPAddress([]byte{192, 168, 1, 1}), 80)
|
||||
assert.Bool(rule.Apply(dest)).IsTrue()
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ func TestPortNotMatching(t *testing.T) {
|
||||
"tag": "test"
|
||||
}`
|
||||
rule := parseRule([]byte(rawJson))
|
||||
dest := v2net.NewTCPDestination(v2net.IPAddress([]byte{10, 0, 0, 1}, 79))
|
||||
dest := v2net.TCPDestination(v2net.IPAddress([]byte{10, 0, 0, 1}), 79)
|
||||
assert.Bool(rule.Apply(dest)).IsFalse()
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ func TestDomainNotMatching(t *testing.T) {
|
||||
"tag": "test"
|
||||
}`
|
||||
rule := parseRule([]byte(rawJson))
|
||||
dest := v2net.NewTCPDestination(v2net.IPAddress([]byte{10, 0, 0, 1}, 80))
|
||||
dest := v2net.TCPDestination(v2net.IPAddress([]byte{10, 0, 0, 1}), 80)
|
||||
assert.Bool(rule.Apply(dest)).IsFalse()
|
||||
}
|
||||
|
||||
@@ -117,9 +117,9 @@ func TestDomainNotMatchingDomain(t *testing.T) {
|
||||
"tag": "test"
|
||||
}`
|
||||
rule := parseRule([]byte(rawJson))
|
||||
dest := v2net.NewTCPDestination(v2net.DomainAddress("baidu.com", 80))
|
||||
dest := v2net.TCPDestination(v2net.DomainAddress("baidu.com"), 80)
|
||||
assert.Bool(rule.Apply(dest)).IsFalse()
|
||||
|
||||
dest = v2net.NewTCPDestination(v2net.DomainAddress("www.google.com", 80))
|
||||
dest = v2net.TCPDestination(v2net.DomainAddress("www.google.com"), 80)
|
||||
assert.Bool(rule.Apply(dest)).IsTrue()
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ func TestSimpleRouter(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
tag, err := router.TakeDetour(v2net.NewTCPDestination(v2net.DomainAddress("v2ray.com", 80)))
|
||||
tag, err := router.TakeDetour(v2net.TCPDestination(v2net.DomainAddress("v2ray.com"), 80))
|
||||
assert.Error(err).IsNil()
|
||||
assert.StringLiteral(tag).Equals("test")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user