Add an on-demand traffic monitor to the tray and Android
Show bidirectional IP conversations with network and peer names, ports, traffic roles, packet totals and directional rates. Aggregate ICMP echoes by address pair. Attribute exit requests and replies from each endpoint's perspective and match VIP traffic on the client-facing side of NAT. Keep authenticated control sessions and opaque relay pairs in a transport view. Each open window owns a bounded interval subscription. The idle path only checks whether a reader exists. Contended writers can use another lane, and observations lost under load are counted without delaying forwarding. Use a dedicated local control connection on desktop and a service handle on Android. Closing or backgrounding the Android screen releases capture. The local IPC format advances to 28. Existing mesh peers and databases remain compatible. Accumulate intervals off the render thread in a private temporary SQLite database. Expire inactive rows after a minute or retain them until close. Indexed, cursor-based pages keep long sessions out of UI memory. Closing the window interrupts pending queries and releases the scratch database. On macOS arm64, workspace formatting and strict Clippy passed. The locked all-targets workspace suite passed 641 tests with five opt-in tests ignored. Coverage includes real WireGuard exit traffic in both directions, local IPC lifetime, Android pause/resume, relay opacity, VIP translation, bounded capture, simulated three-day retention and 320–900 point layouts. The Windows GNU workspace cross-check and the offline Android arm64 debug APK build passed. Windows and Android hardware were not exercised.
This commit is contained in:
1 parent
7afed15f76
commit
e3b74babba
42 files changed
+2476
-31
No files matched your search
@@ -42,6 +42,8 @@ pub struct UiState {
|
||||
pub vip_windows: std::collections::BTreeMap<String, crate::vip::Window>,
|
||||
/// Whether the About window is open.
|
||||
pub about_open: bool,
|
||||
/// Whether the global traffic monitor viewport is open.
|
||||
pub monitor_open: bool,
|
||||
/// An exit-node choice waiting for the user to confirm it.
|
||||
pub exit_confirm: Option<devices::ExitConfirm>,
|
||||
/// A selected offline claim waiting for cleanup confirmation.
|
||||
@@ -59,6 +61,7 @@ impl Default for UiState {
|
||||
open_devices: BTreeSet::new(),
|
||||
vip_windows: Default::default(),
|
||||
about_open: false,
|
||||
monitor_open: false,
|
||||
exit_confirm: None,
|
||||
forget_confirm: None,
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ mod exit;
|
||||
pub mod format;
|
||||
pub mod home;
|
||||
pub mod listeners;
|
||||
pub mod monitor;
|
||||
#[cfg(test)]
|
||||
mod presentation_tests;
|
||||
pub mod stats;
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
//! A private scratch database belongs to one window and one worker thread.
|
||||
//! A capture with millions of flows uses disk, and the UI reads one page at a time.
|
||||
use rusqlite::{Connection, params, params_from_iter, types::Value};
|
||||
use std::path::Path;
|
||||
use tsunagi::traffic::{Flow, FlowDelta, Role};
|
||||
|
||||
pub(super) const PAGE_SIZE: usize = 64;
|
||||
const RETAIN_MS: u64 = 60_000;
|
||||
|
||||
#[derive(Default, Clone, PartialEq, Eq)]
|
||||
pub(super) struct Filter {
|
||||
pub network: Option<[u8; 32]>,
|
||||
pub peer: Option<[u8; 32]>,
|
||||
pub protocol: Option<u8>,
|
||||
pub role: Option<Role>,
|
||||
pub transport: bool,
|
||||
pub before: Option<i64>,
|
||||
}
|
||||
|
||||
pub(super) struct Row {
|
||||
pub id: i64,
|
||||
pub data: FlowDelta,
|
||||
pub last: u64,
|
||||
pub sampled: u64,
|
||||
pub tx_rate: f32,
|
||||
pub rx_rate: f32,
|
||||
}
|
||||
#[derive(Default)]
|
||||
pub(super) struct Page {
|
||||
pub rows: Vec<Row>,
|
||||
pub more: bool,
|
||||
}
|
||||
|
||||
pub(super) struct History {
|
||||
connection: Connection,
|
||||
}
|
||||
|
||||
// SQLite counters are signed 64-bit integers; clamp only at its representable maximum.
|
||||
fn integer(n: u64) -> i64 {
|
||||
i64::try_from(n).unwrap_or(i64::MAX)
|
||||
}
|
||||
|
||||
impl History {
|
||||
pub fn open(directory: Option<&Path>) -> Result<Self, String> {
|
||||
// SQLite chooses a delete-on-close temp file on the desktop. Android supplies
|
||||
// its private writable cache directory (the system temp directory can be read-only).
|
||||
let file = directory
|
||||
.map(tempfile::NamedTempFile::new_in)
|
||||
.transpose()
|
||||
.map_err(|e| e.to_string())?;
|
||||
let path = file
|
||||
.as_ref()
|
||||
.map(|f| f.path())
|
||||
.unwrap_or_else(|| Path::new(""));
|
||||
let db = Connection::open(path).map_err(|e| e.to_string())?;
|
||||
db.execute_batch("PRAGMA locking_mode=EXCLUSIVE;
|
||||
PRAGMA journal_mode=OFF;
|
||||
PRAGMA synchronous=OFF;
|
||||
PRAGMA cache_size=-2048;
|
||||
CREATE TABLE flow (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT, key BLOB UNIQUE NOT NULL, network BLOB NOT NULL,
|
||||
peer BLOB NOT NULL, other BLOB, role INTEGER NOT NULL, protocol INTEGER, transport INTEGER NOT NULL,
|
||||
tx INTEGER NOT NULL, rx INTEGER NOT NULL, ntx INTEGER NOT NULL, nrx INTEGER NOT NULL,
|
||||
last INTEGER NOT NULL, sampled INTEGER NOT NULL, tx_rate REAL NOT NULL, rx_rate REAL NOT NULL
|
||||
);
|
||||
CREATE INDEX by_last ON flow(last);
|
||||
CREATE INDEX by_layer ON flow(transport,id);
|
||||
CREATE INDEX by_network ON flow(transport,network,id);
|
||||
CREATE INDEX by_peer ON flow(transport,network,peer,id);
|
||||
CREATE INDEX by_other ON flow(transport,network,other,id) WHERE other IS NOT NULL;
|
||||
CREATE INDEX by_role ON flow(transport,role,id);
|
||||
CREATE INDEX by_protocol ON flow(transport,protocol,id);").map_err(|e|e.to_string())?;
|
||||
// All platforms that pass a directory are Unix; unlink the open file so even
|
||||
// force-stopping the activity releases it when the OS closes the descriptor.
|
||||
drop(file);
|
||||
Ok(Self { connection: db })
|
||||
}
|
||||
|
||||
pub fn interrupt(&self) -> rusqlite::InterruptHandle {
|
||||
self.connection.get_interrupt_handle()
|
||||
}
|
||||
|
||||
pub fn apply(
|
||||
&mut self,
|
||||
data: &[FlowDelta],
|
||||
now: u64,
|
||||
interval: u64,
|
||||
keep: bool,
|
||||
) -> Result<(), String> {
|
||||
let txn = self.connection.transaction().map_err(|e| e.to_string())?;
|
||||
{
|
||||
let mut statement=txn.prepare_cached("INSERT INTO flow (key,network,peer,other,role,protocol,transport,tx,rx,ntx,nrx,last,sampled,tx_rate,rx_rate)
|
||||
VALUES (?1,?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13,?14,?15)
|
||||
ON CONFLICT(key) DO UPDATE SET tx=min(9223372036854775807,tx+excluded.tx),rx=min(9223372036854775807,rx+excluded.rx),ntx=min(9223372036854775807,ntx+excluded.ntx),nrx=min(9223372036854775807,nrx+excluded.nrx),
|
||||
last=max(last,excluded.last), sampled=excluded.sampled,tx_rate=excluded.tx_rate,rx_rate=excluded.rx_rate").map_err(|e|e.to_string())?;
|
||||
let seconds = interval.max(1) as f64 / 1000.;
|
||||
for d in data {
|
||||
let key = postcard::to_stdvec(&d.key).map_err(|e| e.to_string())?;
|
||||
let (protocol, other) = match &d.key.flow {
|
||||
Flow::Ip { protocol, .. } => (Some(*protocol), None),
|
||||
Flow::Relay { other, .. } => (None, Some(other.as_slice())),
|
||||
Flow::Control => (None, None),
|
||||
};
|
||||
statement
|
||||
.execute(params![
|
||||
key,
|
||||
&d.key.network[..],
|
||||
&d.key.peer[..],
|
||||
other,
|
||||
d.key.role as i64,
|
||||
protocol,
|
||||
d.key.role.transport(),
|
||||
integer(d.tx_bytes),
|
||||
integer(d.rx_bytes),
|
||||
integer(d.tx_packets),
|
||||
integer(d.rx_packets),
|
||||
integer(now.saturating_sub(d.age_ms)),
|
||||
integer(now),
|
||||
d.tx_bytes as f64 / seconds,
|
||||
d.rx_bytes as f64 / seconds
|
||||
])
|
||||
.map_err(|e| e.to_string())?;
|
||||
}
|
||||
}
|
||||
if !keep && now >= RETAIN_MS {
|
||||
txn.execute(
|
||||
"DELETE FROM flow WHERE last <= ?1",
|
||||
[integer(now - RETAIN_MS)],
|
||||
)
|
||||
.map_err(|e| e.to_string())?;
|
||||
}
|
||||
txn.commit().map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
pub fn page(&self, f: &Filter) -> Result<Page, String> {
|
||||
let mut sql = String::from(
|
||||
"SELECT id,key,tx,rx,ntx,nrx,last,sampled,tx_rate,rx_rate FROM flow WHERE transport=?",
|
||||
);
|
||||
let mut args = vec![Value::Integer(i64::from(f.transport))];
|
||||
if let Some(n) = f.network {
|
||||
sql.push_str(" AND network=?");
|
||||
args.push(Value::Blob(n.to_vec()));
|
||||
}
|
||||
if let Some(p) = f.peer {
|
||||
sql.push_str(" AND (peer=? OR other=?)");
|
||||
args.extend([Value::Blob(p.to_vec()), Value::Blob(p.to_vec())]);
|
||||
}
|
||||
if let Some(r) = f.role {
|
||||
sql.push_str(" AND role=?");
|
||||
args.push(Value::Integer(r as i64));
|
||||
}
|
||||
if let Some(p) = f.protocol {
|
||||
sql.push_str(" AND protocol=?");
|
||||
args.push(Value::Integer(p.into()));
|
||||
}
|
||||
if let Some(cursor) = f.before {
|
||||
sql.push_str(" AND id<?");
|
||||
args.push(Value::Integer(cursor));
|
||||
}
|
||||
sql.push_str(" ORDER BY id DESC LIMIT ?");
|
||||
args.push(Value::Integer(PAGE_SIZE as i64 + 1));
|
||||
let mut q = self
|
||||
.connection
|
||||
.prepare_cached(&sql)
|
||||
.map_err(|e| e.to_string())?;
|
||||
let rows = q
|
||||
.query_map(params_from_iter(args), |r| {
|
||||
let blob: Vec<u8> = r.get(1)?;
|
||||
let key = postcard::from_bytes(&blob).map_err(|e| {
|
||||
rusqlite::Error::FromSqlConversionFailure(
|
||||
1,
|
||||
rusqlite::types::Type::Blob,
|
||||
Box::new(e),
|
||||
)
|
||||
})?;
|
||||
Ok(Row {
|
||||
id: r.get(0)?,
|
||||
data: FlowDelta {
|
||||
key,
|
||||
tx_bytes: r.get::<_, i64>(2)? as u64,
|
||||
rx_bytes: r.get::<_, i64>(3)? as u64,
|
||||
tx_packets: r.get::<_, i64>(4)? as u64,
|
||||
rx_packets: r.get::<_, i64>(5)? as u64,
|
||||
age_ms: 0,
|
||||
},
|
||||
last: r.get::<_, i64>(6)? as u64,
|
||||
sampled: r.get::<_, i64>(7)? as u64,
|
||||
tx_rate: r.get(8)?,
|
||||
rx_rate: r.get(9)?,
|
||||
})
|
||||
})
|
||||
.map_err(|e| e.to_string())?
|
||||
.collect::<rusqlite::Result<Vec<_>>>()
|
||||
.map_err(|e| e.to_string())?;
|
||||
let mut page = Page {
|
||||
more: rows.len() > PAGE_SIZE,
|
||||
rows,
|
||||
};
|
||||
page.rows.truncate(PAGE_SIZE);
|
||||
Ok(page)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,550 @@
|
||||
//! Live traffic inspector shared by the tray and Android clients.
|
||||
mod history;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
mod worker;
|
||||
|
||||
use crate::{
|
||||
format::{bytes, short},
|
||||
widgets,
|
||||
};
|
||||
use egui::{RichText, Ui};
|
||||
use egui_phosphor::regular as icon;
|
||||
use history::{Filter, Row};
|
||||
use std::{collections::BTreeMap, net::Ipv4Addr, path::PathBuf, time::Duration};
|
||||
use tsunagi::{
|
||||
NetworkId,
|
||||
ipc::StatusReport,
|
||||
iroh_types::EndpointId,
|
||||
traffic::{Flow, FlowKey, IpDetail, Role},
|
||||
};
|
||||
pub use worker::Feed;
|
||||
use worker::Worker;
|
||||
|
||||
type Id = [u8; 32];
|
||||
#[derive(Default)]
|
||||
struct Network {
|
||||
name: String,
|
||||
peers: BTreeMap<Id, String>,
|
||||
}
|
||||
#[derive(Default)]
|
||||
struct Names {
|
||||
networks: BTreeMap<Id, Network>,
|
||||
generation: Option<u64>,
|
||||
}
|
||||
|
||||
fn public_id(id: &Id) -> String {
|
||||
id.iter().map(|b| format!("{b:02x}")).collect()
|
||||
}
|
||||
impl Names {
|
||||
fn refresh(&mut self, report: Option<&StatusReport>, generation: u64) {
|
||||
let Some(report) = report else { return };
|
||||
if self.generation == Some(generation) {
|
||||
return;
|
||||
}
|
||||
self.generation = Some(generation);
|
||||
for n in &report.networks {
|
||||
let Ok(id) = n.network_id.parse::<NetworkId>() else {
|
||||
continue;
|
||||
};
|
||||
let entry = self.networks.entry(*id.as_bytes()).or_default();
|
||||
entry.name = n.name.clone();
|
||||
for (key, name) in n
|
||||
.members
|
||||
.iter()
|
||||
.map(|m| (&m.endpoint_id, m.hostname.as_deref()))
|
||||
.chain(
|
||||
n.peers
|
||||
.iter()
|
||||
.map(|p| (&p.endpoint_id, p.hostname.as_deref())),
|
||||
)
|
||||
.chain(std::iter::once((
|
||||
&report.endpoint_id,
|
||||
Some(report.hostname.as_str()),
|
||||
)))
|
||||
{
|
||||
if let Ok(peer) = key.parse::<EndpointId>() {
|
||||
let label = name.filter(|s| !s.is_empty()).map(str::to_owned);
|
||||
let current = entry
|
||||
.peers
|
||||
.entry(*peer.as_bytes())
|
||||
.or_insert_with(|| short(key));
|
||||
if let Some(label) = label {
|
||||
*current = label;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fn network(&self, id: &Id) -> String {
|
||||
let Some(n) = self.networks.get(id) else {
|
||||
return short(&NetworkId::from_bytes(*id).to_string());
|
||||
};
|
||||
if self
|
||||
.networks
|
||||
.values()
|
||||
.any(|other| !std::ptr::eq(other, n) && other.name == n.name)
|
||||
{
|
||||
format!(
|
||||
"{} · {}",
|
||||
n.name,
|
||||
short(&NetworkId::from_bytes(*id).to_string())
|
||||
)
|
||||
} else {
|
||||
n.name.clone()
|
||||
}
|
||||
}
|
||||
fn peer(&self, network: &Id, id: &Id) -> String {
|
||||
self.networks
|
||||
.get(network)
|
||||
.and_then(|n| n.peers.get(id))
|
||||
.cloned()
|
||||
.unwrap_or_else(|| short(&public_id(id)))
|
||||
}
|
||||
}
|
||||
|
||||
fn role_name(r: Role) -> &'static str {
|
||||
match r {
|
||||
Role::Mesh => "Mesh",
|
||||
Role::ViaExit => "Via exit node",
|
||||
Role::ServeExit => "Serving exit",
|
||||
Role::Vip => "VIP",
|
||||
Role::Broadcast => "Broadcast",
|
||||
Role::SpeedTest => "Speed test",
|
||||
Role::Control => "Control",
|
||||
Role::Relay => "Encrypted relay",
|
||||
}
|
||||
}
|
||||
fn role_text(role: Role) -> String {
|
||||
let glyph = match role {
|
||||
Role::ViaExit => icon::SIGN_OUT,
|
||||
Role::ServeExit => icon::SIGN_IN,
|
||||
Role::Relay => icon::GIT_FORK,
|
||||
Role::Broadcast => icon::BROADCAST,
|
||||
Role::SpeedTest => icon::GAUGE,
|
||||
_ => return role_name(role).to_owned(),
|
||||
};
|
||||
format!("{glyph} {}", role_name(role))
|
||||
}
|
||||
fn protocol(n: u8) -> String {
|
||||
match n {
|
||||
1 => "ICMP".into(),
|
||||
6 => "TCP".into(),
|
||||
17 => "UDP".into(),
|
||||
n => format!("IP {n}"),
|
||||
}
|
||||
}
|
||||
fn endpoints(k: &FlowKey, n: &Names) -> (String, String, String) {
|
||||
match k.flow {
|
||||
Flow::Control => (
|
||||
"This agent".into(),
|
||||
n.peer(&k.network, &k.peer),
|
||||
"Control session".into(),
|
||||
),
|
||||
Flow::Relay {
|
||||
other,
|
||||
wire_protocol,
|
||||
} => (
|
||||
n.peer(&k.network, &k.peer),
|
||||
n.peer(&k.network, &other),
|
||||
format!("Relay · {wire_protocol:x}"),
|
||||
),
|
||||
Flow::Ip {
|
||||
near,
|
||||
far,
|
||||
protocol: p,
|
||||
detail,
|
||||
} => {
|
||||
let (a, b) = (Ipv4Addr::from(near), Ipv4Addr::from(far));
|
||||
match detail {
|
||||
IpDetail::Ports(x, y) => (format!("{a}:{x}"), format!("{b}:{y}"), protocol(p)),
|
||||
_ => (
|
||||
a.to_string(),
|
||||
b.to_string(),
|
||||
match detail {
|
||||
IpDetail::Echo => "ICMP echo".into(),
|
||||
IpDetail::Icmp(t, c) => format!("ICMP {t}/{c}"),
|
||||
IpDetail::Fragment => format!("{} fragment", protocol(p)),
|
||||
_ => protocol(p),
|
||||
},
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fn ago(ms: u64) -> String {
|
||||
let s = ms / 1000;
|
||||
match s {
|
||||
0 => "now".into(),
|
||||
1..60 => format!("{s}s"),
|
||||
60..3600 => format!("{}m", s / 60),
|
||||
3600..86400 => format!("{}h", s / 3600),
|
||||
_ => format!("{}d", s / 86400),
|
||||
}
|
||||
}
|
||||
|
||||
/// State and temporary storage of exactly one visible monitor.
|
||||
pub struct Window {
|
||||
worker: Worker,
|
||||
names: Names,
|
||||
filter: Filter,
|
||||
keep: bool,
|
||||
previous: Vec<Option<i64>>,
|
||||
selected: Option<i64>,
|
||||
}
|
||||
impl Window {
|
||||
/// Creates an empty view. Android supplies its application-private cache directory.
|
||||
pub fn new(directory: Option<PathBuf>) -> Self {
|
||||
Self {
|
||||
worker: Worker::new(directory),
|
||||
names: Names::default(),
|
||||
filter: Filter::default(),
|
||||
keep: false,
|
||||
previous: Vec::new(),
|
||||
selected: None,
|
||||
}
|
||||
}
|
||||
/// The endpoint into which this window's subscription feeds interval snapshots.
|
||||
pub fn feed(&self) -> Feed {
|
||||
self.worker.feed.clone()
|
||||
}
|
||||
|
||||
fn controls(&mut self, ui: &mut Ui) {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
let layer = self.filter.transport;
|
||||
ui.selectable_value(&mut self.filter.transport, false, format!("{} IP flows", icon::ARROWS_LEFT_RIGHT));
|
||||
ui.selectable_value(&mut self.filter.transport, true, format!("{} Transport", icon::GIT_FORK))
|
||||
.on_hover_text("Authenticated control sessions and encrypted traffic relayed between peers");
|
||||
if layer != self.filter.transport {
|
||||
self.filter.role = None;
|
||||
self.filter.protocol = None;
|
||||
}
|
||||
widgets::hint(ui.checkbox(&mut self.keep,"Keep until close"),
|
||||
"Keep inactive flows for this window session. Otherwise they expire after 60 seconds.");
|
||||
});
|
||||
let width = ((ui.available_width() - ui.spacing().item_spacing.x) / 2.).clamp(60., 135.);
|
||||
if ui.available_width() < 580. {
|
||||
ui.horizontal(|ui| self.identity_filters(ui, width));
|
||||
ui.horizontal(|ui| self.flow_filters(ui, width));
|
||||
} else {
|
||||
ui.horizontal(|ui| {
|
||||
self.identity_filters(ui, width);
|
||||
self.flow_filters(ui, width);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn identity_filters(&mut self, ui: &mut Ui, width: f32) {
|
||||
let network = self.filter.network;
|
||||
egui::ComboBox::from_id_salt("flow-network")
|
||||
.width(width)
|
||||
.truncate()
|
||||
.selected_text(
|
||||
network.map_or_else(|| "All networks".into(), |id| self.names.network(&id)),
|
||||
)
|
||||
.show_ui(ui, |ui| {
|
||||
ui.selectable_value(&mut self.filter.network, None, "All networks");
|
||||
for id in self.names.networks.keys() {
|
||||
ui.selectable_value(
|
||||
&mut self.filter.network,
|
||||
Some(*id),
|
||||
self.names.network(id),
|
||||
);
|
||||
}
|
||||
});
|
||||
if self.filter.network != network {
|
||||
self.filter.peer = None;
|
||||
}
|
||||
ui.add_enabled_ui(self.filter.network.is_some(), |ui| {
|
||||
let id = self.filter.network.unwrap_or_default();
|
||||
let peer = self
|
||||
.filter
|
||||
.peer
|
||||
.map_or_else(|| "All peers".into(), |p| self.names.peer(&id, &p));
|
||||
egui::ComboBox::from_id_salt("flow-peer")
|
||||
.width(width)
|
||||
.truncate()
|
||||
.selected_text(peer)
|
||||
.show_ui(ui, |ui| {
|
||||
ui.selectable_value(&mut self.filter.peer, None, "All peers");
|
||||
if let Some(net) = self.names.networks.get(&id) {
|
||||
for (peer, label) in &net.peers {
|
||||
ui.selectable_value(&mut self.filter.peer, Some(*peer), label)
|
||||
.on_hover_text(public_id(peer));
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
.response
|
||||
.on_disabled_hover_text("Choose a network to filter its peers");
|
||||
}
|
||||
|
||||
fn flow_filters(&mut self, ui: &mut Ui, width: f32) {
|
||||
if !self.filter.transport {
|
||||
egui::ComboBox::from_id_salt("flow-protocol")
|
||||
.width(width)
|
||||
.truncate()
|
||||
.selected_text(
|
||||
self.filter
|
||||
.protocol
|
||||
.map_or_else(|| "All protocols".into(), protocol),
|
||||
)
|
||||
.show_ui(ui, |ui| {
|
||||
ui.selectable_value(&mut self.filter.protocol, None, "All protocols");
|
||||
for p in self.worker.protocols() {
|
||||
ui.selectable_value(&mut self.filter.protocol, Some(p), protocol(p));
|
||||
}
|
||||
});
|
||||
}
|
||||
let roles: &[Role] = if self.filter.transport {
|
||||
&[Role::Control, Role::Relay]
|
||||
} else {
|
||||
&[
|
||||
Role::Mesh,
|
||||
Role::ViaExit,
|
||||
Role::ServeExit,
|
||||
Role::Vip,
|
||||
Role::Broadcast,
|
||||
Role::SpeedTest,
|
||||
]
|
||||
};
|
||||
egui::ComboBox::from_id_salt("flow-role")
|
||||
.width(width)
|
||||
.truncate()
|
||||
.selected_text(self.filter.role.map_or("All roles", role_name))
|
||||
.show_ui(ui, |ui| {
|
||||
ui.selectable_value(&mut self.filter.role, None, "All roles");
|
||||
for &role in roles {
|
||||
ui.selectable_value(&mut self.filter.role, Some(role), role_name(role));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Draw the responsive inspector inside the current viewport.
|
||||
pub fn show(&mut self, ui: &mut Ui, report: Option<&StatusReport>, generation: u64) {
|
||||
self.names.refresh(report, generation);
|
||||
let before = self.filter.clone();
|
||||
let keep = self.keep;
|
||||
self.controls(ui);
|
||||
if self.filter != before {
|
||||
self.filter.before = None;
|
||||
self.previous.clear();
|
||||
self.selected = None;
|
||||
}
|
||||
if self.filter != before || self.keep != keep {
|
||||
self.worker.options(self.filter.clone(), self.keep);
|
||||
}
|
||||
let (page, omitted, error) = self.worker.view();
|
||||
if let Some(e) = &error {
|
||||
ui.colored_label(ui.visuals().error_fg_color, e);
|
||||
}
|
||||
if omitted > 0 {
|
||||
ui.colored_label(
|
||||
ui.visuals().warn_fg_color,
|
||||
format!("{omitted} observations omitted during capture"),
|
||||
);
|
||||
}
|
||||
ui.separator();
|
||||
let now = self.worker.feed.elapsed();
|
||||
let wide = ui.available_width() >= 690.;
|
||||
if !self.previous.is_empty() || page.more {
|
||||
ui.horizontal(|ui| {
|
||||
if ui
|
||||
.add_enabled(
|
||||
!self.previous.is_empty(),
|
||||
egui::Button::new(format!("{} Newer", icon::CARET_LEFT)),
|
||||
)
|
||||
.clicked()
|
||||
&& let Some(cursor) = self.previous.pop()
|
||||
{
|
||||
self.filter.before = cursor;
|
||||
self.selected = None;
|
||||
self.worker.options(self.filter.clone(), self.keep);
|
||||
}
|
||||
ui.weak(format!("Page {}", self.previous.len() + 1));
|
||||
if ui
|
||||
.add_enabled(
|
||||
page.more,
|
||||
egui::Button::new(format!("Older {}", icon::CARET_RIGHT)),
|
||||
)
|
||||
.clicked()
|
||||
&& let Some(r) = page.rows.last()
|
||||
{
|
||||
self.previous.push(self.filter.before);
|
||||
self.filter.before = Some(r.id);
|
||||
self.selected = None;
|
||||
self.worker.options(self.filter.clone(), self.keep);
|
||||
}
|
||||
});
|
||||
}
|
||||
if page.rows.is_empty() {
|
||||
ui.add_space(14.);
|
||||
ui.weak(if error.is_some() {
|
||||
"No captured flows in this view."
|
||||
} else if self.filter.network.is_some()
|
||||
|| self.filter.role.is_some()
|
||||
|| self.filter.protocol.is_some()
|
||||
|| self.filter.before.is_some()
|
||||
{
|
||||
"No flows match these filters."
|
||||
} else {
|
||||
"Listening for traffic…"
|
||||
});
|
||||
} else {
|
||||
if wide {
|
||||
desktop_header(ui);
|
||||
}
|
||||
egui::ScrollArea::vertical()
|
||||
.id_salt("flow-rows")
|
||||
.auto_shrink([false, false])
|
||||
.show(ui, |ui| {
|
||||
for row in &page.rows {
|
||||
let chosen = self.selected == Some(row.id);
|
||||
egui::Frame::new()
|
||||
.inner_margin(egui::Margin::symmetric(5, 3))
|
||||
.fill(if chosen {
|
||||
ui.visuals().selection.bg_fill
|
||||
} else if row.id % 2 == 0 {
|
||||
ui.visuals().faint_bg_color
|
||||
} else {
|
||||
egui::Color32::TRANSPARENT
|
||||
})
|
||||
.show(ui, |ui| {
|
||||
let summary = ui.scope(|ui| self.row(ui, row, now, wide)).response;
|
||||
let selected = ui.interact(
|
||||
summary.rect,
|
||||
ui.id().with(("flow", row.id)),
|
||||
egui::Sense::click(),
|
||||
);
|
||||
if selected.clicked() {
|
||||
self.selected = if chosen { None } else { Some(row.id) };
|
||||
}
|
||||
|
||||
if chosen {
|
||||
ui.separator();
|
||||
let key = &row.data.key;
|
||||
let (a, b, p) = endpoints(key, &self.names);
|
||||
ui.label(format!("{a} ↔ {b} · {p}"));
|
||||
ui.label(format!(
|
||||
"{} {} packets sent {} {} received",
|
||||
icon::ARROW_UP,
|
||||
row.data.tx_packets,
|
||||
icon::ARROW_DOWN,
|
||||
row.data.rx_packets
|
||||
));
|
||||
let id = public_id(&key.peer);
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.weak("Peer ID");
|
||||
crate::format::copy_field(ui, &short(&id), &id);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
ui.ctx().request_repaint_after(Duration::from_secs(1));
|
||||
}
|
||||
|
||||
fn row(&self, ui: &mut Ui, r: &Row, now: u64, wide: bool) {
|
||||
let k = &r.data.key;
|
||||
let (a, b, p) = endpoints(k, &self.names);
|
||||
let network = self.names.network(&k.network);
|
||||
let peer = self.names.peer(&k.network, &k.peer);
|
||||
let role = role_text(k.role);
|
||||
let current = now.saturating_sub(r.sampled) < 1900;
|
||||
let rates = |n: f32| format!("{}/s", bytes(if current { n as f64 } else { 0. }));
|
||||
let (tx, rx) = (bytes(r.data.tx_bytes as f64), bytes(r.data.rx_bytes as f64));
|
||||
let age = ago(now.saturating_sub(r.last));
|
||||
if wide {
|
||||
let widths = widths(ui);
|
||||
ui.horizontal(|ui| {
|
||||
cell(ui, widths[0], &peer, &network);
|
||||
cell(ui, widths[1], &a, &b);
|
||||
cell(ui, widths[2], &p, &role);
|
||||
cell(ui, widths[3], &tx, &rates(r.tx_rate));
|
||||
cell(ui, widths[4], &rx, &rates(r.rx_rate));
|
||||
cell(ui, widths[5], &age, "");
|
||||
});
|
||||
} else {
|
||||
ui.set_min_width(ui.available_width());
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.strong(peer);
|
||||
ui.weak(&network);
|
||||
ui.label(role);
|
||||
ui.weak(age);
|
||||
});
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label(&p);
|
||||
ui.monospace(&a);
|
||||
ui.weak("↔");
|
||||
ui.monospace(&b);
|
||||
});
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label(format!("{} {tx}", icon::ARROW_UP))
|
||||
.on_hover_text("Sent");
|
||||
ui.weak(rates(r.tx_rate));
|
||||
ui.separator();
|
||||
ui.label(format!("{} {rx}", icon::ARROW_DOWN))
|
||||
.on_hover_text("Received");
|
||||
ui.weak(rates(r.rx_rate));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
fn widths(ui: &Ui) -> [f32; 6] {
|
||||
let usable = (ui.available_width() - ui.spacing().item_spacing.x * 5. - 4.).max(0.);
|
||||
[0.18, 0.30, 0.18, 0.13, 0.13, 0.08].map(|s| s * usable)
|
||||
}
|
||||
fn cell(ui: &mut Ui, width: f32, one: &str, two: &str) {
|
||||
ui.allocate_ui_with_layout(
|
||||
egui::vec2(width, 0.),
|
||||
egui::Layout::top_down(egui::Align::Min),
|
||||
|ui| {
|
||||
ui.add(egui::Label::new(one).truncate()).on_hover_text(one);
|
||||
if !two.is_empty() {
|
||||
ui.add(egui::Label::new(RichText::new(two).weak().small()).truncate())
|
||||
.on_hover_text(two);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
fn desktop_header(ui: &mut Ui) {
|
||||
egui::Frame::new()
|
||||
.inner_margin(egui::Margin::symmetric(5, 2))
|
||||
.show(ui, |ui| {
|
||||
let widths = widths(ui);
|
||||
ui.horizontal(|ui| {
|
||||
for ((title, hint), width) in [
|
||||
("Peer / network", "Authenticated peer and local network"),
|
||||
(
|
||||
"Endpoints",
|
||||
"This side ↔ peer side. Encrypted relay shows the two named endpoints.",
|
||||
),
|
||||
(
|
||||
"Protocol / role",
|
||||
"IP protocol or transport observation and forwarding role",
|
||||
),
|
||||
(
|
||||
"↑ Sent",
|
||||
"Total and rate toward the peer (first to second endpoint for relay)",
|
||||
),
|
||||
(
|
||||
"↓ Received",
|
||||
"Total and rate from the peer (second to first endpoint for relay)",
|
||||
),
|
||||
("Seen", "Time since last activity"),
|
||||
]
|
||||
.into_iter()
|
||||
.zip(widths)
|
||||
{
|
||||
ui.add_sized(
|
||||
[width, 17.],
|
||||
egui::Label::new(RichText::new(title).small().weak())
|
||||
.halign(egui::Align::Min)
|
||||
.truncate(),
|
||||
)
|
||||
.on_hover_text(hint);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
use super::history::*;
|
||||
use tsunagi::traffic::*;
|
||||
|
||||
fn sample(port: u16, tx: bool) -> FlowDelta {
|
||||
FlowDelta {
|
||||
key: FlowKey {
|
||||
network: [1; 32],
|
||||
peer: [2; 32],
|
||||
role: Role::Mesh,
|
||||
flow: Flow::Ip {
|
||||
near: [10, 0, 0, 1],
|
||||
far: [10, 0, 0, 2],
|
||||
protocol: 6,
|
||||
detail: IpDetail::Ports(port, 443),
|
||||
},
|
||||
},
|
||||
tx_bytes: if tx { 90 } else { 0 },
|
||||
rx_bytes: if tx { 0 } else { 100 },
|
||||
tx_packets: u64::from(tx),
|
||||
rx_packets: u64::from(!tx),
|
||||
age_ms: 0,
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn window_history_expires_and_long_capture_is_paged_and_bidirectional() {
|
||||
let mut db = History::open(None).unwrap();
|
||||
let filter = Filter::default();
|
||||
db.apply(&[sample(1, true)], 1_000, 1_000, false).unwrap();
|
||||
db.apply(&[sample(1, false)], 2_000, 1_000, false).unwrap();
|
||||
let p = db.page(&filter).unwrap();
|
||||
assert_eq!(
|
||||
(p.rows[0].data.tx_bytes, p.rows[0].data.rx_bytes),
|
||||
(90, 100)
|
||||
);
|
||||
db.apply(&[], 62_000, 1_000, false).unwrap();
|
||||
assert!(db.page(&filter).unwrap().rows.is_empty());
|
||||
let flows: Vec<_> = (0..151).map(|port| sample(port, true)).collect();
|
||||
db.apply(&flows, 63_000, 1_000, true).unwrap();
|
||||
db.apply(&[], 3 * 86_400_000, 1_000, true).unwrap();
|
||||
let p = db.page(&filter).unwrap();
|
||||
assert_eq!(p.rows.len(), PAGE_SIZE);
|
||||
assert!(p.more);
|
||||
let next = Filter {
|
||||
before: Some(p.rows.last().unwrap().id),
|
||||
..filter.clone()
|
||||
};
|
||||
assert!(
|
||||
db.page(&next)
|
||||
.unwrap()
|
||||
.rows
|
||||
.iter()
|
||||
.all(|r| r.id < p.rows.last().unwrap().id)
|
||||
);
|
||||
assert!(
|
||||
db.page(&Filter {
|
||||
network: Some([9; 32]),
|
||||
..filter.clone()
|
||||
})
|
||||
.unwrap()
|
||||
.rows
|
||||
.is_empty()
|
||||
);
|
||||
assert!(
|
||||
db.page(&Filter {
|
||||
transport: true,
|
||||
..filter.clone()
|
||||
})
|
||||
.unwrap()
|
||||
.rows
|
||||
.is_empty()
|
||||
);
|
||||
drop(db);
|
||||
assert!(
|
||||
History::open(None)
|
||||
.unwrap()
|
||||
.page(&filter)
|
||||
.unwrap()
|
||||
.rows
|
||||
.is_empty()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn peer_filter_matches_both_relay_endpoints_only_in_the_selected_network() {
|
||||
let mut db = History::open(None).unwrap();
|
||||
let mut relay = sample(80, true);
|
||||
relay.key.flow = Flow::Relay {
|
||||
other: [3; 32],
|
||||
wire_protocol: 1,
|
||||
};
|
||||
relay.key.role = Role::Relay;
|
||||
let mut other_net = relay.clone();
|
||||
other_net.key.network = [9; 32];
|
||||
db.apply(&[relay, other_net, sample(80, true)], 1000, 1000, true)
|
||||
.unwrap();
|
||||
for id in [[2; 32], [3; 32]] {
|
||||
let f = Filter {
|
||||
network: Some([1; 32]),
|
||||
peer: Some(id),
|
||||
transport: true,
|
||||
role: Some(Role::Relay),
|
||||
..Filter::default()
|
||||
};
|
||||
let page = db.page(&f).unwrap();
|
||||
assert_eq!(page.rows.len(), 1);
|
||||
assert_eq!(page.rows[0].data.key.network, [1; 32]);
|
||||
}
|
||||
let filtered = Filter {
|
||||
network: Some([1; 32]),
|
||||
protocol: Some(17),
|
||||
..Filter::default()
|
||||
};
|
||||
assert!(db.page(&filtered).unwrap().rows.is_empty());
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn private_cache_file_is_unlinked_and_remains_writable_across_transactions() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let mut db = History::open(Some(dir.path())).unwrap();
|
||||
let batch: Vec<_> = (0..4096).map(|n| sample(n, true)).collect();
|
||||
for t in [1000, 3 * 86_400_000] {
|
||||
db.apply(&batch, t, 1000, true).unwrap();
|
||||
}
|
||||
assert_eq!(dir.path().read_dir().unwrap().count(), 0);
|
||||
let p = db.page(&Filter::default()).unwrap();
|
||||
assert!(p.more);
|
||||
assert_eq!(p.rows[0].data.tx_bytes, 180);
|
||||
db.apply(&[], 3 * 86_400_000 + 60_000, 1_000, false)
|
||||
.unwrap();
|
||||
assert!(db.page(&Filter::default()).unwrap().rows.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn live_monitor_has_readable_rows_inside_phone_and_desktop_widths() {
|
||||
use super::Window;
|
||||
use std::time::{Duration, Instant};
|
||||
let mut win = Window::new(None);
|
||||
let feed = win.feed();
|
||||
assert!(win.worker.view().0.rows.is_empty());
|
||||
feed.sample(TrafficSnapshot {
|
||||
flows: vec![sample(55201, true)],
|
||||
interval_ms: 1_000,
|
||||
omitted: 0,
|
||||
});
|
||||
let deadline = Instant::now() + Duration::from_secs(3);
|
||||
while win.worker.view().0.rows.is_empty() {
|
||||
assert!(Instant::now() < deadline, "worker did not publish the flow");
|
||||
std::thread::yield_now();
|
||||
}
|
||||
for width in [320., 390., 720., 900.] {
|
||||
let ctx = egui::Context::default();
|
||||
ctx.set_fonts(crate::app_fonts());
|
||||
let frame = ctx.run(
|
||||
egui::RawInput {
|
||||
screen_rect: Some(egui::Rect::from_min_size(
|
||||
egui::Pos2::ZERO,
|
||||
egui::vec2(width, 600.),
|
||||
)),
|
||||
..Default::default()
|
||||
},
|
||||
|ctx| {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
win.show(ui, None, 0);
|
||||
assert!(
|
||||
ui.min_rect().right() <= width,
|
||||
"monitor grew beyond {width}: {:?}",
|
||||
ui.min_rect()
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
for value in ["10.0.0.1:55201", "10.0.0.2:443", "TCP", "Mesh"] {
|
||||
assert!(frame.shapes.iter().any(|s|matches!(&s.shape,egui::Shape::Text(t) if t.galley.text().contains(value) && t.visual_bounding_rect().right()<=width)), "{value} outside {width}");
|
||||
}
|
||||
}
|
||||
drop(win);
|
||||
assert!(!feed.sample(TrafficSnapshot::default()));
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
use super::history::{Filter, History, Page};
|
||||
use std::{
|
||||
collections::VecDeque,
|
||||
path::PathBuf,
|
||||
sync::{Arc, Condvar, Mutex, MutexGuard},
|
||||
time::Instant,
|
||||
};
|
||||
use tsunagi::traffic::TrafficSnapshot;
|
||||
|
||||
struct Work {
|
||||
samples: VecDeque<(u64, TrafficSnapshot)>,
|
||||
filter: Filter,
|
||||
keep: bool,
|
||||
dirty: bool,
|
||||
closed: bool,
|
||||
omitted: u64,
|
||||
protocols: std::collections::BTreeSet<u8>,
|
||||
interrupt: Option<rusqlite::InterruptHandle>,
|
||||
page: Arc<Page>,
|
||||
error: Option<String>,
|
||||
}
|
||||
|
||||
struct Shared {
|
||||
start: Instant,
|
||||
state: Mutex<Work>,
|
||||
wake: Condvar,
|
||||
}
|
||||
impl Shared {
|
||||
fn lock(&self) -> MutexGuard<'_, Work> {
|
||||
self.state.lock().unwrap_or_else(|e| e.into_inner())
|
||||
}
|
||||
}
|
||||
|
||||
/// A bounded input for the window. Returns false when capture has closed or failed.
|
||||
#[derive(Clone)]
|
||||
pub struct Feed(Arc<Shared>);
|
||||
impl Feed {
|
||||
/// Queue an interval without blocking packet forwarding or the render thread.
|
||||
pub fn sample(&self, s: TrafficSnapshot) -> bool {
|
||||
let mut w = self.0.lock();
|
||||
if w.closed {
|
||||
return false;
|
||||
}
|
||||
for row in &s.flows {
|
||||
if let tsunagi::traffic::Flow::Ip { protocol, .. } = row.key.flow {
|
||||
w.protocols.insert(protocol);
|
||||
}
|
||||
}
|
||||
w.omitted = w.omitted.saturating_add(s.omitted);
|
||||
if w.samples.len() >= 2 {
|
||||
w.omitted = w.omitted.saturating_add(
|
||||
s.flows
|
||||
.iter()
|
||||
.map(|r| r.rx_packets.saturating_add(r.tx_packets))
|
||||
.fold(0u64, u64::saturating_add),
|
||||
);
|
||||
} else {
|
||||
w.samples.push_back((self.elapsed(), s));
|
||||
}
|
||||
self.0.wake.notify_one();
|
||||
true
|
||||
}
|
||||
/// Display a capture failure while keeping the rows already collected available.
|
||||
pub fn error(&self, reason: String) {
|
||||
self.0.lock().error = Some(reason);
|
||||
}
|
||||
pub(super) fn elapsed(&self) -> u64 {
|
||||
self.0.start.elapsed().as_millis() as u64
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Worker {
|
||||
pub feed: Feed,
|
||||
}
|
||||
impl Worker {
|
||||
pub fn new(directory: Option<PathBuf>) -> Self {
|
||||
let shared = Arc::new(Shared {
|
||||
start: Instant::now(),
|
||||
state: Mutex::new(Work {
|
||||
samples: VecDeque::new(),
|
||||
filter: Filter::default(),
|
||||
keep: false,
|
||||
dirty: true,
|
||||
closed: false,
|
||||
omitted: 0,
|
||||
protocols: [1, 6, 17].into_iter().collect(),
|
||||
interrupt: None,
|
||||
page: Arc::default(),
|
||||
error: None,
|
||||
}),
|
||||
wake: Condvar::new(),
|
||||
});
|
||||
let thread = shared.clone();
|
||||
let spawn = std::thread::Builder::new()
|
||||
.name("tsng-traffic-window".into())
|
||||
.spawn(move || {
|
||||
if let Err(e) = run(&thread, directory) {
|
||||
let mut w = thread.lock();
|
||||
w.error = Some(format!("Traffic history: {e}"));
|
||||
w.closed = true;
|
||||
}
|
||||
});
|
||||
if let Err(e) = spawn {
|
||||
let mut w = shared.lock();
|
||||
w.error = Some(e.to_string());
|
||||
w.closed = true;
|
||||
}
|
||||
Self { feed: Feed(shared) }
|
||||
}
|
||||
pub fn protocols(&self) -> Vec<u8> {
|
||||
self.feed.0.lock().protocols.iter().copied().collect()
|
||||
}
|
||||
pub fn options(&self, filter: Filter, keep: bool) {
|
||||
let mut w = self.feed.0.lock();
|
||||
if w.filter != filter {
|
||||
w.page = Arc::default();
|
||||
}
|
||||
w.filter = filter;
|
||||
w.keep = keep;
|
||||
w.dirty = true;
|
||||
self.feed.0.wake.notify_one();
|
||||
}
|
||||
pub fn view(&self) -> (Arc<Page>, u64, Option<String>) {
|
||||
let w = self.feed.0.lock();
|
||||
(w.page.clone(), w.omitted, w.error.clone())
|
||||
}
|
||||
}
|
||||
impl Drop for Worker {
|
||||
fn drop(&mut self) {
|
||||
let mut w = self.feed.0.lock();
|
||||
w.closed = true;
|
||||
w.samples.clear();
|
||||
w.page = Arc::default();
|
||||
if let Some(db) = &w.interrupt {
|
||||
db.interrupt();
|
||||
}
|
||||
self.feed.0.wake.notify_one();
|
||||
}
|
||||
}
|
||||
|
||||
fn run(shared: &Shared, directory: Option<PathBuf>) -> Result<(), String> {
|
||||
let mut db = History::open(directory.as_deref())?;
|
||||
shared.lock().interrupt = Some(db.interrupt());
|
||||
loop {
|
||||
let (mut samples, filter, keep) = {
|
||||
let w = shared.lock();
|
||||
let mut w = shared
|
||||
.wake
|
||||
.wait_while(w, |w| !w.closed && !w.dirty && w.samples.is_empty())
|
||||
.unwrap_or_else(|e| e.into_inner());
|
||||
if w.closed {
|
||||
return Ok(());
|
||||
}
|
||||
w.dirty = false;
|
||||
(std::mem::take(&mut w.samples), w.filter.clone(), w.keep)
|
||||
};
|
||||
if samples.is_empty() {
|
||||
db.apply(&[], shared.start.elapsed().as_millis() as u64, 0, keep)?;
|
||||
}
|
||||
for (now, s) in samples.drain(..) {
|
||||
db.apply(&s.flows, now, s.interval_ms, keep)?;
|
||||
}
|
||||
let page = Arc::new(db.page(&filter)?);
|
||||
let mut w = shared.lock();
|
||||
if !w.closed && filter == w.filter {
|
||||
w.page = page;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user