meta: fix new cargo clippy warnings

This commit is contained in:
Jake McGinty 2022-02-01 04:20:21 +09:00
parent ddac328ae5
commit 050ce1362a
4 changed files with 11 additions and 11 deletions

View file

@ -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) {

View file

@ -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<Body>,
@ -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);

View file

@ -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<Body>,
@ -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();

View file

@ -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)?;