|
|
@ -3,16 +3,13 @@
|
|
|
|
package point_test
|
|
|
|
package point_test
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
|
|
_ "github.com/v2ray/v2ray-core/app/router/rules"
|
|
|
|
_ "github.com/v2ray/v2ray-core/app/router/rules"
|
|
|
|
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
|
|
|
|
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
|
|
|
|
_ "github.com/v2ray/v2ray-core/proxy/dokodemo"
|
|
|
|
|
|
|
|
_ "github.com/v2ray/v2ray-core/proxy/freedom"
|
|
|
|
|
|
|
|
_ "github.com/v2ray/v2ray-core/proxy/socks"
|
|
|
|
|
|
|
|
_ "github.com/v2ray/v2ray-core/proxy/vmess/inbound"
|
|
|
|
|
|
|
|
_ "github.com/v2ray/v2ray-core/proxy/vmess/outbound"
|
|
|
|
|
|
|
|
. "github.com/v2ray/v2ray-core/shell/point"
|
|
|
|
. "github.com/v2ray/v2ray-core/shell/point"
|
|
|
|
|
|
|
|
|
|
|
|
v2testing "github.com/v2ray/v2ray-core/testing"
|
|
|
|
v2testing "github.com/v2ray/v2ray-core/testing"
|
|
|
@ -22,8 +19,8 @@ import (
|
|
|
|
func TestClientSampleConfig(t *testing.T) {
|
|
|
|
func TestClientSampleConfig(t *testing.T) {
|
|
|
|
v2testing.Current(t)
|
|
|
|
v2testing.Current(t)
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: fix for Windows
|
|
|
|
GOPATH := os.Getenv("GOPATH")
|
|
|
|
baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"
|
|
|
|
baseDir := filepath.Join(GOPATH, "src", "github.com", "v2ray", "v2ray-core", "release", "config")
|
|
|
|
|
|
|
|
|
|
|
|
pointConfig, err := LoadConfig(filepath.Join(baseDir, "vpoint_socks_vmess.json"))
|
|
|
|
pointConfig, err := LoadConfig(filepath.Join(baseDir, "vpoint_socks_vmess.json"))
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
assert.Error(err).IsNil()
|
|
|
@ -42,8 +39,8 @@ func TestClientSampleConfig(t *testing.T) {
|
|
|
|
func TestServerSampleConfig(t *testing.T) {
|
|
|
|
func TestServerSampleConfig(t *testing.T) {
|
|
|
|
v2testing.Current(t)
|
|
|
|
v2testing.Current(t)
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: fix for Windows
|
|
|
|
GOPATH := os.Getenv("GOPATH")
|
|
|
|
baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"
|
|
|
|
baseDir := filepath.Join(GOPATH, "src", "github.com", "v2ray", "v2ray-core", "release", "config")
|
|
|
|
|
|
|
|
|
|
|
|
pointConfig, err := LoadConfig(filepath.Join(baseDir, "vpoint_vmess_freedom.json"))
|
|
|
|
pointConfig, err := LoadConfig(filepath.Join(baseDir, "vpoint_vmess_freedom.json"))
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
assert.Error(err).IsNil()
|
|
|
@ -58,3 +55,23 @@ func TestServerSampleConfig(t *testing.T) {
|
|
|
|
assert.StringLiteral(pointConfig.OutboundConfig.Protocol).Equals("freedom")
|
|
|
|
assert.StringLiteral(pointConfig.OutboundConfig.Protocol).Equals("freedom")
|
|
|
|
assert.Pointer(pointConfig.OutboundConfig.Settings).IsNotNil()
|
|
|
|
assert.Pointer(pointConfig.OutboundConfig.Settings).IsNotNil()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestDefaultValueOfRandomAllocation(t *testing.T) {
|
|
|
|
|
|
|
|
v2testing.Current(t)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rawJson := `{
|
|
|
|
|
|
|
|
"protocol": "vmess",
|
|
|
|
|
|
|
|
"port": 1,
|
|
|
|
|
|
|
|
"settings": {},
|
|
|
|
|
|
|
|
"allocate": {
|
|
|
|
|
|
|
|
"strategy": "random"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inboundDetourConfig := new(InboundDetourConfig)
|
|
|
|
|
|
|
|
err := json.Unmarshal([]byte(rawJson), inboundDetourConfig)
|
|
|
|
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
|
|
|
assert.StringLiteral(inboundDetourConfig.Allocation.Strategy).Equals(AllocationStrategyRandom)
|
|
|
|
|
|
|
|
assert.Int(inboundDetourConfig.Allocation.Concurrency).Equals(3)
|
|
|
|
|
|
|
|
assert.Int(inboundDetourConfig.Allocation.Refresh).Equals(5)
|
|
|
|
|
|
|
|
}
|
|
|
|