summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2019-04-15 16:06:47 +0200
committerEmīls Piņķis <emils@mullvad.net>2019-05-27 15:42:41 +0100
commit595ab0a33b0e962a9948dc85b0c3b101b976bed8 (patch)
tree5be676629880b5abbb0a015ae0bad4e2f9e7c56c
parent89d41b3607e0f5f22bd3b4c57f079ae0fcbca41b (diff)
downloadmullvadvpn-595ab0a33b0e962a9948dc85b0c3b101b976bed8.tar.xz
mullvadvpn-595ab0a33b0e962a9948dc85b0c3b101b976bed8.zip
Add bridges field to relay list
-rw-r--r--mullvad-types/src/relay_list.rs43
1 files changed, 41 insertions, 2 deletions
diff --git a/mullvad-types/src/relay_list.rs b/mullvad-types/src/relay_list.rs
index 732a672b5a..dc0a44acfa 100644
--- a/mullvad-types/src/relay_list.rs
+++ b/mullvad-types/src/relay_list.rs
@@ -6,9 +6,12 @@ use crate::{
use serde::{Deserialize, Serialize};
use std::{
fmt,
- net::{IpAddr, Ipv4Addr, Ipv6Addr},
+ net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
+};
+use talpid_types::net::{
+ openvpn::{ProxySettings, ShadowsocksProxySettings},
+ wireguard, Endpoint, TransportProtocol,
};
-use talpid_types::net::{wireguard, Endpoint, TransportProtocol};
#[derive(Debug, Clone, Deserialize, Serialize)]
@@ -48,6 +51,8 @@ pub struct Relay {
pub weight: u64,
#[serde(skip_serializing_if = "RelayTunnels::is_empty", default)]
pub tunnels: RelayTunnels,
+ #[serde(skip_serializing_if = "RelayBridges::is_empty", default)]
+ pub bridges: RelayBridges,
#[serde(skip)]
pub location: Option<Location>,
}
@@ -115,3 +120,37 @@ impl fmt::Display for WireguardEndpointData {
)
}
}
+
+#[derive(Debug, Default, Clone, Deserialize, Serialize)]
+#[serde(default)]
+pub struct RelayBridges {
+ pub shadowsocks: Vec<ShadowsocksEndpointData>,
+}
+
+impl RelayBridges {
+ pub fn is_empty(&self) -> bool {
+ self.shadowsocks.is_empty()
+ }
+
+ pub fn clear(&mut self) {
+ self.shadowsocks.clear();
+ }
+}
+
+#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize)]
+pub struct ShadowsocksEndpointData {
+ pub port: u16,
+ pub cipher: String,
+ pub password: String,
+ pub protocol: TransportProtocol,
+}
+
+impl ShadowsocksEndpointData {
+ pub fn to_proxy_settings(self, addr: IpAddr) -> ProxySettings {
+ ProxySettings::Shadowsocks(ShadowsocksProxySettings {
+ peer: SocketAddr::new(addr, self.port),
+ password: self.password,
+ cipher: self.cipher,
+ })
+ }
+}