fix: normalize discovered IPv4 Cast receiver addresses
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user