chore(macos): tidy discovery and runtime

main
Peter Steinberger 2025-12-20 23:30:05 +01:00
parent 43ba1671f1
commit df9e4bdd63
4 changed files with 9 additions and 9 deletions

View File

@ -327,10 +327,8 @@ final class GatewayDiscoveryModel {
return true return true
} }
if let service = normalizeServiceToken(serviceName) { if let service = normalizeServiceToken(serviceName) {
for token in local.hostTokens { for token in local.hostTokens where service.contains(token) {
if service.contains(token) { return true
return true
}
} }
} }
return false return false
@ -456,8 +454,9 @@ final class GatewayTXTResolver: NSObject, NetServiceDelegate {
func netServiceDidResolveAddress(_ sender: NetService) { func netServiceDidResolveAddress(_ sender: NetService) {
let txt = Self.decodeTXT(sender.txtRecordData()) let txt = Self.decodeTXT(sender.txtRecordData())
if !txt.isEmpty { if !txt.isEmpty {
let payload = self.formatTXT(txt)
self.logger.debug( self.logger.debug(
"discovery: resolved TXT for \(sender.name, privacy: .public): \(self.formatTXT(txt), privacy: .public)") "discovery: resolved TXT for \(sender.name, privacy: .public): \(payload, privacy: .public)")
} }
self.finish(result: .success(txt)) self.finish(result: .success(txt))
} }

View File

@ -585,7 +585,8 @@ extension GeneralSettings {
trimmed.localizedCaseInsensitiveContains("host key verification failed") trimmed.localizedCaseInsensitiveContains("host key verification failed")
{ {
let host = CommandResolver.parseSSHTarget(target)?.host ?? target let host = CommandResolver.parseSSHTarget(target)?.host ?? target
return "SSH check failed: Host key verification failed. Remove the old key with `ssh-keygen -R \(host)` and try again." return "SSH check failed: Host key verification failed. Remove the old key with " +
"`ssh-keygen -R \(host)` and try again."
} }
if let trimmed, !trimmed.isEmpty { if let trimmed, !trimmed.isEmpty {
if let message = response.message, message.hasPrefix("exit ") { if let message = response.message, message.hasPrefix("exit ") {

View File

@ -7,7 +7,7 @@ actor MacNodeRuntime {
private let cameraCapture = CameraCaptureService() private let cameraCapture = CameraCaptureService()
@MainActor private let screenRecorder = ScreenRecordService() @MainActor private let screenRecorder = ScreenRecordService()
// swiftlint:disable:next function_body_length // swiftlint:disable:next function_body_length cyclomatic_complexity
func handleInvoke(_ req: BridgeInvokeRequest) async -> BridgeInvokeResponse { func handleInvoke(_ req: BridgeInvokeRequest) async -> BridgeInvokeResponse {
let command = req.command let command = req.command
if command.hasPrefix("canvas.") || command.hasPrefix("canvas.a2ui."), !Self.canvasEnabled() { if command.hasPrefix("canvas.") || command.hasPrefix("canvas.a2ui."), !Self.canvasEnabled() {

View File

@ -56,8 +56,8 @@ enum ShellExecutor {
let err = stderrPipe.fileHandleForReading.readToEndSafely() let err = stderrPipe.fileHandleForReading.readToEndSafely()
let status = Int(process.terminationStatus) let status = Int(process.terminationStatus)
return ShellResult( return ShellResult(
stdout: String(decoding: out, as: UTF8.self), stdout: String(bytes: out, encoding: .utf8) ?? "",
stderr: String(decoding: err, as: UTF8.self), stderr: String(bytes: err, encoding: .utf8) ?? "",
exitCode: status, exitCode: status,
timedOut: false, timedOut: false,
success: status == 0, success: status == 0,