Skip to content

Commit 9444aa5

Browse files
authored
fix(mac): skip network interfaces without an address (#129265)
1 parent 8c9b6b1 commit 9444aa5

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎apps/shared/OpenClawKit/Sources/OpenClawKit/NetworkInterfaceIPv4.swift‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ public enum NetworkInterfaceIPv4 {
1717
let flags = Int32(ptr.pointee.ifa_flags)
1818
let isUp = (flags & IFF_UP) != 0
1919
let isLoopback = (flags & IFF_LOOPBACK) != 0
20-
let family = ptr.pointee.ifa_addr.pointee.sa_family
21-
if !isUp || isLoopback || family != UInt8(AF_INET) { continue }
20+
guard isUp, !isLoopback, let addrPtr = ptr.pointee.ifa_addr,
21+
addrPtr.pointee.sa_family == UInt8(AF_INET) else { continue }
2222

23-
var addr = ptr.pointee.ifa_addr.pointee
23+
var addr = addrPtr.pointee
2424
var buffer = [CChar](repeating: 0, count: Int(NI_MAXHOST))
2525
let result = getnameinfo(
2626
&addr,
27-
socklen_t(ptr.pointee.ifa_addr.pointee.sa_len),
27+
socklen_t(addrPtr.pointee.sa_len),
2828
&buffer,
2929
socklen_t(buffer.count),
3030
nil,

0 commit comments

Comments
 (0)