v2ray-core/app/router/router_test.go

32 lines
909 B
Go
Raw Normal View History

2015-12-12 19:47:29 +00:00
package router_test
import (
"net"
"path/filepath"
"testing"
. "github.com/v2ray/v2ray-core/app/router"
2016-01-17 15:20:49 +00:00
_ "github.com/v2ray/v2ray-core/app/router/rules"
2015-12-12 19:47:29 +00:00
v2net "github.com/v2ray/v2ray-core/common/net"
2016-01-17 20:43:10 +00:00
"github.com/v2ray/v2ray-core/shell/point"
2015-12-12 19:47:29 +00:00
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
)
func TestRouter(t *testing.T) {
v2testing.Current(t)
baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"
2016-01-17 20:43:10 +00:00
pointConfig, err := point.LoadConfig(filepath.Join(baseDir, "vpoint_socks_vmess.json"))
2015-12-12 19:47:29 +00:00
assert.Error(err).IsNil()
2016-01-17 20:43:10 +00:00
router, err := CreateRouter(pointConfig.RouterConfig.Strategy, pointConfig.RouterConfig.Settings)
2015-12-12 19:47:29 +00:00
assert.Error(err).IsNil()
2015-12-16 22:53:38 +00:00
dest := v2net.TCPDestination(v2net.IPAddress(net.ParseIP("120.135.126.1")), 80)
2015-12-12 19:47:29 +00:00
tag, err := router.TakeDetour(dest)
assert.Error(err).IsNil()
assert.StringLiteral(tag).Equals("direct")
}