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
@@ -1309,6 +1309,7 @@ impl Agent {
|
||||
.exit_via
|
||||
.and_then(|bytes| EndpointId::from_bytes(&bytes).ok()),
|
||||
exit_via_online: false,
|
||||
exit_traffic: None,
|
||||
exit_rules: Default::default(),
|
||||
descriptor: keys.descriptor(),
|
||||
name: stored.name,
|
||||
|
||||
@@ -2810,6 +2810,7 @@ impl Runtime {
|
||||
exit_node,
|
||||
hostname: self.params.hostname.clone(),
|
||||
capabilities,
|
||||
agent_version: Some(env!("CARGO_PKG_VERSION").to_owned()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2999,6 +3000,9 @@ impl Runtime {
|
||||
}
|
||||
if let Some(session) = self.sessions.get_mut(&peer) {
|
||||
session.hostname = Some(announcement.hostname.clone());
|
||||
session
|
||||
.agent_version
|
||||
.clone_from(&announcement.agent_version);
|
||||
session.broadcast = announcement.broadcast;
|
||||
session.exit_node = announcement.exit_node;
|
||||
session.capabilities = capabilities.clone();
|
||||
@@ -3260,6 +3264,7 @@ impl Runtime {
|
||||
exit_node: session.exit_node,
|
||||
endpoint_id: session.peer,
|
||||
role: session.role,
|
||||
agent_version: session.agent_version.clone(),
|
||||
hostname: session
|
||||
.hostname
|
||||
.clone()
|
||||
@@ -3348,6 +3353,12 @@ impl Runtime {
|
||||
exit_offer: exit.offer,
|
||||
exit_via: exit.via,
|
||||
exit_via_online: exit.via.is_some_and(|via| self.exit_node_online(via)),
|
||||
exit_traffic: self
|
||||
.params
|
||||
.interface
|
||||
.as_ref()
|
||||
.and(exit.via)
|
||||
.and_then(|peer| self.params.routes.exit_traffic(self.network_id, peer)),
|
||||
exit_rules: self
|
||||
.params
|
||||
.interface
|
||||
|
||||
@@ -72,6 +72,7 @@ pub(crate) struct Session {
|
||||
/// number of control bytes it queues.
|
||||
pub(crate) outbound: mpsc::Sender<zeroize::Zeroizing<Vec<u8>>>,
|
||||
pub(crate) hostname: Option<String>,
|
||||
pub(crate) agent_version: Option<String>,
|
||||
pub(crate) capabilities: Vec<PluginCapability>,
|
||||
pub(crate) broadcast: bool,
|
||||
/// The peer offers itself as an exit node in this network.
|
||||
@@ -228,6 +229,7 @@ pub(crate) fn spawn(
|
||||
conn,
|
||||
outbound: outbound_tx,
|
||||
hostname: None,
|
||||
agent_version: None,
|
||||
capabilities: Vec::new(),
|
||||
broadcast: false,
|
||||
exit_node: false,
|
||||
|
||||
@@ -152,6 +152,8 @@ pub struct PeerStatus {
|
||||
///
|
||||
/// A mutable binding, not an identity.
|
||||
pub hostname: Option<String>,
|
||||
/// Software version in the peer's latest authenticated announcement.
|
||||
pub agent_version: Option<String>,
|
||||
/// Protocols agreed with this peer: both sides have them at the same
|
||||
/// version.
|
||||
///
|
||||
@@ -247,6 +249,8 @@ pub struct NetworkStatus {
|
||||
pub exit_via: Option<EndpointId>,
|
||||
/// Whether that member is connected and still offering to be one.
|
||||
pub exit_via_online: bool,
|
||||
/// IP byte totals since this exit route was selected.
|
||||
pub exit_traffic: Option<crate::overlay::exit::ExitTraffic>,
|
||||
/// What the host rules for the exit settings are doing.
|
||||
pub exit_rules: crate::overlay::ExitRulesReport,
|
||||
/// Immutable deterministic description of the network space.
|
||||
|
||||
@@ -21,6 +21,9 @@ use crate::error::Result;
|
||||
#[cfg_attr(target_os = "macos", allow(dead_code))]
|
||||
const APP_NAME: &str = "tsunagi";
|
||||
|
||||
/// Maximum length of the optional software release label in a peer announcement.
|
||||
pub const MAX_AGENT_VERSION_LEN: usize = 64;
|
||||
|
||||
/// Rendezvous slots per network; this bounds a discovery sample, not membership.
|
||||
pub const DHT_SLOTS: u8 = 16;
|
||||
/// BEP44 permits 1000 bencoded bytes; a 996-byte string has a four-byte prefix.
|
||||
|
||||
@@ -830,6 +830,8 @@ pub struct MemberReport {
|
||||
/// One control plane peer.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct PeerReport {
|
||||
/// The software version reported by this authenticated peer, when available.
|
||||
pub agent_version: Option<String>,
|
||||
/// Actionable carrier failure or policy mismatch; absent for a usable route.
|
||||
pub data_error: Option<String>,
|
||||
/// The peer's endpoint id.
|
||||
@@ -893,6 +895,8 @@ pub struct RuleSetReport {
|
||||
/// One network's exit-node settings and what they are doing.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ExitReport {
|
||||
/// IP bytes carried through this exit since selection, when locally observed.
|
||||
pub traffic: Option<crate::overlay::exit::ExitTraffic>,
|
||||
/// This agent offers itself as an exit node in this network.
|
||||
pub offering: bool,
|
||||
/// Masquerading and forwarding rules for members' traffic, when offering.
|
||||
@@ -1141,7 +1145,7 @@ pub const EXCHANGE_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
///
|
||||
/// Bump it whenever [`Request`], [`Response`] or anything they contain
|
||||
/// changes shape.
|
||||
pub const CONTROL_PROTOCOL: u32 = u32::from_be_bytes([b'T', b'S', b'N', 24]);
|
||||
pub const CONTROL_PROTOCOL: u32 = u32::from_be_bytes([b'T', b'S', b'N', 25]);
|
||||
|
||||
/// Reads one request off an accepted stream, answers it, writes the response.
|
||||
///
|
||||
|
||||
@@ -5,6 +5,15 @@
|
||||
//! system sees. It is kept apart from the broadcast rules, which have a
|
||||
//! different lifetime and different tags.
|
||||
|
||||
/// Plaintext IP bytes carried through the client's currently selected internet exit.
|
||||
#[derive(Debug, Copy, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct ExitTraffic {
|
||||
/// Bytes accepted by the carrier for off-mesh destinations.
|
||||
pub tx_bytes: u64,
|
||||
/// Internet reply bytes delivered to the local interface.
|
||||
pub rx_bytes: u64,
|
||||
}
|
||||
|
||||
/// How one set of host rules went.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
||||
pub struct RuleSetReport {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -21,9 +21,11 @@
|
||||
//! one is in use.
|
||||
|
||||
use super::broadcast::{BroadcastPolicy, BroadcastTable};
|
||||
use arc_swap::ArcSwap;
|
||||
use super::exit::ExitTraffic;
|
||||
use arc_swap::{ArcSwap, ArcSwapOption};
|
||||
use std::collections::HashMap;
|
||||
use std::net::Ipv4Addr;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use iroh::EndpointId;
|
||||
@@ -43,7 +45,19 @@ pub struct Route {
|
||||
/// An internet source is valid only for a reply to our address in the exit's network.
|
||||
pub(super) enum PacketSource {
|
||||
Member,
|
||||
ExitReply { local: Option<Ipv4Addr> },
|
||||
ExitReply {
|
||||
local: Option<Ipv4Addr>,
|
||||
exit: Arc<SelectedExit>,
|
||||
},
|
||||
}
|
||||
|
||||
/// A packet holds its selection until delivery finishes, even if the operator
|
||||
/// switches to another exit in the meantime.
|
||||
#[derive(Debug)]
|
||||
pub(super) struct SelectedExit {
|
||||
route: Route,
|
||||
pub(super) tx_bytes: AtomicU64,
|
||||
pub(super) rx_bytes: AtomicU64,
|
||||
}
|
||||
|
||||
/// A network's exit-node settings, as far as packets are concerned.
|
||||
@@ -97,6 +111,7 @@ pub enum RouteError {
|
||||
pub struct RoutingTable {
|
||||
pub(crate) vips: Arc<crate::vip::VipRouter>,
|
||||
broadcast: ArcSwap<BroadcastTable>,
|
||||
selected_exit: ArcSwapOption<SelectedExit>,
|
||||
networks: RwLock<HashMap<NetworkId, NetworkRoutes>>,
|
||||
}
|
||||
|
||||
@@ -171,6 +186,7 @@ impl RoutingTable {
|
||||
clear_other_exits(networks, network);
|
||||
}
|
||||
networks.insert(network, routes);
|
||||
self.refresh_exit(networks);
|
||||
self.broadcast
|
||||
.store(Arc::new(BroadcastTable::build(networks)));
|
||||
Ok(())
|
||||
@@ -181,6 +197,7 @@ impl RoutingTable {
|
||||
self.vips.remove_network(network);
|
||||
let mut networks = self.write();
|
||||
networks.remove(&network);
|
||||
self.refresh_exit(&networks);
|
||||
self.broadcast
|
||||
.store(Arc::new(BroadcastTable::build(&networks)));
|
||||
}
|
||||
@@ -213,9 +230,35 @@ impl RoutingTable {
|
||||
if routes.exit.via.is_some() {
|
||||
clear_other_exits(&mut networks, network);
|
||||
}
|
||||
self.refresh_exit(&networks);
|
||||
}
|
||||
}
|
||||
|
||||
/// Publish the current choice under the same write lock as the route edits.
|
||||
fn refresh_exit(&self, networks: &HashMap<NetworkId, NetworkRoutes>) {
|
||||
let route = exit_via(networks).map(|(network, peer)| Route { network, peer });
|
||||
if self.selected_exit.load().as_ref().map(|exit| exit.route) != route {
|
||||
self.selected_exit.store(route.map(|route| {
|
||||
Arc::new(SelectedExit {
|
||||
route,
|
||||
tx_bytes: AtomicU64::default(),
|
||||
rx_bytes: AtomicU64::default(),
|
||||
})
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn exit_traffic(&self, network: NetworkId, peer: EndpointId) -> Option<ExitTraffic> {
|
||||
let current = self.selected_exit.load();
|
||||
let exit = current
|
||||
.as_ref()
|
||||
.filter(|e| e.route == Route { network, peer })?;
|
||||
Some(ExitTraffic {
|
||||
tx_bytes: exit.tx_bytes.load(Ordering::Relaxed),
|
||||
rx_bytes: exit.rx_bytes.load(Ordering::Relaxed),
|
||||
})
|
||||
}
|
||||
|
||||
/// Recognizes limited and configured subnet broadcasts before unicast lookup.
|
||||
pub fn is_broadcast(&self, destination: Ipv4Addr) -> bool {
|
||||
self.broadcast.load().is_destination(destination)
|
||||
@@ -249,6 +292,13 @@ impl RoutingTable {
|
||||
/// unicast destination, goes to this device's exit node when it has one:
|
||||
/// that is what sending *all* traffic through a member means.
|
||||
pub fn route(&self, destination: Ipv4Addr) -> Option<Route> {
|
||||
self.packet_route(destination).map(|(route, _)| route)
|
||||
}
|
||||
|
||||
pub(super) fn packet_route(
|
||||
&self,
|
||||
destination: Ipv4Addr,
|
||||
) -> Option<(Route, Option<Arc<SelectedExit>>)> {
|
||||
let networks = self.read();
|
||||
for (network, routes) in networks.iter() {
|
||||
if routes.local == Some(destination) {
|
||||
@@ -259,10 +309,13 @@ impl RoutingTable {
|
||||
.iter()
|
||||
.find(|(address, _)| *address == destination)
|
||||
{
|
||||
return Some(Route {
|
||||
network: *network,
|
||||
peer: *peer,
|
||||
});
|
||||
return Some((
|
||||
Route {
|
||||
network: *network,
|
||||
peer: *peer,
|
||||
},
|
||||
None,
|
||||
));
|
||||
}
|
||||
}
|
||||
// Inside an overlay range, an unowned address is nobody's, not the
|
||||
@@ -270,7 +323,8 @@ impl RoutingTable {
|
||||
if !is_internet_destination(destination) || in_any_range(&networks, destination) {
|
||||
return None;
|
||||
}
|
||||
exit_via(&networks).map(|(network, peer)| Route { network, peer })
|
||||
let exit = self.selected_exit.load_full()?;
|
||||
Some((exit.route, Some(exit)))
|
||||
}
|
||||
|
||||
/// Whether a peer may send from a source address.
|
||||
@@ -298,11 +352,14 @@ impl RoutingTable {
|
||||
{
|
||||
return Some(PacketSource::Member);
|
||||
}
|
||||
(exit_via(&networks) == Some((network, peer))
|
||||
let current = self.selected_exit.load();
|
||||
let exit = current.as_ref()?;
|
||||
(exit.route == Route { network, peer }
|
||||
&& is_internet_destination(source)
|
||||
&& !in_any_range(&networks, source))
|
||||
.then_some(PacketSource::ExitReply {
|
||||
.then(|| PacketSource::ExitReply {
|
||||
local: routes.local,
|
||||
exit: Arc::clone(exit),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,23 @@ pub struct Announcement {
|
||||
pub hostname: String,
|
||||
/// Announced IP plugin capabilities. Opaque to the core.
|
||||
pub capabilities: Vec<PluginCapability>,
|
||||
/// Software release reported by this peer for display after authentication.
|
||||
/// Keep this trailer last: original v8 readers stop after the capabilities.
|
||||
#[serde(default, deserialize_with = "read_agent_version")]
|
||||
pub agent_version: Option<String>,
|
||||
}
|
||||
|
||||
fn read_agent_version<'de, D: serde::Deserializer<'de>>(d: D) -> Result<Option<String>, D::Error> {
|
||||
// A frame contains exactly one envelope. EOF here is a legacy announcement.
|
||||
// An unreadable display hint can also be discarded without losing the
|
||||
// hostname or capabilities. Borrow the frame until the label is bounded.
|
||||
let version = Option::<&str>::deserialize(d).ok().flatten().filter(|s| {
|
||||
!s.is_empty()
|
||||
&& s.len() <= crate::config::MAX_AGENT_VERSION_LEN
|
||||
&& s.bytes()
|
||||
.all(|b| b.is_ascii_alphanumeric() || matches!(b, b'.' | b'+' | b'-'))
|
||||
});
|
||||
Ok(version.map(str::to_owned))
|
||||
}
|
||||
|
||||
/// Opens a data channel, sent by the initiator right after the membership
|
||||
@@ -395,3 +412,41 @@ pub fn kind(message: &ControlMessage) -> &'static str {
|
||||
ControlMessage::Bye { .. } => "bye",
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#![allow(clippy::unwrap_used, clippy::panic)]
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn v8_announcements_interoperate_with_and_without_a_software_version() {
|
||||
// The original v8 frame ends with the capability list. Decode the
|
||||
// new frame using exactly those fields as an older receiver would.
|
||||
type OldFrame = ([u8; 32], u8, bool, bool, String, Vec<PluginCapability>);
|
||||
let old: OldFrame = ([7; 32], 1, true, false, "lab".into(), vec![]);
|
||||
let legacy = encode(&old).unwrap();
|
||||
assert!(decode::<Envelope>(&legacy[..legacy.len() - 1]).is_err());
|
||||
let read = |bytes: &[u8]| match decode::<Envelope>(bytes).unwrap().message {
|
||||
ControlMessage::Announce(a) => a,
|
||||
_ => panic!("expected announcement"),
|
||||
};
|
||||
let mut a = read(&legacy);
|
||||
assert_eq!(a.agent_version, None);
|
||||
a.agent_version = Some("2.1.0-rc.2+android".into());
|
||||
let wire = encode(&Envelope {
|
||||
network_id: old.0,
|
||||
message: ControlMessage::Announce(a.clone()),
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(decode::<OldFrame>(&wire).unwrap(), old);
|
||||
assert_eq!(read(&wire), a);
|
||||
|
||||
for invalid in ["", "1.2.3\nforged", &"1".repeat(256)] {
|
||||
let mut wire = legacy.clone();
|
||||
wire.extend(encode(&Some(invalid)).unwrap());
|
||||
let a = read(&wire);
|
||||
assert_eq!(a.agent_version, None);
|
||||
assert_eq!(a.hostname, "lab");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user