mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
675 B
30 lines
675 B
9 years ago
|
package rules
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/v2ray/v2ray-core/app/router/rules/config"
|
||
|
testinconfig "github.com/v2ray/v2ray-core/app/router/rules/config/testing"
|
||
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
||
|
"github.com/v2ray/v2ray-core/testing/unit"
|
||
|
)
|
||
|
|
||
|
func TestSimpleRouter(t *testing.T) {
|
||
|
assert := unit.Assert(t)
|
||
|
|
||
|
router := &Router{
|
||
|
rules: []config.Rule{
|
||
|
&testinconfig.TestRule{
|
||
|
TagValue: "test",
|
||
|
Function: func(dest v2net.Destination) bool {
|
||
|
return dest.IsTCP()
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
}
|
||
|
|
||
|
tag, err := router.TakeDetour(v2net.NewTCPDestination(v2net.DomainAddress("v2ray.com", 80)))
|
||
|
assert.Error(err).IsNil()
|
||
|
assert.String(tag).Equals("test")
|
||
|
}
|