mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
929 B
32 lines
929 B
9 years ago
|
package router_test
|
||
|
|
||
|
import (
|
||
|
"net"
|
||
|
"path/filepath"
|
||
|
"testing"
|
||
|
|
||
|
. "github.com/v2ray/v2ray-core/app/router"
|
||
|
_ "github.com/v2ray/v2ray-core/app/router/rules/json"
|
||
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
||
|
"github.com/v2ray/v2ray-core/shell/point/json"
|
||
|
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"
|
||
|
|
||
|
pointConfig, err := json.LoadConfig(filepath.Join(baseDir, "vpoint_socks_vmess.json"))
|
||
|
assert.Error(err).IsNil()
|
||
|
|
||
|
router, err := CreateRouter(pointConfig.RouterConfig().Strategy(), pointConfig.RouterConfig().Settings())
|
||
|
assert.Error(err).IsNil()
|
||
|
|
||
|
dest := v2net.NewTCPDestination(v2net.IPAddress(net.ParseIP("120.135.126.1"), 80))
|
||
|
tag, err := router.TakeDetour(dest)
|
||
|
assert.Error(err).IsNil()
|
||
|
assert.StringLiteral(tag).Equals("direct")
|
||
|
}
|