diff options
| author | David Lönnhager <david.l@mullvad.net> | 2022-01-18 17:19:22 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2022-03-14 12:08:49 +0100 |
| commit | 47585eb5b3507c65408718088c698511fbc7d389 (patch) | |
| tree | e6ab32e31471e75c3942b378637be8f712085190 | |
| parent | 7d241f1fb88e8cb3a26b336462dd7e1b8326c1d1 (diff) | |
| download | mullvadvpn-47585eb5b3507c65408718088c698511fbc7d389.tar.xz mullvadvpn-47585eb5b3507c65408718088c698511fbc7d389.zip | |
Store port identifiers for devices
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 1 | ||||
| -rw-r--r-- | mullvad-management-interface/proto/management_interface.proto | 5 | ||||
| -rw-r--r-- | mullvad-management-interface/src/types.rs | 18 | ||||
| -rw-r--r-- | mullvad-rpc/src/lib.rs | 11 | ||||
| -rw-r--r-- | mullvad-types/src/device.rs | 10 |
5 files changed, 43 insertions, 2 deletions
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 6d82708a88..404e9f9834 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -1794,6 +1794,7 @@ where id: device_id, name: "unknown device".to_string(), pubkey: talpid_types::net::wireguard::PublicKey::from([0u8; 32]), + ports: vec![], } }; event_listener.notify_remove_device_event(RemoveDeviceEvent { diff --git a/mullvad-management-interface/proto/management_interface.proto b/mullvad-management-interface/proto/management_interface.proto index 9f0b3b7109..21eb6ab512 100644 --- a/mullvad-management-interface/proto/management_interface.proto +++ b/mullvad-management-interface/proto/management_interface.proto @@ -533,6 +533,11 @@ message Device { string id = 1; string name = 2; bytes pubkey = 3; + repeated DevicePort ports = 4; +} + +message DevicePort { + string id = 1; } message DeviceList { diff --git a/mullvad-management-interface/src/types.rs b/mullvad-management-interface/src/types.rs index 45e0c1c37c..c76ada98d1 100644 --- a/mullvad-management-interface/src/types.rs +++ b/mullvad-management-interface/src/types.rs @@ -203,10 +203,17 @@ impl From<mullvad_types::device::Device> for Device { id: device.id, name: device.name, pubkey: device.pubkey.as_bytes().to_vec(), + ports: device.ports.into_iter().map(DevicePort::from).collect(), } } } +impl From<mullvad_types::device::DevicePort> for DevicePort { + fn from(port: mullvad_types::device::DevicePort) -> Self { + DevicePort { id: port.id } + } +} + impl From<mullvad_types::device::DeviceEvent> for DeviceEvent { fn from(event: mullvad_types::device::DeviceEvent) -> Self { DeviceEvent { @@ -725,10 +732,21 @@ impl TryFrom<Device> for mullvad_types::device::Device { id: device.id, name: device.name, pubkey: bytes_to_pubkey(&device.pubkey)?, + ports: device + .ports + .into_iter() + .map(mullvad_types::device::DevicePort::from) + .collect(), }) } } +impl From<DevicePort> for mullvad_types::device::DevicePort { + fn from(port: DevicePort) -> Self { + mullvad_types::device::DevicePort { id: port.id } + } +} + impl TryFrom<&WireguardConstraints> for mullvad_types::relay_constraints::WireguardConstraints { type Error = FromProtobufTypeError; diff --git a/mullvad-rpc/src/lib.rs b/mullvad-rpc/src/lib.rs index 1c55059b8d..9e6f42bb23 100644 --- a/mullvad-rpc/src/lib.rs +++ b/mullvad-rpc/src/lib.rs @@ -7,7 +7,7 @@ use futures::Stream; use hyper::Method; use mullvad_types::{ account::{AccountToken, VoucherSubmission}, - device::{Device, DeviceId, DeviceName}, + device::{Device, DeviceId, DeviceName, DevicePort}, version::AppVersion, }; use proxy::ApiConnectionMode; @@ -423,6 +423,7 @@ struct DeviceResponse { pubkey: wireguard::PublicKey, ipv4_address: ipnetwork::Ipv4Network, ipv6_address: ipnetwork::Ipv6Network, + ports: Vec<DevicePort>, } impl DevicesProxy { @@ -466,11 +467,17 @@ impl DevicesProxy { pubkey, ipv4_address, ipv6_address, + ports, .. } = response; Ok(( - Device { id, name, pubkey }, + Device { + id, + name, + pubkey, + ports, + }, mullvad_types::wireguard::AssociatedAddresses { ipv4_address, ipv6_address, diff --git a/mullvad-types/src/device.rs b/mullvad-types/src/device.rs index 294529592f..f27a6516de 100644 --- a/mullvad-types/src/device.rs +++ b/mullvad-types/src/device.rs @@ -19,6 +19,7 @@ pub struct Device { pub name: DeviceName, #[cfg_attr(target_os = "android", jnix(map = "|key| *key.as_bytes()"))] pub pubkey: PublicKey, + pub ports: Vec<DevicePort>, } impl Eq for Device {} @@ -40,6 +41,15 @@ impl Device { } } +/// Ports associated with a device. +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] +#[cfg_attr(target_os = "android", derive(IntoJava))] +#[cfg_attr(target_os = "android", jnix(package = "net.mullvad.mullvadvpn.model"))] +pub struct DevicePort { + /// Port identifier. + pub id: String, +} + /// A complete device configuration. #[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] pub struct DeviceData { |
