Fold network cards and show which peer carries exit traffic
Start the tray and Android overviews with each network folded under its bold name. Keep the selected exit, its host name and its sent and received byte totals visible. Put VIP beside Copy secret and Show devices. Default to bytes and make the unit switch update the desktop traffic column, totals, rates and plots together. Open the devices window at 1000 points wide and bound the network and per-peer plots. Use both sides of the phone detail view for transport, latency, version and traffic. Attach counters to the current network and exit peer. Count off-mesh IP bytes after carrier acceptance and replies after local interface delivery. Changing the selection starts new totals. Ordinary mesh traffic to the same peer and rejected packets stay out of the exit counters. Advertise the agent release as an optional bounded trailer on an authenticated control v8 announcement. Older readers can ignore it and older peers display an unknown version. Release labels live for the session and do not participate in authentication or wire negotiation. The new status fields require local IPC v25, so update the daemon, CLI and tray together. Existing mesh identities and databases need no migration. On Android, request system interface consent on the first app launch. Respect an explicit stop or declined consent across launches. Start Tsunagi Agent re-enables automatic startup. Checked formatting and strict workspace Clippy on macOS arm64. The full locked workspace suite passed 588 tests with four opt-in tests ignored. Built the tray and Android debug APKs. Both instrumentation tests passed on an Android 37 arm64 emulator, including app startup, stop and restart. Checked the first-run permission prompt and the rendered phone and desktop layouts. Native Linux and Windows tests were not run on this host.
This commit is contained in:
1 parent
f9f67f88b1
commit
8c4c2fa34e
39 files changed
+1144
-412
No files matched your search
@@ -320,11 +320,19 @@ impl Interface {
|
||||
tally.multicast.fetch_add(1, Ordering::Relaxed);
|
||||
continue;
|
||||
}
|
||||
let Some(route) = routes.route_v4(destination) else {
|
||||
let selected = match destination {
|
||||
IpAddr::V4(address) => routes.packet_route(address),
|
||||
IpAddr::V6(_) => None,
|
||||
};
|
||||
let Some((route, exit)) = selected else {
|
||||
tally.note_unroutable(destination);
|
||||
continue;
|
||||
};
|
||||
let len = packet.len() as u64;
|
||||
if carrier.carry(route, packet) {
|
||||
if let Some(exit) = exit {
|
||||
exit.tx_bytes.fetch_add(len, Ordering::Relaxed);
|
||||
}
|
||||
tally.sent.fetch_add(1, Ordering::Relaxed);
|
||||
} else {
|
||||
tally.undeliverable.fetch_add(1, Ordering::Relaxed);
|
||||
@@ -840,12 +848,14 @@ impl Interface {
|
||||
self.tally.wrong_source.fetch_add(1, Ordering::Relaxed);
|
||||
return Err(Rejected::WrongSource);
|
||||
};
|
||||
let broadcast = match (origin, header.destination()) {
|
||||
(PacketSource::ExitReply { local: Some(local) }, IpAddr::V4(destination))
|
||||
if destination == local =>
|
||||
{
|
||||
false
|
||||
}
|
||||
let (broadcast, exit) = match (origin, header.destination()) {
|
||||
(
|
||||
PacketSource::ExitReply {
|
||||
local: Some(local),
|
||||
exit,
|
||||
},
|
||||
IpAddr::V4(destination),
|
||||
) if destination == local => (false, Some(exit)),
|
||||
(PacketSource::Member, IpAddr::V4(destination))
|
||||
if self.routes.is_broadcast(destination) =>
|
||||
{
|
||||
@@ -855,13 +865,13 @@ impl Interface {
|
||||
self.tally.broadcast_dropped.fetch_add(1, Ordering::Relaxed);
|
||||
return Err(Rejected::BroadcastDenied);
|
||||
}
|
||||
true
|
||||
(true, None)
|
||||
}
|
||||
(PacketSource::Member, IpAddr::V4(destination))
|
||||
if self.routes.is_local_destination(network, destination)
|
||||
|| self.routes.accepts_exit_traffic(network, destination) =>
|
||||
{
|
||||
false
|
||||
(false, None)
|
||||
}
|
||||
_ => {
|
||||
self.tally.wrong_destination.fetch_add(1, Ordering::Relaxed);
|
||||
@@ -887,7 +897,11 @@ impl Interface {
|
||||
crate::vip::router::Decision::Pass => packet,
|
||||
};
|
||||
// Remote broadcasts terminate here. Only local TUN ingress can fan out.
|
||||
let len = packet.len() as u64;
|
||||
if self.device.send(packet).await.is_ok() {
|
||||
if let Some(exit) = exit {
|
||||
exit.rx_bytes.fetch_add(len, Ordering::Relaxed);
|
||||
}
|
||||
if broadcast {
|
||||
self.tally
|
||||
.broadcast_received
|
||||
@@ -926,18 +940,6 @@ impl Drop for Interface {
|
||||
}
|
||||
}
|
||||
|
||||
impl RoutingTable {
|
||||
/// The route for a destination, when it is one the overlay carries.
|
||||
fn route_v4(&self, destination: IpAddr) -> Option<Route> {
|
||||
match destination {
|
||||
IpAddr::V4(address) => self.route(address),
|
||||
// The overlay is IPv4. An IPv6 packet has no owner here, and
|
||||
// counting it as unroutable is the truth rather than a fault.
|
||||
IpAddr::V6(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether an address is one the overlay has nowhere to send.
|
||||
fn is_multicast_or_broadcast(address: IpAddr) -> bool {
|
||||
match address {
|
||||
@@ -1530,6 +1532,57 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn exit_totals_count_only_accepted_internet_packets_for_the_current_choice() {
|
||||
let (interface, device, routes, _, id) = interface(false).await;
|
||||
let totals = |p| {
|
||||
routes
|
||||
.exit_traffic(id, peer(p))
|
||||
.map(|t| (t.tx_bytes, t.rx_bytes))
|
||||
};
|
||||
assert_eq!(totals(2), None);
|
||||
routes.set_exit(id, using(peer(2)));
|
||||
let outgoing = ipv4(addr(1), INTERNET, b"request");
|
||||
device.push_from_os(outgoing.clone());
|
||||
device.push_from_os(ipv4(addr(1), addr(2), b"ordinary mesh traffic"));
|
||||
wait_for(&interface, |c| c.sent.saturating_sub(1)).await;
|
||||
let incoming = ipv4(INTERNET, addr(1), b"reply");
|
||||
interface
|
||||
.deliver(id, peer(2), incoming.clone())
|
||||
.await
|
||||
.unwrap();
|
||||
interface
|
||||
.deliver(id, peer(2), ipv4(addr(2), addr(1), b"mesh"))
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(
|
||||
interface
|
||||
.deliver(id, peer(3), incoming.clone())
|
||||
.await
|
||||
.is_err()
|
||||
);
|
||||
assert!(
|
||||
interface
|
||||
.deliver(id, peer(2), ipv4(INTERNET, addr(3), b"wrong host"))
|
||||
.await
|
||||
.is_err()
|
||||
);
|
||||
|
||||
routes.set_exit(id, using(peer(2)));
|
||||
assert_eq!(
|
||||
totals(2),
|
||||
Some((outgoing.len() as u64, incoming.len() as u64))
|
||||
);
|
||||
routes.set_exit(id, using(peer(3)));
|
||||
assert_eq!(totals(2), None);
|
||||
assert_eq!(totals(3), Some((0, 0)));
|
||||
routes.set_exit(id, ExitPolicy::default());
|
||||
assert_eq!(totals(3), None);
|
||||
routes.set_exit(id, using(peer(2)));
|
||||
assert_eq!(totals(2), Some((0, 0)));
|
||||
interface.remove().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn internet_traffic_goes_to_the_exit_node_and_only_once_one_is_chosen() {
|
||||
let (interface, device, routes, carrier, id) = interface(false).await;
|
||||
|
||||
Reference in new issue
Block a user