router_test.go 593 B

123456789101112131415161718192021222324
  1. package rules_test
  2. import (
  3. "testing"
  4. . "github.com/v2ray/v2ray-core/app/router/rules"
  5. v2net "github.com/v2ray/v2ray-core/common/net"
  6. v2testing "github.com/v2ray/v2ray-core/testing"
  7. "github.com/v2ray/v2ray-core/testing/assert"
  8. )
  9. func TestSimpleRouter(t *testing.T) {
  10. v2testing.Current(t)
  11. router := NewRouter().AddRule(
  12. &Rule{
  13. Tag: "test",
  14. Condition: NewNetworkMatcher(v2net.Network("tcp").AsList()),
  15. })
  16. tag, err := router.TakeDetour(v2net.TCPDestination(v2net.DomainAddress("v2ray.com"), 80))
  17. assert.Error(err).IsNil()
  18. assert.StringLiteral(tag).Equals("test")
  19. }