fix: normalize discovered IPv4 Cast receiver addresses

This commit is contained in:
2026-10-24 23:44:57 +02:00
parent f6fe617d92
commit 2391dadc75
3 changed files with 21 additions and 1 deletions
+9 -1
View File
@@ -115,9 +115,17 @@ final class CastDiscovery: ObservableObject {
let value = String(data: data, encoding: .utf8), !value.isEmpty else { return nil }
return value
}
// Network.framework scopes IPv4 to an interface; POSIX getaddrinfo
// rejects that suffix. IPv6 scope identifiers must remain intact.
let address: String
if case .ipv4 = host {
address = String(host.debugDescription.prefix { $0 != "%" })
} else {
address = host.debugDescription
}
resolved[endpoint] = CastDevice(id: text("id") ?? domain + type + name,
name: text("fn") ?? name,
host: host.debugDescription, port: port.rawValue)
host: address, port: port.rawValue)
}
services[endpoint]?.timeout?.cancel()
services[endpoint]?.timeout = nil