Read the exit network and endpoint from the published routing choice. Start a normal WireGuard exchange at 120 seconds for that tunnel even when idle. BoringTun keeps the current key usable during the exchange and owns retry and expiry. Switching or clearing the route also moves or removes the renewal policy. Show Idle in the tray, on Android and in CLI status after 30 seconds without IP traffic on a previously established tunnel. Keep key changes and keepalives out of activity, and keep waiting packets, missing paths and transport errors visible. Preserve queued flow tags when a native keepalive occupies a slot and drain pending IP on key confirmation. Bump the local status IPC to 26 and update the workspace, Android and Nix versions. Upgrade the daemon and desktop clients together. Mesh protocols, key lifetimes and persistent storage remain compatible. On macOS arm64 the initial workspace run passed 602 tests. A separate 181-second two-agent test observed renewal only in the selected mesh and delivered its first internet packet after idle. Formatting and strict workspace Clippy passed on the release sources. The maintainer requested publication without waiting for another full test run.
103 lines
3.9 KiB
Rust
103 lines
3.9 KiB
Rust
use super::{DataPathReport, Device, icon};
|
|
use tsunagi::agent::{DATA_CONNECTING, DATA_DISABLED};
|
|
|
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
|
pub(super) enum Channel {
|
|
Ready,
|
|
Idle,
|
|
Waiting,
|
|
Error,
|
|
Offline,
|
|
Disabled,
|
|
}
|
|
|
|
impl Device<'_> {
|
|
pub(super) fn channel(&self) -> Channel {
|
|
if !self.online {
|
|
return Channel::Offline;
|
|
}
|
|
match self.data_error {
|
|
Some(DATA_DISABLED) => Channel::Disabled,
|
|
Some(DATA_CONNECTING) => Channel::Waiting,
|
|
Some(_) => Channel::Error,
|
|
None if matches!(self.path, None | Some(DataPathReport::None)) => Channel::Waiting,
|
|
None if self.overlay.is_some_and(|p| p.idle) => Channel::Idle,
|
|
None if self.overlay.is_some_and(|p| p.is_up()) => Channel::Ready,
|
|
None => Channel::Waiting,
|
|
}
|
|
}
|
|
pub(super) fn channel_hint(&self) -> &str {
|
|
match self.channel() {
|
|
Channel::Offline => "Offline · peer unreachable",
|
|
Channel::Ready => "Ready · encrypted data channel available",
|
|
Channel::Idle => "Idle · online, no recent IP traffic",
|
|
Channel::Waiting => "Waiting for the encrypted data channel",
|
|
Channel::Disabled => "Control only · data transports disabled locally",
|
|
Channel::Error => self.data_error.unwrap_or("Data channel error"),
|
|
}
|
|
}
|
|
}
|
|
impl Channel {
|
|
pub(super) fn label(self) -> &'static str {
|
|
match self {
|
|
Self::Ready => "Ready",
|
|
Self::Idle => "Idle",
|
|
Self::Waiting => "Waiting",
|
|
Self::Error => "Error",
|
|
Self::Offline => "Offline",
|
|
Self::Disabled => "Control only",
|
|
}
|
|
}
|
|
pub(super) fn color(self, ui: &egui::Ui) -> egui::Color32 {
|
|
use egui::Color32;
|
|
match (self, ui.visuals().dark_mode) {
|
|
(Self::Ready, true) => Color32::from_rgb(100, 210, 136),
|
|
(Self::Ready, false) => Color32::from_rgb(25, 120, 61),
|
|
(Self::Idle, true) => Color32::from_rgb(145, 176, 200),
|
|
(Self::Idle, false) => Color32::from_rgb(64, 99, 125),
|
|
(Self::Waiting, true) => Color32::from_rgb(244, 190, 85),
|
|
(Self::Waiting, false) => Color32::from_rgb(150, 94, 8),
|
|
(Self::Error, true) => Color32::from_rgb(255, 129, 116),
|
|
(Self::Error, false) => Color32::from_rgb(179, 52, 44),
|
|
(Self::Offline | Self::Disabled, true) => Color32::from_rgb(136, 139, 145),
|
|
(Self::Offline | Self::Disabled, false) => Color32::from_rgb(98, 102, 108),
|
|
}
|
|
}
|
|
pub(super) fn paint(self, ui: &egui::Ui, rect: egui::Rect) {
|
|
if !ui.is_rect_visible(rect) {
|
|
return;
|
|
}
|
|
let color = self.color(ui);
|
|
let glyph = match self {
|
|
Self::Ready => icon::CHECK_CIRCLE,
|
|
Self::Idle => icon::MOON,
|
|
Self::Error => icon::WARNING,
|
|
Self::Offline => icon::MINUS_CIRCLE,
|
|
Self::Disabled => icon::PAUSE_CIRCLE,
|
|
Self::Waiting => {
|
|
let start = ui.input(|i| (i.time % 1.2) as f32) * std::f32::consts::TAU / 1.2;
|
|
let radius = rect.height() * 0.34;
|
|
let points = (0..=12)
|
|
.map(|i| {
|
|
rect.center()
|
|
+ egui::Vec2::angled(start + std::f32::consts::PI * i as f32 / 12.)
|
|
* radius
|
|
})
|
|
.collect();
|
|
ui.painter()
|
|
.add(egui::Shape::line(points, egui::Stroke::new(1.8_f32, color)));
|
|
ui.ctx()
|
|
.request_repaint_after(std::time::Duration::from_millis(65));
|
|
return;
|
|
}
|
|
};
|
|
ui.painter().text(
|
|
rect.center(),
|
|
egui::Align2::CENTER_CENTER,
|
|
glyph,
|
|
egui::FontId::proportional(rect.height()),
|
|
color,
|
|
);
|
|
}
|
|
}
|