* Send files to a tailnet machine with Taildrop The panel gets a send button next to the copy one on every machine that Tailscale grades as a Taildrop target, and `s` does the same from the keyboard. Picking runs through the XDG portal chooser, so it looks like the file dialog every other app opens. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TJQJfHXXApUk6En8EZisHg * Save incoming Taildrop files and say so Linux keeps Taildrop files in the daemon's inbox until someone asks for them, so nothing arrived until you ran `tailscale file get` by hand. A user service now stages each delivery next to the downloads directory, hands it over under a free name, and announces it — with a preview when it's an image, and a click to open it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TJQJfHXXApUk6En8EZisHg * Float every portal dialog, not just the titled ones The portal only ever shows dialogs, and the title regex missed any chooser an app names something else — ours included. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TJQJfHXXApUk6En8EZisHg * Re-run the Taildrop enable now that the unit ships The unit was never installed to /usr/lib/systemd/user/, so the enable had nothing to act on and machines that already ran the migration carry a marker for a no-op. Rename it so they get a working pass, and report what systemctl says instead of a bare failure line. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Wait for the file chooser on the connection that asked for it The portal answers a request with a Response signal directed at the connection that made it, and dbus-daemon delivers directed signals only to that connection. gdbus monitor registers with AddMatch rather than BecomeMonitor, so it never saw the reply: every pick left omarchy-file-select blocked on a read that could not arrive, taking omarchy-tailscale-send down with it before it reached either its notification or the transfer. Make the call and wait for the signal on one connection, and give up after ten minutes so an unanswered dialog cannot strand the caller. Drop the "Sending to" notification while here, so a send reports once. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Mark Taildrop notifications with the panel's send glyph Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Stop a hung tailscale poll from freezing the panel Each poll is skipped while its own process is still running, so one that never exits leaves the panel showing whatever it last read, for good: the peer list keeps a woken machine missing, and opening the panel cannot help because open runs the same refresh that hits the same guard. Reap anything still running fifteen seconds after a refresh, well inside the thirty second interval, so the next tick starts clean. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Place a moved widget where an added one lands 'move omarchy.media left' named a section, not a slot, but the section went through as an explicit target, which resolves a missing index by appending. The widget landed on the far end of the row instead of after the section anchor where 'add' puts it. Its test has never run: the assertion covering this went in four hours after an unrelated layout change had already stopped the file, and the runner stops the whole suite at the first failure. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Keep the config test from failing on things it is not about The center layout assertion pinned the whole row, so parking the indicators left of the clock broke a test named for update sitting next to weather. Assert that adjacency instead. The package-defaults check reads PKGBUILDs from the omarchy-pkgs repo and blew up with a traceback wherever that is not a sibling checkout. Skip it when the checkout is absent, honour OMARCHY_PKGS_ROOT when it is somewhere else, and keep failing when it is present and wrong. Between them these stopped the suite eighty files early. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Make the file chooser a Python command rather than a bash host for one The portal work was a heredoc wedged inside a bash script that existed only to parse two flags. Drop the host: argparse covers the flags, and the file says at the top why it is the one command here not written in bash. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Tell a chooser that never opened apart from one that was dismissed Three fixes from review: The poll watchdog rearmed on every refresh, so a refresh interval shorter than its timeout — the setting goes down to five seconds — pushed the deadline ahead of a hung process forever. Arm it on the launch that needs watching and leave it alone. omarchy-file-select exited 1 both for nothing picked and for a chooser that could not run, and omarchy-tailscale-send read it through a process substitution, which drops the status anyway. A session bus that was not there looked exactly like someone changing their mind. Separate the two exits and read them with a command substitution. Delivery picked a free name and then renamed, which overwrites anything that takes the name in between. Link to the name instead: link(2) refuses one that is taken, so the check and the claim are the same step. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
326 lines
10 KiB
JavaScript
326 lines
10 KiB
JavaScript
function filterIPv4(ips) {
|
|
var result = []
|
|
if (!ips || typeof ips.length !== "number") return result
|
|
for (var i = 0; i < ips.length; i++) {
|
|
var ip = String(ips[i] || "")
|
|
if (/^100\./.test(ip)) result.push(ip)
|
|
}
|
|
return result
|
|
}
|
|
|
|
function filterIPv6(ips) {
|
|
var result = []
|
|
if (!ips || typeof ips.length !== "number") return result
|
|
for (var i = 0; i < ips.length; i++) {
|
|
var ip = String(ips[i] || "")
|
|
if (/^fd7a:115c:a1e0:/i.test(ip)) result.push(ip)
|
|
}
|
|
return result
|
|
}
|
|
|
|
function cleanDnsName(name) {
|
|
var value = String(name || "")
|
|
return value.charAt(value.length - 1) === "." ? value.slice(0, -1) : value
|
|
}
|
|
|
|
function shortDnsName(name) {
|
|
var clean = cleanDnsName(name)
|
|
if (clean === "") return ""
|
|
return clean.split(".")[0] || clean
|
|
}
|
|
|
|
function displayHostName(hostName, dnsName) {
|
|
var host = String(hostName || "")
|
|
if (host !== "" && host.toLowerCase() !== "localhost") return host
|
|
return shortDnsName(dnsName) || host || "Unknown"
|
|
}
|
|
|
|
function isMullvadHost(name) {
|
|
var value = String(name || "").toLowerCase()
|
|
var suffix = ".mullvad.ts.net"
|
|
return value.length > suffix.length && value.indexOf(suffix) === value.length - suffix.length
|
|
}
|
|
|
|
function isMullvadPeer(peer) {
|
|
var hostName = String((peer && peer.HostName) || "")
|
|
var dnsName = cleanDnsName((peer && peer.DNSName) || "")
|
|
return isMullvadHost(dnsName) || isMullvadHost(hostName)
|
|
}
|
|
|
|
function osIcon(os) {
|
|
var value = String(os || "").toLowerCase()
|
|
if (value === "linux") return ""
|
|
if (value === "macos" || value === "ios") return ""
|
|
if (value === "windows") return ""
|
|
if (value === "android") return ""
|
|
if (value === "mullvad") return ""
|
|
return ""
|
|
}
|
|
|
|
function accountLabel(account) {
|
|
if (!account) return "Unknown account"
|
|
if (account.nickname) return String(account.nickname)
|
|
if (account.tailnet) return String(account.tailnet)
|
|
if (account.account) return String(account.account)
|
|
return String(account.id || "Unknown account")
|
|
}
|
|
|
|
function loginPlan(needsLogin, authUrl) {
|
|
var url = String(authUrl || "").trim()
|
|
if (needsLogin === true && /^https?:\/\//.test(url)) {
|
|
return { authUrl: url, command: [] }
|
|
}
|
|
return { authUrl: "", command: ["tailscale", "up"] }
|
|
}
|
|
|
|
// Taildrop is a tailnet feature the admin can turn off, so the button for it
|
|
// only makes sense when this profile actually carries the capability.
|
|
function hasFileSharing(self) {
|
|
var capability = "https://tailscale.com/cap/file-sharing"
|
|
var capMap = (self && self.CapMap) || null
|
|
if (capMap && capMap[capability] !== undefined) return true
|
|
var capabilities = (self && self.Capabilities) || []
|
|
for (var i = 0; i < capabilities.length; i++) {
|
|
if (String(capabilities[i]) === capability) return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// Tailscale grades every peer itself — offline, wrong owner, an OS without
|
|
// Taildrop, no peer API — so take its word when the status carries one, and
|
|
// fall back to same-owner for daemons too old to say.
|
|
function isTaildropTarget(peer, selfUserId) {
|
|
var target = peer && peer.TaildropTarget
|
|
if (typeof target === "number" && target !== 0) return target === 1
|
|
var owner = String((peer && peer.UserID) || "")
|
|
return owner !== "" && owner === String(selfUserId || "")
|
|
}
|
|
|
|
function peerFromStatus(id, peer) {
|
|
return {
|
|
id: id,
|
|
HostName: displayHostName(peer.HostName, peer.DNSName),
|
|
UserID: String(peer.UserID || ""),
|
|
TaildropTarget: typeof peer.TaildropTarget === "number" ? peer.TaildropTarget : 0,
|
|
DNSName: cleanDnsName(peer.DNSName),
|
|
DisplayName: displayHostName(peer.HostName, peer.DNSName),
|
|
TailscaleIPs: filterIPv4(peer.TailscaleIPs || []),
|
|
TailscaleIPv6: filterIPv6(peer.TailscaleIPs || []),
|
|
Online: peer.Online === true,
|
|
OS: String(peer.OS || ""),
|
|
Tags: peer.Tags || [],
|
|
ExitNodeOption: peer.ExitNodeOption === true,
|
|
ExitNode: peer.ExitNode === true,
|
|
Mullvad: isMullvadPeer(peer)
|
|
}
|
|
}
|
|
|
|
function sliceTableColumn(line, start, end) {
|
|
var text = String(line || "")
|
|
if (start < 0 || start >= text.length) return ""
|
|
if (end < 0) return text.substring(start).trim()
|
|
return text.substring(start, Math.min(end, text.length)).trim()
|
|
}
|
|
|
|
function parseExitNodeList(raw) {
|
|
var lines = String(raw || "").split(/\r?\n/)
|
|
var header = ""
|
|
var headerIndex = -1
|
|
for (var i = 0; i < lines.length; i++) {
|
|
if (/^\s*IP\s+HOSTNAME\s+COUNTRY\s+CITY\s+STATUS\s*$/.test(lines[i])) {
|
|
header = lines[i]
|
|
headerIndex = i
|
|
break
|
|
}
|
|
}
|
|
if (headerIndex === -1) return []
|
|
|
|
var ipStart = header.indexOf("IP")
|
|
var hostStart = header.indexOf("HOSTNAME")
|
|
var countryStart = header.indexOf("COUNTRY")
|
|
var cityStart = header.indexOf("CITY")
|
|
var statusStart = header.indexOf("STATUS")
|
|
var byHost = {}
|
|
|
|
for (var j = headerIndex + 1; j < lines.length; j++) {
|
|
var line = lines[j]
|
|
if (/^\s*$/.test(line) || /^\s*#/.test(line)) continue
|
|
|
|
var ip = sliceTableColumn(line, ipStart, hostStart)
|
|
var host = sliceTableColumn(line, hostStart, countryStart)
|
|
var country = sliceTableColumn(line, countryStart, cityStart)
|
|
var city = sliceTableColumn(line, cityStart, statusStart)
|
|
var status = sliceTableColumn(line, statusStart, -1)
|
|
if (!isMullvadHost(host)) continue
|
|
|
|
byHost[host] = {
|
|
id: "mullvad:" + host,
|
|
HostName: host,
|
|
DNSName: host,
|
|
DisplayName: (city && city !== "Any" ? city + ", " : "") + country,
|
|
TailscaleIPs: ip ? [ip] : [],
|
|
TailscaleIPv6: [],
|
|
Online: true,
|
|
OS: "mullvad",
|
|
Tags: [],
|
|
ExitNodeOption: true,
|
|
ExitNode: status !== "" && status !== "-",
|
|
Mullvad: true,
|
|
Country: country,
|
|
City: city,
|
|
Status: status
|
|
}
|
|
}
|
|
|
|
var result = []
|
|
for (var hostName in byHost) result.push(byHost[hostName])
|
|
result.sort(function(a, b) {
|
|
var countryCompare = String(a.Country).localeCompare(String(b.Country))
|
|
if (countryCompare !== 0) return countryCompare
|
|
return String(a.DisplayName).localeCompare(String(b.DisplayName))
|
|
})
|
|
return result
|
|
}
|
|
|
|
function mullvadRegionOptions(nodes) {
|
|
var byRegion = {}
|
|
var values = Array.isArray(nodes) ? nodes : []
|
|
for (var i = 0; i < values.length; i++) {
|
|
var node = values[i] || {}
|
|
if (node.Mullvad !== true) continue
|
|
var country = String(node.Country || "").trim()
|
|
var city = String(node.City || "").trim()
|
|
if (country === "") continue
|
|
if (city === "" || city === "Any") continue
|
|
|
|
var key = country + "\n" + city
|
|
if (byRegion[key]) continue
|
|
|
|
var option = {}
|
|
for (var propertyName in node) option[propertyName] = node[propertyName]
|
|
option.id = "mullvad-region:" + key
|
|
option.DisplayName = city + ", " + country
|
|
option.Country = country
|
|
option.City = city
|
|
option.MullvadRegion = true
|
|
byRegion[key] = option
|
|
}
|
|
|
|
var result = []
|
|
for (var name in byRegion) result.push(byRegion[name])
|
|
result.sort(function(a, b) {
|
|
var countryCompare = String(a.Country).localeCompare(String(b.Country))
|
|
if (countryCompare !== 0) return countryCompare
|
|
return String(a.City).localeCompare(String(b.City))
|
|
})
|
|
return result
|
|
}
|
|
|
|
function mullvadCountryOptions(nodes) {
|
|
return mullvadRegionOptions(nodes)
|
|
}
|
|
|
|
function parseStatus(raw) {
|
|
var text = String(raw || "").trim()
|
|
if (text === "") return { ok: true, unavailable: true, message: "Disconnected" }
|
|
|
|
try {
|
|
var data = JSON.parse(text)
|
|
var backendState = String(data.BackendState || "Unknown")
|
|
var self = data.Self || {}
|
|
var selfIps = filterIPv4(self.TailscaleIPs || data.TailscaleIPs || [])
|
|
var peers = []
|
|
var exitNodes = []
|
|
var rawPeers = data.Peer || {}
|
|
|
|
for (var id in rawPeers) {
|
|
var peer = rawPeers[id] || {}
|
|
var normalized = peerFromStatus(id, peer)
|
|
if (normalized.Mullvad) continue
|
|
if (normalized.Online) {
|
|
peers.push(normalized)
|
|
if (normalized.ExitNodeOption) exitNodes.push(normalized)
|
|
}
|
|
}
|
|
|
|
peers.sort(function(a, b) {
|
|
return String(a.HostName).localeCompare(String(b.HostName))
|
|
})
|
|
exitNodes.sort(function(a, b) {
|
|
return String(a.HostName).localeCompare(String(b.HostName))
|
|
})
|
|
|
|
return {
|
|
ok: true,
|
|
unavailable: false,
|
|
backendState: backendState,
|
|
running: backendState === "Running",
|
|
needsLogin: backendState === "NeedsLogin",
|
|
authUrl: String(data.AuthURL || ""),
|
|
selfName: displayHostName(self.HostName, self.DNSName),
|
|
selfDnsName: cleanDnsName(self.DNSName),
|
|
selfIp: selfIps.length > 0 ? selfIps[0] : "",
|
|
selfUserId: String(self.UserID || ""),
|
|
fileSharing: hasFileSharing(self),
|
|
peers: peers,
|
|
exitNodes: exitNodes
|
|
}
|
|
} catch (e) {
|
|
return { ok: false, unavailable: true, message: "Status error", error: "Failed to parse tailscale status" }
|
|
}
|
|
}
|
|
|
|
function parseAccounts(raw) {
|
|
var text = String(raw || "").trim()
|
|
if (text === "") return { accounts: [], selectedAccountId: "", selectedAccountLabel: "" }
|
|
|
|
try {
|
|
var parsed = JSON.parse(text)
|
|
var next = []
|
|
var selected = null
|
|
if (parsed && typeof parsed.length === "number") {
|
|
for (var i = 0; i < parsed.length; i++) {
|
|
var rawAccount = parsed[i] || {}
|
|
var account = {
|
|
id: String(rawAccount.id || rawAccount.ID || ""),
|
|
nickname: String(rawAccount.nickname || rawAccount.Nickname || rawAccount.name || rawAccount.Name || ""),
|
|
tailnet: String(rawAccount.tailnet || rawAccount.Tailnet || ""),
|
|
account: String(rawAccount.account || rawAccount.Account || rawAccount.loginName || rawAccount.LoginName || rawAccount.user || rawAccount.User || ""),
|
|
selected: rawAccount.selected === true || rawAccount.Selected === true
|
|
}
|
|
next.push(account)
|
|
if (account.selected === true) selected = account
|
|
}
|
|
}
|
|
return {
|
|
accounts: next,
|
|
selectedAccountId: selected ? String(selected.id || "") : "",
|
|
selectedAccountLabel: selected ? accountLabel(selected) : ""
|
|
}
|
|
} catch (e) {
|
|
return { accounts: [], selectedAccountId: "", selectedAccountLabel: "" }
|
|
}
|
|
}
|
|
|
|
if (typeof module !== "undefined") {
|
|
module.exports = {
|
|
filterIPv4: filterIPv4,
|
|
filterIPv6: filterIPv6,
|
|
cleanDnsName: cleanDnsName,
|
|
shortDnsName: shortDnsName,
|
|
displayHostName: displayHostName,
|
|
osIcon: osIcon,
|
|
accountLabel: accountLabel,
|
|
loginPlan: loginPlan,
|
|
hasFileSharing: hasFileSharing,
|
|
isTaildropTarget: isTaildropTarget,
|
|
isMullvadPeer: isMullvadPeer,
|
|
peerFromStatus: peerFromStatus,
|
|
parseExitNodeList: parseExitNodeList,
|
|
mullvadRegionOptions: mullvadRegionOptions,
|
|
mullvadCountryOptions: mullvadCountryOptions,
|
|
parseStatus: parseStatus,
|
|
parseAccounts: parseAccounts
|
|
}
|
|
}
|