Selaa lähdekoodia

test case for shadowsocks as inbound detour

v2ray 9 vuotta sitten
vanhempi
commit
f7c6ecde90
2 muutettua tiedostoa jossa 30 lisäystä ja 0 poistoa
  1. 11 0
      testing/scenarios/data/test_6_server.json
  2. 19 0
      testing/scenarios/shadowsocks_test.go

+ 11 - 0
testing/scenarios/data/test_6_server.json

@@ -7,6 +7,17 @@
       "password": "v2ray-password"
     }
   },
+  "inboundDetour": [
+    {
+      "protocol": "shadowsocks",
+      "port": 50055,
+      "settings": {
+        "method": "aes-128-cfb",
+        "password": "v2ray-another",
+        "udp": true
+      }
+    }
+  ],
   "outbound": {
     "protocol": "freedom",
     "settings": {}

+ 19 - 0
testing/scenarios/shadowsocks_test.go

@@ -50,5 +50,24 @@ func TestShadowsocksTCP(t *testing.T) {
 	assert.StringLiteral("Processed: " + payload).Equals(string(response[:nBytes]))
 	conn.Close()
 
+	cipher, err = ssclient.NewCipher("aes-128-cfb", "v2ray-another")
+	assert.Error(err).IsNil()
+
+	conn, err = ssclient.DialWithRawAddr(rawAddr, "127.0.0.1:50055", cipher)
+	assert.Error(err).IsNil()
+
+	payload = "shadowsocks request 2."
+	nBytes, err = conn.Write([]byte(payload))
+	assert.Error(err).IsNil()
+	assert.Int(nBytes).Equals(len(payload))
+
+	conn.Conn.(*net.TCPConn).CloseWrite()
+
+	response = make([]byte, 1024)
+	nBytes, err = conn.Read(response)
+	assert.Error(err).IsNil()
+	assert.StringLiteral("Processed: " + payload).Equals(string(response[:nBytes]))
+	conn.Close()
+
 	CloseAllServers()
 }