diff options
author | laanwj <126646+laanwj@users.noreply.github.com> | 2024-04-28 11:35:27 +0200 |
---|---|---|
committer | laanwj <126646+laanwj@users.noreply.github.com> | 2024-04-28 11:37:54 +0200 |
commit | 7766dd280d9a4a7ffdfcec58224d0985cfd4169b (patch) | |
tree | e038bd90ccf6fe5f007da9d4458c114c3d901da3 /src/net.cpp | |
parent | 3aaf7328eb656b642e5f0f74f3e4d51645a1d0ab (diff) | |
download | bitcoin-7766dd280d9a4a7ffdfcec58224d0985cfd4169b.tar.xz |
net: Replace ifname check with IFF_LOOPBACK in Discover
Checking the interface name is kind of brittle. In the age of network
namespaces and containers, there is no reason a loopback interface can't
be called differently.
Check for the `IFF_LOOPBACK` flag to detect loopback interface instead.
Diffstat (limited to 'src/net.cpp')
-rw-r--r-- | src/net.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/net.cpp b/src/net.cpp index 4801f5c1f9..7e60ef6df5 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -3077,8 +3077,7 @@ void Discover() { if (ifa->ifa_addr == nullptr) continue; if ((ifa->ifa_flags & IFF_UP) == 0) continue; - if (strcmp(ifa->ifa_name, "lo") == 0) continue; - if (strcmp(ifa->ifa_name, "lo0") == 0) continue; + if ((ifa->ifa_flags & IFF_LOOPBACK) != 0) continue; if (ifa->ifa_addr->sa_family == AF_INET) { struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr); |