mirror of
https://github.com/eycorsican/leaf.git
synced 2026-12-06 08:02:36 +00:00
tests: more integration tests
This commit is contained in:
1 parent
6ef895a274
commit
75d28684be
6 files changed
+656
-2
No files matched your search
@@ -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": [
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
Reference in new issue
Block a user