diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2019-01-18 17:41:39 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2019-01-18 17:43:47 +0100 |
| commit | 1cac24bdad9e9d412f8c8b28b08212f5ea631f8d (patch) | |
| tree | 0df85dbdfe8385a7310be34489fa4a5ff7317560 | |
| parent | 9a20cf40b4eedbd7fbb2aba45ed81724cbd538ac (diff) | |
| download | mullvadvpn-1cac24bdad9e9d412f8c8b28b08212f5ea631f8d.tar.xz mullvadvpn-1cac24bdad9e9d412f8c8b28b08212f5ea631f8d.zip | |
Get rid of almost all remaining "extern crate" statements
22 files changed, 68 insertions, 210 deletions
diff --git a/mullvad-daemon/build.rs b/mullvad-daemon/build.rs index 39cac1707d..09181c1013 100644 --- a/mullvad-daemon/build.rs +++ b/mullvad-daemon/build.rs @@ -1,10 +1,5 @@ use std::{env, fs, path::PathBuf, process::Command}; -#[cfg(windows)] -extern crate winapi; -#[cfg(windows)] -extern crate winres; - fn main() { let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); diff --git a/mullvad-daemon/src/account_history.rs b/mullvad-daemon/src/account_history.rs index a3820add44..de57b60d3f 100644 --- a/mullvad-daemon/src/account_history.rs +++ b/mullvad-daemon/src/account_history.rs @@ -1,13 +1,10 @@ -extern crate serde_json; - +use mullvad_types::account::AccountToken; use std::{ fs::File, io, path::{Path, PathBuf}, }; -use mullvad_types::account::AccountToken; - error_chain! { errors { ReadError(path: PathBuf) { diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index d3ae39676a..63dee4e536 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -6,34 +6,11 @@ //! GNU General Public License as published by the Free Software Foundation, either version 3 of //! the License, or (at your option) any later version. -extern crate chrono; #[macro_use] extern crate error_chain; -extern crate futures; -#[cfg(unix)] -extern crate libc; -extern crate log; - #[macro_use] extern crate serde; -extern crate serde_json; - -extern crate jsonrpc_core; -extern crate jsonrpc_ipc_server; -extern crate jsonrpc_macros; -extern crate jsonrpc_pubsub; -extern crate rand; -extern crate tokio_core; -extern crate tokio_timer; -extern crate uuid; -extern crate mullvad_ipc_client; -extern crate mullvad_paths; -extern crate mullvad_rpc; -extern crate mullvad_types; -extern crate talpid_core; -extern crate talpid_ipc; -extern crate talpid_types; mod account_history; mod geoip; diff --git a/mullvad-daemon/src/logging.rs b/mullvad-daemon/src/logging.rs index 7005f2f7ea..39f5a2cd59 100644 --- a/mullvad-daemon/src/logging.rs +++ b/mullvad-daemon/src/logging.rs @@ -1,14 +1,10 @@ -extern crate fern; - -use self::fern::{ +use chrono; +use fern::{ colors::{Color, ColoredLevelConfig}, Output, }; -use chrono; use log; - use std::{fmt, io, path::PathBuf}; - use talpid_core::logging::rotate_log; error_chain! { diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs index dbb526801f..2d71ba45cd 100644 --- a/mullvad-daemon/src/main.rs +++ b/mullvad-daemon/src/main.rs @@ -6,20 +6,9 @@ //! GNU General Public License as published by the Free Software Foundation, either version 3 of //! the License, or (at your option) any later version. -extern crate chrono; -extern crate clap; #[macro_use] extern crate error_chain; -#[cfg(unix)] -extern crate libc; -extern crate log; -extern crate log_panics; -extern crate mullvad_daemon; -extern crate mullvad_paths; -extern crate talpid_core; -#[cfg(windows)] -extern crate windows_service; use error_chain::ChainedError; use log::{debug, error, info, warn}; diff --git a/mullvad-daemon/src/shutdown.rs b/mullvad-daemon/src/shutdown.rs index ed86068d38..05c1e7f1af 100644 --- a/mullvad-daemon/src/shutdown.rs +++ b/mullvad-daemon/src/shutdown.rs @@ -2,10 +2,8 @@ error_chain! {} #[cfg(unix)] mod platform { - extern crate simple_signal; - - use self::simple_signal::Signal; use super::Result; + use simple_signal::Signal; pub fn set_shutdown_signal_handler<F>(f: F) -> Result<()> where @@ -21,8 +19,6 @@ mod platform { #[cfg(windows)] mod platform { - extern crate ctrlc; - use super::{Result, ResultExt}; pub fn set_shutdown_signal_handler<F>(f: F) -> Result<()> diff --git a/talpid-core/src/lib.rs b/talpid-core/src/lib.rs index c8556ca0ec..437fb2ff6f 100644 --- a/talpid-core/src/lib.rs +++ b/talpid-core/src/lib.rs @@ -10,41 +10,8 @@ //! GNU General Public License as published by the Free Software Foundation, either version 3 of //! the License, or (at your option) any later version. -extern crate atty; -extern crate duct; -extern crate log; - #[macro_use] extern crate error_chain; -#[cfg(target_os = "linux")] -extern crate failure; -extern crate futures; -#[cfg(unix)] -extern crate hex; -#[cfg(unix)] -extern crate ipnetwork; -extern crate jsonrpc_core; -extern crate jsonrpc_macros; -#[cfg(unix)] -extern crate lazy_static; -extern crate libc; -#[cfg(unix)] -extern crate nix; -extern crate shell_escape; -extern crate tokio_core; -#[cfg(unix)] -extern crate tun; -extern crate uuid; -#[cfg(target_os = "linux")] -extern crate which; -#[cfg(windows)] -extern crate widestring; -#[cfg(windows)] -extern crate winreg; - -extern crate openvpn_plugin; -extern crate talpid_ipc; -extern crate talpid_types; #[cfg(windows)] mod winnet; diff --git a/talpid-core/src/offline/linux.rs b/talpid-core/src/offline/linux.rs index 4a2d9b2888..cc18a48a78 100644 --- a/talpid-core/src/offline/linux.rs +++ b/talpid-core/src/offline/linux.rs @@ -1,19 +1,13 @@ -extern crate iproute2; -extern crate netlink_socket; -extern crate rtnetlink; - -use self::{ - iproute2::Link, - netlink_socket::{Protocol, SocketAddr, TokioSocket}, - rtnetlink::{ - LinkFlags, LinkHeader, LinkLayerType, LinkMessage, NetlinkCodec, NetlinkFramed, - NetlinkMessage, RtnlMessage, - }, -}; use crate::tunnel_state_machine::TunnelCommand; use error_chain::ChainedError; use futures::{future::Either, sync::mpsc::UnboundedSender, Future, Stream}; +use iproute2::Link; use log::{error, trace, warn}; +use netlink_socket::{Protocol, SocketAddr, TokioSocket}; +use rtnetlink::{ + LinkFlags, LinkHeader, LinkLayerType, LinkMessage, NetlinkCodec, NetlinkFramed, NetlinkMessage, + RtnlMessage, +}; use std::{collections::BTreeSet, thread}; error_chain! { diff --git a/talpid-core/src/offline/macos.rs b/talpid-core/src/offline/macos.rs index e55fa376d3..bf5a269160 100644 --- a/talpid-core/src/offline/macos.rs +++ b/talpid-core/src/offline/macos.rs @@ -1,6 +1,7 @@ -extern crate system_configuration; - -use self::system_configuration::{ +use futures::sync::mpsc::UnboundedSender; +use log::{debug, trace}; +use std::{sync::mpsc, thread}; +use system_configuration::{ core_foundation::{ array::CFArray, runloop::{kCFRunLoopCommonModes, CFRunLoop}, @@ -8,11 +9,9 @@ use self::system_configuration::{ }, dynamic_store::{SCDynamicStore, SCDynamicStoreBuilder, SCDynamicStoreCallBackContext}, }; -use futures::sync::mpsc::UnboundedSender; -use log::{debug, trace}; -use std::{sync::mpsc, thread}; use tunnel_state_machine::TunnelCommand; + const PRIMARY_INTERFACE_KEY: &str = "State:/Network/Global/IPv4"; error_chain! { diff --git a/talpid-core/src/offline/windows.rs b/talpid-core/src/offline/windows.rs index e5dbbaaed2..0b798e1d36 100644 --- a/talpid-core/src/offline/windows.rs +++ b/talpid-core/src/offline/windows.rs @@ -6,9 +6,17 @@ //! GNU General Public License as published by the Free Software Foundation, either version 3 of //! the License, or (at your option) any later version. -extern crate winapi; - -use self::winapi::{ +use futures::sync::mpsc::UnboundedSender; +use log::debug; +use std::{ + ffi::c_void, + mem::zeroed, + os::windows::io::{IntoRawHandle, RawHandle}, + ptr, thread, + time::Duration, +}; +use tunnel_state_machine::TunnelCommand; +use winapi::{ shared::{ basetsd::LONG_PTR, minwindef::{DWORD, LPARAM, LRESULT, UINT, WPARAM}, @@ -28,16 +36,6 @@ use self::winapi::{ }, }, }; -use futures::sync::mpsc::UnboundedSender; -use log::debug; -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"; const REQUEST_THREAD_SHUTDOWN: UINT = WM_USER + 1; diff --git a/talpid-core/src/process/openvpn.rs b/talpid-core/src/process/openvpn.rs index 8197784f0b..104471db2b 100644 --- a/talpid-core/src/process/openvpn.rs +++ b/talpid-core/src/process/openvpn.rs @@ -1,18 +1,15 @@ use duct; -extern crate os_pipe; use super::stoppable_process::StoppableProcess; +use atty; +use os_pipe::{pipe, PipeWriter}; +use shell_escape; use std::{ ffi::{OsStr, OsString}, - fmt, + fmt, io, path::{Path, PathBuf}, sync::Mutex, }; - -use self::os_pipe::{pipe, PipeWriter}; -use atty; -use shell_escape; -use std::io; use talpid_types::net; static BASE_ARGUMENTS: &[&[&str]] = &[ diff --git a/talpid-core/src/security/linux/dns/mod.rs b/talpid-core/src/security/linux/dns/mod.rs index 7266e7263b..729dfc2799 100644 --- a/talpid-core/src/security/linux/dns/mod.rs +++ b/talpid-core/src/security/linux/dns/mod.rs @@ -1,16 +1,14 @@ -extern crate resolv_conf; - mod network_manager; mod resolvconf; mod static_resolv_conf; mod systemd_resolved; -use std::{env, fmt, net::IpAddr, path::Path}; - use self::{ network_manager::NetworkManager, resolvconf::Resolvconf, static_resolv_conf::StaticResolvConf, - systemd_resolved::SystemdResolved, }; +use std::{env, fmt, net::IpAddr, path::Path}; +use 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 118be6e62d..73d49eb1a8 100644 --- a/talpid-core/src/security/linux/dns/network_manager.rs +++ b/talpid-core/src/security/linux/dns/network_manager.rs @@ -1,21 +1,17 @@ -extern crate dbus; - -use std::{collections::HashMap, net::IpAddr}; - -use self::dbus::{ +use dbus::{ arg::{RefArg, Variant}, stdintf::*, BusType, }; - +use error_chain::ChainedError; use std::{ + collections::HashMap, fs::File, io::{BufRead, BufReader}, + net::IpAddr, path::Path, }; -use error_chain::ChainedError; - error_chain! { errors { NoNetworkManager { 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 e8534d3f8d..cea1b1ac2f 100644 --- a/talpid-core/src/security/linux/dns/static_resolv_conf.rs +++ b/talpid-core/src/security/linux/dns/static_resolv_conf.rs @@ -1,5 +1,7 @@ -extern crate notify; - +use super::RESOLV_CONF_PATH; +use error_chain::ChainedError; +use notify::{RecommendedWatcher, RecursiveMode, Watcher}; +use resolv_conf::{Config, ScopedIp}; use std::{ fs, io, net::IpAddr, @@ -7,13 +9,6 @@ use std::{ thread, }; -use self::notify::{RecommendedWatcher, RecursiveMode, Watcher}; -use super::{ - resolv_conf::{Config, ScopedIp}, - RESOLV_CONF_PATH, -}; -use error_chain::ChainedError; - const RESOLV_CONF_BACKUP_PATH: &str = "/etc/resolv.conf.mullvadbackup"; error_chain! { diff --git a/talpid-core/src/security/linux/dns/systemd_resolved.rs b/talpid-core/src/security/linux/dns/systemd_resolved.rs index 3d6cd19fd3..f4eac9e486 100644 --- a/talpid-core/src/security/linux/dns/systemd_resolved.rs +++ b/talpid-core/src/security/linux/dns/systemd_resolved.rs @@ -1,5 +1,8 @@ -extern crate dbus; - +use super::{super::iface_index, RESOLV_CONF_PATH}; +use dbus::{ + arg::RefArg, stdintf::*, BusType, Interface, Member, Message, MessageItem, MessageItemArray, + Signature, +}; use error_chain::ChainedError; use lazy_static::lazy_static; use libc::{AF_INET, AF_INET6}; @@ -9,13 +12,6 @@ use std::{ path::Path, }; -use self::dbus::{ - arg::RefArg, stdintf::*, BusType, Interface, Member, Message, MessageItem, MessageItemArray, - Signature, -}; - -use super::{super::iface_index, resolv_conf, RESOLV_CONF_PATH}; - error_chain! { errors { diff --git a/talpid-core/src/security/linux/mod.rs b/talpid-core/src/security/linux/mod.rs index 5cbe786e46..f12bf4a803 100644 --- a/talpid-core/src/security/linux/mod.rs +++ b/talpid-core/src/security/linux/mod.rs @@ -1,16 +1,13 @@ -extern crate mnl; -extern crate nftnl; - -use self::nftnl::{ - expr::{self, Verdict}, - nft_expr, nft_expr_bitwise, nft_expr_cmp, nft_expr_ct, nft_expr_meta, nft_expr_payload, Batch, - Chain, FinalizedBatch, ProtoFamily, Rule, Table, -}; use super::{NetworkSecurityT, SecurityPolicy}; use crate::tunnel; use ipnetwork::IpNetwork; use lazy_static::lazy_static; use libc; +use nftnl::{ + expr::{self, Verdict}, + nft_expr, nft_expr_bitwise, nft_expr_cmp, nft_expr_ct, nft_expr_meta, nft_expr_payload, Batch, + Chain, FinalizedBatch, ProtoFamily, Rule, Table, +}; use std::{ env, ffi::CString, @@ -19,6 +16,7 @@ use std::{ }; use talpid_types::net::{Endpoint, TransportProtocol}; + mod dns; pub use self::dns::{DnsMonitor, Error as DnsError}; diff --git a/talpid-core/src/security/macos/dns.rs b/talpid-core/src/security/macos/dns.rs index 4937ffab03..a1fad021de 100644 --- a/talpid-core/src/security/macos/dns.rs +++ b/talpid-core/src/security/macos/dns.rs @@ -1,6 +1,14 @@ -extern crate system_configuration; - -use self::system_configuration::{ +use error_chain::ChainedError; +use log::{debug, trace}; +use std::{ + collections::HashMap, + fmt, + net::IpAddr, + path::Path, + sync::{mpsc, Arc, Mutex}, + thread, +}; +use system_configuration::{ core_foundation::{ array::CFArray, base::{CFType, TCFType, ToVoid}, @@ -12,16 +20,6 @@ use self::system_configuration::{ dynamic_store::{SCDynamicStore, SCDynamicStoreBuilder, SCDynamicStoreCallBackContext}, sys::schema_definitions::kSCPropNetDNSServerAddresses, }; -use error_chain::ChainedError; -use log::{debug, trace}; -use std::{ - collections::HashMap, - fmt, - net::IpAddr, - path::Path, - sync::{mpsc, Arc, Mutex}, - thread, -}; error_chain! { errors { diff --git a/talpid-core/src/security/macos/mod.rs b/talpid-core/src/security/macos/mod.rs index 135b94f153..b4d300e66f 100644 --- a/talpid-core/src/security/macos/mod.rs +++ b/talpid-core/src/security/macos/mod.rs @@ -1,15 +1,12 @@ -extern crate pfctl; -extern crate tokio_core; - -use self::pfctl::FilterRuleAction; use super::{NetworkSecurityT, SecurityPolicy}; +use pfctl::FilterRuleAction; use std::{env, net::Ipv4Addr}; use talpid_types::net; mod dns; pub use self::dns::{DnsMonitor, Error as DnsError}; -pub use self::pfctl::Error; +pub use pfctl::Error; type Result<T> = ::std::result::Result<T, Error>; diff --git a/talpid-core/src/security/windows/system_state.rs b/talpid-core/src/security/windows/system_state.rs index 55948340d7..f5e1d073dd 100644 --- a/talpid-core/src/security/windows/system_state.rs +++ b/talpid-core/src/security/windows/system_state.rs @@ -59,8 +59,6 @@ impl SystemStateWriter { #[cfg(test)] mod tests { - extern crate tempfile; - use super::*; #[test] diff --git a/talpid-core/src/tunnel_state_machine/macros.rs b/talpid-core/src/tunnel_state_machine/macros.rs index 9c667e579f..332d518de5 100644 --- a/talpid-core/src/tunnel_state_machine/macros.rs +++ b/talpid-core/src/tunnel_state_machine/macros.rs @@ -10,9 +10,9 @@ macro_rules! try_handle_event { ($same_state:expr, $event:expr) => { match $event { - Ok(crate::futures::Async::Ready(Some(event))) => Ok(event), - Ok(crate::futures::Async::Ready(None)) => Err(None), - Ok(crate::futures::Async::NotReady) => { + Ok(futures::Async::Ready(Some(event))) => Ok(event), + Ok(futures::Async::Ready(None)) => Err(None), + Ok(futures::Async::NotReady) => { return crate::tunnel_state_machine::EventConsequence::NoEvents($same_state); } Err(error) => Err(Some(error)), diff --git a/talpid-ipc/src/lib.rs b/talpid-ipc/src/lib.rs index 772b3a1dd8..a84a982aa7 100644 --- a/talpid-ipc/src/lib.rs +++ b/talpid-ipc/src/lib.rs @@ -11,17 +11,6 @@ #[macro_use] extern crate error_chain; -extern crate serde; -extern crate serde_json; - -extern crate jsonrpc_core; -extern crate jsonrpc_ipc_server; -extern crate jsonrpc_pubsub; - -extern crate futures; -extern crate jsonrpc_client_core; -extern crate jsonrpc_client_ipc; -extern crate tokio; use futures::Future; use std::thread; diff --git a/talpid-ipc/tests/ipc-client-server.rs b/talpid-ipc/tests/ipc-client-server.rs index 5f647d07a2..00caf716f1 100644 --- a/talpid-ipc/tests/ipc-client-server.rs +++ b/talpid-ipc/tests/ipc-client-server.rs @@ -1,18 +1,6 @@ // TODO fix these tests on Windows #![cfg(not(windows))] -extern crate assert_matches; -extern crate env_logger; -extern crate jsonrpc_client_core; -extern crate jsonrpc_client_ipc; -extern crate jsonrpc_core; -extern crate jsonrpc_macros; -extern crate talpid_ipc; -extern crate tokio; -extern crate uuid; - -extern crate futures; - use assert_matches::assert_matches; use futures::{sync::oneshot, Future}; |
