mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-13 11:00:50 +00:00
18 lines
428 B
Swift
18 lines
428 B
Swift
import Foundation
|
|
|
|
public enum NetworkInterfaces {
|
|
public static func primaryIPv4Address() -> String? {
|
|
var fallback: String?
|
|
var en0: String?
|
|
for entry in NetworkInterfaceIPv4.addresses() {
|
|
if entry.name == "en0" {
|
|
en0 = entry.ip
|
|
break
|
|
}
|
|
if fallback == nil { fallback = entry.ip }
|
|
}
|
|
|
|
return en0 ?? fallback
|
|
}
|
|
}
|