diff --git a/apps/ios/Sources/Bridge/BridgeSession.swift b/apps/ios/Sources/Bridge/BridgeSession.swift index 4d0e11815..db3be5a8c 100644 --- a/apps/ios/Sources/Bridge/BridgeSession.swift +++ b/apps/ios/Sources/Bridge/BridgeSession.swift @@ -27,12 +27,32 @@ actor BridgeSession { private static func prettyRemoteEndpoint(_ endpoint: NWEndpoint) -> String? { switch endpoint { case let .hostPort(host, port): - "\(host):\(port)".replacingOccurrences(of: "::ffff:", with: "") + let hostString = Self.prettyHostString(host) + if hostString.contains(":") { + return "[\(hostString)]:\(port)" + } + return "\(hostString):\(port)" default: - String(describing: endpoint) + return String(describing: endpoint) } } + private static func prettyHostString(_ host: NWEndpoint.Host) -> String { + var hostString = String(describing: host) + hostString = hostString.replacingOccurrences(of: "::ffff:", with: "") + + guard let percentIndex = hostString.firstIndex(of: "%") else { return hostString } + + let prefix = hostString[..