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:
Aleksandr Bogomiakov committed 2026-11-25 20:19:40 +02:00
1 parent 7afed15f76
commit e3b74babba
42 files changed
+2476 -31

No files matched your search

+15 -2
View File
@@ -38,7 +38,15 @@ fn with_display<T: Default>(f: impl FnOnce(&mut Display) -> T) -> T {
}
#[unsafe(no_mangle)]
extern "system" fn Java_cy_hexor_tsunagi_Native_surface(mut env: JNIEnv, _: JObject) {
extern "system" fn Java_cy_hexor_tsunagi_Native_pauseTraffic(_: JNIEnv, _: JObject) {
with_display(|d| d.ui.pause_monitor());
}
#[unsafe(no_mangle)]
extern "system" fn Java_cy_hexor_tsunagi_Native_surface(
mut env: JNIEnv,
_: JObject,
cache: JString,
) {
// SAFETY: GLSurfaceView invokes this callback on the GL thread with its ES3 context current.
let gl = unsafe {
glow::Context::from_loader_function_cstr(|name| eglGetProcAddress(name.as_ptr()))
@@ -52,9 +60,10 @@ extern "system" fn Java_cy_hexor_tsunagi_Native_surface(mut env: JNIEnv, _: JObj
};
let ctx = egui::Context::default();
crate::view::configure(&ctx);
let cache = env.get_string(&cache).ok().map(String::from);
DISPLAY.with_borrow_mut(|d| {
// If Android discarded the old EGL context, its GPU resources are already gone.
let ui = d
let mut ui = d
.take()
.map(|old| {
// A rotation can recreate EGL. Keep expanded peers and scroll positions
@@ -64,6 +73,9 @@ extern "system" fn Java_cy_hexor_tsunagi_Native_surface(mut env: JNIEnv, _: JObj
old.ui
})
.unwrap_or_default();
if let Some(cache) = cache {
ui.set_cache_dir(cache.into());
}
*d = Some(Display {
painter,
ctx,
@@ -112,6 +124,7 @@ extern "system" fn Java_cy_hexor_tsunagi_Native_draw(
let output = d.ctx.run(input, |ctx| {
action = d.ui.draw(ctx, &state, super::send).or(action);
});
d.ui.poll_monitor(|| super::submit(crate::service::Request::WatchTraffic));
if let Some(action) = action {
let method = match action {
SystemAction::Start => "startAgent",