mirror of
https://github.com/e1732a364fed/v2ray_simple.git
synced 2025-12-24 13:27:56 +08:00
改进proxy的测试代码;vmess在不给出security时直接使用auto
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
20
proxy/vmess/vmess_test.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user