Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jkilpatr committed Aug 16, 2022
1 parent 4d031d2 commit 8d8a6c0
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 48 deletions.
8 changes: 4 additions & 4 deletions althea_kernel_interface/src/interface_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ impl dyn KernelInterface {
pub fn set_if_up_down(&self, if_name: &str, up_down: &str) -> Result<(), Error> {
let output = self.run_command("ip", &["link", "set", "dev", if_name, up_down])?;
if !output.stderr.is_empty() {
return Err(Error::RuntimeError(format!(
Err(Error::RuntimeError(format!(
"received error setting wg interface up: {}",
String::from_utf8(output.stderr)?
)));
)))
} else {
Ok(())
}
Expand Down Expand Up @@ -188,10 +188,10 @@ impl dyn KernelInterface {
&["link", "set", "dev", if_name, "mtu", &mtu.to_string()],
)?;
if !output.stderr.is_empty() {
return Err(Error::RuntimeError(format!(
Err(Error::RuntimeError(format!(
"received error setting interface mtu: {}",
String::from_utf8(output.stderr)?
)));
)))
} else {
Ok(())
}
Expand Down
10 changes: 4 additions & 6 deletions rita_common/src/dashboard/nickname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ pub async fn set_nickname(nickname: Json<Nickname>) -> HttpResponse {

HttpResponse::Ok().json(())
}
Err(_e) => {
return HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR).json(format!(
"{}",
RitaCommonError::CapacityError("Insufficient capacity for string!".to_string())
));
}
Err(_e) => HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR).json(format!(
"{}",
RitaCommonError::CapacityError("Insufficient capacity for string!".to_string())
)),
}
}

