aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorlaanwj <126646+laanwj@users.noreply.github.com>2024-04-28 11:35:27 +0200
committerlaanwj <126646+laanwj@users.noreply.github.com>2024-04-28 11:37:54 +0200
commit7766dd280d9a4a7ffdfcec58224d0985cfd4169b (patch)
treee038bd90ccf6fe5f007da9d4458c114c3d901da3 /src/net.cpp
parent3aaf7328eb656b642e5f0f74f3e4d51645a1d0ab (diff)
downloadbitcoin-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.cpp3
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);