router_config_test.go 586 B

123456789101112131415161718192021222324252627
  1. // +build json
  2. package rules_test
  3. import (
  4. "testing"
  5. . "github.com/v2ray/v2ray-core/app/router/rules"
  6. v2net "github.com/v2ray/v2ray-core/common/net"
  7. v2testing "github.com/v2ray/v2ray-core/testing"
  8. "github.com/v2ray/v2ray-core/testing/assert"
  9. )
  10. func TestFieldRule(t *testing.T) {
  11. v2testing.Current(t)
  12. rule := ParseRule([]byte(`{
  13. "type": "field",
  14. "domain": [
  15. "ooxx.com",
  16. "oxox.com"
  17. ],
  18. "outboundTag": "direct"
  19. }`))
  20. assert.Pointer(rule).IsNotNil()
  21. assert.Bool(rule.Apply(v2net.TCPDestination(v2net.DomainAddress("www.ooxx.com"), 80))).IsTrue()
  22. }