router_test.go 675 B

1234567891011121314151617181920212223242526272829
  1. package rules
  2. import (
  3. "testing"
  4. "github.com/v2ray/v2ray-core/app/router/rules/config"
  5. testinconfig "github.com/v2ray/v2ray-core/app/router/rules/config/testing"
  6. v2net "github.com/v2ray/v2ray-core/common/net"
  7. "github.com/v2ray/v2ray-core/testing/unit"
  8. )
  9. func TestSimpleRouter(t *testing.T) {
  10. assert := unit.Assert(t)
  11. router := &Router{
  12. rules: []config.Rule{
  13. &testinconfig.TestRule{
  14. TagValue: "test",
  15. Function: func(dest v2net.Destination) bool {
  16. return dest.IsTCP()
  17. },
  18. },
  19. },
  20. }
  21. tag, err := router.TakeDetour(v2net.NewTCPDestination(v2net.DomainAddress("v2ray.com", 80)))
  22. assert.Error(err).IsNil()
  23. assert.String(tag).Equals("test")
  24. }