diff --git a/Sources/tart/Commands/Run.swift b/Sources/tart/Commands/Run.swift index 09352ab..7590c12 100644 --- a/Sources/tart/Commands/Run.swift +++ b/Sources/tart/Commands/Run.swift @@ -290,7 +290,7 @@ struct Run: AsyncParsableCommand { try await vm!.start(recovery: recovery, resume: resume) if let vncImpl = vncImpl { - let vncURL = try await vncImpl.waitForURL() + let vncURL = try await vncImpl.waitForURL(netBridged: !netBridged.isEmpty) if noGraphics || ProcessInfo.processInfo.environment["CI"] != nil { print("VNC server is running at \(vncURL)") diff --git a/Sources/tart/VNC/FullFledgedVNC.swift b/Sources/tart/VNC/FullFledgedVNC.swift index bbcca4b..ae88b4d 100644 --- a/Sources/tart/VNC/FullFledgedVNC.swift +++ b/Sources/tart/VNC/FullFledgedVNC.swift @@ -15,7 +15,7 @@ class FullFledgedVNC: VNC { vnc.start() } - func waitForURL() async throws -> URL { + func waitForURL(netBridged: Bool) async throws -> URL { while true { // Port is 0 shortly after start(), // but will be initialized later diff --git a/Sources/tart/VNC/ScreenSharingVNC.swift b/Sources/tart/VNC/ScreenSharingVNC.swift index 11b78ff..52c1581 100644 --- a/Sources/tart/VNC/ScreenSharingVNC.swift +++ b/Sources/tart/VNC/ScreenSharingVNC.swift @@ -9,9 +9,9 @@ class ScreenSharingVNC: VNC { self.vmConfig = vmConfig } - func waitForURL() async throws -> URL { + func waitForURL(netBridged: Bool) async throws -> URL { let vmMACAddress = MACAddress(fromString: vmConfig.macAddress.string)! - let ip = try await IP.resolveIP(vmMACAddress, secondsToWait: 60) + let ip = try await IP.resolveIP(vmMACAddress, resolutionStrategy: netBridged ? .arp : .dhcp, secondsToWait: 60) if let ip = ip { return URL(string: "vnc://\(ip)")! diff --git a/Sources/tart/VNC/VNC.swift b/Sources/tart/VNC/VNC.swift index 76afe53..e1bf2f5 100644 --- a/Sources/tart/VNC/VNC.swift +++ b/Sources/tart/VNC/VNC.swift @@ -1,6 +1,6 @@ import Foundation protocol VNC { - func waitForURL() async throws -> URL + func waitForURL(netBridged: Bool) async throws -> URL func stop() throws }