mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
Fix CActiveMasternodeManager::GetLocalAddress to prefer IPv4 if multiple local addresses are known (#3304)
* Fix CActiveMasternodeManager::GetLocalAddress to prefer IPv4 if multiple local addresses are known * Make sure LookupHost succeeded
This commit is contained in:
parent
e4ef7e8d09
commit
546e69f1af
@ -177,8 +177,15 @@ void CActiveMasternodeManager::UpdatedBlockTip(const CBlockIndex* pindexNew, con
|
|||||||
|
|
||||||
bool CActiveMasternodeManager::GetLocalAddress(CService& addrRet)
|
bool CActiveMasternodeManager::GetLocalAddress(CService& addrRet)
|
||||||
{
|
{
|
||||||
// First try to find whatever local address is specified by externalip option
|
// First try to find whatever our own local address is known internally.
|
||||||
bool fFoundLocal = GetLocal(addrRet) && IsValidNetAddr(addrRet);
|
// Addresses could be specified via externalip or bind option, discovered via UPnP
|
||||||
|
// or added by TorController. Use some random dummy IPv4 peer to prefer the one
|
||||||
|
// reachable via IPv4.
|
||||||
|
CNetAddr addrDummyPeer;
|
||||||
|
bool fFoundLocal{false};
|
||||||
|
if (LookupHost("8.8.8.8", addrDummyPeer, false)) {
|
||||||
|
fFoundLocal = GetLocal(addrRet, &addrDummyPeer) && IsValidNetAddr(addrRet);
|
||||||
|
}
|
||||||
if (!fFoundLocal && Params().NetworkIDString() == CBaseChainParams::REGTEST) {
|
if (!fFoundLocal && Params().NetworkIDString() == CBaseChainParams::REGTEST) {
|
||||||
if (Lookup("127.0.0.1", addrRet, GetListenPort(), false)) {
|
if (Lookup("127.0.0.1", addrRet, GetListenPort(), false)) {
|
||||||
fFoundLocal = true;
|
fFoundLocal = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user