diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2018-12-13 17:32:24 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2018-12-13 17:36:07 +0100 |
| commit | ffd272313cdfc77a79876050170272ab36fe932d (patch) | |
| tree | 4036176402e0f1d306d57a2860074699cbf4f319 | |
| parent | e175aaa139da8010fd3ae85bfc10dc7d98d50acc (diff) | |
| download | mullvadvpn-ffd272313cdfc77a79876050170272ab36fe932d.tar.xz mullvadvpn-ffd272313cdfc77a79876050170272ab36fe932d.zip | |
Activate the merge_imports rustfmt feature
44 files changed, 246 insertions, 200 deletions
diff --git a/mullvad-cli/src/cmds/relay.rs b/mullvad-cli/src/cmds/relay.rs index 058c17976a..edabbe8b9b 100644 --- a/mullvad-cli/src/cmds/relay.rs +++ b/mullvad-cli/src/cmds/relay.rs @@ -2,11 +2,13 @@ use crate::{new_rpc_client, Command, Result, ResultExt}; use clap::value_t; use std::str::FromStr; -use mullvad_types::relay_constraints::{ - Constraint, LocationConstraint, OpenVpnConstraints, RelayConstraintsUpdate, - RelaySettingsUpdate, TunnelConstraints, +use mullvad_types::{ + relay_constraints::{ + Constraint, LocationConstraint, OpenVpnConstraints, RelayConstraintsUpdate, + RelaySettingsUpdate, TunnelConstraints, + }, + CustomTunnelEndpoint, }; -use mullvad_types::CustomTunnelEndpoint; use talpid_types::net::{ OpenVpnEndpointData, TransportProtocol, TunnelEndpointData, WireguardEndpointData, }; diff --git a/mullvad-cli/src/cmds/status.rs b/mullvad-cli/src/cmds/status.rs index 11b0156edf..46a2968d72 100644 --- a/mullvad-cli/src/cmds/status.rs +++ b/mullvad-cli/src/cmds/status.rs @@ -1,8 +1,10 @@ use crate::{new_rpc_client, Command, Result}; use mullvad_ipc_client::DaemonRpcClient; use mullvad_types::auth_failed::AuthFailed; -use talpid_types::tunnel::BlockReason; -use talpid_types::tunnel::TunnelStateTransition::{self, *}; +use talpid_types::tunnel::{ + BlockReason, + TunnelStateTransition::{self, *}, +}; pub struct Status; diff --git a/mullvad-daemon/build.rs b/mullvad-daemon/build.rs index f35e2fa4a1..39cac1707d 100644 --- a/mullvad-daemon/build.rs +++ b/mullvad-daemon/build.rs @@ -1,7 +1,4 @@ -use std::env; -use std::fs; -use std::path::PathBuf; -use std::process::Command; +use std::{env, fs, path::PathBuf, process::Command}; #[cfg(windows)] extern crate winapi; diff --git a/mullvad-daemon/src/account_history.rs b/mullvad-daemon/src/account_history.rs index 51b677e675..a3820add44 100644 --- a/mullvad-daemon/src/account_history.rs +++ b/mullvad-daemon/src/account_history.rs @@ -1,8 +1,10 @@ extern crate serde_json; -use std::fs::File; -use std::io; -use std::path::{Path, PathBuf}; +use std::{ + fs::File, + io, + path::{Path, PathBuf}, +}; use mullvad_types::account::AccountToken; diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 57755f83b5..cf1a5f7443 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -58,8 +58,7 @@ use mullvad_types::{ TunnelConstraints, }, relay_list::{Relay, RelayList}, - settings, - settings::Settings, + settings::{self, Settings}, states::TargetState, version::{AppVersion, AppVersionInfo}, }; diff --git a/mullvad-daemon/src/logging.rs b/mullvad-daemon/src/logging.rs index 8779e32068..7005f2f7ea 100644 --- a/mullvad-daemon/src/logging.rs +++ b/mullvad-daemon/src/logging.rs @@ -1,13 +1,13 @@ extern crate fern; -use self::fern::colors::{Color, ColoredLevelConfig}; -use self::fern::Output; +use self::fern::{ + colors::{Color, ColoredLevelConfig}, + Output, +}; use chrono; use log; -use std::fmt; -use std::io; -use std::path::PathBuf; +use std::{fmt, io, path::PathBuf}; use talpid_core::logging::rotate_log; diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs index f9eb8ffa63..59e29381a2 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -1,8 +1,13 @@ use crate::account_history::{AccountHistory, Error as AccountHistoryError}; use error_chain::ChainedError; -use jsonrpc_core::futures::sync::oneshot::Sender as OneshotSender; -use jsonrpc_core::futures::{future, sync, Future}; -use jsonrpc_core::{Error, ErrorCode, MetaIoHandler, Metadata}; +use jsonrpc_core::{ + futures::{ + future, + sync::{self, oneshot::Sender as OneshotSender}, + Future, + }, + Error, ErrorCode, MetaIoHandler, Metadata, +}; use jsonrpc_ipc_server; use jsonrpc_macros::{build_rpc_trait, metadata, pubsub}; use jsonrpc_pubsub::{PubSubHandler, PubSubMetadata, Session, SubscriptionId}; diff --git a/mullvad-daemon/src/relays.rs b/mullvad-daemon/src/relays.rs index 74f071e487..a2c43d3b0a 100644 --- a/mullvad-daemon/src/relays.rs +++ b/mullvad-daemon/src/relays.rs @@ -3,22 +3,28 @@ use error_chain::ChainedError; use futures::Future; use mullvad_rpc::{HttpHandle, RelayListProxy}; -use mullvad_types::location::Location; -use mullvad_types::relay_constraints::{ - Constraint, LocationConstraint, Match, OpenVpnConstraints, RelayConstraints, TunnelConstraints, +use mullvad_types::{ + location::Location, + relay_constraints::{ + Constraint, LocationConstraint, Match, OpenVpnConstraints, RelayConstraints, + TunnelConstraints, + }, + relay_list::{Relay, RelayList, RelayTunnels}, }; -use mullvad_types::relay_list::{Relay, RelayList, RelayTunnels}; use serde_json; use talpid_types::net::{TransportProtocol, TunnelEndpoint, TunnelEndpointData}; -use std::fs::File; -use std::net::IpAddr; -use std::path::{Path, PathBuf}; -use std::sync::{mpsc, Arc, Mutex, MutexGuard}; -use std::time::{self, Duration, SystemTime}; -use std::{io, thread}; +use std::{ + fs::File, + io, + net::IpAddr, + path::{Path, PathBuf}, + sync::{mpsc, Arc, Mutex, MutexGuard}, + thread, + time::{self, Duration, SystemTime}, +}; use log::{debug, error, info, trace, warn}; use rand::{self, Rng, ThreadRng}; diff --git a/mullvad-daemon/src/system_service.rs b/mullvad-daemon/src/system_service.rs index 96aaf75d03..64e49d8e77 100644 --- a/mullvad-daemon/src/system_service.rs +++ b/mullvad-daemon/src/system_service.rs @@ -4,20 +4,23 @@ use std::{ env, ffi::OsString, io, - sync::atomic::{AtomicUsize, Ordering}, - sync::{mpsc, Arc}, + sync::{ + atomic::{AtomicUsize, Ordering}, + mpsc, Arc, + }, thread, time::Duration, }; -use windows_service::service::{ - ServiceAccess, ServiceControl, ServiceControlAccept, ServiceDependency, ServiceErrorControl, - ServiceExitCode, ServiceInfo, ServiceStartType, ServiceState, ServiceStatus, ServiceType, +use windows_service::{ + service::{ + ServiceAccess, ServiceControl, ServiceControlAccept, ServiceDependency, + ServiceErrorControl, ServiceExitCode, ServiceInfo, ServiceStartType, ServiceState, + ServiceStatus, ServiceType, + }, + service_control_handler::{self, ServiceControlHandlerResult, ServiceStatusHandle}, + service_dispatcher, + service_manager::{ServiceManager, ServiceManagerAccess}, }; -use windows_service::service_control_handler::{ - self, ServiceControlHandlerResult, ServiceStatusHandle, -}; -use windows_service::service_dispatcher; -use windows_service::service_manager::{ServiceManager, ServiceManagerAccess}; use super::{Result, ResultExt}; use mullvad_daemon::DaemonShutdownHandle; diff --git a/mullvad-rpc/src/lib.rs b/mullvad-rpc/src/lib.rs index cd2f287a32..18ba30fa92 100644 --- a/mullvad-rpc/src/lib.rs +++ b/mullvad-rpc/src/lib.rs @@ -12,8 +12,7 @@ extern crate error_chain; use chrono::{offset::Utc, DateTime}; use jsonrpc_client_core::{expand_params, jsonrpc_client}; -use jsonrpc_client_http::header::Host; -use jsonrpc_client_http::{HttpTransport, HttpTransportBuilder}; +use jsonrpc_client_http::{header::Host, HttpTransport, HttpTransportBuilder}; use lazy_static::lazy_static; use mullvad_types::{account::AccountToken, relay_list::RelayList, version}; use std::{ diff --git a/mullvad-tests/src/lib.rs b/mullvad-tests/src/lib.rs index c13c67b6ce..da5f36c3b4 100644 --- a/mullvad-tests/src/lib.rs +++ b/mullvad-tests/src/lib.rs @@ -1,5 +1,4 @@ -use self::mock_openvpn::MOCK_OPENVPN_ARGS_FILE; -use self::platform_specific::*; +use self::{mock_openvpn::MOCK_OPENVPN_ARGS_FILE, platform_specific::*}; use futures::sync::oneshot; use jsonrpc_client_core::{Future, Transport}; use jsonrpc_client_ipc::IpcTransport; @@ -7,12 +6,13 @@ use mullvad_ipc_client::{DaemonRpcClient, ResultExt}; use mullvad_paths::resources::API_CA_FILENAME; use notify::{RawEvent, RecommendedWatcher, RecursiveMode, Watcher}; use std::{ + cmp, collections::HashMap, fs::{self, File}, path::{Path, PathBuf}, sync::{mpsc, Arc}, + thread, time::{Duration, Instant}, - {cmp, thread}, }; use tempfile::TempDir; use tokio::reactor::Handle; diff --git a/mullvad-tests/tests/account.rs b/mullvad-tests/tests/account.rs index 16b877bb76..e4cff3b4b9 100644 --- a/mullvad-tests/tests/account.rs +++ b/mullvad-tests/tests/account.rs @@ -1,7 +1,6 @@ #![cfg(feature = "integration-tests")] -use mullvad_tests::mock_openvpn::search_openvpn_args; -use mullvad_tests::{watch_event, DaemonRunner, PathWatcher}; +use mullvad_tests::{mock_openvpn::search_openvpn_args, watch_event, DaemonRunner, PathWatcher}; use std::{ fs::File, io::{BufRead, BufReader}, diff --git a/mullvad-types/src/relay_constraints.rs b/mullvad-types/src/relay_constraints.rs index f2799cc07c..52f22a9229 100644 --- a/mullvad-types/src/relay_constraints.rs +++ b/mullvad-types/src/relay_constraints.rs @@ -1,5 +1,7 @@ -use crate::location::{CityCode, CountryCode, Hostname}; -use crate::CustomTunnelEndpoint; +use crate::{ + location::{CityCode, CountryCode, Hostname}, + CustomTunnelEndpoint, +}; use serde::{Deserialize, Serialize}; use std::fmt; use talpid_types::net::{OpenVpnEndpointData, TransportProtocol, WireguardEndpointData}; diff --git a/rustfmt.toml b/rustfmt.toml index c061bec008..d77d6af544 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -4,6 +4,7 @@ use_field_init_shorthand = true condense_wildcard_suffixes = true normalize_comments = true wrap_comments = true +merge_imports = true # Heavily subjective style choices comment_width = 100 diff --git a/talpid-core/build.rs b/talpid-core/build.rs index b4c66db87c..afd8eccefb 100644 --- a/talpid-core/build.rs +++ b/talpid-core/build.rs @@ -1,7 +1,6 @@ #[cfg(windows)] mod win { - use std::env; - use std::path::PathBuf; + use std::{env, path::PathBuf}; pub static WINFW_BUILD_DIR: &'static str = "..\\windows\\winfw\\bin"; pub static WINDNS_BUILD_DIR: &'static str = "..\\windows\\windns\\bin"; diff --git a/talpid-core/src/logging.rs b/talpid-core/src/logging.rs index 512f86c9a6..9f63c70a33 100644 --- a/talpid-core/src/logging.rs +++ b/talpid-core/src/logging.rs @@ -1,5 +1,4 @@ -use std::path::Path; -use std::{fs, io}; +use std::{fs, io, path::Path}; error_chain! {} diff --git a/talpid-core/src/mktemp.rs b/talpid-core/src/mktemp.rs index 5e72044809..b5b5ec0719 100644 --- a/talpid-core/src/mktemp.rs +++ b/talpid-core/src/mktemp.rs @@ -1,7 +1,7 @@ -use std::env; -use std::fs; -use std::io; -use std::path::{Path, PathBuf}; +use std::{ + env, fs, io, + path::{Path, PathBuf}, +}; use uuid::Uuid; diff --git a/talpid-core/src/mpsc.rs b/talpid-core/src/mpsc.rs index c8e5b7449d..fd8814ab74 100644 --- a/talpid-core/src/mpsc.rs +++ b/talpid-core/src/mpsc.rs @@ -1,5 +1,4 @@ -use std::marker::PhantomData; -use std::sync::mpsc; +use std::{marker::PhantomData, sync::mpsc}; /// Abstraction over an `mpsc::Sender` that first converts the value to another type before sending. #[derive(Debug, Clone)] @@ -33,8 +32,7 @@ where #[cfg(test)] mod tests { use super::*; - use std::sync::mpsc; - use std::thread; + use std::{sync::mpsc, thread}; #[derive(Debug, Eq, PartialEq)] enum Inner { diff --git a/talpid-core/src/network_interface.rs b/talpid-core/src/network_interface.rs index 0bdc23072e..761fcbf794 100644 --- a/talpid-core/src/network_interface.rs +++ b/talpid-core/src/network_interface.rs @@ -1,6 +1,8 @@ use nix::fcntl; -use std::net::IpAddr; -use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd}; +use std::{ + net::IpAddr, + os::unix::io::{AsRawFd, IntoRawFd, RawFd}, +}; use tun::{platform, Configuration, Device}; error_chain! { diff --git a/talpid-core/src/offline/linux.rs b/talpid-core/src/offline/linux.rs index 68792f39bb..cf0daca86a 100644 --- a/talpid-core/src/offline/linux.rs +++ b/talpid-core/src/offline/linux.rs @@ -2,18 +2,19 @@ extern crate iproute2; extern crate netlink_socket; extern crate rtnetlink; -use std::collections::BTreeSet; -use std::thread; +use std::{collections::BTreeSet, thread}; use error_chain::ChainedError; use futures::{future::Either, sync::mpsc::UnboundedSender, Future, Stream}; use log::{error, trace, warn}; -use self::iproute2::Link; -use self::netlink_socket::{Protocol, SocketAddr, TokioSocket}; -use self::rtnetlink::{ - LinkFlags, LinkHeader, LinkLayerType, LinkMessage, NetlinkCodec, NetlinkFramed, NetlinkMessage, - RtnlMessage, +use self::{ + iproute2::Link, + netlink_socket::{Protocol, SocketAddr, TokioSocket}, + rtnetlink::{ + LinkFlags, LinkHeader, LinkLayerType, LinkMessage, NetlinkCodec, NetlinkFramed, + NetlinkMessage, RtnlMessage, + }, }; use tunnel_state_machine::TunnelCommand; diff --git a/talpid-core/src/offline/windows.rs b/talpid-core/src/offline/windows.rs index eb8fe9a5b8..e5dbbaaed2 100644 --- a/talpid-core/src/offline/windows.rs +++ b/talpid-core/src/offline/windows.rs @@ -8,28 +8,35 @@ extern crate winapi; -use self::winapi::shared::basetsd::LONG_PTR; -use self::winapi::shared::minwindef::{DWORD, LPARAM, LRESULT, UINT, WPARAM}; -use self::winapi::shared::windef::HWND; -use self::winapi::um::handleapi::CloseHandle; -use self::winapi::um::libloaderapi::GetModuleHandleW; -use self::winapi::um::processthreadsapi::GetThreadId; -use self::winapi::um::synchapi::WaitForSingleObject; -use self::winapi::um::winbase::INFINITE; -use self::winapi::um::winuser::{ - CreateWindowExW, DefWindowProcW, DestroyWindow, DispatchMessageW, GetMessageW, - GetWindowLongPtrW, PostQuitMessage, PostThreadMessageW, SetWindowLongPtrW, GWLP_USERDATA, - GWLP_WNDPROC, PBT_APMRESUMEAUTOMATIC, PBT_APMSUSPEND, WM_DESTROY, WM_POWERBROADCAST, WM_USER, +use self::winapi::{ + shared::{ + basetsd::LONG_PTR, + minwindef::{DWORD, LPARAM, LRESULT, UINT, WPARAM}, + windef::HWND, + }, + um::{ + handleapi::CloseHandle, + libloaderapi::GetModuleHandleW, + processthreadsapi::GetThreadId, + synchapi::WaitForSingleObject, + winbase::INFINITE, + winuser::{ + CreateWindowExW, DefWindowProcW, DestroyWindow, DispatchMessageW, GetMessageW, + GetWindowLongPtrW, PostQuitMessage, PostThreadMessageW, SetWindowLongPtrW, + GWLP_USERDATA, GWLP_WNDPROC, PBT_APMRESUMEAUTOMATIC, PBT_APMSUSPEND, WM_DESTROY, + WM_POWERBROADCAST, WM_USER, + }, + }, }; use futures::sync::mpsc::UnboundedSender; use log::debug; -use std::ffi::c_void; -use std::mem::zeroed; -use std::os::windows::io::IntoRawHandle; -use std::os::windows::io::RawHandle; -use std::ptr; -use std::thread; -use std::time::Duration; +use std::{ + ffi::c_void, + mem::zeroed, + os::windows::io::{IntoRawHandle, RawHandle}, + ptr, thread, + time::Duration, +}; use tunnel_state_machine::TunnelCommand; const CLASS_NAME: &[u8] = b"S\0T\0A\0T\0I\0C\0\0\0"; diff --git a/talpid-core/src/process/openvpn.rs b/talpid-core/src/process/openvpn.rs index c524277290..8197784f0b 100644 --- a/talpid-core/src/process/openvpn.rs +++ b/talpid-core/src/process/openvpn.rs @@ -2,10 +2,12 @@ use duct; extern crate os_pipe; use super::stoppable_process::StoppableProcess; -use std::ffi::{OsStr, OsString}; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::sync::Mutex; +use std::{ + ffi::{OsStr, OsString}, + fmt, + path::{Path, PathBuf}, + sync::Mutex, +}; use self::os_pipe::{pipe, PipeWriter}; use atty; @@ -378,8 +380,7 @@ impl StoppableProcess for OpenVpnProcHandle { #[cfg(test)] mod tests { use super::OpenVpnCommand; - use std::ffi::OsString; - use std::net::Ipv4Addr; + use std::{ffi::OsString, net::Ipv4Addr}; use talpid_types::net::{Endpoint, TransportProtocol}; #[test] diff --git a/talpid-core/src/process/stoppable_process.rs b/talpid-core/src/process/stoppable_process.rs index bcbd71973d..6de7eb104d 100644 --- a/talpid-core/src/process/stoppable_process.rs +++ b/talpid-core/src/process/stoppable_process.rs @@ -1,7 +1,8 @@ use log::{debug, trace, warn}; -use std::io; -use std::thread; -use std::time::{Duration, Instant}; +use std::{ + io, thread, + time::{Duration, Instant}, +}; static POLL_INTERVAL_MS: Duration = Duration::from_millis(50); diff --git a/talpid-core/src/routing/linux.rs b/talpid-core/src/routing/linux.rs index e45c469c57..da256a849f 100644 --- a/talpid-core/src/routing/linux.rs +++ b/talpid-core/src/routing/linux.rs @@ -1,8 +1,7 @@ use super::{NetNode, RequiredRoutes}; use super::subprocess::{Exec, RunExpr}; -use std::collections::HashSet; -use std::net::IpAddr; +use std::{collections::HashSet, net::IpAddr}; error_chain! { diff --git a/talpid-core/src/routing/macos.rs b/talpid-core/src/routing/macos.rs index 6928084273..582c453439 100644 --- a/talpid-core/src/routing/macos.rs +++ b/talpid-core/src/routing/macos.rs @@ -1,8 +1,7 @@ use super::{NetNode, RequiredRoutes, Route}; use super::subprocess::{Exec, RunExpr}; -use std::collections::HashSet; -use std::net::IpAddr; +use std::{collections::HashSet, net::IpAddr}; error_chain! { errors { diff --git a/talpid-core/src/security/linux/dns/mod.rs b/talpid-core/src/security/linux/dns/mod.rs index e9756b56b2..7266e7263b 100644 --- a/talpid-core/src/security/linux/dns/mod.rs +++ b/talpid-core/src/security/linux/dns/mod.rs @@ -7,10 +7,10 @@ mod systemd_resolved; use std::{env, fmt, net::IpAddr, path::Path}; -use self::network_manager::NetworkManager; -use self::resolvconf::Resolvconf; -use self::static_resolv_conf::StaticResolvConf; -use self::systemd_resolved::SystemdResolved; +use self::{ + network_manager::NetworkManager, resolvconf::Resolvconf, static_resolv_conf::StaticResolvConf, + systemd_resolved::SystemdResolved, +}; const RESOLV_CONF_PATH: &str = "/etc/resolv.conf"; diff --git a/talpid-core/src/security/linux/dns/network_manager.rs b/talpid-core/src/security/linux/dns/network_manager.rs index bc87685399..118be6e62d 100644 --- a/talpid-core/src/security/linux/dns/network_manager.rs +++ b/talpid-core/src/security/linux/dns/network_manager.rs @@ -1,15 +1,18 @@ extern crate dbus; -use std::collections::HashMap; -use std::net::IpAddr; +use std::{collections::HashMap, net::IpAddr}; -use self::dbus::arg::{RefArg, Variant}; -use self::dbus::stdintf::*; -use self::dbus::BusType; +use self::dbus::{ + arg::{RefArg, Variant}, + stdintf::*, + BusType, +}; -use std::fs::File; -use std::io::{BufRead, BufReader}; -use std::path::Path; +use std::{ + fs::File, + io::{BufRead, BufReader}, + path::Path, +}; use error_chain::ChainedError; diff --git a/talpid-core/src/security/linux/dns/static_resolv_conf.rs b/talpid-core/src/security/linux/dns/static_resolv_conf.rs index 37d20c49f1..e8534d3f8d 100644 --- a/talpid-core/src/security/linux/dns/static_resolv_conf.rs +++ b/talpid-core/src/security/linux/dns/static_resolv_conf.rs @@ -1,12 +1,17 @@ extern crate notify; -use std::net::IpAddr; -use std::sync::{mpsc, Arc, Mutex, MutexGuard}; -use std::{fs, io, thread}; +use std::{ + fs, io, + net::IpAddr, + sync::{mpsc, Arc, Mutex, MutexGuard}, + thread, +}; use self::notify::{RecommendedWatcher, RecursiveMode, Watcher}; -use super::resolv_conf::{Config, ScopedIp}; -use super::RESOLV_CONF_PATH; +use super::{ + resolv_conf::{Config, ScopedIp}, + RESOLV_CONF_PATH, +}; use error_chain::ChainedError; const RESOLV_CONF_BACKUP_PATH: &str = "/etc/resolv.conf.mullvadbackup"; diff --git a/talpid-core/src/security/linux/dns/systemd_resolved.rs b/talpid-core/src/security/linux/dns/systemd_resolved.rs index ae68206473..3d6cd19fd3 100644 --- a/talpid-core/src/security/linux/dns/systemd_resolved.rs +++ b/talpid-core/src/security/linux/dns/systemd_resolved.rs @@ -9,12 +9,12 @@ use std::{ path::Path, }; -use self::dbus::arg::RefArg; -use self::dbus::stdintf::*; -use self::dbus::{BusType, Interface, Member, Message, MessageItem, MessageItemArray, Signature}; +use self::dbus::{ + arg::RefArg, stdintf::*, BusType, Interface, Member, Message, MessageItem, MessageItemArray, + Signature, +}; -use super::super::iface_index; -use super::{resolv_conf, RESOLV_CONF_PATH}; +use super::{super::iface_index, resolv_conf, RESOLV_CONF_PATH}; error_chain! { diff --git a/talpid-core/src/security/mod.rs b/talpid-core/src/security/mod.rs index d057fb8336..ff59c0507e 100644 --- a/talpid-core/src/security/mod.rs +++ b/talpid-core/src/security/mod.rs @@ -2,11 +2,9 @@ use ipnetwork::{IpNetwork, Ipv4Network, Ipv6Network}; #[cfg(unix)] use lazy_static::lazy_static; -use std::fmt; -use std::net::IpAddr; #[cfg(unix)] use std::net::{Ipv4Addr, Ipv6Addr}; -use std::path::Path; +use std::{fmt, net::IpAddr, path::Path}; use talpid_types::net::Endpoint; diff --git a/talpid-core/src/security/windows/dns.rs b/talpid-core/src/security/windows/dns.rs index 8023d07b03..efe7dd9c73 100644 --- a/talpid-core/src/security/windows/dns.rs +++ b/talpid-core/src/security/windows/dns.rs @@ -1,10 +1,11 @@ use log::{debug, error, info, trace, warn}; -use std::borrow::Borrow; -use std::net::IpAddr; -use std::os::raw::{c_char, c_void}; -use std::path::Path; -use std::ptr; -use std::slice; +use std::{ + borrow::Borrow, + net::IpAddr, + os::raw::{c_char, c_void}, + path::Path, + ptr, slice, +}; use error_chain::ChainedError; use widestring::WideCString; diff --git a/talpid-core/src/security/windows/mod.rs b/talpid-core/src/security/windows/mod.rs index 35dd57a1de..e2930b92fc 100644 --- a/talpid-core/src/security/windows/mod.rs +++ b/talpid-core/src/security/windows/mod.rs @@ -1,5 +1,4 @@ -use std::net::IpAddr; -use std::ptr; +use std::{net::IpAddr, ptr}; use log::{debug, error, trace}; use talpid_types::net::Endpoint; diff --git a/talpid-core/src/security/windows/system_state.rs b/talpid-core/src/security/windows/system_state.rs index cdc36f4e36..55948340d7 100644 --- a/talpid-core/src/security/windows/system_state.rs +++ b/talpid-core/src/security/windows/system_state.rs @@ -1,9 +1,11 @@ //! A writer for a blob that would persistently store the system state. Useful //! for when the application of a secuirty policy proves to be persistent across //! reboots -use std::fs::{self, File}; -use std::io::{self, Write}; -use std::path::Path; +use std::{ + fs::{self, File}, + io::{self, Write}, + path::Path, +}; /// This struct is responsible for saving a binary blob to disk. The binary blob is intended to /// store system state that should be resotred when the security policy is reset. diff --git a/talpid-core/src/tunnel/mod.rs b/talpid-core/src/tunnel/mod.rs index fbf5a06f9d..078f23cf16 100644 --- a/talpid-core/src/tunnel/mod.rs +++ b/talpid-core/src/tunnel/mod.rs @@ -1,12 +1,14 @@ use crate::{mktemp, process::openvpn::OpenVpnCommand}; -use std::collections::HashMap; -use std::ffi::OsString; -use std::fs; -use std::io::{self, Write}; -use std::net::Ipv4Addr; -use std::path::{Path, PathBuf}; -use std::result::Result as StdResult; +use std::{ + collections::HashMap, + ffi::OsString, + fs, + io::{self, Write}, + net::Ipv4Addr, + path::{Path, PathBuf}, + result::Result as StdResult, +}; #[cfg(target_os = "linux")] use failure::ResultExt as FailureResultExt; @@ -362,8 +364,7 @@ impl CloseHandle { fn is_ipv6_enabled_in_os() -> bool { #[cfg(windows)] { - use winreg::enums::*; - use winreg::RegKey; + use winreg::{enums::*, RegKey}; const IPV6_DISABLED_ON_TUNNELS_MASK: u32 = 0x01; diff --git a/talpid-core/src/tunnel/openvpn.rs b/talpid-core/src/tunnel/openvpn.rs index dd7af9e5a2..fd2437f2e6 100644 --- a/talpid-core/src/tunnel/openvpn.rs +++ b/talpid-core/src/tunnel/openvpn.rs @@ -2,14 +2,18 @@ use crate::process::{ openvpn::{OpenVpnCommand, OpenVpnProcHandle}, stoppable_process::StoppableProcess, }; -use std::collections::HashMap; -use std::io; -use std::path::Path; -use std::process::ExitStatus; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::{mpsc, Arc}; -use std::thread; -use std::time::Duration; +use std::{ + collections::HashMap, + io, + path::Path, + process::ExitStatus, + sync::{ + atomic::{AtomicBool, Ordering}, + mpsc, Arc, + }, + thread, + time::Duration, +}; use talpid_ipc; diff --git a/talpid-core/src/tunnel_state_machine/blocked_state.rs b/talpid-core/src/tunnel_state_machine/blocked_state.rs index 14b72a20f8..d392318c6a 100644 --- a/talpid-core/src/tunnel_state_machine/blocked_state.rs +++ b/talpid-core/src/tunnel_state_machine/blocked_state.rs @@ -1,6 +1,5 @@ use error_chain::ChainedError; -use futures::sync::mpsc; -use futures::Stream; +use futures::{sync::mpsc, Stream}; use talpid_types::tunnel::BlockReason; use super::{ diff --git a/talpid-core/src/tunnel_state_machine/connected_state.rs b/talpid-core/src/tunnel_state_machine/connected_state.rs index 35d8a4f7c2..961889d6c2 100644 --- a/talpid-core/src/tunnel_state_machine/connected_state.rs +++ b/talpid-core/src/tunnel_state_machine/connected_state.rs @@ -1,8 +1,12 @@ use error_chain::ChainedError; -use futures::sync::{mpsc, oneshot}; -use futures::{Async, Future, Stream}; -use talpid_types::net::{Endpoint, OpenVpnProxySettings, TransportProtocol}; -use talpid_types::tunnel::BlockReason; +use futures::{ + sync::{mpsc, oneshot}, + Async, Future, Stream, +}; +use talpid_types::{ + net::{Endpoint, OpenVpnProxySettings, TransportProtocol}, + tunnel::BlockReason, +}; use super::{ AfterDisconnect, ConnectingState, DisconnectingState, EventConsequence, Result, ResultExt, diff --git a/talpid-core/src/tunnel_state_machine/connecting_state.rs b/talpid-core/src/tunnel_state_machine/connecting_state.rs index e4d81dd51e..20fdb249ff 100644 --- a/talpid-core/src/tunnel_state_machine/connecting_state.rs +++ b/talpid-core/src/tunnel_state_machine/connecting_state.rs @@ -1,16 +1,20 @@ -use std::ffi::OsString; -use std::path::{Path, PathBuf}; -use std::thread; -use std::time::{Duration, Instant}; +use std::{ + ffi::OsString, + path::{Path, PathBuf}, + thread, + time::{Duration, Instant}, +}; use error_chain::ChainedError; -use futures::sync::{mpsc, oneshot}; -use futures::{Async, Future, Stream}; +use futures::{ + sync::{mpsc, oneshot}, + Async, Future, Stream, +}; use log::{debug, error, info, trace, warn}; -use talpid_types::net::{ - Endpoint, OpenVpnProxySettings, TransportProtocol, TunnelEndpoint, TunnelEndpointData, +use talpid_types::{ + net::{Endpoint, OpenVpnProxySettings, TransportProtocol, TunnelEndpoint, TunnelEndpointData}, + tunnel::BlockReason, }; -use talpid_types::tunnel::BlockReason; use super::{ AfterDisconnect, BlockedState, ConnectedState, ConnectedStateBootstrap, DisconnectingState, diff --git a/talpid-core/src/tunnel_state_machine/disconnected_state.rs b/talpid-core/src/tunnel_state_machine/disconnected_state.rs index 6c57e287a1..0634c75da4 100644 --- a/talpid-core/src/tunnel_state_machine/disconnected_state.rs +++ b/talpid-core/src/tunnel_state_machine/disconnected_state.rs @@ -4,8 +4,7 @@ use super::{ }; use crate::security::SecurityPolicy; use error_chain::ChainedError; -use futures::sync::mpsc; -use futures::Stream; +use futures::{sync::mpsc, Stream}; /// No tunnel is running. pub struct DisconnectedState; diff --git a/talpid-core/src/tunnel_state_machine/disconnecting_state.rs b/talpid-core/src/tunnel_state_machine/disconnecting_state.rs index 928880f274..ec8be8cfe1 100644 --- a/talpid-core/src/tunnel_state_machine/disconnecting_state.rs +++ b/talpid-core/src/tunnel_state_machine/disconnecting_state.rs @@ -1,8 +1,10 @@ use std::thread; use error_chain::ChainedError; -use futures::sync::{mpsc, oneshot}; -use futures::{Async, Future, Stream}; +use futures::{ + sync::{mpsc, oneshot}, + Async, Future, Stream, +}; use talpid_types::tunnel::{ActionAfterDisconnect, BlockReason}; use super::{ diff --git a/talpid-core/src/tunnel_state_machine/mod.rs b/talpid-core/src/tunnel_state_machine/mod.rs index dcb4ada26c..53d58060d3 100644 --- a/talpid-core/src/tunnel_state_machine/mod.rs +++ b/talpid-core/src/tunnel_state_machine/mod.rs @@ -7,23 +7,28 @@ mod connecting_state; mod disconnected_state; mod disconnecting_state; -use std::path::{Path, PathBuf}; -use std::sync::mpsc as sync_mpsc; -use std::thread; +use std::{ + path::{Path, PathBuf}, + sync::mpsc as sync_mpsc, + thread, +}; use error_chain::ChainedError; -use futures::sync::mpsc; -use futures::{Async, Future, Poll, Stream}; +use futures::{sync::mpsc, Async, Future, Poll, Stream}; use tokio_core::reactor::Core; -use talpid_types::net::{TunnelEndpoint, TunnelOptions}; -use talpid_types::tunnel::{BlockReason, TunnelStateTransition}; +use talpid_types::{ + net::{TunnelEndpoint, TunnelOptions}, + tunnel::{BlockReason, TunnelStateTransition}, +}; -use self::blocked_state::BlockedState; -use self::connected_state::{ConnectedState, ConnectedStateBootstrap}; -use self::connecting_state::ConnectingState; -use self::disconnected_state::DisconnectedState; -use self::disconnecting_state::{AfterDisconnect, DisconnectingState}; +use self::{ + blocked_state::BlockedState, + connected_state::{ConnectedState, ConnectedStateBootstrap}, + connecting_state::ConnectingState, + disconnected_state::DisconnectedState, + disconnecting_state::{AfterDisconnect, DisconnectingState}, +}; use crate::{ mpsc::IntoSender, offline, @@ -249,8 +254,7 @@ enum TunnelStateMachineAction { impl<T: TunnelState> From<EventConsequence<T>> for TunnelStateMachineAction { fn from(event_consequence: EventConsequence<T>) -> Self { - use self::EventConsequence::*; - use self::TunnelStateMachineAction::*; + use self::{EventConsequence::*, TunnelStateMachineAction::*}; match event_consequence { NewState((state_wrapper, transition)) => { diff --git a/talpid-ipc/src/lib.rs b/talpid-ipc/src/lib.rs index 847228bec2..772b3a1dd8 100644 --- a/talpid-ipc/src/lib.rs +++ b/talpid-ipc/src/lib.rs @@ -89,8 +89,7 @@ impl IpcServer { #[cfg(unix)] { - use std::fs; - use std::os::unix::fs::PermissionsExt; + use std::{fs, os::unix::fs::PermissionsExt}; fs::set_permissions(&path, PermissionsExt::from_mode(0o766)) .chain_err(|| ErrorKind::PermissionsError)?; } diff --git a/talpid-ipc/tests/ipc-client-server.rs b/talpid-ipc/tests/ipc-client-server.rs index 254671962c..5f647d07a2 100644 --- a/talpid-ipc/tests/ipc-client-server.rs +++ b/talpid-ipc/tests/ipc-client-server.rs @@ -14,14 +14,15 @@ extern crate uuid; extern crate futures; use assert_matches::assert_matches; -use futures::sync::oneshot; -use futures::Future; +use futures::{sync::oneshot, Future}; use jsonrpc_client_core::{Error as ClientError, Transport}; use jsonrpc_core::{Error, IoHandler}; use jsonrpc_macros::build_rpc_trait; -use std::sync::{mpsc, Mutex}; -use std::time::Duration; +use std::{ + sync::{mpsc, Mutex}, + time::Duration, +}; build_rpc_trait! { pub trait TestApi { diff --git a/talpid-openvpn-plugin/src/lib.rs b/talpid-openvpn-plugin/src/lib.rs index 36db6aefed..a2a523f125 100644 --- a/talpid-openvpn-plugin/src/lib.rs +++ b/talpid-openvpn-plugin/src/lib.rs @@ -11,9 +11,7 @@ extern crate error_chain; use error_chain::ChainedError; use openvpn_plugin::{openvpn_plugin, EventResult, EventType}; -use std::collections::HashMap; -use std::ffi::CString; -use std::sync::Mutex; +use std::{collections::HashMap, ffi::CString, sync::Mutex}; mod processing; |
