Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ jobs:
key: spm-${{ runner.os }}-${{ hashFiles('project.yml') }}
restore-keys: spm-${{ runner.os }}-

# The tailscale-rs static archives are git-ignored (~115 MB for the four
# slices). The script pins the upstream commit and both toolchains, so
# its hash plus the header fully determine the output.
- name: Cache tailscale-rs archives
id: tailscale-rs
uses: actions/cache@v4
with:
path: Vendor/tailscale-rs/lib
key: tailscale-rs-${{ runner.os }}-${{ hashFiles('Tools/build-tailscale-rs.sh', 'Vendor/tailscale-rs/include/tailscale.h') }}

- name: Build tailscale-rs archives
if: steps.tailscale-rs.outputs.cache-hit != 'true'
run: ./Tools/build-tailscale-rs.sh

- name: Generate the Xcode project
run: ./Tools/build.sh gen

Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ xcuserdata/
# Dev harness artifacts (generated keys, sshd runtime state)
Tools/dev-sshd/state/

# Vendored tailscale-rs static archives (~17-44 MB each) — rebuild with
# Tools/build-tailscale-rs.sh; the header/modulemap stay tracked
Vendor/tailscale-rs/lib/

local-plan/

# fastlane — generated reports and local secrets (see fastlane/SETUP.md)
Expand Down
192 changes: 192 additions & 0 deletions Multiplex/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -2546,6 +2546,22 @@
}
}
},
"Auth key" : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "認証キー"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "驗證金鑰"
}
}
}
},
"auto submit" : {
"localizations" : {
"ja" : {
Expand Down Expand Up @@ -4220,6 +4236,22 @@
}
}
},
"Connect via Tailscale" : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "Tailscale経由で接続"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "透過 Tailscale 連線"
}
}
}
},
"Connect with mosh" : {
"localizations" : {
"ja" : {
Expand Down Expand Up @@ -4424,6 +4456,22 @@
}
}
},
"Control URL" : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "コントロールURL"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "控制伺服器 URL"
}
}
}
},
"Copy" : {
"localizations" : {
"ja" : {
Expand Down Expand Up @@ -6252,6 +6300,38 @@
}
}
},
"Experimental · SSH runs through this device's embedded Tailscale node. Add a reusable auth key in Settings. Mosh is unavailable on this path." : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "実験的機能 · SSHはこのデバイスに組み込まれたTailscaleノードを経由します。「設定」で再利用可能な認証キーを追加してください。この経路ではmoshを使用できません。"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "實驗性功能 · SSH 經由此裝置內建的 Tailscale 節點連線。請在「設定」中加入可重複使用的驗證金鑰。此路徑無法使用 mosh。"
}
}
}
},
"Experimental. Use a reusable auth key — it syncs through iCloud Keychain, and each device joins as its own tailnet node. The optional Headscale control URL stays on this device. Changes apply the next time the embedded node starts." : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "実験的機能です。再利用可能な認証キーを使用してください — キーはiCloudキーチェーンで同期され、各デバイスはそれぞれ独立したtailnetノードとして参加します。オプションのHeadscaleコントロールURLはこのデバイスにのみ保存されます。変更は組み込みノードの次回起動時に反映されます。"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "實驗性功能。請使用可重複使用的驗證金鑰——金鑰會透過 iCloud 鑰匙圈同步,每部裝置各自以獨立的 tailnet 節點加入。選用的 Headscale 控制伺服器 URL 只保留在此裝置上。變更會在內建節點下次啟動時生效。"
}
}
}
},
"File Path" : {
"localizations" : {
"ja" : {
Expand Down Expand Up @@ -8532,6 +8612,22 @@
}
}
},
"mosh can't run over the embedded Tailscale connection — turn one of them off." : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "moshは組み込みのTailscale接続上では動作しません — どちらか一方をオフにしてください。"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "mosh 無法在內建的 Tailscale 連線上執行——請關閉其中一項。"
}
}
}
},
"MOSH LINK — SRTT FROM EVERY DATAGRAM · LOSS FROM SEQUENCE GAPS" : {
"localizations" : {
"ja" : {
Expand Down Expand Up @@ -9744,6 +9840,22 @@
}
}
},
"No Tailscale auth key is set yet — add a reusable one in Settings › Tailscale, or this host can't connect." : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "Tailscaleの認証キーがまだ設定されていません — 「設定 › Tailscale」で再利用可能なキーを追加しないと、このホストに接続できません。"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "尚未設定 Tailscale 驗證金鑰——請在「設定 › Tailscale」中加入可重複使用的金鑰,否則此主機無法連線。"
}
}
}
},
"No terminal selected" : {
"localizations" : {
"ja" : {
Expand Down Expand Up @@ -10742,6 +10854,22 @@
}
}
},
"Optional · Headscale URL" : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "オプション · Headscale URL"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "選用 · Headscale URL"
}
}
}
},
"Optional initial prompt" : {
"localizations" : {
"ja" : {
Expand Down Expand Up @@ -12436,6 +12564,22 @@
}
}
},
"Routes this host's SSH connection through the embedded Tailscale node" : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "このホストのSSH接続を組み込みのTailscaleノード経由にします"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "讓此主機的 SSH 連線經由內建的 Tailscale 節點"
}
}
}
},
"Run" : {
"localizations" : {
"ja" : {
Expand Down Expand Up @@ -14193,6 +14337,22 @@
}
}
},
"Starts the embedded Tailscale node, signs in to SSH through it, then looks for %@ on the host." : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "組み込みのTailscaleノードを起動し、それを経由してSSHにサインインしてから、ホスト上の%@を探します。"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "啟動內建的 Tailscale 節點,經由它登入 SSH,然後在主機上尋找 %@。"
}
}
}
},
"stays open" : {
"localizations" : {
"ja" : {
Expand Down Expand Up @@ -14531,6 +14691,22 @@
}
}
},
"Tailscale auth key" : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "Tailscale認証キー"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "Tailscale 驗證金鑰"
}
}
}
},
"Tap again to forget. The next connection trusts whatever answers, and records that." : {
"localizations" : {
"ja" : {
Expand Down Expand Up @@ -15751,6 +15927,22 @@
}
}
},
"The Tailscale backend isn't available in this build." : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "このビルドではTailscaleバックエンドを利用できません。"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "此版本不提供 Tailscale 後端。"
}
}
}
},
"The terminal's canvas, text, and insertion cursor." : {
"localizations" : {
"ja" : {
Expand Down
5 changes: 5 additions & 0 deletions Multiplex/Models/Host.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ struct Host: Identifiable, Codable, Hashable {
/// The credentials above still authenticate the SSH bootstrap that
/// launches `mosh-server`; deck probing stays on SSH either way.
var useMosh: Bool = false
/// Reach this host's SSH endpoint through the app's embedded userspace
/// Tailscale node (tailscale-rs backend). Works on all three platforms;
/// for v1 it cannot carry mosh's datagram transport.
var useTailscale: Bool = false
/// The session backend the probe and attach paths use. Rides the synced
/// record, and deliberately participates in
/// `connectionModelConfiguration`: flipping it must tear down and
Expand Down Expand Up @@ -351,6 +355,7 @@ extension Host {
(try container.decodeIfPresent([String].self, forKey: .secondaryBackends) ?? [])
.compactMap(SessionBackend.init(rawValue:))
).subtracting([sessionBackend])
useTailscale = try container.decodeIfPresent(Bool.self, forKey: .useTailscale) ?? false
moshServerPath = try container.decodeIfPresent(String.self, forKey: .moshServerPath)
moshPorts = try container.decodeIfPresent(String.self, forKey: .moshPorts)
workingDirs = try container.decodeIfPresent([String].self, forKey: .workingDirs) ?? []
Expand Down
75 changes: 75 additions & 0 deletions Multiplex/Models/TailscaleRSDialAddress.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import Foundation

/// Pure classification of a Host's address for the tailscale-rs dial path.
/// tailscale-rs has no MagicDNS: a literal 100.x/IPv6 is parsed straight to
/// a sockaddr, while a hostname must be resolved to a peer IP via
/// `ts_peer_ipv4_addr` before dialing. This type decides which, and
/// normalizes the string the C layer parses — the actual `ts_*` calls stay
/// in the actor, so this stays module-free and unit-testable.
enum TailscaleRSDialAddress {
enum Target: Equatable {
/// A literal address `ts_parse_ip` can consume directly.
case literalIP(String)
/// A tailnet peer name to resolve via `ts_peer_ipv4_addr`. Any
/// surrounding brackets are stripped — peer lookup wants the bare
/// name.
case peerName(String)
}

static func classify(hostname: String) -> Target {
let trimmed = hostname.trimmingCharacters(in: .whitespaces)
let unbracketed: String
if trimmed.hasPrefix("["), trimmed.hasSuffix("]"), trimmed.count >= 2 {
unbracketed = String(trimmed.dropFirst().dropLast())
} else {
unbracketed = trimmed
}

if isIPv4(unbracketed) || isIPv6(unbracketed) {
return .literalIP(unbracketed)
}
return .peerName(unbracketed)
}

static func isIPv4(_ s: String) -> Bool {
let parts = s.split(separator: ".", omittingEmptySubsequences: false)
guard parts.count == 4 else { return false }
return parts.allSatisfy { part in
part.count >= 1 && part.count <= 3
&& part.allSatisfy(\.isNumber)
&& (Int(part).map { $0 >= 0 && $0 <= 255 } ?? false)
}
}

static func isIPv6(_ s: String) -> Bool {
// Loose but sufficient to tell a v6 literal from a hostname: hex
// groups and at least one colon, no characters a DNS/tailnet name
// would carry. `ts_parse_ip` is the real validator downstream.
guard s.contains(":") else { return false }
let allowed = CharacterSet(charactersIn: "0123456789abcdefABCDEF:.")
return s.unicodeScalars.allSatisfy { allowed.contains($0) }
}
}

enum TailscaleNodeHostname {
static func format(deviceName: String) -> String {
var sanitized = ""
var needsSeparator = false

for scalar in deviceName.lowercased().unicodeScalars {
let isLowercaseLetter = scalar.value >= 97 && scalar.value <= 122
let isDigit = scalar.value >= 48 && scalar.value <= 57
if isLowercaseLetter || isDigit {
if needsSeparator, !sanitized.isEmpty {
sanitized.append("-")
}
sanitized.unicodeScalars.append(scalar)
needsSeparator = false
} else if !sanitized.isEmpty {
needsSeparator = true
}
}

return sanitized.isEmpty ? "multiplex" : "multiplex-\(sanitized)"
}
}
Loading
Loading