fix(mac): harden remote tunnel recovery

This commit is contained in:
Peter Steinberger
2026-01-03 00:02:27 +01:00
parent 88ed58b3d0
commit 9dd613edf7
7 changed files with 108 additions and 3 deletions

View File

@@ -84,6 +84,7 @@ final class ControlChannel {
}
func configure() async {
self.logger.info("control channel configure mode=local")
self.state = .connecting
do {
try await GatewayConnection.shared.refresh()
@@ -102,6 +103,9 @@ final class ControlChannel {
case let .remote(target, identity):
do {
_ = (target, identity)
let idSet = !identity.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
self.logger.info(
"control channel configure mode=remote target=\(target, privacy: .public) identitySet=\(idSet, privacy: .public)")
_ = try await GatewayEndpointStore.shared.ensureRemoteControlTunnel()
await self.configure()
} catch {
@@ -261,6 +265,15 @@ final class ControlChannel {
if mode == .local {
GatewayProcessManager.shared.setActive(true)
}
if mode == .remote {
do {
let port = try await GatewayEndpointStore.shared.ensureRemoteControlTunnel()
self.logger.info("control channel recovery ensured SSH tunnel port=\(port, privacy: .public)")
} catch {
self.logger.error(
"control channel recovery tunnel failed \(error.localizedDescription, privacy: .public)")
}
}
do {
try await GatewayConnection.shared.refresh()