router_test.go 926 B

12345678910111213141516171819202122232425262728293031
  1. package router_test
  2. import (
  3. "net"
  4. "path/filepath"
  5. "testing"
  6. . "github.com/v2ray/v2ray-core/app/router"
  7. _ "github.com/v2ray/v2ray-core/app/router/rules/json"
  8. v2net "github.com/v2ray/v2ray-core/common/net"
  9. "github.com/v2ray/v2ray-core/shell/point/json"
  10. v2testing "github.com/v2ray/v2ray-core/testing"
  11. "github.com/v2ray/v2ray-core/testing/assert"
  12. )
  13. func TestRouter(t *testing.T) {
  14. v2testing.Current(t)
  15. baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"
  16. pointConfig, err := json.LoadConfig(filepath.Join(baseDir, "vpoint_socks_vmess.json"))
  17. assert.Error(err).IsNil()
  18. router, err := CreateRouter(pointConfig.RouterConfig().Strategy(), pointConfig.RouterConfig().Settings())
  19. assert.Error(err).IsNil()
  20. dest := v2net.TCPDestination(v2net.IPAddress(net.ParseIP("120.135.126.1")), 80)
  21. tag, err := router.TakeDetour(dest)
  22. assert.Error(err).IsNil()
  23. assert.StringLiteral(tag).Equals("direct")
  24. }