改进proxy的测试代码;vmess在不给出security时直接使用auto

This commit is contained in:
e1732a364fed
2000-01-01 00:00:00 +00:00
parent e788186d0a
commit 8bde5e460b
6 changed files with 35 additions and 9 deletions

View File

@@ -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) {

View File

@@ -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)

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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

20
proxy/vmess/vmess_test.go Normal file
View File

@@ -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)
}