diff --git a/leaf/tests/test_proxy_chain.rs b/leaf/tests/test_proxy_chain_1.rs similarity index 96% rename from leaf/tests/test_proxy_chain.rs rename to leaf/tests/test_proxy_chain_1.rs index e8b847e..5516e73 100644 --- a/leaf/tests/test_proxy_chain.rs +++ b/leaf/tests/test_proxy_chain_1.rs @@ -1,6 +1,6 @@ mod common; -// app(socks) -> (socks)client(ws+trojan+ws+trojan) -> (ws+trojan)server1(direct) -> (ws+trojan)server2(direct) -> echo +// app(socks) -> (socks)client(ws+trojan->ws+trojan) -> (ws+trojan)server1(direct) -> (ws+trojan)server2(direct) -> echo #[cfg(all( feature = "outbound-socks", feature = "inbound-socks", @@ -11,7 +11,7 @@ mod common; feature = "outbound-direct", ))] #[test] -fn test_proxy_chain() { +fn test_proxy_chain_1() { let config1 = r#" { "inbounds": [ diff --git a/leaf/tests/test_proxy_chain_2.rs b/leaf/tests/test_proxy_chain_2.rs new file mode 100644 index 0000000..c9d80c1 --- /dev/null +++ b/leaf/tests/test_proxy_chain_2.rs @@ -0,0 +1,104 @@ +mod common; + +// app(socks) -> (socks)client(shadowsocks->shadowsocks) -> (shadowsocks)server1(direct) -> (shadowsocks)server2(direct) -> echo +#[cfg(all( + feature = "outbound-socks", + feature = "inbound-socks", + feature = "outbound-shadowsocks", + feature = "inbound-shadowsocks", + feature = "outbound-direct", +))] +#[test] +fn test_proxy_chain_2() { + let config1 = r#" + { + "inbounds": [ + { + "protocol": "socks", + "address": "127.0.0.1", + "port": 1086 + } + ], + "outbounds": [ + { + "protocol": "chain", + "settings": { + "actors": [ + "server1", + "server2" + ] + } + }, + { + "protocol": "shadowsocks", + "tag": "server1", + "settings": { + "address": "127.0.0.1", + "port": 3001, + "method": "chacha20-ietf-poly1305", + "password": "password" + } + }, + { + "protocol": "shadowsocks", + "tag": "server2", + "settings": { + "address": "127.0.0.1", + "port": 3002, + "method": "aes-128-gcm", + "password": "password" + } + } + ] + } + "#; + + let config2 = r#" + { + "inbounds": [ + { + "protocol": "shadowsocks", + "address": "127.0.0.1", + "port": 3001, + "settings": { + "method": "chacha20-ietf-poly1305", + "password": "password" + } + } + ], + "outbounds": [ + { + "protocol": "direct" + } + ] + } + "#; + + let config3 = r#" + { + "inbounds": [ + { + "protocol": "shadowsocks", + "address": "127.0.0.1", + "port": 3002, + "settings": { + "method": "aes-128-gcm", + "password": "password" + } + } + ], + "outbounds": [ + { + "protocol": "direct" + } + ] + } + "#; + + let configs = vec![ + config1.to_string(), + config2.to_string(), + config3.to_string(), + ]; + common::test_configs(configs, "127.0.0.1", 1086); +} diff --git a/leaf/tests/test_proxy_chain_3.rs b/leaf/tests/test_proxy_chain_3.rs new file mode 100644 index 0000000..1001e93 --- /dev/null +++ b/leaf/tests/test_proxy_chain_3.rs @@ -0,0 +1,142 @@ +mod common; + +// app(socks) -> (socks)client(ws+trojan->shadowsocks) -> (ws+trojan)server1(direct) -> (shadowsocks)server2(direct) -> echo +#[cfg(all( + feature = "outbound-socks", + feature = "inbound-socks", + feature = "outbound-ws", + feature = "outbound-trojan", + feature = "inbound-ws", + feature = "inbound-trojan", + feature = "outbound-shadowsocks", + feature = "inbound-shadowsocks", + feature = "outbound-direct", +))] +#[test] +fn test_proxy_chain_3() { + let config1 = r#" + { + "inbounds": [ + { + "protocol": "socks", + "address": "127.0.0.1", + "port": 1086 + } + ], + "outbounds": [ + { + "protocol": "chain", + "tag": "chain-server1-server2", + "settings": { + "actors": [ + "server1", + "server2" + ] + } + }, + { + "protocol": "chain", + "tag": "server1", + "settings": { + "actors": [ + "server1-ws", + "server1-trojan" + ] + } + }, + { + "protocol": "ws", + "tag": "server1-ws", + "settings": { + "path": "/leaf" + } + }, + { + "protocol": "trojan", + "tag": "server1-trojan", + "settings": { + "address": "127.0.0.1", + "port": 3001, + "password": "password" + } + }, + { + "protocol": "shadowsocks", + "tag": "server2", + "settings": { + "address": "127.0.0.1", + "port": 3002, + "method": "aes-128-gcm", + "password": "password" + } + } + ] + } + "#; + + let config2 = r#" + { + "inbounds": [ + { + "protocol": "chain", + "tag": "server1", + "address": "127.0.0.1", + "port": 3001, + "settings": { + "actors": [ + "ws", + "trojan" + ] + } + }, + { + "protocol": "ws", + "tag": "ws", + "settings": { + "path": "/leaf" + } + }, + { + "protocol": "trojan", + "tag": "trojan", + "settings": { + "password": "password" + } + } + ], + "outbounds": [ + { + "protocol": "direct" + } + ] + } + "#; + + let config3 = r#" + { + "inbounds": [ + { + "protocol": "shadowsocks", + "address": "127.0.0.1", + "port": 3002, + "settings": { + "method": "aes-128-gcm", + "password": "password" + } + } + ], + "outbounds": [ + { + "protocol": "direct" + } + ] + } + "#; + + let configs = vec![ + config1.to_string(), + config2.to_string(), + config3.to_string(), + ]; + common::test_configs(configs, "127.0.0.1", 1086); +} diff --git a/leaf/tests/test_proxy_chain_4.rs b/leaf/tests/test_proxy_chain_4.rs new file mode 100644 index 0000000..ad60fae --- /dev/null +++ b/leaf/tests/test_proxy_chain_4.rs @@ -0,0 +1,142 @@ +mod common; + +// app(socks) -> (socks)client(shadowsocks->ws+trojan) -> (shadowsocks)server2(direct) -> (ws+trojan)server1(direct) -> echo +#[cfg(all( + feature = "outbound-socks", + feature = "inbound-socks", + feature = "outbound-ws", + feature = "outbound-trojan", + feature = "inbound-ws", + feature = "inbound-trojan", + feature = "outbound-shadowsocks", + feature = "inbound-shadowsocks", + feature = "outbound-direct", +))] +#[test] +fn test_proxy_chain_4() { + let config1 = r#" + { + "inbounds": [ + { + "protocol": "socks", + "address": "127.0.0.1", + "port": 1086 + } + ], + "outbounds": [ + { + "protocol": "chain", + "tag": "chain-server1-server2", + "settings": { + "actors": [ + "server2", + "server1" + ] + } + }, + { + "protocol": "chain", + "tag": "server1", + "settings": { + "actors": [ + "server1-ws", + "server1-trojan" + ] + } + }, + { + "protocol": "ws", + "tag": "server1-ws", + "settings": { + "path": "/leaf" + } + }, + { + "protocol": "trojan", + "tag": "server1-trojan", + "settings": { + "address": "127.0.0.1", + "port": 3001, + "password": "password" + } + }, + { + "protocol": "shadowsocks", + "tag": "server2", + "settings": { + "address": "127.0.0.1", + "port": 3002, + "method": "aes-128-gcm", + "password": "password" + } + } + ] + } + "#; + + let config2 = r#" + { + "inbounds": [ + { + "protocol": "chain", + "tag": "server1", + "address": "127.0.0.1", + "port": 3001, + "settings": { + "actors": [ + "ws", + "trojan" + ] + } + }, + { + "protocol": "ws", + "tag": "ws", + "settings": { + "path": "/leaf" + } + }, + { + "protocol": "trojan", + "tag": "trojan", + "settings": { + "password": "password" + } + } + ], + "outbounds": [ + { + "protocol": "direct" + } + ] + } + "#; + + let config3 = r#" + { + "inbounds": [ + { + "protocol": "shadowsocks", + "address": "127.0.0.1", + "port": 3002, + "settings": { + "method": "aes-128-gcm", + "password": "password" + } + } + ], + "outbounds": [ + { + "protocol": "direct" + } + ] + } + "#; + + let configs = vec![ + config1.to_string(), + config2.to_string(), + config3.to_string(), + ]; + common::test_configs(configs, "127.0.0.1", 1086); +} diff --git a/leaf/tests/test_proxy_chain_5.rs b/leaf/tests/test_proxy_chain_5.rs new file mode 100644 index 0000000..d37cbc0 --- /dev/null +++ b/leaf/tests/test_proxy_chain_5.rs @@ -0,0 +1,133 @@ +mod common; + +// app(socks) -> (socks)client(shadowsocks+ws+trojan) -> (shadowsocks)server2(direct) -> (ws+trojan)server1(direct) -> echo +#[cfg(all( + feature = "outbound-socks", + feature = "inbound-socks", + feature = "outbound-ws", + feature = "outbound-trojan", + feature = "inbound-ws", + feature = "inbound-trojan", + feature = "outbound-shadowsocks", + feature = "inbound-shadowsocks", + feature = "outbound-direct", +))] +#[test] +fn test_proxy_chain_5() { + let config1 = r#" + { + "inbounds": [ + { + "protocol": "socks", + "address": "127.0.0.1", + "port": 1086 + } + ], + "outbounds": [ + { + "protocol": "chain", + "tag": "chain", + "settings": { + "actors": [ + "server2", + "server1-ws", + "server1-trojan" + ] + } + }, + { + "protocol": "ws", + "tag": "server1-ws", + "settings": { + "path": "/leaf" + } + }, + { + "protocol": "trojan", + "tag": "server1-trojan", + "settings": { + "address": "127.0.0.1", + "port": 3001, + "password": "password" + } + }, + { + "protocol": "shadowsocks", + "tag": "server2", + "settings": { + "address": "127.0.0.1", + "port": 3002, + "method": "aes-128-gcm", + "password": "password" + } + } + ] + } + "#; + + let config2 = r#" + { + "inbounds": [ + { + "protocol": "chain", + "tag": "server1", + "address": "127.0.0.1", + "port": 3001, + "settings": { + "actors": [ + "ws", + "trojan" + ] + } + }, + { + "protocol": "ws", + "tag": "ws", + "settings": { + "path": "/leaf" + } + }, + { + "protocol": "trojan", + "tag": "trojan", + "settings": { + "password": "password" + } + } + ], + "outbounds": [ + { + "protocol": "direct" + } + ] + } + "#; + + let config3 = r#" + { + "inbounds": [ + { + "protocol": "shadowsocks", + "address": "127.0.0.1", + "port": 3002, + "settings": { + "method": "aes-128-gcm", + "password": "password" + } + } + ], + "outbounds": [ + { + "protocol": "direct" + } + ] + } + "#; + + let configs = vec![ + config1.to_string(), + config2.to_string(), + config3.to_string(), + ]; + common::test_configs(configs, "127.0.0.1", 1086); +} diff --git a/leaf/tests/test_proxy_chain_6.rs b/leaf/tests/test_proxy_chain_6.rs new file mode 100644 index 0000000..df2a4e1 --- /dev/null +++ b/leaf/tests/test_proxy_chain_6.rs @@ -0,0 +1,133 @@ +mod common; + +// app(socks) -> (socks)client(ws+trojan+shadowsocks) -> (ws+trojan)server1(direct) -> (shadowsocks)server2(direct) -> echo +#[cfg(all( + feature = "outbound-socks", + feature = "inbound-socks", + feature = "outbound-ws", + feature = "outbound-trojan", + feature = "inbound-ws", + feature = "inbound-trojan", + feature = "outbound-shadowsocks", + feature = "inbound-shadowsocks", + feature = "outbound-direct", +))] +#[test] +fn test_proxy_chain_6() { + let config1 = r#" + { + "inbounds": [ + { + "protocol": "socks", + "address": "127.0.0.1", + "port": 1086 + } + ], + "outbounds": [ + { + "protocol": "chain", + "tag": "chain", + "settings": { + "actors": [ + "server1-ws", + "server1-trojan", + "server2" + ] + } + }, + { + "protocol": "ws", + "tag": "server1-ws", + "settings": { + "path": "/leaf" + } + }, + { + "protocol": "trojan", + "tag": "server1-trojan", + "settings": { + "address": "127.0.0.1", + "port": 3001, + "password": "password" + } + }, + { + "protocol": "shadowsocks", + "tag": "server2", + "settings": { + "address": "127.0.0.1", + "port": 3002, + "method": "aes-128-gcm", + "password": "password" + } + } + ] + } + "#; + + let config2 = r#" + { + "inbounds": [ + { + "protocol": "chain", + "tag": "server1", + "address": "127.0.0.1", + "port": 3001, + "settings": { + "actors": [ + "ws", + "trojan" + ] + } + }, + { + "protocol": "ws", + "tag": "ws", + "settings": { + "path": "/leaf" + } + }, + { + "protocol": "trojan", + "tag": "trojan", + "settings": { + "password": "password" + } + } + ], + "outbounds": [ + { + "protocol": "direct" + } + ] + } + "#; + + let config3 = r#" + { + "inbounds": [ + { + "protocol": "shadowsocks", + "address": "127.0.0.1", + "port": 3002, + "settings": { + "method": "aes-128-gcm", + "password": "password" + } + } + ], + "outbounds": [ + { + "protocol": "direct" + } + ] + } + "#; + + let configs = vec![ + config1.to_string(), + config2.to_string(), + config3.to_string(), + ]; + common::test_configs(configs, "127.0.0.1", 1086); +}