Skip to content

Commit

Permalink
Add Shadowsocks feature indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Aug 15, 2024
1 parent 0286fdd commit a3ba162
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 20 deletions.
6 changes: 3 additions & 3 deletions gui/src/main/daemon-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1137,9 +1137,9 @@ function convertFromTunnelType(tunnelType: grpcTypes.TunnelType): TunnelType {
}

function convertFromProxyEndpoint(proxyEndpoint: grpcTypes.ProxyEndpoint.AsObject): IProxyEndpoint {
const proxyTypeMap: Record<grpcTypes.ProxyType, ProxyType> = {
[grpcTypes.ProxyType.CUSTOM]: 'custom',
[grpcTypes.ProxyType.SHADOWSOCKS]: 'shadowsocks',
const proxyTypeMap: Record<grpcTypes.ProxyEndpoint.ProxyType, ProxyType> = {
[grpcTypes.ProxyEndpoint.ProxyType.CUSTOM]: 'custom',
[grpcTypes.ProxyEndpoint.ProxyType.SHADOWSOCKS]: 'shadowsocks',
};

return {
Expand Down
8 changes: 8 additions & 0 deletions mullvad-daemon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2931,6 +2931,13 @@ impl Daemon {
.as_ref()
.filter(|obfuscation| obfuscation.obfuscation_type == ObfuscationType::Udp2Tcp)
.is_some();
let shadowsocks = endpoint
.obfuscation
.as_ref()
.filter(|obfuscation| {
obfuscation.obfuscation_type == ObfuscationType::Shadowsocks
})
.is_some();

let mtu = settings.tunnel_options.wireguard.mtu.is_some();

Expand All @@ -2941,6 +2948,7 @@ impl Daemon {
(quantum_resistant, FeatureIndicator::QuantumResistance),
(multihop, FeatureIndicator::Multihop),
(udp_tcp, FeatureIndicator::Udp2Tcp),
(shadowsocks, FeatureIndicator::Shadowsocks),
(mtu, FeatureIndicator::CustomMtu),
#[cfg(daita)]
(daita, FeatureIndicator::Daita),
Expand Down
25 changes: 13 additions & 12 deletions mullvad-management-interface/proto/management_interface.proto
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,14 @@ enum FeatureIndicator {
SPLIT_TUNNELING = 3;
LOCKDOWN_MODE = 4;
UDP_2_TCP = 5;
LAN_SHARING = 6;
DNS_CONTENT_BLOCKERS = 7;
CUSTOM_DNS = 8;
SERVER_IP_OVERRIDE = 9;
CUSTOM_MTU = 10;
CUSTOM_MSS_FIX = 11;
DAITA = 12;
SHADOWSOCKS = 6;
LAN_SHARING = 7;
DNS_CONTENT_BLOCKERS = 8;
CUSTOM_DNS = 9;
SERVER_IP_OVERRIDE = 10;
CUSTOM_MTU = 11;
CUSTOM_MSS_FIX = 12;
DAITA = 13;
}

message ObfuscationEndpoint {
Expand All @@ -275,17 +276,17 @@ message ObfuscationEndpoint {
ObfuscationType obfuscation_type = 4;
}

enum ProxyType {
SHADOWSOCKS = 0;
CUSTOM = 1;
}

message Endpoint {
string address = 1;
TransportProtocol protocol = 2;
}

message ProxyEndpoint {
enum ProxyType {
SHADOWSOCKS = 0;
CUSTOM = 1;
}

string address = 1;
TransportProtocol protocol = 2;
ProxyType proxy_type = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ impl From<mullvad_types::features::FeatureIndicator> for proto::FeatureIndicator
mullvad_types::features::FeatureIndicator::SplitTunneling => SplitTunneling,
mullvad_types::features::FeatureIndicator::LockdownMode => LockdownMode,
mullvad_types::features::FeatureIndicator::Udp2Tcp => Udp2Tcp,
mullvad_types::features::FeatureIndicator::Shadowsocks => Shadowsocks,
mullvad_types::features::FeatureIndicator::LanSharing => LanSharing,
mullvad_types::features::FeatureIndicator::DnsContentBlockers => DnsContentBlockers,
mullvad_types::features::FeatureIndicator::CustomDns => CustomDns,
Expand All @@ -30,6 +31,7 @@ impl From<proto::FeatureIndicator> for mullvad_types::features::FeatureIndicator
proto::FeatureIndicator::SplitTunneling => Self::SplitTunneling,
proto::FeatureIndicator::LockdownMode => Self::LockdownMode,
proto::FeatureIndicator::Udp2Tcp => Self::Udp2Tcp,
proto::FeatureIndicator::Shadowsocks => Self::Shadowsocks,
proto::FeatureIndicator::LanSharing => Self::LanSharing,
proto::FeatureIndicator::DnsContentBlockers => Self::DnsContentBlockers,
proto::FeatureIndicator::CustomDns => Self::CustomDns,
Expand Down
18 changes: 13 additions & 5 deletions mullvad-management-interface/src/types/conversions/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ impl From<talpid_types::net::TunnelEndpoint> for proto::TunnelEndpoint {
address: proxy_ep.endpoint.address.to_string(),
protocol: i32::from(proto::TransportProtocol::from(proxy_ep.endpoint.protocol)),
proxy_type: match proxy_ep.proxy_type {
net::proxy::ProxyType::Shadowsocks => i32::from(proto::ProxyType::Shadowsocks),
net::proxy::ProxyType::Custom => i32::from(proto::ProxyType::Custom),
net::proxy::ProxyType::Shadowsocks => {
i32::from(proto::proxy_endpoint::ProxyType::Shadowsocks)
}
net::proxy::ProxyType::Custom => {
i32::from(proto::proxy_endpoint::ProxyType::Custom)
}
},
}),
obfuscation: endpoint.obfuscation.map(|obfuscation_endpoint| {
Expand Down Expand Up @@ -77,11 +81,15 @@ impl TryFrom<proto::TunnelEndpoint> for talpid_types::net::TunnelEndpoint {
)?,
protocol: try_transport_protocol_from_i32(proxy_ep.protocol)?,
},
proxy_type: match proto::ProxyType::try_from(proxy_ep.proxy_type) {
Ok(proto::ProxyType::Shadowsocks) => {
proxy_type: match proto::proxy_endpoint::ProxyType::try_from(
proxy_ep.proxy_type,
) {
Ok(proto::proxy_endpoint::ProxyType::Shadowsocks) => {
talpid_net::proxy::ProxyType::Shadowsocks
}
Ok(proto::ProxyType::Custom) => talpid_net::proxy::ProxyType::Custom,
Ok(proto::proxy_endpoint::ProxyType::Custom) => {
talpid_net::proxy::ProxyType::Custom
}
Err(_) => {
return Err(FromProtobufTypeError::InvalidArgument(
"unknown proxy type",
Expand Down
2 changes: 2 additions & 0 deletions mullvad-types/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub enum FeatureIndicator {
SplitTunneling,
LockdownMode,
Udp2Tcp,
Shadowsocks,
LanSharing,
DnsContentBlockers,
CustomDns,
Expand All @@ -49,6 +50,7 @@ impl std::fmt::Display for FeatureIndicator {
FeatureIndicator::SplitTunneling => "Split Tunneling",
FeatureIndicator::LockdownMode => "Lockdown Mode",
FeatureIndicator::Udp2Tcp => "Udp2Tcp",
FeatureIndicator::Shadowsocks => "Shadowsocks",
FeatureIndicator::LanSharing => "LAN Sharing",
FeatureIndicator::DnsContentBlockers => "Dns Content Blocker",
FeatureIndicator::CustomDns => "Custom Dns",
Expand Down

0 comments on commit a3ba162

Please sign in to comment.