Expand Down
2 changes: 1 addition & 1 deletion rita_common/src/peer_listener/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const MSG_HELLO: u8 = 0x6c;
/**
* An enum that contains all supported p2p packets
*/
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum PeerMessage {
ImHere(Ipv6Addr),
/// This is the message sent over the udp socket. It contains the necessary information to set up a tunnel
Expand Down
2 changes: 1 addition & 1 deletion rita_common/src/peer_listener/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub struct PeerListener {
///and when we receive a response to a hello we sent. 1 indicates we received a response hello message.
///This is the internal struct that carries information about local identity and which peer to send
///this message to, as well as whether this is a response or intial contact message.
#[derive(Debug, Serialize, Deserialize, PartialEq)]
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct Hello {
pub my_id: LocalIdentity,
pub to: Peer,
Expand Down
6 changes: 3 additions & 3 deletions rita_common/src/usage_tracker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub enum UsageType {

/// A struct for tracking each hour of usage, indexed by time in hours since
/// the unix epoch
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)]
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct UsageHour {
index: u64,
up: u64,
Expand Down Expand Up @@ -101,7 +101,7 @@ fn to_formatted_payment_tx(input: PaymentTx) -> FormattedPaymentTx {
}

/// A struct for tracking each hours of payments indexed in hours since unix epoch
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct PaymentHour {
index: u64,
payments: Vec<FormattedPaymentTx>,
Expand All @@ -110,7 +110,7 @@ pub struct PaymentHour {
/// The main actor that holds the usage state for the duration of operations
/// at some point loading and saving will be defined in service started
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct UsageTracker {
last_save_hour: u64,
// at least one of these will be left unused
Expand Down
26 changes: 13 additions & 13 deletions rita_exit/src/database/database_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub fn update_client(
);
diesel::update(filtered_list.clone())
.set(email.eq(mail))
.execute(&*conn)?;
.execute(conn)?;
}
}

Expand All @@ -106,7 +106,7 @@ pub fn update_client(
);
diesel::update(filtered_list.clone())
.set(phone.eq(number))
.execute(&*conn)?;
.execute(conn)?;
}
}

Expand All @@ -117,7 +117,7 @@ pub fn update_client(
info!("Bumping client timestamp for {}", their_record.wg_pubkey);
diesel::update(filtered_list)
.set(last_seen.eq(secs_since_unix_epoch() as i64))
.execute(&*conn)?;
.execute(conn)?;
}

Ok(())
Expand Down Expand Up @@ -179,7 +179,7 @@ pub fn verify_client(

diesel::update(filtered_list)
.set(verified.eq(client_verified))
.execute(&*conn)?;
.execute(conn)?;

Ok(())
}
Expand All @@ -201,7 +201,7 @@ pub fn verify_db_client(

diesel::update(filtered_list)
.set(verified.eq(client_verified))
.execute(&*conn)?;
.execute(conn)?;

Ok(())
}
Expand All @@ -223,7 +223,7 @@ pub fn text_sent(

diesel::update(filtered_list)
.set(text_sent.eq(val + 1))
.execute(&*conn)?;
.execute(conn)?;

Ok(())
}
Expand All @@ -238,7 +238,7 @@ fn client_exists(client: &ExitClientIdentity, conn: &PgConnection) -> Result<boo
.filter(mesh_ip.eq(ip.to_string()))
.filter(wg_pubkey.eq(wg.to_string()))
.filter(eth_address.eq(key.to_string().to_lowercase()));
Ok(select(exists(filtered_list)).get_result(&*conn)?)
Ok(select(exists(filtered_list)).get_result(conn)?)
}

/// True if there is any client with the same eth address, wg key, or ip address already registered
Expand All @@ -260,9 +260,9 @@ pub fn client_conflict(
let ip_match = clients.filter(mesh_ip.eq(ip.to_string()));
let wg_key_match = clients.filter(wg_pubkey.eq(wg.to_string()));
let eth_address_match = clients.filter(eth_address.eq(key.to_string().to_lowercase()));
let ip_exists = select(exists(ip_match)).get_result(&*conn)?;
let wg_exists = select(exists(wg_key_match)).get_result(&*conn)?;
let eth_exists = select(exists(eth_address_match)).get_result(&*conn)?;
let ip_exists = select(exists(ip_match)).get_result(conn)?;
let wg_exists = select(exists(wg_key_match)).get_result(conn)?;
let eth_exists = select(exists(eth_address_match)).get_result(conn)?;
info!(
"Signup conflict ip {} eth {} wg {}",
ip_exists, eth_exists, wg_exists
Expand Down Expand Up @@ -405,7 +405,7 @@ pub fn update_mail_sent_time(

diesel::update(clients.filter(email.eq(mail_addr)))
.set(email_sent_time.eq(secs_since_unix_epoch()))
.execute(&*conn)?;
.execute(conn)?;

Ok(())
}
Expand Down Expand Up @@ -614,10 +614,10 @@ pub fn get_client_subnet(
Ok(addr)
} else {
error!("Chosen subnet: {:?} is in use! Race condition hit", addr);
return Err(RitaExitError::MiscStringError(format!(
Err(RitaExitError::MiscStringError(format!(
"Unable to assign user ipv6 subnet. Chosen subnet {:?} is in use",
addr
)));
)))
}
}
Err(e) => {
Expand Down
20 changes: 8 additions & 12 deletions rita_exit/src/database/geoip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,16 @@ pub fn get_gateway_ip_single(mesh_ip: IpAddr) -> Result<IpAddr, RitaExitError> {
None => Err(RitaExitError::IpAddrError(mesh_ip)),
}
}
Err(e) => {
return Err(RitaExitError::MiscStringError(format!(
"Parse routes babel monitor error, {:?}",
e
)))
}
Err(e) => Err(RitaExitError::MiscStringError(format!(
"Parse routes babel monitor error, {:?}",
e
))),
}
}
Err(e) => {
return Err(RitaExitError::MiscStringError(format!(
"Error opening babel stream, {:?}",
e
)));
}
Err(e) => Err(RitaExitError::MiscStringError(format!(
"Error opening babel stream, {:?}",
e
))),
}
}

Expand Down
10 changes: 4 additions & 6 deletions rita_exit/src/database/sms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,10 @@ async fn send_text(number: String, api_key: String) -> Result<(), RitaExitError>
.await
{
Ok(_a) => Ok(()),
Err(e) => {
return Err(RitaExitError::MiscStringError(format!(
"Send text error: {:?}",
e
)))
}
Err(e) => Err(RitaExitError::MiscStringError(format!(
"Send text error: {:?}",
e
))),
}
}

Expand Down
4 changes: 2 additions & 2 deletions rita_exit/src/network_endpoints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ pub async fn secure_setup_request(
)),
Err(e) => {
error!("Signup client failed with {:?}", e);
return HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR)
.json(format!("Signup client failed with {:?}", e));
HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR)
.json(format!("Signup client failed with {:?}", e))
}
}
} else {
Expand Down

0 comments on commit 8d8a6c0

Please sign in to comment.