From 82325509db11626dc2f3f68c5159860fc9285819 Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Mon, 2 Aug 2021 23:10:20 +0900 Subject: [PATCH] meta: cargo clippy & fmt --- Cargo.lock | 16 ++++++++-------- client/src/main.rs | 15 ++++++++++++--- wgctrl-rs/src/backends/userspace.rs | 12 ++++++++++-- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ef97808..515482c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -895,18 +895,18 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.126" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" +checksum = "f03b9878abf6d14e6779d3f24f07b2cfa90352cfec4acc5aab8f1ac7f146fae8" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.126" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" +checksum = "a024926d3432516606328597e0f224a51355a493b49fdd67e9209187cbe55ecc" dependencies = [ "proc-macro2", "quote", @@ -915,9 +915,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.64" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +checksum = "336b10da19a12ad094b59d870ebde26a45402e5b470add4b5fd03c5048a32127" dependencies = [ "itoa", "ryu", @@ -997,9 +997,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "socket2" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" +checksum = "765f090f0e423d2b55843402a07915add955e7d60657db13707a159727326cad" dependencies = [ "libc", "winapi", diff --git a/client/src/main.rs b/client/src/main.rs index 56cd9a4..f60b995 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -284,10 +284,19 @@ fn install( let target_conf = CLIENT_CONFIG_DIR.join(&iface).with_extension("conf"); if target_conf.exists() { - bail!("An existing innernet network with the name \"{}\" already exists.", iface); + bail!( + "An existing innernet network with the name \"{}\" already exists.", + iface + ); } - if Device::list(network.backend)?.iter().any(|name| name.as_str_lossy() == iface) { - bail!("An existing WireGuard interface with the name \"{}\" already exists.", iface); + if Device::list(network.backend)? + .iter() + .any(|name| name.as_str_lossy() == iface) + { + bail!( + "An existing WireGuard interface with the name \"{}\" already exists.", + iface + ); } let iface = iface.parse()?; diff --git a/wgctrl-rs/src/backends/userspace.rs b/wgctrl-rs/src/backends/userspace.rs index b63e1f9..dbb8e51 100644 --- a/wgctrl-rs/src/backends/userspace.rs +++ b/wgctrl-rs/src/backends/userspace.rs @@ -3,7 +3,14 @@ use crate::{Backend, Device, DeviceUpdate, InterfaceName, PeerConfig, PeerInfo, #[cfg(target_os = "linux")] use crate::Key; -use std::{fs, io::{self, prelude::*, BufReader}, os::unix::net::UnixStream, path::{Path, PathBuf}, process::{Command, Output}, time::{Duration, SystemTime}}; +use std::{ + fs, + io::{self, prelude::*, BufReader}, + os::unix::net::UnixStream, + path::{Path, PathBuf}, + process::{Command, Output}, + time::{Duration, SystemTime}, +}; static VAR_RUN_PATH: &str = "/var/run/wireguard"; static RUN_PATH: &str = "/run/wireguard"; @@ -59,7 +66,8 @@ pub fn enumerate() -> Result, io::Error> { for entry in fs::read_dir(get_base_folder()?)? { let path = entry?.path(); if path.extension() == Some(OsStr::new("name")) { - let stem = path.file_stem() + let stem = path + .file_stem() .and_then(|stem| stem.to_str()) .and_then(|name| name.parse::().ok()) .filter(|iface| open_socket(iface).is_ok());