Skip to content

Commit

Permalink
Remove forwarded port from devices in Rust code
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Aug 31, 2023
1 parent a540bd0 commit cfca898
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 58 deletions.
5 changes: 1 addition & 4 deletions mullvad-api/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use chrono::{DateTime, Utc};
use http::{Method, StatusCode};
use mullvad_types::{
account::AccountToken,
device::{Device, DeviceId, DeviceName, DevicePort},
device::{Device, DeviceId, DeviceName},
};
use std::future::Future;
use talpid_types::net::wireguard;
Expand All @@ -23,7 +23,6 @@ struct DeviceResponse {
pubkey: wireguard::PublicKey,
ipv4_address: ipnetwork::Ipv4Network,
ipv6_address: ipnetwork::Ipv6Network,
ports: Vec<DevicePort>,
hijack_dns: bool,
created: DateTime<Utc>,
}
Expand Down Expand Up @@ -73,7 +72,6 @@ impl DevicesProxy {
pubkey,
ipv4_address,
ipv6_address,
ports,
hijack_dns,
created,
..
Expand All @@ -84,7 +82,6 @@ impl DevicesProxy {
id,
name,
pubkey,
ports,
hijack_dns,
created,
},
Expand Down
6 changes: 0 additions & 6 deletions mullvad-cli/src/cmds/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ impl Account {
println!("Device id : {}", device.device.id);
println!("Device pubkey : {}", device.device.pubkey);
println!("Device created : {}", device.device.created,);
for port in device.device.ports {
println!("Device port : {port}");
}
}
let expiry = rpc.get_account_data(device.account_token).await?;
println!(
Expand Down Expand Up @@ -156,9 +153,6 @@ impl Account {
"Created : {}",
device.created.with_timezone(&chrono::Local)
);
for port in device.ports {
println!("Port : {port}");
}
} else {
println!("{}", device.pretty_name());
}
Expand Down
7 changes: 1 addition & 6 deletions mullvad-daemon/src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ use mullvad_api::rest;
use mullvad_types::{
account::{AccountToken, VoucherSubmission},
device::{
AccountAndDevice, Device, DeviceEvent, DeviceEventCause, DeviceId, DeviceName, DevicePort,
DeviceState,
AccountAndDevice, Device, DeviceEvent, DeviceEventCause, DeviceId, DeviceName, DeviceState,
},
wireguard::{self, RotationInterval, WireguardData},
};
Expand Down Expand Up @@ -160,7 +159,6 @@ pub struct PrivateDevice {
pub id: DeviceId,
pub name: DeviceName,
pub wg_data: wireguard::WireguardData,
pub ports: Vec<DevicePort>,
// FIXME: Reasonable default to avoid migration code for the field,
// as it was previously missing.
// This attribute may be removed once upgrades from `2022.2-beta1`
Expand Down Expand Up @@ -190,7 +188,6 @@ impl PrivateDevice {
id: device.id,
name: device.name,
wg_data,
ports: device.ports,
hijack_dns: device.hijack_dns,
created: device.created,
})
Expand All @@ -203,7 +200,6 @@ impl PrivateDevice {
return Err(Error::InvalidDevice);
}
self.id = device.id;
self.ports = device.ports;
self.name = device.name;
self.hijack_dns = device.hijack_dns;
self.created = device.created;
Expand All @@ -215,7 +211,6 @@ impl From<PrivateDevice> for Device {
fn from(device: PrivateDevice) -> Self {
Device {
id: device.id,
ports: device.ports,
pubkey: device.wg_data.private_key.public_key(),
name: device.name,
hijack_dns: device.hijack_dns,
Expand Down
3 changes: 0 additions & 3 deletions mullvad-management-interface/proto/management_interface.proto
Original file line number Diff line number Diff line change
Expand Up @@ -622,13 +622,10 @@ message Device {
string id = 1;
string name = 2;
bytes pubkey = 3;
repeated DevicePort ports = 4;
bool hijack_dns = 5;
google.protobuf.Timestamp created = 6;
}

message DevicePort { string id = 1; }

message DeviceList { repeated Device devices = 1; }

message DeviceRemoval {
Expand Down
22 changes: 0 additions & 22 deletions mullvad-management-interface/src/types/conversions/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ impl TryFrom<proto::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(),
hijack_dns: device.hijack_dns,
created: chrono::DateTime::from_utc(
chrono::NaiveDateTime::from_timestamp_opt(
Expand All @@ -38,11 +33,6 @@ impl From<mullvad_types::device::Device> for proto::Device {
id: device.id,
name: device.name,
pubkey: device.pubkey.as_bytes().to_vec(),
ports: device
.ports
.into_iter()
.map(proto::DevicePort::from)
.collect(),
hijack_dns: device.hijack_dns,
created: Some(Timestamp {
seconds: device.created.timestamp(),
Expand Down Expand Up @@ -86,12 +76,6 @@ impl TryFrom<proto::DeviceState> for mullvad_types::device::DeviceState {
}
}

impl From<mullvad_types::device::DevicePort> for proto::DevicePort {
fn from(port: mullvad_types::device::DevicePort) -> Self {
proto::DevicePort { id: port.id }
}
}

impl From<mullvad_types::device::DeviceState> for proto::DeviceState {
fn from(state: mullvad_types::device::DeviceState) -> Self {
proto::DeviceState {
Expand Down Expand Up @@ -211,9 +195,3 @@ impl From<Vec<mullvad_types::device::Device>> for proto::DeviceList {
}
}
}

impl From<proto::DevicePort> for mullvad_types::device::DevicePort {
fn from(port: proto::DevicePort) -> Self {
mullvad_types::device::DevicePort { id: port.id }
}
}
17 changes: 0 additions & 17 deletions mullvad-types/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use chrono::{DateTime, Utc};
#[cfg(target_os = "android")]
use jnix::IntoJava;
use serde::{Deserialize, Serialize};
use std::fmt;
use talpid_types::net::wireguard::PublicKey;

/// UUID for a device.
Expand All @@ -21,7 +20,6 @@ pub struct Device {
pub name: DeviceName,
#[cfg_attr(target_os = "android", jnix(map = "|key| *key.as_bytes()"))]
pub pubkey: PublicKey,
pub ports: Vec<DevicePort>,
#[cfg_attr(target_os = "android", jnix(skip))]
pub hijack_dns: bool,
#[cfg_attr(target_os = "android", jnix(map = "|expiry| expiry.to_string()"))]
Expand Down Expand Up @@ -49,21 +47,6 @@ impl Device {
}
}

/// Ports associated with a device.
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[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,
}

impl fmt::Display for DevicePort {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.id)
}
}

/// Contains a device state.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
Expand Down

0 comments on commit cfca898

Please sign in to comment.