Feature Enhancement Planning

Nucleic-Session: 3CD3A375-8BC1-407E-951F-8EF136B08390
Co-authored-by: Nucleic <[email protected]>
This commit is contained in:
2026-07-04 23:50:53 -07:00
co-authored by Nucleic
parent ae951e45e7
commit 8701b2516e
@@ -177,6 +177,39 @@ final class HostConnection {
callbacks.didUpdate()
}
/// Translate a gossiped mesh member (mesh "join") into a pinnable/dialable `PairedHost`. The
/// member carries the host static key + last-known addresses — everything IK reconnect needs.
/// No relay token yet (the phone never directly paired this Mac); it's adopted from the host's
/// `relayMembership` push after the first LAN/tailnet contact, so first contact needs one of
/// those paths.
static func pairedHost(from member: MeshMember) -> PairedHost {
let (lanHost, lanPort) = splitHostPort(member.addresses?.lanHint)
let tailnetHost = member.addresses?.tailnet
let hasTailnet = !(tailnetHost?.isEmpty ?? true)
return PairedHost(
deviceID: IdentityStore.deviceID(),
hostName: member.label,
hostStaticKey: member.staticPublicKey,
fingerprint: member.staticPublicKey.fingerprintHex,
lanHost: lanHost, lanPort: lanPort,
transport: (hasTailnet ? SyncTransportHint.tailnet : .lan).rawValue,
tailnetHost: hasTailnet ? tailnetHost : nil,
// The sync port on a tailnet is fixed protocol-wide (SyncTransportSetting.tailnetPort);
// a gossiped address carries only the IP.
tailnetPort: hasTailnet ? 43_753 : nil,
relayRoomID: member.addresses?.relayRoomID,
relayMembershipToken: nil, relayURL: nil)
}
/// Split a "host:port" hint (last-colon split so a bracketed IPv6 host survives).
private static func splitHostPort(_ hint: String?) -> (String?, UInt16?) {
guard let hint, let colon = hint.lastIndex(of: ":"),
let port = UInt16(hint[hint.index(after: colon)...]) else { return (nil, nil) }
var host = String(hint[..<colon])
if host.hasPrefix("["), host.hasSuffix("]") { host = String(host.dropFirst().dropLast()) }
return (host.isEmpty ? nil : host, port)
}
private func buildCandidates(
fingerprint: String?, lanHost: String?, lanPort: UInt16?,
tailnet: (host: String?, port: UInt16?)?,