Skip to content

Commit 58bbd88

Browse files
WIP Add Shadowsocks access method test
1 parent 1bfe15a commit 58bbd88

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

talpid-types/src/net/proxy.rs

+6
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ pub struct Shadowsocks {
7676
pub cipher: String,
7777
}
7878

79+
impl From<Shadowsocks> for CustomProxy {
80+
fn from(value: Shadowsocks) -> Self {
81+
CustomProxy::Shadowsocks(value)
82+
}
83+
}
84+
7985
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
8086
pub struct Socks5Local {
8187
pub remote_endpoint: Endpoint,

test/test-manager/src/tests/access_methods.rs

+37-4
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,52 @@ use test_rpc::ServiceClient;
2121
pub async fn test_custom_access_methods(
2222
_: TestContext,
2323
_rpc: ServiceClient,
24-
_mullvad_client: MullvadProxyClient,
24+
mullvad_client: MullvadProxyClient,
2525
) -> Result<(), Error> {
2626
log::info!("Testing Shadowsocks access method");
27-
test_shadowsocks().await?;
27+
test_shadowsocks(mullvad_client.clone()).await?;
2828
log::info!("Testing SOCKS5 (Remote) access method");
2929
test_socks_remote().await?;
3030
Ok(())
3131
}
3232

33-
async fn test_shadowsocks() -> Result<(), Error> {
34-
panic!("Testing Shadowsocks access method has not been fully implemented yet!")
33+
async fn test_shadowsocks(mut mullvad_client: MullvadProxyClient) -> Result<(), Error> {
34+
use mullvad_types::relay_list::RelayEndpointData;
35+
use talpid_types::net::proxy::CustomProxy;
36+
// Set up all the parameters needed to create a custom Shadowsocks access method.
37+
//
38+
// Since Mullvad host's Shadowsocks relays on their bridge servers, we can
39+
// simply select a bridge server to derive all the needed parameters.
40+
// mullvad_client
41+
let relay_list = mullvad_client.get_relay_locations().await.unwrap();
42+
let bridge = relay_list
43+
.relays()
44+
.filter(|relay| matches!(relay.endpoint_data, RelayEndpointData::Bridge))
45+
.nth(0)
46+
.expect("`test_shadowsocks` needs at least one shadowsocks relay to execute. Found non in relay list.");
47+
48+
let access_method: CustomProxy = relay_list
49+
.bridge
50+
.shadowsocks
51+
.first()
52+
.map(|shadowsocks| {
53+
shadowsocks.to_proxy_settings(bridge.ipv4_addr_in.into())
54+
})
55+
.expect("`test_shadowsocks` needs at least one shadowsocks relay to execute. Found non in relay list.");
56+
57+
let successful = mullvad_client
58+
.test_custom_api_access_method(access_method.clone().into())
59+
.await?;
60+
61+
assert!(
62+
successful,
63+
"Failed while testing access method - {access_method:?}"
64+
);
65+
66+
Ok(())
3567
}
3668

69+
#[allow(clippy::unused_async)]
3770
async fn test_socks_remote() -> Result<(), Error> {
3871
unimplemented!("Testing SOCKS5 (Remote) access method is not implemented")
3972
}

0 commit comments

Comments
 (0)