summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xformat.sh13
-rw-r--r--mullvad-cli/src/cmds/relay.rs5
-rw-r--r--mullvad-daemon/src/bin/problem-report.rs4
-rw-r--r--mullvad-daemon/src/main.rs8
-rw-r--r--mullvad-daemon/src/management_interface.rs10
-rw-r--r--mullvad-daemon/src/relays.rs4
-rw-r--r--mullvad-daemon/src/rpc_info.rs4
-rw-r--r--socket-relay/src/udp.rs4
-rw-r--r--talpid-core/src/firewall/macos/dns.rs13
-rw-r--r--talpid-openvpn-plugin/src/lib.rs6
10 files changed, 35 insertions, 36 deletions
diff --git a/format.sh b/format.sh
index a0765bd03e..87e3d80014 100755
--- a/format.sh
+++ b/format.sh
@@ -5,16 +5,25 @@
set -u
-VERSION="0.2.16"
+VERSION="0.2.17"
CMD="rustfmt"
INSTALL_CMD="cargo install --vers $VERSION --force rustfmt-nightly"
+case "$(uname -s)" in
+ Linux*) export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib;;
+ Darwin*) export DYLD_LIBRARY_PATH=$(rustc --print sysroot)/lib;;
+ *) exit 1
+esac
+
+# Allow rustfmt to use "nighly" features. `comment_width` is one of those for example.
+# 0.2.17 started enforcing setting this variable to allow using the nighly features.
+export CFG_RELEASE_CHANNEL=nightly
+
function correct_rustfmt() {
if ! which $CMD; then
echo "$CMD is not installed" >&2
return 1
fi
- export DYLD_LIBRARY_PATH=$(rustc --print sysroot)/lib
local installed_version=$($CMD --version | cut -d'-' -f1)
if [[ "$installed_version" != "$VERSION" ]]; then
echo "Wrong version of $CMD installed. Expected $VERSION, got $installed_version" >&2
diff --git a/mullvad-cli/src/cmds/relay.rs b/mullvad-cli/src/cmds/relay.rs
index 4f81af9192..cbd18f1f03 100644
--- a/mullvad-cli/src/cmds/relay.rs
+++ b/mullvad-cli/src/cmds/relay.rs
@@ -208,9 +208,8 @@ impl Relay {
fn parse_port_constraint(raw_port: &str) -> Result<Constraint<u16>> {
match raw_port.to_lowercase().as_str() {
"any" => Ok(Constraint::Any),
- port => Ok(Constraint::Only(
- u16::from_str(port).chain_err(|| "Invalid port")?,
- )),
+ port => Ok(Constraint::Only(u16::from_str(port)
+ .chain_err(|| "Invalid port")?)),
}
}
diff --git a/mullvad-daemon/src/bin/problem-report.rs b/mullvad-daemon/src/bin/problem-report.rs
index 11b5e0688c..b7324ae866 100644
--- a/mullvad-daemon/src/bin/problem-report.rs
+++ b/mullvad-daemon/src/bin/problem-report.rs
@@ -370,9 +370,7 @@ fn command_stdout_lossy(cmd: &str, args: &[&str]) -> Option<String> {
Command::new(cmd)
.args(args)
.output()
- .map(|output| {
- String::from_utf8_lossy(&output.stdout).trim().to_string()
- })
+ .map(|output| String::from_utf8_lossy(&output.stdout).trim().to_string())
.ok()
}
diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs
index c1c7aa4980..f82a668940 100644
--- a/mullvad-daemon/src/main.rs
+++ b/mullvad-daemon/src/main.rs
@@ -125,7 +125,8 @@ const DATE_TIME_FORMAT_STR: &str = "%Y-%m-%d %H:%M:%S%.3f";
pub enum DaemonEvent {
/// An event coming from the tunnel software to indicate a change in state.
TunnelEvent(TunnelEvent),
- /// Triggered by the thread waiting for the tunnel process. Means the tunnel process exited.
+ /// Triggered by the thread waiting for the tunnel process. Means the tunnel process
+ /// exited.
TunnelExited(tunnel::Result<()>),
/// Triggered by the thread waiting for a tunnel close operation to complete. Contains the
/// result of trying to kill the tunnel.
@@ -264,9 +265,8 @@ impl Daemon {
event_tx: IntoSender<TunnelCommand, DaemonEvent>,
) -> Result<ManagementInterfaceServer> {
let shared_secret = uuid::Uuid::new_v4().to_string();
- let server = ManagementInterfaceServer::start(event_tx, shared_secret.clone()).chain_err(
- || ErrorKind::ManagementInterfaceError("Failed to start server"),
- )?;
+ let server = ManagementInterfaceServer::start(event_tx, shared_secret.clone())
+ .chain_err(|| ErrorKind::ManagementInterfaceError("Failed to start server"))?;
info!(
"Mullvad management interface listening on {}",
server.address()
diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs
index 1f56d5ba0d..58f62b1ede 100644
--- a/mullvad-daemon/src/management_interface.rs
+++ b/mullvad-daemon/src/management_interface.rs
@@ -397,9 +397,9 @@ impl<T: From<TunnelCommand> + 'static + Send> ManagementInterfaceApi for Managem
trace!("set_account");
try_future!(self.check_auth(&meta));
let (tx, rx) = sync::oneshot::channel();
- let future = self.send_command_to_daemon(
- TunnelCommand::SetAccount(tx, account_token.clone()),
- ).and_then(|_| rx.map_err(|_| Error::internal_error()));
+ let future =
+ self.send_command_to_daemon(TunnelCommand::SetAccount(tx, account_token.clone()))
+ .and_then(|_| rx.map_err(|_| Error::internal_error()));
if let Some(new_account_token) = account_token {
if let Err(e) = AccountHistory::load().and_then(|mut account_history| {
@@ -521,9 +521,7 @@ impl<T: From<TunnelCommand> + 'static + Send> ManagementInterfaceApi for Managem
try_future!(self.check_auth(&meta));
Box::new(future::result(
AccountHistory::load()
- .and_then(|mut account_history| {
- account_history.remove_account_token(account_token)
- })
+ .and_then(|mut account_history| account_history.remove_account_token(account_token))
.map_err(|error| {
error!(
"Unable to remove account from history: {}",
diff --git a/mullvad-daemon/src/relays.rs b/mullvad-daemon/src/relays.rs
index b15e32ae07..8ebbf49171 100644
--- a/mullvad-daemon/src/relays.rs
+++ b/mullvad-daemon/src/relays.rs
@@ -239,9 +239,7 @@ impl RelaySelector {
self.rng
.choose(&tunnels.openvpn)
.cloned()
- .map(|openvpn_endpoint| {
- TunnelParameters::OpenVpn(openvpn_endpoint)
- })
+ .map(|openvpn_endpoint| TunnelParameters::OpenVpn(openvpn_endpoint))
}
/// Downloads the latest relay list and caches it. This operation is blocking.
diff --git a/mullvad-daemon/src/rpc_info.rs b/mullvad-daemon/src/rpc_info.rs
index 3bd42d9751..cf9951fc98 100644
--- a/mullvad-daemon/src/rpc_info.rs
+++ b/mullvad-daemon/src/rpc_info.rs
@@ -31,9 +31,7 @@ lazy_static! {
/// Writes down the RPC connection info to some API to a file.
pub fn write(rpc_address: &str, shared_secret: &str) -> Result<()> {
open_file(RPC_ADDRESS_FILE_PATH.as_path())
- .and_then(|mut file| {
- write!(file, "{}\n{}", rpc_address, shared_secret)
- })
+ .and_then(|mut file| write!(file, "{}\n{}", rpc_address, shared_secret))
.chain_err(|| ErrorKind::WriteFailed(RPC_ADDRESS_FILE_PATH.to_owned()))?;
debug!(
diff --git a/socket-relay/src/udp.rs b/socket-relay/src/udp.rs
index c5b48ffb7c..f4417d15f0 100644
--- a/socket-relay/src/udp.rs
+++ b/socket-relay/src/udp.rs
@@ -115,9 +115,7 @@ impl Relay {
None
}
})
- .map_err(|e| {
- error!("Error reading datagrams from forward socket: {}", e)
- });
+ .map_err(|e| error!("Error reading datagrams from forward socket: {}", e));
let timeout_recv_future = Timer::default()
.timeout_stream(recv_stream, Duration::from_millis(FORWARD_TIMEOUT_MS))
diff --git a/talpid-core/src/firewall/macos/dns.rs b/talpid-core/src/firewall/macos/dns.rs
index abf12353ab..1843cbe9d3 100644
--- a/talpid-core/src/firewall/macos/dns.rs
+++ b/talpid-core/src/firewall/macos/dns.rs
@@ -243,7 +243,8 @@ fn read_all_dns(store: &SCDynamicStore) -> HashMap<ServicePath, Option<Vec<DnsSe
// Backup all "state" DNS, and all corresponding "setup" DNS even if they don't exist
if let Some(paths) = store.get_keys(STATE_PATH_PATTERN) {
for path_ptr in paths.as_untyped().iter() {
- let state_path = unsafe { CFString::wrap_under_get_rule(path_ptr as CFStringRef) };
+ let state_path =
+ unsafe { CFString::wrap_under_get_rule(path_ptr as CFStringRef) };
let state_path_str = state_path.to_string();
let setup_path_str = state_to_setup_path(&state_path_str).unwrap();
let setup_path = CFString::new(&setup_path_str);
@@ -254,7 +255,8 @@ fn read_all_dns(store: &SCDynamicStore) -> HashMap<ServicePath, Option<Vec<DnsSe
// Backup all "setup" DNS not already covered
if let Some(paths) = store.get_keys(SETUP_PATH_PATTERN) {
for path_ptr in paths.as_untyped().iter() {
- let setup_path = unsafe { CFString::wrap_under_get_rule(path_ptr as CFStringRef) };
+ let setup_path =
+ unsafe { CFString::wrap_under_get_rule(path_ptr as CFStringRef) };
let setup_path_str = setup_path.to_string();
if !backup.contains_key(&setup_path_str) {
backup.insert(setup_path_str, read_dns(store, setup_path));
@@ -281,9 +283,7 @@ fn read_dns(store: &SCDynamicStore, path: CFString) -> Option<Vec<DnsServer>> {
.and_then(|dictionary| {
dictionary
.find2(&CFString::from_static_string("ServerAddresses"))
- .map(|array_ptr| unsafe {
- CFType::wrap_under_get_rule(array_ptr)
- })
+ .map(|array_ptr| unsafe { CFType::wrap_under_get_rule(array_ptr) })
})
.and_then(|addresses: CFType| {
if addresses.instance_of::<_, CFArray>() {
@@ -305,7 +305,8 @@ fn parse_cf_string_array(array: CFArray) -> Option<Vec<String>> {
for string_ptr in array.iter() {
let cf_type = unsafe { CFType::wrap_under_get_rule(string_ptr) };
if cf_type.instance_of::<_, CFString>() {
- let address = unsafe { CFString::wrap_under_get_rule(string_ptr as CFStringRef) };
+ let address =
+ unsafe { CFString::wrap_under_get_rule(string_ptr as CFStringRef) };
strings.push(address.to_string());
} else {
error!("DNS server entry is not a string: {:?}", cf_type);
diff --git a/talpid-openvpn-plugin/src/lib.rs b/talpid-openvpn-plugin/src/lib.rs
index 4449814e31..f08aa4a9a5 100644
--- a/talpid-openvpn-plugin/src/lib.rs
+++ b/talpid-openvpn-plugin/src/lib.rs
@@ -76,9 +76,9 @@ fn parse_args(args: &[CString]) -> Result<talpid_ipc::IpcServerId> {
.chain_err(|| ErrorKind::ParseArgsFailed)?
.into_iter();
let _plugin_path = args_iter.next();
- let core_server_id: talpid_ipc::IpcServerId = args_iter.next().ok_or_else(|| {
- ErrorKind::Msg("No core server id given as first argument".to_owned())
- })?;
+ let core_server_id: talpid_ipc::IpcServerId = args_iter
+ .next()
+ .ok_or_else(|| ErrorKind::Msg("No core server id given as first argument".to_owned()))?;
Ok(core_server_id)
}