From c512985214220fdab9201663decd5e1240f6f3eb Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Thu, 20 May 2021 03:18:19 +0900 Subject: [PATCH] meta: remove unused code and format --- client/Cargo.toml | 2 +- client/src/main.rs | 5 +---- client/src/util.rs | 14 ++++++++++---- docker-tests/run-docker-tests.sh | 6 ------ publicip/Cargo.toml | 4 ++-- server/Cargo.toml | 4 ++-- shared/src/wg.rs | 10 ++-------- wgctrl-rs/src/lib.rs | 8 ++++++-- 8 files changed, 24 insertions(+), 29 deletions(-) diff --git a/client/Cargo.toml b/client/Cargo.toml index 9c5800c..85ba17f 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -54,8 +54,8 @@ package = "innernet" buildflags = ["--release"] [package.metadata.rpm.files] -"../innernet@.service" = { path = "/usr/lib/systemd/system/innernet@.service" } "../../doc/innernet-server.8.gz" = { path = "/usr/share/man/man8/innernet.8.gz" } +"../innernet@.service" = { path = "/usr/lib/systemd/system/innernet@.service" } [package.metadata.rpm.targets] innernet = { path = "/usr/bin/innernet" } diff --git a/client/src/main.rs b/client/src/main.rs index c039b80..155bfbb 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -498,10 +498,7 @@ fn fetch( } println!(); - log::info!( - "updated interface {}\n", - interface.as_str_lossy().yellow() - ); + log::info!("updated interface {}\n", interface.as_str_lossy().yellow()); } else { log::info!("{}", "peers are already up to date.".green()); } diff --git a/client/src/util.rs b/client/src/util.rs index 0635b4a..55a421b 100644 --- a/client/src/util.rs +++ b/client/src/util.rs @@ -10,9 +10,10 @@ static LOGGER: Logger = Logger; struct Logger; impl log::Log for Logger { fn enabled(&self, metadata: &log::Metadata) -> bool { - metadata.level() <= log::max_level() && (log::max_level() == LevelFilter::Trace - || metadata.target().starts_with("shared::") - || metadata.target() == "innernet") + metadata.level() <= log::max_level() + && (log::max_level() == LevelFilter::Trace + || metadata.target().starts_with("shared::") + || metadata.target() == "innernet") } fn log(&self, record: &log::Record) { @@ -25,7 +26,12 @@ impl log::Log for Logger { Level::Trace => "[T]".purple(), }; if record.level() <= LevelFilter::Debug && record.target() != "innernet" { - println!("{} {} {}", level_str, format!("[{}]", record.target()).dimmed(), record.args()); + println!( + "{} {} {}", + level_str, + format!("[{}]", record.target()).dimmed(), + record.args() + ); } else { println!("{} {}", level_str, record.args()); } diff --git a/docker-tests/run-docker-tests.sh b/docker-tests/run-docker-tests.sh index 2ef07a4..d0afee2 100755 --- a/docker-tests/run-docker-tests.sh +++ b/docker-tests/run-docker-tests.sh @@ -22,12 +22,6 @@ cleanup() { } trap cleanup EXIT -if [[ "$OSTYPE" == "darwin"* ]]; then - info "Loading wireguard kernel module in Docker VM." - # ensure the wireguard kernel module is loaded in the macOS docker VM. - cmd docker run --rm --pid=host --privileged justincormack/nsenter1 /sbin/modprobe wireguard -fi - info "Creating network." NETWORK=$(cmd docker network create -d bridge --subnet=172.18.0.0/16 innernet) diff --git a/publicip/Cargo.toml b/publicip/Cargo.toml index ca7087a..45f88a7 100644 --- a/publicip/Cargo.toml +++ b/publicip/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "publicip" -version = "0.1.0" authors = ["Jake McGinty "] edition = "2018" +name = "publicip" +version = "0.1.0" [dependencies] diff --git a/server/Cargo.toml b/server/Cargo.toml index c82110b..c34920a 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -23,8 +23,8 @@ libc = "0.2" libsqlite3-sys = "0.22" log = "0.4" parking_lot = "0.11" -publicip = { path = "../publicip" } pretty_env_logger = "0.4" +publicip = { path = "../publicip" } regex = { version = "1", default-features = false, features = ["std"] } rusqlite = "0.25" serde = { version = "1", features = ["derive"] } @@ -64,8 +64,8 @@ package = "innernet-server" buildflags = ["--release"] [package.metadata.rpm.files] -"../innernet-server@.service" = { path = "/usr/lib/systemd/system/innernet-server@.service" } "../../doc/innernet-server.8.gz" = { path = "/usr/share/man/man8/innernet-server.8.gz" } +"../innernet-server@.service" = { path = "/usr/lib/systemd/system/innernet-server@.service" } [package.metadata.rpm.targets] innernet-server = { path = "/usr/bin/innernet-server" } diff --git a/shared/src/wg.rs b/shared/src/wg.rs index 383ac79..2a9ec3f 100644 --- a/shared/src/wg.rs +++ b/shared/src/wg.rs @@ -10,14 +10,8 @@ fn cmd(bin: &str, args: &[&str]) -> Result { let output = Command::new(bin).args(args).output()?; log::debug!("{} {}", bin, args.join(" ")); log::debug!("status code {:?}", output.status.code()); - log::trace!( - "stdout: {}", - String::from_utf8_lossy(&output.stdout) - ); - log::trace!( - "stderr: {}", - String::from_utf8_lossy(&output.stderr) - ); + log::trace!("stdout: {}", String::from_utf8_lossy(&output.stdout)); + log::trace!("stderr: {}", String::from_utf8_lossy(&output.stderr)); if output.status.success() { Ok(output) } else { diff --git a/wgctrl-rs/src/lib.rs b/wgctrl-rs/src/lib.rs index 47dcacc..c3453c9 100644 --- a/wgctrl-rs/src/lib.rs +++ b/wgctrl-rs/src/lib.rs @@ -57,9 +57,13 @@ impl FromStr for Backend { impl Backend { pub fn variants() -> &'static [&'static str] { #[cfg(target_os = "linux")] - { &["kernel", "userspace"] } + { + &["kernel", "userspace"] + } #[cfg(not(target_os = "linux"))] - { &["userspace"] } + { + &["userspace"] + } } }