1
0
mirror of https://github.com/tonarino/innernet.git synced 2024-11-28 08:58:37 +02:00

meta: cargo clippy

This commit is contained in:
Jake McGinty 2021-06-22 11:27:29 +09:00
parent b23f952e79
commit 0c8a2ee991
5 changed files with 14 additions and 14 deletions

View File

@ -364,7 +364,7 @@ fn redeem_invite(
.resolve()
.with_str(config.server.external_endpoint.to_string())?;
wg::up(
&iface,
iface,
&config.interface.private_key,
config.interface.address,
None,
@ -402,7 +402,7 @@ fn redeem_invite(
log::info!("Changing keys and waiting for server's WireGuard interface to transition.",);
DeviceUpdate::new()
.set_private_key(keypair.private)
.apply(&iface, network.backend)
.apply(iface, network.backend)
.with_str(iface.to_string())?;
thread::sleep(*REDEEM_TRANSITION_WAIT);
@ -469,11 +469,11 @@ fn fetch(
}
log::info!("fetching state from server.");
let mut store = DataStore::open_or_create(&interface)?;
let mut store = DataStore::open_or_create(interface)?;
let State { peers, cidrs } = Api::new(&config.server).http("GET", "/user/state")?;
let device_info =
Device::get(&interface, network.backend).with_str(interface.as_str_lossy())?;
Device::get(interface, network.backend).with_str(interface.as_str_lossy())?;
let interface_public_key = device_info
.public_key
.as_ref()
@ -533,7 +533,7 @@ fn fetch(
if device_config_changed {
device_config_builder
.apply(&interface, network.backend)
.apply(interface, network.backend)
.with_str(interface.to_string())?;
if let Some(path) = hosts_path {
@ -936,7 +936,7 @@ fn print_tree(cidr: &CidrTree, peers: &[PeerState], level: usize) {
children.sort();
children
.iter()
.for_each(|child| print_tree(&child, peers, level + 1));
.for_each(|child| print_tree(child, peers, level + 1));
for peer in peers.iter().filter(|p| p.peer.cidr_id == cidr.id) {
print_peer(peer, true, level);

View File

@ -75,7 +75,7 @@ impl DatabasePeer {
} = &contents;
log::info!("creating peer {:?}", contents);
if !Self::is_valid_name(&name) {
if !Self::is_valid_name(name) {
log::warn!("peer name is invalid, must conform to hostname(7) requirements.");
return Err(ServerError::InvalidQuery);
}

View File

@ -57,7 +57,7 @@ fn populate_database(conn: &Connection, db_init_data: DbInitData) -> Result<(),
const SERVER_NAME: &str = "innernet-server";
let root_cidr = DatabaseCidr::create(
&conn,
conn,
CidrContents {
name: db_init_data.network_name.clone(),
cidr: db_init_data.network_cidr,
@ -67,7 +67,7 @@ fn populate_database(conn: &Connection, db_init_data: DbInitData) -> Result<(),
.map_err(|_| anyhow!("failed to create root CIDR"))?;
let server_cidr = DatabaseCidr::create(
&conn,
conn,
CidrContents {
name: SERVER_NAME.into(),
cidr: db_init_data.server_cidr,
@ -77,7 +77,7 @@ fn populate_database(conn: &Connection, db_init_data: DbInitData) -> Result<(),
.map_err(|_| anyhow!("failed to create innernet-server CIDR"))?;
let _me = DatabasePeer::create(
&conn,
conn,
PeerContents {
name: SERVER_NAME.parse().map_err(|e: &str| anyhow!(e))?,
ip: db_init_data.our_ip,

View File

@ -263,7 +263,7 @@ fn open_database_connection(
interface: &InterfaceName,
conf: &ServerConfig,
) -> Result<rusqlite::Connection, Error> {
let database_path = conf.database_path(&interface);
let database_path = conf.database_path(interface);
if !Path::new(&database_path).exists() {
bail!(
"no database file found at {}",
@ -612,7 +612,7 @@ fn get_session(
.get(INNERNET_PUBKEY_HEADER)
.ok_or(ServerError::Unauthorized)?;
let pubkey = pubkey.to_str().map_err(|_| ServerError::Unauthorized)?;
let pubkey = Key::from_base64(&pubkey).map_err(|_| ServerError::Unauthorized)?;
let pubkey = Key::from_base64(pubkey).map_err(|_| ServerError::Unauthorized)?;
if pubkey.0.ct_eq(&context.public_key.0).into() {
let peer = DatabasePeer::get_from_ip(&context.db.lock(), addr).map_err(|e| match e {
rusqlite::Error::QueryReturnedNoRows => ServerError::Unauthorized,

View File

@ -78,7 +78,7 @@ pub fn up(
if let Some((public_key, address, endpoint)) = peer {
let prefix = if address.is_ipv4() { 32 } else { 128 };
let peer_config =
PeerConfigBuilder::new(&wgctrl::Key::from_base64(&public_key).map_err(|_| {
PeerConfigBuilder::new(&wgctrl::Key::from_base64(public_key).map_err(|_| {
io::Error::new(
io::ErrorKind::InvalidInput,
"failed to parse base64 public key",
@ -92,7 +92,7 @@ pub fn up(
device = device.set_listen_port(listen_port);
}
device
.set_private_key(wgctrl::Key::from_base64(&private_key).unwrap())
.set_private_key(wgctrl::Key::from_base64(private_key).unwrap())
.apply(interface, network.backend)?;
set_addr(interface, address)?;
set_up(