meta: remove unused code and format

pull/74/head
Jake McGinty 2021-05-20 03:18:19 +09:00
parent 3fcacc2ad8
commit c512985214
8 changed files with 24 additions and 29 deletions

View File

@ -54,8 +54,8 @@ package = "innernet"
buildflags = ["--release"] buildflags = ["--release"]
[package.metadata.rpm.files] [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" } "../../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] [package.metadata.rpm.targets]
innernet = { path = "/usr/bin/innernet" } innernet = { path = "/usr/bin/innernet" }

View File

@ -498,10 +498,7 @@ fn fetch(
} }
println!(); println!();
log::info!( log::info!("updated interface {}\n", interface.as_str_lossy().yellow());
"updated interface {}\n",
interface.as_str_lossy().yellow()
);
} else { } else {
log::info!("{}", "peers are already up to date.".green()); log::info!("{}", "peers are already up to date.".green());
} }

View File

@ -10,9 +10,10 @@ static LOGGER: Logger = Logger;
struct Logger; struct Logger;
impl log::Log for Logger { impl log::Log for Logger {
fn enabled(&self, metadata: &log::Metadata) -> bool { fn enabled(&self, metadata: &log::Metadata) -> bool {
metadata.level() <= log::max_level() && (log::max_level() == LevelFilter::Trace metadata.level() <= log::max_level()
|| metadata.target().starts_with("shared::") && (log::max_level() == LevelFilter::Trace
|| metadata.target() == "innernet") || metadata.target().starts_with("shared::")
|| metadata.target() == "innernet")
} }
fn log(&self, record: &log::Record) { fn log(&self, record: &log::Record) {
@ -25,7 +26,12 @@ impl log::Log for Logger {
Level::Trace => "[T]".purple(), Level::Trace => "[T]".purple(),
}; };
if record.level() <= LevelFilter::Debug && record.target() != "innernet" { 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 { } else {
println!("{} {}", level_str, record.args()); println!("{} {}", level_str, record.args());
} }

View File

@ -22,12 +22,6 @@ cleanup() {
} }
trap cleanup EXIT 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." info "Creating network."
NETWORK=$(cmd docker network create -d bridge --subnet=172.18.0.0/16 innernet) NETWORK=$(cmd docker network create -d bridge --subnet=172.18.0.0/16 innernet)

View File

@ -1,7 +1,7 @@
[package] [package]
name = "publicip"
version = "0.1.0"
authors = ["Jake McGinty <me@jake.su>"] authors = ["Jake McGinty <me@jake.su>"]
edition = "2018" edition = "2018"
name = "publicip"
version = "0.1.0"
[dependencies] [dependencies]

View File

@ -23,8 +23,8 @@ libc = "0.2"
libsqlite3-sys = "0.22" libsqlite3-sys = "0.22"
log = "0.4" log = "0.4"
parking_lot = "0.11" parking_lot = "0.11"
publicip = { path = "../publicip" }
pretty_env_logger = "0.4" pretty_env_logger = "0.4"
publicip = { path = "../publicip" }
regex = { version = "1", default-features = false, features = ["std"] } regex = { version = "1", default-features = false, features = ["std"] }
rusqlite = "0.25" rusqlite = "0.25"
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
@ -64,8 +64,8 @@ package = "innernet-server"
buildflags = ["--release"] buildflags = ["--release"]
[package.metadata.rpm.files] [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" } "../../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] [package.metadata.rpm.targets]
innernet-server = { path = "/usr/bin/innernet-server" } innernet-server = { path = "/usr/bin/innernet-server" }

View File

@ -10,14 +10,8 @@ fn cmd(bin: &str, args: &[&str]) -> Result<process::Output, Error> {
let output = Command::new(bin).args(args).output()?; let output = Command::new(bin).args(args).output()?;
log::debug!("{} {}", bin, args.join(" ")); log::debug!("{} {}", bin, args.join(" "));
log::debug!("status code {:?}", output.status.code()); log::debug!("status code {:?}", output.status.code());
log::trace!( log::trace!("stdout: {}", String::from_utf8_lossy(&output.stdout));
"stdout: {}", log::trace!("stderr: {}", String::from_utf8_lossy(&output.stderr));
String::from_utf8_lossy(&output.stdout)
);
log::trace!(
"stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
if output.status.success() { if output.status.success() {
Ok(output) Ok(output)
} else { } else {

View File

@ -57,9 +57,13 @@ impl FromStr for Backend {
impl Backend { impl Backend {
pub fn variants() -> &'static [&'static str] { pub fn variants() -> &'static [&'static str] {
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
{ &["kernel", "userspace"] } {
&["kernel", "userspace"]
}
#[cfg(not(target_os = "linux"))] #[cfg(not(target_os = "linux"))]
{ &["userspace"] } {
&["userspace"]
}
} }
} }