From 050ce1362ac26015a66c94b260446212699b8dad Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Tue, 1 Feb 2022 04:20:21 +0900 Subject: [PATCH] meta: fix new cargo clippy warnings --- hostsfile/src/lib.rs | 12 ++++++------ server/src/api/admin/peer.rs | 4 ++-- server/src/api/user.rs | 4 ++-- server/src/main.rs | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hostsfile/src/lib.rs b/hostsfile/src/lib.rs index e19db3b..8d3c702 100644 --- a/hostsfile/src/lib.rs +++ b/hostsfile/src/lib.rs @@ -231,25 +231,25 @@ impl HostsBuilder { let mut s = vec![]; for line in &lines[..insert] { - writeln!(&mut s, "{}", line)?; + writeln!(s, "{}", line)?; } if !self.hostname_map.is_empty() { - writeln!(&mut s, "{}", begin_marker)?; + writeln!(s, "{}", begin_marker)?; for (ip, hostnames) in &self.hostname_map { if cfg!(windows) { // windows only allows one hostname per line for hostname in hostnames { - writeln!(&mut s, "{} {}", ip, hostname)?; + writeln!(s, "{} {}", ip, hostname)?; } } else { // assume the same format as Unix - writeln!(&mut s, "{} {}", ip, hostnames.join(" "))?; + writeln!(s, "{} {}", ip, hostnames.join(" "))?; } } - writeln!(&mut s, "{}", end_marker)?; + writeln!(s, "{}", end_marker)?; } for line in &lines[insert..] { - writeln!(&mut s, "{}", line)?; + writeln!(s, "{}", line)?; } match Self::write_and_swap(&temp_path, hosts_path, &s) { diff --git a/server/src/api/admin/peer.rs b/server/src/api/admin/peer.rs index 25c3003..1680e1b 100644 --- a/server/src/api/admin/peer.rs +++ b/server/src/api/admin/peer.rs @@ -8,7 +8,7 @@ use crate::{ }; use hyper::{Body, Method, Request, Response, StatusCode}; use shared::PeerContents; -use wireguard_control::DeviceUpdate; +use wireguard_control::{DeviceUpdate, PeerConfigBuilder}; pub async fn routes( req: Request, @@ -50,7 +50,7 @@ mod handlers { if cfg!(not(test)) { // Update the current WireGuard interface with the new peers. DeviceUpdate::new() - .add_peer((&*peer).into()) + .add_peer(PeerConfigBuilder::from(&*peer)) .apply(&session.context.interface, session.context.backend) .map_err(|_| ServerError::WireGuard)?; log::info!("updated WireGuard interface, adding {}", &*peer); diff --git a/server/src/api/user.rs b/server/src/api/user.rs index d83e760..42f73fa 100644 --- a/server/src/api/user.rs +++ b/server/src/api/user.rs @@ -8,7 +8,7 @@ use crate::{ }; use hyper::{Body, Method, Request, Response, StatusCode}; use shared::{EndpointContents, PeerContents, RedeemContents, State, REDEEM_TRANSITION_WAIT}; -use wireguard_control::DeviceUpdate; +use wireguard_control::{DeviceUpdate, PeerConfigBuilder}; pub async fn routes( req: Request, @@ -117,7 +117,7 @@ mod handlers { ); DeviceUpdate::new() .remove_peer_by_key(&old_public_key) - .add_peer((&*selected_peer).into()) + .add_peer(PeerConfigBuilder::from(&*selected_peer)) .apply(&interface, backend) .map_err(|e| log::error!("{:?}", e)) .ok(); diff --git a/server/src/main.rs b/server/src/main.rs index e1b74fd..6aebcd7 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -311,7 +311,7 @@ fn add_peer( if cfg!(not(test)) && Device::get(interface, network.backend).is_ok() { // Update the current WireGuard interface with the new peers. DeviceUpdate::new() - .add_peer((&*peer).into()) + .add_peer(PeerConfigBuilder::from(&*peer)) .apply(interface, network.backend) .map_err(|_| ServerError::WireGuard)?;