1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-19 10:26:10 -04:00
v2fly/app/router/rules/router_test.go

30 lines
651 B
Go
Raw Normal View History

2015-12-07 16:47:47 -05:00
package rules_test
import (
"testing"
2015-12-07 16:47:47 -05:00
. "github.com/v2ray/v2ray-core/app/router/rules"
v2net "github.com/v2ray/v2ray-core/common/net"
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
)
func TestSimpleRouter(t *testing.T) {
v2testing.Current(t)
2016-02-01 17:21:54 -05:00
config := &RouterRuleConfig{
Rules: []*Rule{
&Rule{
Tag: "test",
Condition: NewNetworkMatcher(v2net.Network("tcp").AsList()),
},
},
}
router := NewRouter(config)
2015-12-16 17:53:38 -05:00
tag, err := router.TakeDetour(v2net.TCPDestination(v2net.DomainAddress("v2ray.com"), 80))
assert.Error(err).IsNil()
2015-12-02 10:41:19 -05:00
assert.StringLiteral(tag).Equals("test")
}