Skip to content

Commit

Permalink
Merge branch 'update-dependencies'
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Sep 11, 2023
2 parents 6428279 + ea815b8 commit 64d0b37
Show file tree
Hide file tree
Showing 35 changed files with 716 additions and 910 deletions.
1,344 changes: 576 additions & 768 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ members = [
[workspace.dependencies]
tokio = { version = "1.8" }
# Tonic and related crates
tonic = "0.8"
tonic-build = { version = "0.8", default-features = false }
tonic = "0.10.0"
tonic-build = { version = "0.10.0", default-features = false }
tower = "0.4"
prost = "0.11"
prost-types = "0.11"
prost = "0.12.0"
prost-types = "0.12.0"

env_logger = "0.10.0"
err-derive = "0.3.1"
log = "0.4"

shadowsocks = { version = "1.16" }
shadowsocks-service = { version = "1.16" }
Expand Down
2 changes: 1 addition & 1 deletion android/translations-converter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition.workspace = true
publish.workspace = true

[dependencies]
err-derive = "0.3.1"
err-derive = { workspace = true }
htmlize = { version = "1.0.2", features = ["unescape"] }
once_cell = "1.13"
regex = "1"
Expand Down
4 changes: 2 additions & 2 deletions mullvad-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ api-override = []

[dependencies]
chrono = { workspace = true }
err-derive = "0.3.1"
err-derive = { workspace = true }
futures = "0.3"
http = "0.2"
hyper = { version = "0.14", features = ["client", "stream", "http1", "tcp" ] }
ipnetwork = "0.16"
log = "0.4"
log = { workspace = true }
serde = "1"
serde_json = "1.0"
tokio = { workspace = true, features = ["macros", "time", "rt-multi-thread", "net", "io-std", "io-util", "fs"] }
Expand Down
2 changes: 1 addition & 1 deletion mullvad-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ path = "src/main.rs"
anyhow = "1.0"
chrono = { workspace = true }
clap = { workspace = true }
env_logger = "0.10.0"
env_logger = { workspace = true }
futures = "0.3"
natord = "1.0.9"
itertools = "0.10"
Expand Down
4 changes: 2 additions & 2 deletions mullvad-daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ api-override = ["mullvad-api/api-override"]

[dependencies]
chrono = { workspace = true }
err-derive = "0.3.1"
err-derive = { workspace = true }
fern = { version = "0.6", features = ["colored"] }
futures = "0.3"
once_cell = "1.13"
libc = "0.2"
log = "0.4"
log = { workspace = true }
parking_lot = "0.12.0"
regex = "1.0"
serde = { version = "1.0", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion mullvad-exclude/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ publish.workspace = true

[target.'cfg(target_os = "linux")'.dependencies]
nix = "0.23"
err-derive = "0.3.1"
err-derive = { workspace = true }
talpid-types = { path = "../talpid-types" }
2 changes: 1 addition & 1 deletion mullvad-fs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition.workspace = true
publish.workspace = true

[dependencies]
log = "0.4"
log = { workspace = true }
tokio = { workspace = true, features = ["fs", "rt"] }
uuid = { version = "1.4.1", features = ["v4"] }

Expand Down
4 changes: 2 additions & 2 deletions mullvad-jni/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ api-override = ["mullvad-api/api-override"]
crate_type = ["cdylib"]

[target.'cfg(target_os = "android")'.dependencies]
err-derive = "0.3.1"
err-derive = { workspace = true }
futures = "0.3"
ipnetwork = "0.16"
jnix = { version = "0.5", features = ["derive"] }
log = "0.4"
log = { workspace = true }
log-panics = "2"
nix = "0.23"
rand = "0.8.5"
Expand Down
4 changes: 2 additions & 2 deletions mullvad-management-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ publish.workspace = true

[dependencies]
chrono = { workspace = true }
err-derive = "0.3.1"
err-derive = { workspace = true }
mullvad-types = { path = "../mullvad-types" }
mullvad-paths = { path = "../mullvad-paths" }
talpid-types = { path = "../talpid-types" }
Expand All @@ -21,7 +21,7 @@ prost-types = { workspace = true }
parity-tokio-ipc = "0.9"
futures = "0.3"
tokio = { workspace = true, features = ["rt"] }
log = "0.4"
log = { workspace = true }

[target.'cfg(unix)'.dependencies]
nix = "0.23"
Expand Down
5 changes: 3 additions & 2 deletions mullvad-management-interface/src/types/conversions/account.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::types;
use chrono::TimeZone;
use mullvad_types::account::{AccountData, VoucherSubmission};

use super::FromProtobufTypeError;
Expand Down Expand Up @@ -27,7 +28,7 @@ impl TryFrom<types::VoucherSubmission> for VoucherSubmission {
.unwrap();

Ok(VoucherSubmission {
new_expiry: chrono::DateTime::<chrono::Utc>::from_utc(ndt, chrono::Utc),
new_expiry: chrono::Utc.from_utc_datetime(&ndt),
time_added: submission.seconds_added,
})
}
Expand Down Expand Up @@ -55,7 +56,7 @@ impl TryFrom<types::AccountData> for AccountData {
chrono::NaiveDateTime::from_timestamp_opt(expiry.seconds, expiry.nanos as u32).unwrap();

Ok(AccountData {
expiry: chrono::DateTime::<chrono::Utc>::from_utc(ndt, chrono::Utc),
expiry: chrono::Utc.from_utc_datetime(&ndt),
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ impl TryFrom<proto::CustomListLocationUpdate>
.location
.ok_or(FromProtobufTypeError::InvalidArgument("missing location"))?,
);
match proto::custom_list_location_update::State::from_i32(custom_list.state) {
Some(proto::custom_list_location_update::State::Add) => Ok(Self::Add {
match proto::custom_list_location_update::State::try_from(custom_list.state) {
Ok(proto::custom_list_location_update::State::Add) => Ok(Self::Add {
name: custom_list.name,
location,
}),
Some(proto::custom_list_location_update::State::Remove) => Ok(Self::Remove {
Ok(proto::custom_list_location_update::State::Remove) => Ok(Self::Remove {
name: custom_list.name,
location,
}),
None => Err(FromProtobufTypeError::InvalidArgument("incorrect state")),
Err(_) => Err(FromProtobufTypeError::InvalidArgument("incorrect state")),
}
}
}
Expand Down
15 changes: 7 additions & 8 deletions mullvad-management-interface/src/types/conversions/device.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::types::{conversions::bytes_to_pubkey, proto, FromProtobufTypeError};
use chrono::TimeZone;
use prost_types::Timestamp;

impl TryFrom<proto::Device> for mullvad_types::device::Device {
Expand All @@ -10,8 +11,8 @@ impl TryFrom<proto::Device> for mullvad_types::device::Device {
name: device.name,
pubkey: bytes_to_pubkey(&device.pubkey)?,
hijack_dns: device.hijack_dns,
created: chrono::DateTime::from_utc(
chrono::NaiveDateTime::from_timestamp_opt(
created: chrono::Utc.from_utc_datetime(
&chrono::NaiveDateTime::from_timestamp_opt(
device
.created
.ok_or(FromProtobufTypeError::InvalidArgument(
Expand All @@ -21,7 +22,6 @@ impl TryFrom<proto::Device> for mullvad_types::device::Device {
0,
)
.unwrap(),
chrono::Utc,
),
})
}
Expand All @@ -46,9 +46,8 @@ impl TryFrom<proto::DeviceState> for mullvad_types::device::DeviceState {
type Error = FromProtobufTypeError;

fn try_from(state: proto::DeviceState) -> Result<Self, FromProtobufTypeError> {
let state_type = proto::device_state::State::from_i32(state.state).ok_or(
FromProtobufTypeError::InvalidArgument("invalid device state"),
)?;
let state_type = proto::device_state::State::try_from(state.state)
.map_err(|_| FromProtobufTypeError::InvalidArgument("invalid device state"))?;

match state_type {
proto::device_state::State::LoggedIn => {
Expand Down Expand Up @@ -112,8 +111,8 @@ impl TryFrom<proto::DeviceEvent> for mullvad_types::device::DeviceEvent {
type Error = FromProtobufTypeError;

fn try_from(event: proto::DeviceEvent) -> Result<Self, Self::Error> {
let cause = proto::device_event::Cause::from_i32(event.cause)
.ok_or(FromProtobufTypeError::InvalidArgument("invalid event"))?;
let cause = proto::device_event::Cause::try_from(event.cause)
.map_err(|_| FromProtobufTypeError::InvalidArgument("invalid event"))?;
let cause = mullvad_types::device::DeviceEventCause::from(cause);

let new_state = mullvad_types::device::DeviceState::try_from(event.new_state.ok_or(
Expand Down
28 changes: 13 additions & 15 deletions mullvad-management-interface/src/types/conversions/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ impl TryFrom<proto::TunnelEndpoint> for talpid_types::net::TunnelEndpoint {
)?,
protocol: try_transport_protocol_from_i32(proxy_ep.protocol)?,
},
proxy_type: match proto::ProxyType::from_i32(proxy_ep.proxy_type) {
Some(proto::ProxyType::Shadowsocks) => {
proxy_type: match proto::ProxyType::try_from(proxy_ep.proxy_type) {
Ok(proto::ProxyType::Shadowsocks) => {
talpid_net::proxy::ProxyType::Shadowsocks
}
Some(proto::ProxyType::Custom) => talpid_net::proxy::ProxyType::Custom,
None => {
Ok(proto::ProxyType::Custom) => talpid_net::proxy::ProxyType::Custom,
Err(_) => {
return Err(FromProtobufTypeError::InvalidArgument(
"unknown proxy type",
))
Expand All @@ -97,13 +97,13 @@ impl TryFrom<proto::TunnelEndpoint> for talpid_types::net::TunnelEndpoint {
),
protocol: try_transport_protocol_from_i32(obfs_ep.protocol)?,
},
obfuscation_type: match proto::ObfuscationType::from_i32(
obfuscation_type: match proto::ObfuscationType::try_from(
obfs_ep.obfuscation_type,
) {
Some(proto::ObfuscationType::Udp2tcp) => {
Ok(proto::ObfuscationType::Udp2tcp) => {
talpid_net::ObfuscationType::Udp2Tcp
}
None => {
Err(_) => {
return Err(FromProtobufTypeError::InvalidArgument(
"unknown obfuscation type",
))
Expand Down Expand Up @@ -177,10 +177,10 @@ impl From<proto::IpVersion> for proto::IpVersionConstraint {
pub fn try_tunnel_type_from_i32(
tunnel_type: i32,
) -> Result<talpid_types::net::TunnelType, FromProtobufTypeError> {
match proto::TunnelType::from_i32(tunnel_type) {
Some(proto::TunnelType::Openvpn) => Ok(talpid_types::net::TunnelType::OpenVpn),
Some(proto::TunnelType::Wireguard) => Ok(talpid_types::net::TunnelType::Wireguard),
None => Err(FromProtobufTypeError::InvalidArgument(
match proto::TunnelType::try_from(tunnel_type) {
Ok(proto::TunnelType::Openvpn) => Ok(talpid_types::net::TunnelType::OpenVpn),
Ok(proto::TunnelType::Wireguard) => Ok(talpid_types::net::TunnelType::Wireguard),
Err(_) => Err(FromProtobufTypeError::InvalidArgument(
"invalid tunnel protocol",
)),
}
Expand All @@ -189,9 +189,7 @@ pub fn try_tunnel_type_from_i32(
pub fn try_transport_protocol_from_i32(
protocol: i32,
) -> Result<talpid_types::net::TransportProtocol, FromProtobufTypeError> {
Ok(proto::TransportProtocol::from_i32(protocol)
.ok_or(FromProtobufTypeError::InvalidArgument(
"invalid transport protocol",
))?
Ok(proto::TransportProtocol::try_from(protocol)
.map_err(|_| FromProtobufTypeError::InvalidArgument("invalid transport protocol"))?
.into())
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ impl TryFrom<&proto::WireguardConstraints>
use talpid_types::net;

let ip_version = match &constraints.ip_version {
Some(constraint) => match proto::IpVersion::from_i32(constraint.protocol) {
Some(proto::IpVersion::V4) => Some(net::IpVersion::V4),
Some(proto::IpVersion::V6) => Some(net::IpVersion::V6),
None => {
Some(constraint) => match proto::IpVersion::try_from(constraint.protocol) {
Ok(proto::IpVersion::V4) => Some(net::IpVersion::V4),
Ok(proto::IpVersion::V6) => Some(net::IpVersion::V6),
Err(_) => {
return Err(FromProtobufTypeError::InvalidArgument(
"invalid ip protocol version",
))
Expand Down Expand Up @@ -660,11 +660,11 @@ impl TryFrom<proto::ObfuscationSettings> for mullvad_types::relay_constraints::O
use mullvad_types::relay_constraints::SelectedObfuscation;
use proto::obfuscation_settings::SelectedObfuscation as IpcSelectedObfuscation;
let selected_obfuscation =
match IpcSelectedObfuscation::from_i32(settings.selected_obfuscation) {
Some(IpcSelectedObfuscation::Auto) => SelectedObfuscation::Auto,
Some(IpcSelectedObfuscation::Off) => SelectedObfuscation::Off,
Some(IpcSelectedObfuscation::Udp2tcp) => SelectedObfuscation::Udp2Tcp,
None => {
match IpcSelectedObfuscation::try_from(settings.selected_obfuscation) {
Ok(IpcSelectedObfuscation::Auto) => SelectedObfuscation::Auto,
Ok(IpcSelectedObfuscation::Off) => SelectedObfuscation::Off,
Ok(IpcSelectedObfuscation::Udp2tcp) => SelectedObfuscation::Udp2Tcp,
Err(_) => {
return Err(FromProtobufTypeError::InvalidArgument(
"invalid selected obfuscator",
));
Expand Down Expand Up @@ -709,17 +709,17 @@ impl TryFrom<proto::BridgeState> for mullvad_types::relay_constraints::BridgeSta
type Error = FromProtobufTypeError;

fn try_from(state: proto::BridgeState) -> Result<Self, Self::Error> {
match proto::bridge_state::State::from_i32(state.state) {
Some(proto::bridge_state::State::Auto) => {
match proto::bridge_state::State::try_from(state.state) {
Ok(proto::bridge_state::State::Auto) => {
Ok(mullvad_types::relay_constraints::BridgeState::Auto)
}
Some(proto::bridge_state::State::On) => {
Ok(proto::bridge_state::State::On) => {
Ok(mullvad_types::relay_constraints::BridgeState::On)
}
Some(proto::bridge_state::State::Off) => {
Ok(proto::bridge_state::State::Off) => {
Ok(mullvad_types::relay_constraints::BridgeState::Off)
}
None => Err(FromProtobufTypeError::InvalidArgument(
Err(_) => Err(FromProtobufTypeError::InvalidArgument(
"invalid bridge state",
)),
}
Expand Down Expand Up @@ -758,11 +758,9 @@ pub fn try_providers_constraint_from_proto(
pub fn try_ownership_constraint_from_i32(
ownership: i32,
) -> Result<Constraint<mullvad_types::relay_constraints::Ownership>, FromProtobufTypeError> {
proto::Ownership::from_i32(ownership)
proto::Ownership::try_from(ownership)
.map(ownership_constraint_from_proto)
.ok_or(FromProtobufTypeError::InvalidArgument(
"invalid ownership argument",
))
.map_err(|_| FromProtobufTypeError::InvalidArgument("invalid ownership argument"))
}

pub fn ownership_constraint_from_proto(
Expand Down
20 changes: 9 additions & 11 deletions mullvad-management-interface/src/types/conversions/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,15 @@ impl TryFrom<proto::Settings> for mullvad_types::settings::Settings {
pub fn try_bridge_state_from_i32(
bridge_state: i32,
) -> Result<mullvad_types::relay_constraints::BridgeState, FromProtobufTypeError> {
match proto::bridge_state::State::from_i32(bridge_state) {
Some(proto::bridge_state::State::Auto) => {
match proto::bridge_state::State::try_from(bridge_state) {
Ok(proto::bridge_state::State::Auto) => {
Ok(mullvad_types::relay_constraints::BridgeState::Auto)
}
Some(proto::bridge_state::State::On) => {
Ok(mullvad_types::relay_constraints::BridgeState::On)
}
Some(proto::bridge_state::State::Off) => {
Ok(proto::bridge_state::State::On) => Ok(mullvad_types::relay_constraints::BridgeState::On),
Ok(proto::bridge_state::State::Off) => {
Ok(mullvad_types::relay_constraints::BridgeState::Off)
}
None => Err(FromProtobufTypeError::InvalidArgument(
Err(_) => Err(FromProtobufTypeError::InvalidArgument(
"invalid bridge state",
)),
}
Expand Down Expand Up @@ -286,10 +284,10 @@ impl TryFrom<proto::DnsOptions> for mullvad_types::settings::DnsOptions {
DnsState as MullvadDnsState,
};

let state = match proto::dns_options::DnsState::from_i32(options.state) {
Some(proto::dns_options::DnsState::Default) => MullvadDnsState::Default,
Some(proto::dns_options::DnsState::Custom) => MullvadDnsState::Custom,
None => {
let state = match proto::dns_options::DnsState::try_from(options.state) {
Ok(proto::dns_options::DnsState::Default) => MullvadDnsState::Default,
Ok(proto::dns_options::DnsState::Custom) => MullvadDnsState::Custom,
Err(_) => {
return Err(FromProtobufTypeError::InvalidArgument(
"invalid DNS options state",
))
Expand Down
Loading

0 comments on commit 64d0b37

Please sign in to comment.