mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-06-13 16:23:30 -07:00
Fix various clippy warnings
This commit fixes various clippy warnings that do not affect the function of the code and aren't stylistic in nature.
This commit is contained in:
committed by
Will Greenberg
parent
9c26e89b24
commit
d0d01089dd
+3
-5
@@ -88,11 +88,9 @@ async fn pcapify(qmdl_path: &PathBuf) {
|
||||
let mut pcap_writer = GsmtapPcapWriter::new(pcap_file).await.unwrap();
|
||||
pcap_writer.write_iface_header().await.unwrap();
|
||||
while let Some(container) = qmdl_reader.get_next_messages_container().await.expect("failed to get container") {
|
||||
for maybe_msg in container.into_messages() {
|
||||
if let Ok(msg) = maybe_msg {
|
||||
if let Ok(Some((timestamp, parsed))) = gsmtap_parser::parse(msg) {
|
||||
pcap_writer.write_gsmtap_message(parsed, timestamp).await.expect("failed to write");
|
||||
}
|
||||
for msg in container.into_messages().into_iter().flatten() {
|
||||
if let Ok(Some((timestamp, parsed))) = gsmtap_parser::parse(msg) {
|
||||
pcap_writer.write_gsmtap_message(parsed, timestamp).await.expect("failed to write");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -195,7 +195,8 @@ fn update_ui(task_tracker: &TaskTracker, config: &config::Config, mut ui_shutdo
|
||||
fb.draw_line(framebuffer::Color565::Pink, 50);
|
||||
fb.draw_line(framebuffer::Color565::Cyan, 25);
|
||||
},
|
||||
1 | _ => {
|
||||
_ => { // this branch id for ui_level 1, which is also the default if an
|
||||
// unknown value is used
|
||||
fb.draw_line(display_color, 2);
|
||||
},
|
||||
};
|
||||
|
||||
+5
-6
@@ -104,7 +104,7 @@ pub fn run_diag_read_thread(
|
||||
}
|
||||
let mut qmdl_store = qmdl_store_lock.write().await;
|
||||
let index = qmdl_store.current_entry.expect("DiagDevice had qmdl_writer, but QmdlStore didn't have current entry???");
|
||||
qmdl_store.update_entry_analysis_size(index, analysis_file_len as usize).await
|
||||
qmdl_store.update_entry_analysis_size(index, analysis_file_len).await
|
||||
.expect("failed to update analysis file size");
|
||||
}
|
||||
},
|
||||
@@ -130,12 +130,11 @@ pub async fn start_recording(State(state): State<Arc<ServerState>>) -> Result<(S
|
||||
state.diag_device_ctrl_sender.send(DiagDeviceCtrlMessage::StartRecording((qmdl_writer, analysis_file))).await
|
||||
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, format!("couldn't send stop recording message: {}", e)))?;
|
||||
|
||||
let display_state: framebuffer::DisplayState;
|
||||
if state.colorblind_mode {
|
||||
display_state = framebuffer::DisplayState::RecordingCBM;
|
||||
let display_state = if state.colorblind_mode {
|
||||
framebuffer::DisplayState::RecordingCBM
|
||||
} else {
|
||||
display_state = framebuffer::DisplayState::Recording;
|
||||
}
|
||||
framebuffer::DisplayState::Recording
|
||||
};
|
||||
state.ui_update_sender.send(display_state).await
|
||||
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, format!("couldn't send ui update message: {}", e)))?;
|
||||
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ pub struct ServerState {
|
||||
pub async fn get_qmdl(State(state): State<Arc<ServerState>>, Path(qmdl_name): Path<String>) -> Result<Response, (StatusCode, String)> {
|
||||
let qmdl_idx = qmdl_name.trim_end_matches(".qmdl");
|
||||
let qmdl_store = state.qmdl_store_lock.read().await;
|
||||
let (entry_index, entry) = qmdl_store.entry_for_name(&qmdl_idx)
|
||||
let (entry_index, entry) = qmdl_store.entry_for_name(qmdl_idx)
|
||||
.ok_or((StatusCode::NOT_FOUND, format!("couldn't find qmdl file with name {}", qmdl_idx)))?;
|
||||
let qmdl_file = qmdl_store.open_entry_qmdl(entry_index).await
|
||||
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, format!("error opening QMDL file: {}", e)))?;
|
||||
|
||||
@@ -97,11 +97,9 @@ impl AnalysisRow {
|
||||
|
||||
pub fn contains_warnings(&self) -> bool {
|
||||
for analysis in &self.analysis {
|
||||
for maybe_event in &analysis.events {
|
||||
if let Some(event) = maybe_event {
|
||||
if matches!(event.event_type, EventType::QualitativeWarning { .. }) {
|
||||
return true;
|
||||
}
|
||||
for event in analysis.events.iter().flatten() {
|
||||
if matches!(event.event_type, EventType::QualitativeWarning { .. }) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ impl Analyzer for ConnectionRedirect2GDowngradeAnalyzer {
|
||||
match carrier_info {
|
||||
RedirectedCarrierInfo::Geran(_carrier_freqs_geran) => Some(Event {
|
||||
event_type: EventType::QualitativeWarning { severity: Severity::High },
|
||||
message: format!("Detected 2G downgrade"),
|
||||
message: "Detected 2G downgrade".to_owned(),
|
||||
}),
|
||||
_ => Some(Event {
|
||||
event_type: EventType::Informational,
|
||||
|
||||
@@ -50,7 +50,7 @@ impl Analyzer for ImsiRequestedAnalyzer {
|
||||
event_type: EventType::QualitativeWarning {
|
||||
severity: Severity::High
|
||||
},
|
||||
message: format!("NAS IMSI identity request detected"),
|
||||
message: "NAS IMSI identity request detected".to_owned(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,18 +29,18 @@ impl NullCipherAnalyzer {
|
||||
}
|
||||
// Use map/flatten to dig into a long chain of nested Option types
|
||||
let maybe_v1250 = c1.non_critical_extension.as_ref()
|
||||
.map(|v890| v890.non_critical_extension.as_ref()).flatten()
|
||||
.map(|v920| v920.non_critical_extension.as_ref()).flatten()
|
||||
.map(|v1020| v1020.non_critical_extension.as_ref()).flatten()
|
||||
.map(|v1130| v1130.non_critical_extension.as_ref()).flatten();
|
||||
.and_then(|v890| v890.non_critical_extension.as_ref())
|
||||
.and_then(|v920| v920.non_critical_extension.as_ref())
|
||||
.and_then(|v1020| v1020.non_critical_extension.as_ref())
|
||||
.and_then(|v1130| v1130.non_critical_extension.as_ref());
|
||||
let Some(v1250) = maybe_v1250 else {
|
||||
return false;
|
||||
};
|
||||
|
||||
if let Some(SCG_Configuration_r12::Setup(scg_setup)) = v1250.scg_configuration_r12.as_ref() {
|
||||
let maybe_cipher = scg_setup.scg_config_part_scg_r12.as_ref()
|
||||
.map(|scg| scg.mobility_control_info_scg_r12.as_ref()).flatten()
|
||||
.map(|mci| mci.ciphering_algorithm_scg_r12.as_ref()).flatten();
|
||||
.and_then(|scg| scg.mobility_control_info_scg_r12.as_ref())
|
||||
.and_then(|mci| mci.ciphering_algorithm_scg_r12.as_ref());
|
||||
if let Some(cipher) = maybe_cipher {
|
||||
if cipher.0 == CipheringAlgorithm_r12::EEA0 {
|
||||
return true;
|
||||
@@ -49,10 +49,10 @@ impl NullCipherAnalyzer {
|
||||
}
|
||||
|
||||
let maybe_v1530_security_config = v1250.non_critical_extension.as_ref()
|
||||
.map(|v1310| v1310.non_critical_extension.as_ref()).flatten()
|
||||
.map(|v1430| v1430.non_critical_extension.as_ref()).flatten()
|
||||
.map(|v1510| v1510.non_critical_extension.as_ref()).flatten()
|
||||
.map(|v1530| v1530.security_config_ho_v1530.as_ref()).flatten();
|
||||
.and_then(|v1310| v1310.non_critical_extension.as_ref())
|
||||
.and_then(|v1430| v1430.non_critical_extension.as_ref())
|
||||
.and_then(|v1510| v1510.non_critical_extension.as_ref())
|
||||
.and_then(|v1530| v1530.security_config_ho_v1530.as_ref());
|
||||
let Some(v1530_security_config) = maybe_v1530_security_config else {
|
||||
return false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user