diff --git a/proxy/simplesocks/simplesocks_test.go b/proxy/simplesocks/simplesocks_test.go index 0af26bb..5427eb1 100644 --- a/proxy/simplesocks/simplesocks_test.go +++ b/proxy/simplesocks/simplesocks_test.go @@ -8,7 +8,7 @@ import ( ) func TestTCP(t *testing.T) { - proxy.TestTCP("simplesocks", 0, netLayer.RandPortStr(true, false), t) + proxy.TestTCP("simplesocks", 0, netLayer.RandPortStr(true, false), "", t) } func TestUDP(t *testing.T) { diff --git a/proxy/test.go b/proxy/test.go index 38bf87b..41cd475 100644 --- a/proxy/test.go +++ b/proxy/test.go @@ -16,11 +16,14 @@ import ( "github.com/e1732a364fed/v2ray_simple/utils" ) -func TestTCP(protocol string, version int, port string, t *testing.T) { +func TestTCP(protocol string, version int, port string, extraQuery string, t *testing.T) { utils.LogLevel = utils.Log_debug utils.InitLog("") - url := protocol + "://a684455c-b14f-11ea-bf0d-42010aaa0003@127.0.0.1:" + port + "?version=" + strconv.Itoa(version) + url := protocol + "://a684455c-b14f-11ea-bf0d-42010aaa0003@127.0.0.1:" + port + "?v=" + strconv.Itoa(version) + if extraQuery != "" { + url += "&" + extraQuery + } server, e := ServerFromURL(url) if e != nil { t.FailNow() @@ -129,7 +132,7 @@ func TestUDP(protocol string, version int, proxyPort string, use_multi int, t *t t.Log("fakeServerEndLocalServer port is ", proxyPort) - fmtStr := protocol + "://a684455c-b14f-11ea-bf0d-42010aaa0003@127.0.0.1:%s?version=%d&vless1_udp_multi=%d" + fmtStr := protocol + "://a684455c-b14f-11ea-bf0d-42010aaa0003@127.0.0.1:%s?v=%d&vless1_udp_multi=%d" url := fmt.Sprintf(fmtStr, proxyPort, version, use_multi) fakeServerEndLocalServer, errx := ServerFromURL(url) diff --git a/proxy/trojan/trojan_test.go b/proxy/trojan/trojan_test.go index 849cd35..cd7c6e9 100644 --- a/proxy/trojan/trojan_test.go +++ b/proxy/trojan/trojan_test.go @@ -8,7 +8,7 @@ import ( ) func TestTCP(t *testing.T) { - proxy.TestTCP("trojan", 0, netLayer.RandPortStr(true, false), t) + proxy.TestTCP("trojan", 0, netLayer.RandPortStr(true, false), "", t) } func TestUDP(t *testing.T) { diff --git a/proxy/vless/vless_test.go b/proxy/vless/vless_test.go index 242ab09..73e961a 100644 --- a/proxy/vless/vless_test.go +++ b/proxy/vless/vless_test.go @@ -8,11 +8,11 @@ import ( ) func TestVLess0(t *testing.T) { - proxy.TestTCP("vless", 0, netLayer.RandPortStr(true, false), t) + proxy.TestTCP("vless", 0, netLayer.RandPortStr(true, false), "", t) } func TestVLess1(t *testing.T) { - proxy.TestTCP("vless", 1, netLayer.RandPortStr(true, true), t) + proxy.TestTCP("vless", 1, netLayer.RandPortStr(true, false), "", t) } func TestVLess0_udp(t *testing.T) { diff --git a/proxy/vmess/client.go b/proxy/vmess/client.go index 636add1..0f6b037 100644 --- a/proxy/vmess/client.go +++ b/proxy/vmess/client.go @@ -109,7 +109,7 @@ func (c *Client) specifySecurityByStr(security string) error { c.security = SecurityAES128GCM case "chacha20-poly1305": c.security = SecurityChacha20Poly1305 - case "auto": + case "auto", "": //这里我们为了保护用户,当字符串为空时,依然设为auto,而不是zero if systemAutoUseAes { c.security = SecurityAES128GCM } else { @@ -119,7 +119,10 @@ func (c *Client) specifySecurityByStr(security string) error { case "none": c.security = SecurityNone - case "", "zero", "0": // NOTE: use basic format when no method specified. + case "zero", "0": + + // NOTE: use basic format when no method specified. + // 注意,BasicFormat 只用于向前兼容,本作的vmess的服务端并不支持 注意,BasicFormat c.opt = OptBasicFormat c.security = SecurityNone diff --git a/proxy/vmess/vmess_test.go b/proxy/vmess/vmess_test.go new file mode 100644 index 0000000..05fc2ca --- /dev/null +++ b/proxy/vmess/vmess_test.go @@ -0,0 +1,20 @@ +package vmess_test + +import ( + "testing" + + "github.com/e1732a364fed/v2ray_simple/netLayer" + "github.com/e1732a364fed/v2ray_simple/proxy" +) + +func TestTCP(t *testing.T) { + proxy.TestTCP("vmess", 0, netLayer.RandPortStr(true, false), "", t) +} + +func TestTCP_none(t *testing.T) { + proxy.TestTCP("vmess", 0, netLayer.RandPortStr(true, false), "security=none", t) +} + +func TestUDP(t *testing.T) { + proxy.TestUDP("vmess", 0, netLayer.RandPortStr(true, true), 0, t) +}