Add network connection check

This commit is contained in:
Leon Böttger committed 2025-05-16 10:47:39 +02:00
1 parent 6f1c4f4cf9
commit d9f23f9b44
10 files changed
+111 -331

No files matched your search

+4 -2
View File
@@ -11,10 +11,12 @@ import Network
class IPv6DeviceScanner {
/// Scans for IPv6 devices using `ping6 ff02::1` multicast on the given interface.
/// - Parameters:
/// - interface: The interface to scan on (e.g. "en0").
/// - timeout: How long to wait for replies (default 2 seconds).
/// - completion: Callback with a list of detected device IPs (excluding router).
func scan(interface: String = "en0", timeout: TimeInterval = 2.0, completion: @escaping ([String]) -> Void) {
func scan(timeout: TimeInterval = 2.0, completion: @escaping ([String]) -> Void) {
let interface = getActiveNetworkInterface() ?? "en0"
let process = Process()
process.executableURL = URL(fileURLWithPath: "/sbin/ping6")
process.arguments = ["-I", interface, "-c", "2", "ff02::1"]