From f4af02e827b97a051bd12b813d4e09fcc41b45c3 Mon Sep 17 00:00:00 2001 From: will Date: Fri, 20 Mar 2026 10:39:30 +0000 Subject: [PATCH] net: add an add_even_if_unreachable argument to AddLocal Prepare for letting explicitly configured local addresses bypass the reachable-net filter without tying that behavior to LOCAL_MANUAL score. Pass an `add_even_if_unreachable` bool through `AddLocal()`, defaulting to `false`. --- src/net.cpp | 6 +++--- src/net.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index d046c2a2722..c903afc653f 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -274,7 +274,7 @@ void ClearLocal() } // learn a new local address -bool AddLocal(const CService& addr_, int nScore) +bool AddLocal(const CService& addr_, int nScore, bool add_even_if_unreachable) { CService addr{MaybeFlipIPv6toCJDNS(addr_)}; @@ -304,9 +304,9 @@ bool AddLocal(const CService& addr_, int nScore) return true; } -bool AddLocal(const CNetAddr &addr, int nScore) +bool AddLocal(const CNetAddr& addr, int nScore, bool add_even_if_unreachable) { - return AddLocal(CService(addr, GetListenPort()), nScore); + return AddLocal(CService(addr, GetListenPort()), nScore, add_even_if_unreachable); } void RemoveLocal(const CService& addr) diff --git a/src/net.h b/src/net.h index 928d518eda6..62e97b48944 100644 --- a/src/net.h +++ b/src/net.h @@ -164,8 +164,8 @@ enum std::optional GetLocalAddrForPeer(CNode& node); void ClearLocal(); -bool AddLocal(const CService& addr, int nScore = LOCAL_NONE); -bool AddLocal(const CNetAddr& addr, int nScore = LOCAL_NONE); +bool AddLocal(const CService& addr, int nScore = LOCAL_NONE, bool add_even_if_unreachable = false); +bool AddLocal(const CNetAddr& addr, int nScore = LOCAL_NONE, bool add_even_if_unreachable = false); void RemoveLocal(const CService& addr); bool SeenLocal(const CService& addr); bool IsLocal(const CService& addr);