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