Skip to content

armgit / muxin

Public Imported from GitHub
0

All your machines, one app. For you and your AI agents: agent sessions, desktops, files, logs and GitHub across your Macs, Linux and Windows machines, with an MCP server.

Tailscale: don't offer Mullvad exit nodes or hello.ts.net as machines to add (#17)

Spencer Owen59eb91ca594b
diff --git a/src/fleet/tailscale.rs b/src/fleet/tailscale.rs
index 2309419..56e5847 100644
--- a/src/fleet/tailscale.rs
+++ b/src/fleet/tailscale.rs
@@ -42,6 +42,10 @@ pub struct Peer {
pub relay: Option<String>,
/// Traffic went to it recently.
pub active: bool,
+ /// One of Tailscale's own devices shared into every tailnet: Mullvad's
+ /// exit nodes (Tailscale's Mullvad add-on) or the hello.ts.net demo. Not
+ /// the user's, and nothing to ssh to.
+ pub tailscale_owned: bool,
}
impl Tailnet {
@@ -86,9 +90,9 @@ impl Peer {
self.dns_name.split('.').next().filter(|s| !s.is_empty()).unwrap_or(&self.host_name)
}
- /// Whether you can ssh to it (phones and tablets: no).
+ /// Whether you can ssh to it (phones, tablets and Tailscale's own devices: no).
pub fn is_computer(&self) -> bool {
- !matches!(self.os.to_ascii_lowercase().as_str(), "ios" | "android" | "tvos")
+ !self.tailscale_owned && !matches!(self.os.to_ascii_lowercase().as_str(), "ios" | "android" | "tvos")
}
/// "direct" (peer-to-peer), "relay" (through a Tailscale relay), or
@@ -126,6 +130,7 @@ pub fn parse(output: &str) -> Option<Tailnet> {
direct_addr: text(&p["CurAddr"]),
relay: text(&p["Relay"]),
active: p["Active"].as_bool().unwrap_or(false),
+ tailscale_owned: tailscale_owned(p),
})
.collect()
})
@@ -137,6 +142,15 @@ pub fn parse(output: &str) -> Option<Tailnet> {
})
}
+/// Whether a peer is one of Tailscale's own devices rather than the user's (or
+/// one shared with them from another tailnet, which stays).
+fn tailscale_owned(p: &Value) -> bool {
+ let dns = p["DNSName"].as_str().unwrap_or("").trim_end_matches('.').to_ascii_lowercase();
+ let tagged = |t: &str| p["Tags"].as_array().is_some_and(|tags| tags.iter().any(|x| x.as_str() == Some(t)));
+ // Only Mullvad's nodes come with a location.
+ dns == "hello.ts.net" || dns.ends_with(".mullvad.ts.net") || tagged("tag:mullvad-exit-node") || p["Location"].is_object()
+}
+
/// The Tailscale command-line tool, if Tailscale is installed. On macOS the
/// one inside Tailscale.app comes first: it always matches the running app
/// (a Homebrew one may not, and says so on every call).
@@ -275,7 +289,15 @@ mod tests {
"nodekey:b": { "HostName": "localhost", "DNSName": "phone.tail0000.ts.net.", "OS": "iOS", "TailscaleIPs": ["100.64.56.41"],
"Online": false, "LastSeen": "2026-10-08T23:17:05.1Z", "CurAddr": "", "Relay": "iad", "Active": false },
"nodekey:c": { "HostName": "nas", "DNSName": "nas.tail0000.ts.net.", "OS": "linux", "TailscaleIPs": ["100.99.89.52"],
- "Online": true, "LastSeen": "0001-01-01T00:00:00Z", "CurAddr": "", "Relay": "mia", "Active": true }
+ "Online": true, "LastSeen": "0001-01-01T00:00:00Z", "CurAddr": "", "Relay": "mia", "Active": true },
+ "nodekey:d": { "HostName": "us-nyc-wg-301.mullvad.ts.net", "DNSName": "us-nyc-wg-301.mullvad.ts.net.", "OS": "linux", "TailscaleIPs": ["100.101.12.34"],
+ "Online": true, "LastSeen": "0001-01-01T00:00:00Z", "CurAddr": "", "Relay": "nyc", "Active": false, "ExitNodeOption": true,
+ "Tags": ["tag:mullvad-exit-node"],
+ "Location": { "Country": "USA", "CountryCode": "US", "City": "New York, NY", "CityCode": "NYC", "Priority": 100 } },
+ "nodekey:e": { "HostName": "hello", "DNSName": "hello.ts.net.", "OS": "linux", "TailscaleIPs": ["100.101.102.103"],
+ "Online": true, "LastSeen": "0001-01-01T00:00:00Z", "CurAddr": "", "Relay": "sea", "Active": false },
+ "nodekey:f": { "HostName": "pi", "DNSName": "pi.friend-tailnet.ts.net.", "OS": "linux", "TailscaleIPs": ["100.77.1.2"],
+ "Online": true, "LastSeen": "0001-01-01T00:00:00Z", "CurAddr": "", "Relay": "den", "Active": false }
}
}"#;
@@ -284,7 +306,7 @@ mod tests {
let t = parse(STATUS).unwrap();
assert!(t.running());
assert_eq!(t.name.as_deref(), Some("[email protected]"));
- assert_eq!(t.peers.len(), 3);
+ assert_eq!(t.peers.len(), 6);
let box_ = t.peers.iter().find(|p| p.host_name == "box-SER").unwrap();
assert_eq!((box_.dns_name.as_str(), box_.short_name(), box_.path()), ("box-ser.tail0000.ts.net", "box-ser", "direct"));
assert_eq!(box_.last_seen, None, "online devices have no last-seen time");
@@ -292,6 +314,13 @@ mod tests {
assert!(!phone.online && phone.last_seen.is_some() && !phone.is_computer());
assert_eq!(phone.path(), "idle");
assert_eq!(t.peers.iter().find(|p| p.host_name == "nas").unwrap().path(), "relay");
+ let exit = t.peers.iter().find(|p| p.dns_name.ends_with(".mullvad.ts.net")).unwrap();
+ assert!(exit.tailscale_owned && !exit.is_computer(), "Mullvad's exit nodes aren't machines to add");
+ let hello = t.peers.iter().find(|p| p.dns_name == "hello.ts.net").unwrap();
+ assert!(hello.tailscale_owned && !hello.is_computer(), "nor is Tailscale's demo device");
+ // A machine shared in from another tailnet is.
+ assert!(t.peers.iter().find(|p| p.dns_name == "pi.friend-tailnet.ts.net").unwrap().is_computer());
+ assert!(t.peers.iter().filter(|p| p.os == "linux" && !p.tailscale_owned).all(|p| p.is_computer()));
}
#[test]