Add 'download unknown' link to the unknown IPs page.

This commit is contained in:
Herbert Wolverson
2023-01-13 14:16:48 +00:00
parent d7034d1e42
commit f3a5739133
3 changed files with 17 additions and 0 deletions

View File

@@ -53,6 +53,7 @@ fn rocket() -> _ {
unknown_devices::all_unknown_devices,
unknown_devices::unknown_devices_count,
unknown_devices::unknown_devices_range,
unknown_devices::unknown_devices_csv,
queue_info::raw_queue_by_circuit,
queue_info::run_btest,
queue_info::circuit_info,

View File

@@ -22,3 +22,14 @@ pub fn unknown_devices_range(
let result: Vec<IpStats> = reader.iter().skip(start).take(end).cloned().collect();
NoCache::new(Json(result))
}
#[get("/api/unknown_devices_csv")]
pub fn unknown_devices_csv(_auth: AuthGuard) -> NoCache<String> {
let mut result = String::new();
let reader = UNKNOWN_DEVICES.read();
for unknown in reader.iter() {
result += &format!("{}\n", unknown.ip_address);
}
NoCache::new(result)
}

View File

@@ -56,6 +56,8 @@
<div class="card-body">
<h5 class="card-title"><i class="fa fa-address-card"></i> Unmapped IP Addresses (Most recently seen first)</h5>
<a id="btnDownloadCsv" class="btn btn-info"><i class="fa fa-download"></i> Download Text File of Unknown IP addresses.</a>
<table class="table table-striped">
<thead>
<th>IP</th>
@@ -115,6 +117,9 @@
console.log(devices);
fillDeviceTable(devices);
});
$("#btnDownloadCsv").on('click', () => {
window.location.href = "/api/unknown_devices_csv";
});
}
$(document).ready(start);