Skip to content

Commit

Permalink
fix: ignore interface with no link address (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tudyx authored Jul 26, 2022
1 parent 4c24d8d commit a213322
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ pub fn list_afinet_netifas() -> Result<Vec<(String, IpAddr)>, Error> {
while !(**ifa).ifa_next.is_null() {
let ifa_addr = (**ifa).ifa_addr;

// If a tun device is present, no link address is assigned to it and `ifa_addr` is null.
// See https://github.com/EstebanBorai/local-ip-address/issues/24
if ifa_addr.is_null() {
*ifa = (**ifa).ifa_next;
continue;
}

match (*ifa_addr).sa_family as i32 {
// AF_INET IPv4 protocol implementation
AF_INET => {
Expand Down

0 comments on commit a213322

Please sign in to comment.