File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -239,10 +239,14 @@ bool CActiveMasternodeManager::GetLocalAddress(CService& addrRet)
239239 if (!fFoundLocal ) {
240240 bool empty = true ;
241241 // If we have some peers, let's try to find our local address from one of them
242- auto service = m_info.service ;
243242 m_connman.ForEachNodeContinueIf (CConnman::AllNodes, [&](CNode* pnode) {
244243 empty = false ;
245- if (pnode->addr .IsIPv4 ()) fFoundLocal = GetLocal (service, *pnode) && IsValidNetAddr (service);
244+ if (pnode->addr .IsIPv4 ()) {
245+ if (auto addr = ::GetLocalAddress (*pnode); IsValidNetAddr (addr)) {
246+ addrRet = addr;
247+ fFoundLocal = true ;
248+ }
249+ }
246250 return !fFoundLocal ;
247251 });
248252 // nothing and no live connections, can't do anything for now
@@ -257,10 +261,10 @@ bool CActiveMasternodeManager::GetLocalAddress(CService& addrRet)
257261
258262bool CActiveMasternodeManager::IsValidNetAddr (const CService& addrIn)
259263{
264+ if (!addrIn.IsValid () || !addrIn.IsIPv4 ()) return false ;
260265 // TODO: regtest is fine with any addresses for now,
261266 // should probably be a bit smarter if one day we start to implement tests for this
262- return !Params ().RequireRoutableExternalIP () ||
263- (addrIn.IsIPv4 () && IsReachable (addrIn) && addrIn.IsRoutable ());
267+ return !Params ().RequireRoutableExternalIP () || (IsReachable (addrIn) && addrIn.IsRoutable ());
264268}
265269
266270template <template <typename > class EncryptedObj , typename Obj>
You can’t perform that action at this time.
0 commit comments