mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-04-28 08:29:58 -07:00
Revert "Add warning about default routes"
This reverts commit 9ae1563286.
Reverts #804
Reverts #830
Reopens #345
This commit is contained in:
committed by
Cooper Quintin
parent
987d95c23e
commit
2a68c99897
@@ -25,7 +25,7 @@ use crate::server::{
|
||||
ServerState, debug_set_display_state, get_config, get_qmdl, get_time, get_zip, serve_static,
|
||||
set_config, set_time_offset, test_notification,
|
||||
};
|
||||
use crate::stats::{get_qmdl_manifest, get_route_status, get_system_stats};
|
||||
use crate::stats::{get_qmdl_manifest, get_system_stats};
|
||||
|
||||
use analysis::{
|
||||
AnalysisCtrlMessage, AnalysisStatus, get_analysis_status, run_analysis_thread, start_analysis,
|
||||
@@ -58,7 +58,6 @@ fn get_router() -> AppRouter {
|
||||
.route("/api/qmdl/{name}", get(get_qmdl))
|
||||
.route("/api/zip/{name}", get(get_zip))
|
||||
.route("/api/system-stats", get(get_system_stats))
|
||||
.route("/api/route-status", get(get_route_status))
|
||||
.route("/api/qmdl-manifest", get(get_qmdl_manifest))
|
||||
.route("/api/log", get(get_log))
|
||||
.route("/api/start-recording", post(start_recording))
|
||||
|
||||
@@ -174,33 +174,3 @@ pub async fn get_log() -> Result<String, (StatusCode, String)> {
|
||||
.await
|
||||
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct RouteStatus {
|
||||
pub has_default_route: bool,
|
||||
}
|
||||
|
||||
pub async fn get_route_status() -> Json<RouteStatus> {
|
||||
let has_default_route = match check_default_route().await {
|
||||
Ok(result) => result,
|
||||
Err(err) => {
|
||||
log::warn!("Failed to check default route: {err}");
|
||||
// More likely than not, this is a portability issue. The logic hasn't been fully
|
||||
// tested on all devices. We shouldn't scare users unnecessarily.
|
||||
true
|
||||
}
|
||||
};
|
||||
|
||||
Json(RouteStatus { has_default_route })
|
||||
}
|
||||
|
||||
// Checks for an IPv4 default route by reading /proc/net/route
|
||||
// instead of shelling out to `ip route`, which may not be available on all devices.
|
||||
async fn check_default_route() -> std::io::Result<bool> {
|
||||
let contents = tokio::fs::read_to_string("/proc/net/route").await?;
|
||||
Ok(contents.lines().skip(1).any(|line| {
|
||||
line.split_whitespace()
|
||||
.nth(1)
|
||||
.is_some_and(|dest| dest == "00000000")
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user