Import ErrorExt from talpid-error instead of talpid-types

This commit is contained in:
Markus Pettersson committed 2026-09-25 15:55:16 +02:00
1 parent 6bb8fb785f
commit 36f926828d
90 files changed
+138 -236

No files matched your search

Generated
+17 -8
View File
@@ -3403,6 +3403,7 @@ dependencies = [
"sha2",
"shadowsocks",
"sigsum",
"talpid-error",
"talpid-time",
"talpid-types",
"thiserror 2.0.19",
@@ -3483,6 +3484,7 @@ dependencies = [
"talpid-core",
"talpid-dbus",
"talpid-dns",
"talpid-error",
"talpid-future",
"talpid-macos",
"talpid-platform-metadata",
@@ -3513,6 +3515,7 @@ dependencies = [
"mullvad-relay-selector",
"mullvad-types",
"serde_json",
"talpid-error",
"talpid-future",
"talpid-types",
"thiserror 2.0.19",
@@ -3546,7 +3549,7 @@ name = "mullvad-fs"
version = "0.0.0"
dependencies = [
"log",
"talpid-types",
"talpid-error",
"tokio",
"uuid",
]
@@ -3575,6 +3578,7 @@ dependencies = [
"regex",
"shadowsocks",
"smoltcp",
"talpid-error",
"talpid-future",
"talpid-net",
"talpid-netstack",
@@ -3601,6 +3605,7 @@ dependencies = [
"mullvad-api",
"mullvad-daemon",
"mullvad-problem-report",
"talpid-error",
"talpid-platform-metadata",
"talpid-types",
"thiserror 2.0.19",
@@ -3643,6 +3648,7 @@ dependencies = [
"nix 0.31.3",
"prost",
"prost-types",
"talpid-error",
"talpid-types",
"thiserror 2.0.19",
"tipsy",
@@ -3717,8 +3723,8 @@ dependencies = [
"mullvad-paths",
"mullvad-version",
"regex",
"talpid-error",
"talpid-platform-metadata",
"talpid-types",
"thiserror 2.0.19",
"tokio",
"tracing-subscriber",
@@ -3791,8 +3797,8 @@ dependencies = [
"mullvad-types",
"mullvad-version",
"talpid-core",
"talpid-error",
"talpid-future",
"talpid-types",
"thiserror 2.0.19",
"tokio",
"tracing",
@@ -6077,6 +6083,7 @@ dependencies = [
"talpid-cgroup",
"talpid-dbus",
"talpid-dns",
"talpid-error",
"talpid-macos",
"talpid-net",
"talpid-platform-metadata",
@@ -6126,8 +6133,8 @@ dependencies = [
"resolv-conf",
"system-configuration",
"talpid-dbus",
"talpid-error",
"talpid-routing",
"talpid-types",
"talpid-windows",
"thiserror 2.0.19",
"tokio",
@@ -6173,7 +6180,7 @@ dependencies = [
"log",
"nix 0.31.3",
"socket2",
"talpid-types",
"talpid-error",
"thiserror 2.0.19",
]
@@ -6216,6 +6223,7 @@ dependencies = [
"nix 0.31.3",
"rtnetlink",
"system-configuration",
"talpid-error",
"talpid-types",
"talpid-windows",
"thiserror 2.0.19",
@@ -6245,6 +6253,7 @@ dependencies = [
"netlink-packet-route",
"netlink-sys",
"rtnetlink",
"talpid-error",
"talpid-routing",
"talpid-types",
"talpid-windows",
@@ -6289,7 +6298,6 @@ dependencies = [
"ipnetwork",
"itertools 0.14.0",
"jnix",
"log",
"safelog",
"serde",
"shadowsocks-crypto",
@@ -6305,7 +6313,7 @@ dependencies = [
"futures",
"log",
"socket2",
"talpid-types",
"talpid-error",
"thiserror 2.0.19",
"tokio",
"windows-sys 0.61.2",
@@ -6338,6 +6346,7 @@ dependencies = [
"socket2",
"surge-ping",
"talpid-dbus",
"talpid-error",
"talpid-net",
"talpid-routing",
"talpid-tunnel",
@@ -7848,7 +7857,7 @@ name = "windows-utils"
version = "0.0.0"
dependencies = [
"neon",
"talpid-types",
"talpid-error",
"talpid-windows",
"thiserror 2.0.19",
"windows",
+1
View File
@@ -128,6 +128,7 @@ strum = { version = "0.27" }
surge-ping = "0.8.4"
system-configuration = "0.7.0"
talpid-dbus = { path = "./talpid-dbus" }
talpid-error = { path = "./talpid-error" }
tempfile = "3.27.0"
thiserror = "2.0"
tipsy = "0.7.0"
+1 -1
View File
@@ -13,7 +13,7 @@ path = "windows-utils-rs/lib.rs"
[target.'cfg(target_os = "windows")'.dependencies]
neon = "1"
talpid-types = { path = "../../../talpid-types" }
talpid-error.workspace = true
talpid-windows = { path = "../../../talpid-windows" }
thiserror = { workspace = true }
windows = { workspace = true, features = [
@@ -5,7 +5,7 @@ use neon::prelude::{Context, FunctionContext};
use neon::result::JsResult;
use neon::types::{JsString, JsValue, Value};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
#[derive(thiserror::Error, Debug)]
enum Error {
+1
View File
@@ -35,6 +35,7 @@ serde_json = { workspace = true }
sha2 = { workspace = true }
shadowsocks = { workspace = true, features = ["stream-cipher"] }
sigsum = { workspace = true }
talpid-error.workspace = true
talpid-time = { path = "../talpid-time" }
talpid-types = { path = "../talpid-types" }
thiserror = { workspace = true }
+1 -1
View File
@@ -11,7 +11,7 @@ mod imp {
ApiEndpoint, RelayListProxy, proxy::ApiConnectionMode, rest::Error as RestError,
};
use std::process;
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
pub async fn main() {
let api_endpoint = ApiEndpoint::from_env_vars();
+1 -1
View File
@@ -9,7 +9,7 @@ use mullvad_types::account::{PlayExternalObfuscatedAccountId, PlayPurchase};
use proxy::{ApiConnectionMode, ConnectionModeSource};
use std::sync::LazyLock;
use std::{collections::BTreeMap, future::Future, io, net::SocketAddr, path::Path, sync::Arc};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use tracing::{Instrument, Level, instrument, trace_span};
pub mod availability;
+2 -4
View File
@@ -7,10 +7,8 @@ use std::{
pin::Pin,
task::{self, Poll},
};
use talpid_types::{
ErrorExt,
net::{Endpoint, TransportProtocol, proxy},
};
use talpid_error::ErrorExt;
use talpid_types::net::{Endpoint, TransportProtocol, proxy};
use tokio::{
fs,
io::{AsyncRead, AsyncWrite, AsyncWriteExt, ReadBuf},
+1
View File
@@ -14,6 +14,7 @@ mullvad-management-interface = { path = "../mullvad-management-interface" }
mullvad-relay-selector = { path = "../mullvad-relay-selector" }
mullvad-types = { path = "../mullvad-types" }
serde_json = { workspace = true, features = ["std"] }
talpid-error.workspace = true
talpid-future = { path = "../talpid-future/" }
talpid-types = { path = "../talpid-types" }
thiserror = { workspace = true }
@@ -17,8 +17,8 @@ use mullvad_api::{
CachedRelayList, RelayListProxy, availability::ApiAvailability, rest::MullvadRestHandle,
};
use mullvad_types::relay_list::{BridgeList, RelayList};
use talpid_error::ErrorExt;
use talpid_future::retry::{ExponentialBackoff, Jittered, retry_future};
use talpid_types::ErrorExt;
use crate::relay_selector::RelaySelectorIO;
+1
View File
@@ -96,6 +96,7 @@ serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true, features = ["std"] }
talpid-core = { path = "../talpid-core" }
talpid-dns = { path = "../talpid-dns" }
talpid-error.workspace = true
talpid-future = { path = "../talpid-future" }
talpid-platform-metadata = { path = "../talpid-platform-metadata" }
talpid-routing = { path = "../talpid-routing" }
+1 -1
View File
@@ -1,6 +1,6 @@
use mullvad_types::account::AccountNumber;
use std::path::Path;
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use tokio::{
fs,
io::{self, AsyncReadExt, AsyncSeekExt, AsyncWriteExt},
+2 -1
View File
@@ -27,7 +27,8 @@ use std::{
time::{Duration, SystemTime},
};
use talpid_core::mpsc::Sender;
use talpid_types::{ErrorExt, tunnel::TunnelStateTransition};
use talpid_error::ErrorExt;
use talpid_types::tunnel::TunnelStateTransition;
use tokio::{
fs,
io::{self, AsyncReadExt, AsyncSeekExt, AsyncWriteExt},
+1 -1
View File
@@ -11,7 +11,7 @@ use std::{
ptr,
sync::atomic::{AtomicBool, Ordering},
};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use talpid_windows::process::{ModuleEntry, ProcessSnapshot};
use winapi::vc::excpt::EXCEPTION_EXECUTE_HANDLER;
use windows_sys::Win32::{
+1 -1
View File
@@ -11,8 +11,8 @@ use mullvad_api::{
use mullvad_types::location::{AmIMullvad, GeoIpLocation, LocationEventData};
use std::sync::LazyLock;
use talpid_core::mpsc::Sender;
use talpid_error::ErrorExt;
use talpid_future::retry::{ExponentialBackoff, Jittered, retry_future};
use talpid_types::ErrorExt;
use crate::DaemonEventSender;
+1 -1
View File
@@ -105,13 +105,13 @@ use talpid_core::{
split_tunnel,
tunnel_state_machine::{self, TunnelCommand, TunnelStateMachineHandle},
};
use talpid_error::ErrorExt;
use talpid_routing::RouteManagerHandle;
#[cfg(target_os = "android")]
use talpid_types::android::AndroidContext;
#[cfg(target_os = "windows")]
use talpid_types::split_tunnel::ExcludedProcess;
use talpid_types::{
ErrorExt,
net::{IpVersion, proxy::ShadowsocksCipher},
tunnel::{ErrorStateCause, TunnelStateTransition},
};
+1 -1
View File
@@ -7,7 +7,7 @@ use mullvad_daemon::{
logging::{self, LogLocation},
rpc_uniqueness_check, runtime, version,
};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
#[cfg(all(feature = "default-allocator", target_os = "linux"))]
#[global_allocator]
+1 -1
View File
@@ -34,7 +34,7 @@ use std::{
sync::{Arc, Mutex},
time::Duration,
};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use tokio::time::timeout;
use tokio_stream::wrappers::UnboundedReceiverStream;
@@ -2,7 +2,7 @@ use super::{Error, Result};
use mullvad_types::account::AccountNumber;
use serde::Deserialize;
use std::path::Path;
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use tokio::{
fs::{self, File},
io::{self, AsyncReadExt, AsyncSeekExt, AsyncWriteExt},
+1 -1
View File
@@ -15,7 +15,7 @@ use crate::{
use mullvad_types::{account::AccountNumber, wireguard::WireguardData};
use std::time::Duration;
use talpid_core::mpsc::Sender;
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use tokio::time::timeout;
const TIMEOUT: Duration = Duration::from_secs(30);
+1 -1
View File
@@ -276,7 +276,7 @@ mod windows {
path::Path,
ptr::{self, NonNull},
};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use tokio::fs;
use windows_sys::Win32::{
Foundation::{ERROR_SUCCESS, LocalFree},
+1 -1
View File
@@ -1,5 +1,5 @@
use mullvad_management_interface::MullvadProxyClient;
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
/// Checks if there is another instance of the daemon running.
///
+1 -1
View File
@@ -11,7 +11,7 @@ use std::{
pin::Pin,
};
use talpid_core::firewall::is_local_address;
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use tokio::{
fs,
io::{self, AsyncWriteExt},
+2 -1
View File
@@ -1,4 +1,6 @@
use ctrlc;
#[cfg(target_os = "linux")]
use talpid_error::ErrorExt;
use thiserror::Error;
#[derive(Error, Debug)]
@@ -15,7 +17,6 @@ pub fn set_shutdown_signal_handler(f: impl Fn() + 'static + Send) -> Result<(),
/// be assumed that the machine is shutting down.
#[cfg(target_os = "linux")]
pub fn is_shutdown_user_initiated() -> bool {
use talpid_types::ErrorExt;
talpid_dbus::systemd::is_host_running()
.map_err(|err| {
err.display_chain_with_msg(
+1 -1
View File
@@ -18,7 +18,7 @@ use std::{
thread,
time::{Duration, Instant},
};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use windows_service::{
service::{
PowerEventParam, Service, ServiceAccess, ServiceAction, ServiceActionType, ServiceControl,
+1 -1
View File
@@ -4,7 +4,7 @@ use std::{
ops::Deref,
path::{Path, PathBuf},
};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use tokio::{fs, io};
/// State to use by default if there is no cache.
+2 -1
View File
@@ -1,6 +1,7 @@
use ipnetwork::{IpNetwork, Ipv4Network, Ipv6Network};
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr};
use std::{future::Future, net::IpAddr, pin::Pin, sync::Arc};
use talpid_error::ErrorExt;
use talpid_types::net::wireguard::TunnelParameters;
use tokio::sync::Mutex;
@@ -18,7 +19,7 @@ use talpid_types::net::{
ALLOWED_LAN_MULTICAST_NETS, ALLOWED_LAN_NETS, ipnetwork_sub::IpNetworkSub,
obfuscation::Obfuscators, wireguard,
};
use talpid_types::{ErrorExt, net::IpAvailability, tunnel::ParameterGenerationError};
use talpid_types::{net::IpAvailability, tunnel::ParameterGenerationError};
use crate::device::{AccountManagerHandle, Error as DeviceError, PrivateAccountAndDevice};
+1 -1
View File
@@ -21,8 +21,8 @@ use std::{
time::{Duration, SystemTime},
};
use talpid_core::mpsc::Sender;
use talpid_error::ErrorExt;
use talpid_future::retry::{ConstantInterval, retry_future};
use talpid_types::ErrorExt;
use super::Error;
+1 -1
View File
@@ -9,7 +9,7 @@ use rand::seq::IndexedRandom;
use std::io;
use std::path::PathBuf;
use std::time::{Duration, Instant};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use tokio::fs;
use tokio::sync::broadcast;
+1 -1
View File
@@ -13,7 +13,7 @@ use mullvad_update::app::{AppDownloader, AppDownloaderParameters, HttpAppDownloa
use mullvad_update::version::{VersionInfo, rollout::Rollout};
use talpid_core::mpsc::Sender;
#[cfg(in_app_upgrade)]
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use crate::DaemonEventSender;
use crate::management_interface::AppUpgradeBroadcast;
+1 -1
View File
@@ -8,7 +8,7 @@ license.workspace = true
[dependencies]
log = { workspace = true }
talpid-types = { path = "../talpid-types" }
talpid-error.workspace = true
tokio = { workspace = true, features = ["fs", "rt"] }
uuid = { version = "1.4.1", features = ["v4"] }
+1 -1
View File
@@ -2,7 +2,7 @@ use std::{
ops::{Deref, DerefMut},
path::{Path, PathBuf},
};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use tokio::{fs, io};
/// Stores content in a temporary file before moving it to the
+1
View File
@@ -34,6 +34,7 @@ smoltcp = { version = "0.13", default-features = false, features = [
"socket-tcp",
"std",
] }
talpid-error.workspace = true
talpid-net = { path = "../talpid-net" }
talpid-netstack = { path = "../talpid-netstack" }
talpid-time = { path = "../talpid-time" }
+1
View File
@@ -35,6 +35,7 @@ exceptions = [
{ crate = "mullvad-types", allow = ["GPL-3.0-or-later"] },
{ crate = "mullvad-update", allow = ["GPL-3.0-or-later"] },
{ crate = "mullvad-version", allow = ["GPL-3.0-or-later"] },
{ crate = "talpid-error", allow = ["GPL-3.0-or-later"] },
{ crate = "talpid-future", allow = ["GPL-3.0-or-later"] },
{ crate = "talpid-net", allow = ["GPL-3.0-or-later"] },
{ crate = "talpid-netstack", allow = ["GPL-3.0-or-later"] },
+2 -4
View File
@@ -27,6 +27,7 @@ use gotatun::{
},
x25519::StaticSecret,
};
use talpid_error::ErrorExt;
use talpid_netstack::{
ip_mux::ip_mux,
smoltcp_network::{SmoltcpHandle, smoltcp_network},
@@ -34,10 +35,7 @@ use talpid_netstack::{
use talpid_tunnel_config_client::negotiation::{
Negotiables, NegotiationConfig, NegotiationError, Relay, Relays, negotiate_ephemeral_peers,
};
use talpid_types::{
ErrorExt,
net::wireguard::{PrivateKey, PublicKey},
};
use talpid_types::net::wireguard::{PrivateKey, PublicKey};
use tokio::sync::{
Mutex,
mpsc::{UnboundedReceiver, UnboundedSender},
+1
View File
@@ -16,6 +16,7 @@ log-panics = "2"
mullvad-api = { path = "../mullvad-api" }
mullvad-daemon = { path = "../mullvad-daemon" }
mullvad-problem-report = { path = "../mullvad-problem-report" }
talpid-error.workspace = true
talpid-platform-metadata = { path = "../talpid-platform-metadata" }
talpid-types = { path = "../talpid-types" }
thiserror = { workspace = true }
+2 -1
View File
@@ -27,7 +27,8 @@ use std::{
path::{Path, PathBuf},
sync::{Arc, Mutex, Once},
};
use talpid_types::{ErrorExt, android::AndroidContext};
use talpid_error::ErrorExt;
use talpid_types::android::AndroidContext;
/// Mullvad daemon instance. It must be initialized and destroyed by `MullvadDaemon.initialize` and
/// `MullvadDaemon.shutdown`, respectively.
+1 -1
View File
@@ -9,7 +9,7 @@ use jnix::{
use mullvad_api::ApiEndpoint;
use std::path::Path;
use std::path::PathBuf;
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
#[unsafe(no_mangle)]
#[expect(non_snake_case)]
+1
View File
@@ -18,6 +18,7 @@ mullvad-paths = { path = "../mullvad-paths" }
mullvad-types = { path = "../mullvad-types" }
prost = { workspace = true }
prost-types = { workspace = true }
talpid-error.workspace = true
talpid-types = { path = "../talpid-types" }
thiserror = { workspace = true }
tipsy = { workspace = true }
@@ -1,6 +1,6 @@
use crate::types::{FromProtobufTypeError, proto};
use mullvad_types::{constraints::Constraint, settings::CURRENT_SETTINGS_VERSION};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
impl From<&mullvad_types::settings::Settings> for proto::Settings {
fn from(settings: &mullvad_types::settings::Settings) -> Self {
+1 -1
View File
@@ -20,8 +20,8 @@ mullvad-api = { path = "../mullvad-api" }
mullvad-paths = { path = "../mullvad-paths" }
mullvad-version = { path = "../mullvad-version" }
regex = "1.0"
talpid-error.workspace = true
talpid-platform-metadata = { path = "../talpid-platform-metadata" }
talpid-types = { path = "../talpid-types" }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["rt"] }
uuid = { version = "1.4.1", features = ["v4"] }
+1 -1
View File
@@ -10,7 +10,7 @@ use std::{
path::{Path, PathBuf},
sync::LazyLock,
};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
pub mod metadata;
+1 -1
View File
@@ -6,7 +6,7 @@ use std::{
path::{Path, PathBuf},
process,
};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
fn main() {
process::exit(match run() {
+1 -1
View File
@@ -19,8 +19,8 @@ mullvad-paths = { path = "../mullvad-paths" }
mullvad-types = { path = "../mullvad-types" }
mullvad-version = { path = "../mullvad-version" }
talpid-core = { path = "../talpid-core" }
talpid-error.workspace = true
talpid-future = { path = "../talpid-future" }
talpid-types = { path = "../talpid-types" }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["rt-multi-thread"] }
tracing = "0.1.44"
+1 -1
View File
@@ -4,8 +4,8 @@ use mullvad_management_interface::MullvadProxyClient;
use mullvad_version::Version;
use std::{path::PathBuf, process, str::FromStr, sync::LazyLock, time::Duration};
use talpid_core::firewall::{self, Firewall};
use talpid_error::ErrorExt;
use talpid_future::retry::{ConstantInterval, retry_future};
use talpid_types::ErrorExt;
use tracing_subscriber::EnvFilter;
#[cfg(target_os = "windows")]
+1
View File
@@ -15,6 +15,7 @@ libc = "0.2"
log = { workspace = true }
rand = { workspace = true }
talpid-dns = { path = "../talpid-dns" }
talpid-error.workspace = true
talpid-routing = { path = "../talpid-routing" }
talpid-tunnel = { path = "../talpid-tunnel" }
talpid-types = { path = "../talpid-types" }
+2 -1
View File
@@ -12,7 +12,8 @@ use std::{
net::IpAddr,
sync::{Arc, Mutex},
};
use talpid_types::{ErrorExt, android::AndroidContext, net::Connectivity};
use talpid_error::ErrorExt;
use talpid_types::{android::AndroidContext, net::Connectivity};
/// Error related to Android connectivity monitor
#[derive(thiserror::Error, Debug)]
+1 -1
View File
@@ -1,8 +1,8 @@
use std::{net::IpAddr, sync::LazyLock};
use talpid_error::ErrorExt;
use talpid_tunnel::TunnelMetadata;
use talpid_types::{
ErrorExt,
net::{AllowedEndpoint, AllowedTunnelTraffic},
tunnel::FirewallPolicyError,
};
+2 -1
View File
@@ -3,8 +3,9 @@ use std::{
net::{IpAddr, Ipv4Addr, Ipv6Addr},
sync::Arc,
};
use talpid_error::ErrorExt;
use talpid_routing::RouteManagerHandle;
use talpid_types::{ErrorExt, net::Connectivity};
use talpid_types::net::Connectivity;
pub type Result<T> = std::result::Result<T, Error>;
+1 -1
View File
@@ -94,7 +94,7 @@ pub async fn spawn_monitor(
let mut route_listener = route_listener.fuse();
loop {
talpid_types::detect_flood!();
talpid_error::detect_flood!();
select! {
_ = timeout => {
+2 -1
View File
@@ -2,9 +2,10 @@
use crate::connectivity_listener::ConnectivityListener;
use futures::channel::mpsc::UnboundedSender;
use std::sync::LazyLock;
use talpid_error::ErrorExt;
#[cfg(not(target_os = "android"))]
use talpid_routing::RouteManagerHandle;
use talpid_types::{ErrorExt, net::Connectivity};
use talpid_types::net::Connectivity;
#[cfg(target_os = "macos")]
#[path = "macos.rs"]
+2 -1
View File
@@ -6,8 +6,9 @@ use std::{
sync::{Arc, Weak},
time::Duration,
};
use talpid_error::ErrorExt;
use talpid_routing::{CallbackHandle, EventType, RouteManagerHandle, get_best_default_route};
use talpid_types::{ErrorExt, net::Connectivity};
use talpid_types::net::Connectivity;
use talpid_windows::net::AddressFamily;
#[derive(thiserror::Error, Debug)]
+2 -1
View File
@@ -4,8 +4,9 @@ use std::{
path::PathBuf,
sync::{Arc, Weak},
};
use talpid_error::ErrorExt;
use talpid_routing::RouteManagerHandle;
use talpid_types::{ErrorExt, tunnel::ErrorStateCause};
use talpid_types::tunnel::ErrorStateCause;
use tokio::sync::{mpsc, oneshot};
use self::process::ExclusionStatus;
@@ -23,7 +23,7 @@ use std::{
ptr,
time::Duration,
};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use talpid_windows::{io::Overlapped, process::ProcessSnapshot, sync::Event};
use windows_sys::Win32::{
Foundation::{
+2 -1
View File
@@ -22,9 +22,10 @@ use std::{
},
time::Duration,
};
use talpid_error::ErrorExt;
use talpid_routing::{CallbackHandle, EventType, RouteManagerHandle, get_best_default_route};
use talpid_tunnel::TunnelMetadata;
use talpid_types::{ErrorExt, split_tunnel::ExcludedProcess, tunnel::ErrorStateCause};
use talpid_types::{split_tunnel::ExcludedProcess, tunnel::ErrorStateCause};
use talpid_windows::{
io::Overlapped,
net::{AddressFamily, get_ip_address_for_interface},
@@ -9,7 +9,7 @@ use std::{
path::{self, Path},
sync::{Arc, Mutex, MutexGuard, mpsc as sync_mpsc},
};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use windows_sys::Win32::{
Storage::FileSystem::GetLogicalDrives,
UI::WindowsAndMessaging::{
@@ -2,10 +2,10 @@ use futures::StreamExt;
use futures::channel::{mpsc, oneshot};
use futures::stream::Fuse;
use talpid_error::{BoxedError, ErrorExt};
use talpid_tunnel::{TunnelEvent, TunnelMetadata};
use talpid_types::net::{AllowedClients, AllowedEndpoint, wireguard::TunnelParameters};
use talpid_types::tunnel::{ErrorStateCause, FirewallPolicyError};
use talpid_types::{BoxedError, ErrorExt};
use crate::firewall::FirewallPolicy;
#[cfg(target_os = "macos")]
@@ -6,10 +6,10 @@ use std::time::{Duration, Instant};
use futures::channel::{mpsc, oneshot};
use futures::future::Fuse;
use futures::{FutureExt, StreamExt};
use talpid_error::ErrorExt;
use talpid_routing::RouteManagerHandle;
use talpid_tunnel::tun_provider::TunProvider;
use talpid_tunnel::{EventHook, SelectedObfuscation, TunnelArgs, TunnelEvent, TunnelMetadata};
use talpid_types::ErrorExt;
use talpid_types::net::obfuscation::Obfuscators;
use talpid_types::net::{
AllowedClients, AllowedEndpoint, AllowedTunnelTraffic, wireguard::TunnelParameters,
@@ -7,7 +7,7 @@ use crate::firewall::FirewallPolicy;
#[cfg(target_os = "macos")]
use crate::tunnel_state_machine::ErrorState;
use futures::StreamExt;
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
#[cfg(target_os = "macos")]
use talpid_types::tunnel::ErrorStateCause;
@@ -9,10 +9,8 @@ use crate::resolver::LOCAL_DNS_RESOLVER;
use futures::StreamExt;
#[cfg(target_os = "macos")]
use talpid_dns::DnsConfig;
use talpid_types::{
ErrorExt,
tunnel::{ErrorStateCause, FirewallPolicyError, ParameterGenerationError},
};
use talpid_error::ErrorExt;
use talpid_types::tunnel::{ErrorStateCause, FirewallPolicyError, ParameterGenerationError};
/// No tunnel is running and all network connections are blocked.
pub struct ErrorState {
+5 -3
View File
@@ -24,12 +24,12 @@ use std::ffi::OsString;
#[cfg(target_os = "linux")]
use talpid_cgroup::v2::CGroup2;
use talpid_dns::{DnsConfig, DnsMonitor};
#[cfg(target_os = "macos")]
use talpid_error::ErrorExt;
use talpid_routing::RouteManagerHandle;
#[cfg(target_os = "macos")]
use talpid_tunnel::TunnelMetadata;
use talpid_tunnel::{TunnelEvent, tun_provider::TunProvider};
#[cfg(target_os = "macos")]
use talpid_types::ErrorExt;
use futures::{
StreamExt,
@@ -47,7 +47,9 @@ use std::{
time::Duration,
};
#[cfg(target_os = "android")]
use talpid_types::{ErrorExt, android::AndroidContext};
use talpid_error::ErrorExt;
#[cfg(target_os = "android")]
use talpid_types::android::AndroidContext;
use talpid_types::{
net::{AllowedEndpoint, Connectivity, IpAvailability, wireguard::TunnelParameters},
tunnel::{ErrorStateCause, ParameterGenerationError, TunnelStateTransition},
+1 -1
View File
@@ -8,7 +8,7 @@ license.workspace = true
[dependencies]
log = { workspace = true }
talpid-types = { path = "../talpid-types" }
talpid-error.workspace = true
thiserror = { workspace = true }
[target.'cfg(target_os = "linux")'.dependencies]
+1 -1
View File
@@ -7,6 +7,7 @@ mod systemd_resolved;
use std::env;
use std::fmt;
use std::net::IpAddr;
use talpid_error::ErrorExt;
use self::network_manager::NetworkManager;
use self::resolvconf::Resolvconf;
@@ -112,7 +113,6 @@ impl DnsMonitorHolder {
fn with_detected_dns_manager() -> Result<Self> {
fn log_err<E: std::error::Error>(method: &'static str) -> impl Fn(&E) {
use talpid_types::ErrorExt;
move |err: &E| {
log::debug!(
"{}",
+1 -1
View File
@@ -3,7 +3,7 @@ use inotify::{Inotify, WatchMask};
use parking_lot::Mutex;
use resolv_conf::{Config, ScopedIp};
use std::{fs, io, net::IpAddr, path::Path, sync::Arc};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use triggered::{Listener, Trigger, trigger};
const RESOLV_CONF_BACKUP_PATH: &str = "/etc/resolv.conf.mullvadbackup";
+1 -1
View File
@@ -1,6 +1,6 @@
use std::net::IpAddr;
use talpid_dbus::systemd_resolved::{AsyncHandle, SystemdResolved as DbusInterface};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
pub(crate) use talpid_dbus::systemd_resolved::Error as SystemdDbusError;
+1 -1
View File
@@ -88,7 +88,7 @@ impl State {
servers: &[IpAddr],
port: u16,
) -> Result<()> {
talpid_types::detect_flood!();
talpid_error::detect_flood!();
let servers: Vec<DnsServer> = servers.iter().map(|ip| ip.to_string()).collect();
let new_settings =
+1 -1
View File
@@ -10,7 +10,7 @@ use std::{
os::windows::ffi::OsStrExt,
ptr,
};
use talpid_types::win32_err;
use talpid_error::win32_err;
use talpid_windows::net::{guid_from_luid, luid_from_alias};
use windows_sys::{
Win32::NetworkManagement::IpHelper::{
+1 -1
View File
@@ -1,6 +1,6 @@
use super::{DnsMonitorT, ResolvedDnsConfig};
use std::{io, net::IpAddr};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use talpid_windows::net::{guid_from_luid, luid_from_alias};
use windows_registry::{LOCAL_MACHINE, Transaction};
use windows_sys::{Win32::System::Com::StringFromGUID2, core::GUID};
+1 -1
View File
@@ -13,7 +13,7 @@ socket2 = { workspace = true, features = ["all"] }
[target."cfg(unix)".dependencies]
libc = "0.2"
nix = { workspace = true, features = ["net"] }
talpid-types = { path = "../talpid-types" }
talpid-error.workspace = true
thiserror = { workspace = true }
[lints]
+1 -1
View File
@@ -10,7 +10,7 @@ use nix::errno::Errno;
use nix::libc::ifreq;
use nix::net::if_::if_nametoindex;
use socket2::{Domain, Protocol, Socket, Type};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
#[derive(Debug, thiserror::Error)]
#[error("Failed to get index for interface {interface_name}: {error}")]
+2 -1
View File
@@ -10,7 +10,7 @@ license.workspace = true
futures = { workspace = true }
ipnetwork = { workspace = true }
log = { workspace = true }
talpid-types = { path = "../talpid-types" }
talpid-error.workspace = true
thiserror = { workspace = true }
tokio = { workspace = true, features = ["io-util", "net", "process", "rt-multi-thread", "time"] }
@@ -19,6 +19,7 @@ tokio = { workspace = true, features = ["test-util"] }
[target.'cfg(target_os = "android")'.dependencies]
jnix = { version = "0.5.2", features = ["derive"] }
talpid-types = { path = "../talpid-types" }
[target.'cfg(target_os = "linux")'.dependencies]
libc = "0.2"
+1 -1
View File
@@ -100,7 +100,7 @@ impl BurstGuard {
/// Asynchronously trigger burst
pub fn trigger(&self) {
talpid_types::detect_flood!();
talpid_error::detect_flood!();
self.trigger_with_period(self.buffer_period)
}
+1 -1
View File
@@ -13,7 +13,7 @@ use netlink_packet_core::{
};
use netlink_packet_route::route::RouteFlags;
use rtnetlink::sys::AsyncSocket;
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use futures::{
StreamExt, TryStreamExt,
+5 -5
View File
@@ -16,7 +16,7 @@ use std::{
sync::Weak,
time::Duration,
};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use super::RouteManagerCommand;
use data::{Destination, RouteDestination, RouteMessage, RouteSocketMessage};
@@ -173,7 +173,7 @@ impl RouteManagerImpl {
let mut completion_tx = None;
loop {
talpid_types::detect_flood!();
talpid_error::detect_flood!();
futures::select_biased! {
route_message = self.routing_table.next_message().fuse() => {
@@ -181,7 +181,7 @@ impl RouteManagerImpl {
}
_ = self.check_default_routes_restored.next() => {
talpid_types::detect_flood!();
talpid_error::detect_flood!();
if self.check_default_routes_restored.is_terminated() {
continue;
@@ -379,7 +379,7 @@ impl RouteManagerImpl {
&mut self,
message: std::result::Result<RouteSocketMessage, watch::Error>,
) {
talpid_types::detect_flood!();
talpid_error::detect_flood!();
log::trace!("got RouteSocketMessage::{:?}", message.as_ref().unwrap());
@@ -448,7 +448,7 @@ impl RouteManagerImpl {
/// server. The gateway of the relay route is set to the first interface in the network
/// service order that has a working ifscoped default route.
async fn refresh_routes(&mut self) -> Result<()> {
talpid_types::detect_flood!();
talpid_error::detect_flood!();
for (_, event) in self.best_default_route_update.drain() {
self.default_route_listeners
@@ -104,7 +104,7 @@ impl RoutingSocket {
async fn wait_for_response(&mut self, response_num: i32) -> Result<Vec<u8>> {
loop {
talpid_types::detect_flood!();
talpid_error::detect_flood!();
let mut buffer = vec![0u8; 2048];
// do not truncate the buffer - trailing empty bytes won't be written but will be
@@ -11,7 +11,7 @@ use std::{
sync::{Arc, Mutex},
time::Duration,
};
use talpid_types::win32_err;
use talpid_error::win32_err;
use windows_sys::Win32::NetworkManagement::{
IpHelper::{
CancelMibChangeNotify2, ConvertInterfaceLuidToIndex, MIB_IPFORWARD_ROW2,
@@ -1,6 +1,6 @@
use super::{Error, Result};
use std::{net::SocketAddr, slice};
use talpid_types::win32_err;
use talpid_error::win32_err;
use talpid_windows::net::{
AddressFamily, get_ip_interface_entry, try_socketaddr_from_inet_sockaddr,
};
+1 -1
View File
@@ -12,7 +12,7 @@ use ipnetwork::IpNetwork;
use net::AddressFamily;
pub use route_manager::{Callback, CallbackHandle, Route, RouteManagerInternal};
use std::{collections::HashSet, io, net::IpAddr};
use talpid_types::ErrorExt;
use talpid_error::ErrorExt;
use talpid_windows::net;
mod default_route_monitor;
+1 -1
View File
@@ -11,7 +11,7 @@ use std::{
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
sync::{Arc, Mutex},
};
use talpid_types::win32_err;
use talpid_error::win32_err;
use talpid_windows::net::{
AddressFamily, inet_sockaddr_from_socketaddr, try_socketaddr_from_inet_sockaddr,
};
+1
View File
@@ -21,6 +21,7 @@ tun = { workspace = true }
[target.'cfg(target_os = "android")'.dependencies]
jnix = { version = "0.5.1", features = ["derive"] }
talpid-error.workspace = true
[target.'cfg(target_os = "linux")'.dependencies]
netlink-packet-core.workspace = true
@@ -17,10 +17,11 @@ use std::{
},
sync::Arc,
};
use talpid_error::ErrorExt;
use talpid_routing::Route;
use talpid_types::net::ipnetwork_sub::IpNetworkSub;
use talpid_types::net::{ALLOWED_LAN_MULTICAST_NETS, ALLOWED_LAN_NETS};
use talpid_types::{ErrorExt, android::AndroidContext, android::InetNetwork};
use talpid_types::{android::AndroidContext, android::InetNetwork};
/// Socks5 proxies on Mullvad relays can be connected on the range 10.124.0.0/23 if already
/// connected to another Mullvad relay.
-1
View File
@@ -10,7 +10,6 @@ license.workspace = true
base64 = "0.22.0"
ipnetwork = { workspace = true, features = ["serde"] }
itertools.workspace = true
log = { workspace = true }
safelog = { workspace = true, features = ["serde"] }
serde = { workspace = true, features = ["derive"] }
shadowsocks-crypto.workspace = true
-132
View File
@@ -1,132 +0,0 @@
use std::{error::Error, fmt, fmt::Write};
/// Used to generate string representations of error chains.
pub trait ErrorExt {
/// Creates a string representation of the entire error chain.
fn display_chain(&self) -> String;
/// Like [Self::display_chain] but with an extra message at the start of the chain
fn display_chain_with_msg(&self, msg: &str) -> String;
}
impl<E: Error> ErrorExt for E {
fn display_chain(&self) -> String {
let mut s = format!("Error: {self}");
let mut source = self.source();
while let Some(error) = source {
write!(&mut s, "\nCaused by: {error}").expect("formatting failed");
source = error.source();
}
s
}
fn display_chain_with_msg(&self, msg: &str) -> String {
let mut s = format!("Error: {msg}\nCaused by: {self}");
let mut source = self.source();
while let Some(error) = source {
write!(&mut s, "\nCaused by: {error}").expect("formatting failed");
source = error.source();
}
s
}
}
#[derive(Debug)]
pub struct BoxedError(Box<dyn Error + 'static + Send>);
impl fmt::Display for BoxedError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
impl Error for BoxedError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
self.0.source()
}
}
impl BoxedError {
pub fn new(error: impl Error + 'static + Send) -> Self {
BoxedError(Box::new(error))
}
}
/// Helper macro allowing simpler handling of Windows FFI returning `WIN32_ERROR`
/// status codes. Converts a `WIN32_ERROR` into an `io::Result<()>`.
///
/// The caller of this macro must have `windows_sys` as a dependency.
#[cfg(windows)]
#[macro_export]
macro_rules! win32_err {
($expr:expr) => {{
let status = $expr;
if status == ::windows_sys::Win32::Foundation::NO_ERROR {
Ok(())
} else {
Err(::std::io::Error::from_raw_os_error(status as i32))
}
}};
}
pub mod flood {
#[doc(hidden)]
pub use log;
use std::time::{Duration, Instant};
const CALLS_INTERVAL: Duration = Duration::from_secs(5);
const CALLS_THRESHOLD: usize = 1000;
/// Log when a line is hit unusually frequently, that is, over `CALLS_THRESHOLD` times within a
/// period of `CALLS_INTERVAL`.
#[macro_export]
macro_rules! detect_flood {
() => {{
static FLOOD: ::std::sync::Mutex<$crate::flood::DetectFlood> =
::std::sync::Mutex::new($crate::flood::DetectFlood::new());
if FLOOD.lock().unwrap().bump() {
$crate::flood::log::warn!(
"Flood: {}, line {}, col {}",
file!(),
line!(),
column!()
);
}
}};
}
/// Used to detect code that is running too frequently
pub struct DetectFlood {
last_clear: Option<Instant>,
counter: usize,
}
impl Default for DetectFlood {
fn default() -> Self {
DetectFlood::new()
}
}
impl DetectFlood {
pub const fn new() -> Self {
DetectFlood {
last_clear: None,
counter: 0,
}
}
pub fn bump(&mut self) -> bool {
let now = Instant::now();
let last_clear = self.last_clear.get_or_insert(now);
if now.saturating_duration_since(*last_clear) >= CALLS_INTERVAL {
self.last_clear = Some(now);
self.counter = 0;
false
} else {
self.counter = self.counter.saturating_add(1);
self.counter == CALLS_THRESHOLD
}
}
}
}
-3
View File
@@ -7,6 +7,3 @@ pub mod tunnel;
pub mod split_tunnel;
pub mod drop_guard;
mod error;
pub use error::*;
+1 -1
View File
@@ -25,7 +25,7 @@ features = ["Win32_Storage", "Win32_Storage_FileSystem"]
futures = { workspace = true }
log = { workspace = true }
socket2 = { workspace = true }
talpid-types = { path = "../talpid-types" }
talpid-error.workspace = true
thiserror = { workspace = true }
[target."cfg(windows)".dependencies.windows-sys]
+1 -1
View File
@@ -12,7 +12,7 @@ use std::{
sync::{Arc, Mutex},
time::{Duration, Instant},
};
use talpid_types::win32_err;
use talpid_error::win32_err;
use windows_sys::{
Win32::{
Foundation::{ERROR_NOT_FOUND, HANDLE, WIN32_ERROR},
+1
View File
@@ -19,6 +19,7 @@ parking_lot = "0.12.0"
rand = { workspace = true }
socket2 = { workspace = true, features = ["all"] }
surge-ping = { workspace = true }
talpid-error.workspace = true
talpid-net = { path = "../talpid-net" }
talpid-routing = { path = "../talpid-routing" }
talpid-tunnel = { path = "../talpid-tunnel" }
+2 -1
View File
@@ -28,10 +28,11 @@ use talpid_tunnel::{
WIREGUARD_HEADER_SIZE, tun_provider,
};
use talpid_error::{BoxedError, ErrorExt};
use talpid_net::bypass::SocketBypass;
#[cfg(all(not(target_os = "android"), not(target_os = "linux")))]
use talpid_types::net::obfuscation::Obfuscators;
use talpid_types::{BoxedError, ErrorExt, net::wireguard::TunnelParameters};
use talpid_types::net::wireguard::TunnelParameters;
use tokio::sync::Mutex as AsyncMutex;
mod gotatun;
+1 -1
View File
@@ -24,7 +24,7 @@ use std::{
},
time::{Duration, SystemTime, UNIX_EPOCH},
};
use talpid_types::{BoxedError, ErrorExt};
use talpid_error::{BoxedError, ErrorExt};
use talpid_windows::net;
use widestring::{U16CStr, U16CString};
use windows_sys::{
+12 -3
View File
@@ -2339,6 +2339,7 @@ dependencies = [
"sha2",
"shadowsocks",
"sigsum",
"talpid-error",
"talpid-time",
"talpid-types",
"thiserror 2.0.18",
@@ -2364,6 +2365,7 @@ dependencies = [
"mullvad-relay-selector",
"mullvad-types",
"serde_json",
"talpid-error",
"talpid-future",
"talpid-types",
"thiserror 2.0.18",
@@ -2387,7 +2389,7 @@ name = "mullvad-fs"
version = "0.0.0"
dependencies = [
"log",
"talpid-types",
"talpid-error",
"tokio",
"uuid",
]
@@ -2405,6 +2407,7 @@ dependencies = [
"nix 0.31.3",
"prost",
"prost-types",
"talpid-error",
"talpid-types",
"thiserror 2.0.18",
"tipsy",
@@ -3713,6 +3716,13 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417"
[[package]]
name = "talpid-error"
version = "0.0.0"
dependencies = [
"log",
]
[[package]]
name = "talpid-future"
version = "0.0.0"
@@ -3756,7 +3766,6 @@ dependencies = [
"ipnetwork 0.21.1",
"itertools 0.14.0",
"jnix",
"log",
"safelog",
"serde",
"shadowsocks-crypto",
@@ -3772,7 +3781,7 @@ dependencies = [
"futures",
"log",
"socket2 0.6.5",
"talpid-types",
"talpid-error",
"thiserror 2.0.18",
"windows-sys 0.61.2",
]