Skip to content

Commit 63081f1

Browse files
setoelkahfiCopilot
andcommitted
fix(tvos): bind DeviceKit server on IPv6 tunnel hosts
Allow the tvOS XCTest server to bind CoreDevice IPv6 tunnel addresses while preserving IPv4 localhost behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 53c79e6 commit 63081f1

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

DeviceKitTests/XCTestServer.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import FlyingFox
2+
import FlyingSocks
23
import Foundation
34
import os
45

@@ -100,7 +101,7 @@ final class XCTestServer {
100101
func start() async throws {
101102
let port = ProcessInfo.processInfo.environment["DEVICEKIT_LISTEN_PORT"]?.toUInt16() ?? defaultPort
102103
let server = HTTPServer(
103-
address: try .inet(ip4: localhost, port: port),
104+
address: try listenAddress(host: localhost, port: port),
104105
timeout: defaultTimeout
105106
)
106107

@@ -134,5 +135,11 @@ final class XCTestServer {
134135
logger.info("Server is ready (WebSocket: ws://\(self.localhost):\(port)/ws, HTTP: POST http://\(self.localhost):\(port)/rpc, MJPEG: http://\(self.localhost):\(port)/mjpeg)")
135136
try await server.run()
136137
}
137-
}
138138

139+
private func listenAddress(host: String, port: UInt16) throws -> any SocketAddress {
140+
if host.contains(":") {
141+
return try sockaddr_in6.inet6(ip6: host, port: port)
142+
}
143+
return try sockaddr_in.inet(ip4: host, port: port)
144+
}
145+
}

0 commit comments

Comments
 (0)