Fix macOS exit sharing and bring exit selection onto the phone home screen
A Mac could install PF rules and advertise itself while IPv4 forwarding was still off. Check and enable forwarding when applying the offer and refresh the physical route when the uplink changes. Try the agent's existing privileges first. When an existing utun needs additional permission, the foreground tray or CLI can obtain an administrator grant scoped to the local UID and overlay subnet. Reconcile the current offer after the dialog so a withdrawal during authorization stays effective. A user agent denied a host utun can serve peers over bounded TCP, UDP and ICMP echo sockets bound to the physical interface. Keep host routes and ordinary local application traffic on the system-utun path. Preserve the saved choice for intentionally off-host setups and report readiness separately. Report exit selection directly to the selected peer over its authenticated session. Older peers appear for one minute following forwarded traffic. The optional announcement trailer remains compatible with control v8. Local IPC v29 carries the new status and authorization results. Keep the exit user count, left-aligned names and one-row scroll controls in a single fixed-height block alongside the network details. Show health and a small traffic trace on folded cards. Open desktop Devices at a usable width and keep the exit action clickable in its compact layout. Replace Android's per-card exit buttons with a fixed thumb-sized control. The chooser and Quick Settings share one list with a single local option, network groups, measured latency and an accessible confirmation sheet. Release the applications and packages as 1.0.9. On macOS, checked formatting, strict workspace Clippy and the workspace all-target test suite, including real encrypted agents and loopback TCP, UDP and ICMP. Ran the opt-in user-mode exit UDP round trip on a physical IPv4 interface. Verified the authorization scripts and syntax of their PF, sudoers and AppleScript components. The privileged two-utun kernel test is reserved for an isolated macOS runner. Rendered phone and desktop layouts in both themes, built the arm64 Android debug APK and cross- checked all workspace targets for Windows GNU.
This commit is contained in:
1 parent
d8b7787430
commit
43894612ee
65 files changed
+3110
-654
No files matched your search
@@ -760,6 +760,7 @@ async fn network_cards_start_closed_and_keep_exit_traffic_visible_when_folded()
|
||||
};
|
||||
let opened = click(titles[0]);
|
||||
assert_eq!(positions(&opened, "Show devices").len(), 1);
|
||||
assert!(positions(&opened, "Exit node…").is_empty());
|
||||
use egui_phosphor::regular as icon;
|
||||
let vip = format!("{} VIP", icon::NETWORK);
|
||||
let y = |label: &str| positions(&opened, label)[0].y;
|
||||
@@ -771,6 +772,18 @@ async fn network_cards_start_closed_and_keep_exit_traffic_visible_when_folded()
|
||||
let folded = click(positions(&opened, name.as_str())[0]);
|
||||
assert!(positions(&folded, "Show devices").is_empty());
|
||||
assert_eq!(positions(&folded, "Exit via gateway").len(), 1);
|
||||
let fab = positions(&folded, icon::SIGN_OUT)
|
||||
.into_iter()
|
||||
.find(|p| p.y > 625. && p.x > 265.)
|
||||
.expect("fixed exit button");
|
||||
let picker = click(fab);
|
||||
assert_eq!(positions(&picker, "No exit node").len(), 1);
|
||||
assert_eq!(positions(&picker, "gateway").len(), 1);
|
||||
let dialog = click(positions(&picker, "No exit node")[0]);
|
||||
assert_eq!(positions(&dialog, "Disconnect").len(), 1);
|
||||
let picker = click(positions(&dialog, "Cancel")[0]);
|
||||
assert!(positions(&picker, "Disconnect").is_empty());
|
||||
assert_eq!(positions(&picker, "gateway").len(), 1);
|
||||
agent.shutdown().await;
|
||||
}
|
||||
|
||||
@@ -803,6 +816,12 @@ fn the_system_tile_waits_for_the_agent_and_distinguishes_networks_with_the_same_
|
||||
[("alpha", true), ("bravo", true), ("paused", false)].map(|(id, active)| NetworkReport {
|
||||
network_id: id.into(),
|
||||
name: "home".into(),
|
||||
peers: vec![tsunagi::ipc::PeerReport {
|
||||
endpoint_id: "same-device".into(),
|
||||
hostname: Some(format!("gateway-{id}")),
|
||||
exit_node: true,
|
||||
..Default::default()
|
||||
}],
|
||||
active,
|
||||
..Default::default()
|
||||
});
|
||||
@@ -817,6 +836,9 @@ fn the_system_tile_waits_for_the_agent_and_distinguishes_networks_with_the_same_
|
||||
let chooser = draw(&mut phone, &state);
|
||||
assert!(chooser.iter().any(|s| s == "home · alpha"));
|
||||
assert!(chooser.iter().any(|s| s == "home · bravo"));
|
||||
assert!(chooser.iter().any(|s| s == "gateway-alpha"));
|
||||
assert!(chooser.iter().any(|s| s == "gateway-bravo"));
|
||||
assert_eq!(chooser.iter().filter(|s| *s == "No exit node").count(), 1);
|
||||
assert!(!chooser.iter().any(|s| s.contains("paused")));
|
||||
assert!(phone.back().is_none());
|
||||
assert!(draw(&mut phone, &state).iter().any(|s| s == "tsunagi"));
|
||||
|
||||
@@ -24,14 +24,13 @@ enum Page {
|
||||
Join,
|
||||
Devices(String),
|
||||
Vips(String),
|
||||
Exit(String),
|
||||
ExitNetworks,
|
||||
Exits,
|
||||
Leave(String),
|
||||
}
|
||||
impl Page {
|
||||
fn network(&self) -> Option<&str> {
|
||||
match self {
|
||||
Self::Devices(id) | Self::Vips(id) | Self::Exit(id) | Self::Leave(id) => Some(id),
|
||||
Self::Devices(id) | Self::Vips(id) | Self::Leave(id) => Some(id),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -43,7 +42,7 @@ impl Page {
|
||||
Self::Join => "Join a network",
|
||||
Self::Devices(_) => "Devices",
|
||||
Self::Vips(_) => "VIP",
|
||||
Self::Exit(_) | Self::ExitNetworks => "Exit node",
|
||||
Self::Exits => "Exit nodes",
|
||||
Self::Leave(_) => "Leave network",
|
||||
}
|
||||
}
|
||||
@@ -187,34 +186,56 @@ impl Phone {
|
||||
self.pick_exit = true;
|
||||
}
|
||||
|
||||
fn exit_networks(&mut self, ui: &mut egui::Ui, networks: &[tsunagi::ipc::NetworkReport]) {
|
||||
if networks.is_empty() {
|
||||
ui.label("Join a network to choose an exit node.");
|
||||
if ui.button("Join or create a network").clicked() {
|
||||
self.page = Page::Join;
|
||||
}
|
||||
return;
|
||||
fn open_exit_picker(&mut self) {
|
||||
if self.page != Page::Exits {
|
||||
self.before_picker = Some(std::mem::replace(&mut self.page, Page::Exits));
|
||||
self.forms.exit_confirm = None;
|
||||
}
|
||||
if !networks.iter().any(|n| n.active) {
|
||||
ui.label("Start a network to choose an exit node.");
|
||||
if ui.button("Show networks").clicked() {
|
||||
self.home();
|
||||
}
|
||||
return;
|
||||
}
|
||||
ui.label("Choose a network for the exit node");
|
||||
for n in networks.iter().filter(|n| n.active) {
|
||||
let ambiguous = networks.iter().any(|other| {
|
||||
other.active && other.name == n.name && other.network_id != n.network_id
|
||||
});
|
||||
let label = if ambiguous {
|
||||
format!("{} · {}", n.name, tsunagi_ui::format::short(&n.network_id))
|
||||
} else {
|
||||
n.name.clone()
|
||||
};
|
||||
if ui.button(label).clicked() {
|
||||
self.page = Page::Exit(n.network_id.clone());
|
||||
}
|
||||
}
|
||||
|
||||
/// This control lives outside both portrait and landscape scroll areas.
|
||||
fn exit_button(&mut self, ctx: &Context, ready: bool) {
|
||||
let clicked = egui::Area::new("home exit button".into())
|
||||
.anchor(egui::Align2::RIGHT_BOTTOM, [-16., -16.])
|
||||
.order(egui::Order::Middle)
|
||||
.movable(false)
|
||||
.show(ctx, |ui| {
|
||||
let (rect, response) = ui.allocate_exact_size(
|
||||
egui::vec2(60., 60.),
|
||||
if ready {
|
||||
egui::Sense::click()
|
||||
} else {
|
||||
egui::Sense::hover()
|
||||
},
|
||||
);
|
||||
let (mut fill, mut ink) = devices::exit_action_colors(ui.visuals().dark_mode);
|
||||
if !ready {
|
||||
fill = ui.visuals().widgets.inactive.bg_fill;
|
||||
ink = ui.visuals().weak_text_color();
|
||||
}
|
||||
ui.painter().circle_filled(rect.center(), 30., fill);
|
||||
if ready && (response.hovered() || response.has_focus()) {
|
||||
ui.painter().circle_stroke(rect.center(), 27., (1_f32, ink));
|
||||
}
|
||||
ui.painter().text(
|
||||
rect.center(),
|
||||
egui::Align2::CENTER_CENTER,
|
||||
icon::SIGN_OUT,
|
||||
egui::FontId::proportional(29.),
|
||||
ink,
|
||||
);
|
||||
response.widget_info(|| {
|
||||
egui::WidgetInfo::labeled(
|
||||
egui::WidgetType::Button,
|
||||
ready,
|
||||
"Choose an exit node",
|
||||
)
|
||||
});
|
||||
tsunagi_ui::widgets::hint(response, "Choose an exit node").clicked()
|
||||
})
|
||||
.inner;
|
||||
if ready && clicked {
|
||||
self.open_exit_picker();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +260,13 @@ impl Phone {
|
||||
.id_salt("network list")
|
||||
.show(ui, |ui| {
|
||||
for network in &report.networks {
|
||||
home::draw_network_selector(ui, network, report, &mut self.forms);
|
||||
home::draw_network_selector(
|
||||
ui,
|
||||
network,
|
||||
report,
|
||||
&mut self.forms,
|
||||
&self.traffic,
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -254,7 +281,7 @@ impl Phone {
|
||||
if let Some(n) = selected {
|
||||
ui.heading(&n.name);
|
||||
ui.push_id(&n.network_id, |ui| {
|
||||
if home::draw_network_details(
|
||||
home::draw_network_details(
|
||||
ui,
|
||||
actions,
|
||||
&mut self.forms,
|
||||
@@ -262,15 +289,14 @@ impl Phone {
|
||||
n,
|
||||
report,
|
||||
false,
|
||||
) {
|
||||
self.page = Page::Exit(n.network_id.clone());
|
||||
}
|
||||
);
|
||||
});
|
||||
} else {
|
||||
ui.heading("This device");
|
||||
ui.label("Tsunagi Agent is running");
|
||||
home::draw_header(ui, actions, &mut self.forms, report);
|
||||
}
|
||||
ui.add_space(80.);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -341,18 +367,13 @@ impl Phone {
|
||||
}
|
||||
if self.pick_exit && self.pending.is_none() {
|
||||
self.pick_exit = false;
|
||||
let mut active = report.networks.iter().filter(|n| n.active);
|
||||
let picker = match (active.next(), active.next()) {
|
||||
(Some(n), None) => Page::Exit(n.network_id.clone()),
|
||||
_ => Page::ExitNetworks,
|
||||
};
|
||||
if !matches!(self.page, Page::Exit(_) | Page::ExitNetworks) {
|
||||
self.before_picker = Some(std::mem::replace(&mut self.page, picker));
|
||||
}
|
||||
self.open_exit_picker();
|
||||
}
|
||||
Some(report)
|
||||
} else {
|
||||
if self.page.network().is_some() || matches!(self.page, Page::Join | Page::Monitor) {
|
||||
if self.page.network().is_some()
|
||||
|| matches!(self.page, Page::Join | Page::Monitor | Page::Exits)
|
||||
{
|
||||
self.home();
|
||||
}
|
||||
self.snapshot = Snapshot::default();
|
||||
@@ -446,7 +467,7 @@ impl Phone {
|
||||
self.landscape_home(ui, &actions, report);
|
||||
return;
|
||||
}
|
||||
egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| {
|
||||
egui::ScrollArea::vertical().id_salt(self.page.title()).auto_shrink([false, false]).show(ui, |ui| {
|
||||
let Some(report) = report else {
|
||||
match state {
|
||||
State::Starting => {ui.spinner(); ui.label("Starting Tsunagi Agent…");}
|
||||
@@ -463,19 +484,23 @@ impl Phone {
|
||||
ui.separator();
|
||||
if ui.button("Join or create a network").clicked() {self.page = Page::Join;}
|
||||
for n in &report.networks {
|
||||
if home::draw_network(ui, &actions, &mut self.forms, &self.traffic, n, report, false) {self.page = Page::Exit(n.network_id.clone());}
|
||||
home::draw_network(ui, &actions, &mut self.forms, &self.traffic, n, report, false);
|
||||
}
|
||||
ui.add_space(80.);
|
||||
}
|
||||
Page::Join => {
|
||||
home::draw_join(ui, &actions, &mut self.forms.join);
|
||||
if ui.button(format!("{} Paste secret", icon::CLIPBOARD)).clicked() {system = Some(SystemAction::PasteSecret);}
|
||||
}
|
||||
Page::Exit(_) => {
|
||||
if let Some(n) = selected && let Some(choice) = devices::choose_exit(ui, n, &report.endpoint_id) {
|
||||
Page::Exits => {
|
||||
if let Some(choice) = devices::choose_exit_from_networks(ui, &report.networks, &report.endpoint_id) {
|
||||
self.forms.exit_confirm = Some(choice);
|
||||
}
|
||||
if report.networks.is_empty() && ui.button("Join or create a network").clicked() {
|
||||
self.before_picker = None;
|
||||
self.page = Page::Join;
|
||||
}
|
||||
}
|
||||
Page::ExitNetworks => self.exit_networks(ui, &report.networks),
|
||||
Page::Leave(id) => {
|
||||
if let Some(n) = selected {
|
||||
ui.label(format!("Leave {} on this phone? You will need its secret to join again.", n.name));
|
||||
@@ -501,6 +526,9 @@ impl Phone {
|
||||
}
|
||||
}
|
||||
}
|
||||
if self.page == Page::Home && self.forms.exit_confirm.is_none() {
|
||||
self.exit_button(ctx, report.is_some() && !actions.busy());
|
||||
}
|
||||
devices::confirm_exit(ctx, &actions, &mut self.forms.exit_confirm, None);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user