|
|
@ -164,8 +164,9 @@ int GetnScore(const CService& addr)
|
|
|
|
// Is our peer's addrLocal potentially useful as an external IP source?
|
|
|
|
// Is our peer's addrLocal potentially useful as an external IP source?
|
|
|
|
bool IsPeerAddrLocalGood(CNode *pnode)
|
|
|
|
bool IsPeerAddrLocalGood(CNode *pnode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return fDiscover && pnode->addr.IsRoutable() && pnode->addrLocal.IsRoutable() &&
|
|
|
|
CService addrLocal = pnode->GetAddrLocal();
|
|
|
|
!IsLimited(pnode->addrLocal.GetNetwork());
|
|
|
|
return fDiscover && pnode->addr.IsRoutable() && addrLocal.IsRoutable() &&
|
|
|
|
|
|
|
|
!IsLimited(addrLocal.GetNetwork());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// pushes our own address to a peer
|
|
|
|
// pushes our own address to a peer
|
|
|
@ -180,7 +181,7 @@ void AdvertiseLocal(CNode *pnode)
|
|
|
|
if (IsPeerAddrLocalGood(pnode) && (!addrLocal.IsRoutable() ||
|
|
|
|
if (IsPeerAddrLocalGood(pnode) && (!addrLocal.IsRoutable() ||
|
|
|
|
GetRand((GetnScore(addrLocal) > LOCAL_MANUAL) ? 8:2) == 0))
|
|
|
|
GetRand((GetnScore(addrLocal) > LOCAL_MANUAL) ? 8:2) == 0))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
addrLocal.SetIP(pnode->addrLocal);
|
|
|
|
addrLocal.SetIP(pnode->GetAddrLocal());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (addrLocal.IsRoutable())
|
|
|
|
if (addrLocal.IsRoutable())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -606,6 +607,20 @@ void CNode::MaybeSetAddrName(const std::string& addrNameIn) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CService CNode::GetAddrLocal() const {
|
|
|
|
|
|
|
|
LOCK(cs_addrLocal);
|
|
|
|
|
|
|
|
return addrLocal;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CNode::SetAddrLocal(const CService& addrLocalIn) {
|
|
|
|
|
|
|
|
LOCK(cs_addrLocal);
|
|
|
|
|
|
|
|
if (addrLocal.IsValid()) {
|
|
|
|
|
|
|
|
error("Addr local already set for node: %i. Refusing to change from %s to %s", id, addrLocal.ToString(), addrLocalIn.ToString());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
addrLocal = addrLocalIn;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#undef X
|
|
|
|
#undef X
|
|
|
|
#define X(name) stats.name = name
|
|
|
|
#define X(name) stats.name = name
|
|
|
|
void CNode::copyStats(CNodeStats &stats)
|
|
|
|
void CNode::copyStats(CNodeStats &stats)
|
|
|
@ -659,7 +674,8 @@ void CNode::copyStats(CNodeStats &stats)
|
|
|
|
stats.dPingWait = (((double)nPingUsecWait) / 1e6);
|
|
|
|
stats.dPingWait = (((double)nPingUsecWait) / 1e6);
|
|
|
|
|
|
|
|
|
|
|
|
// Leave string empty if addrLocal invalid (not filled in yet)
|
|
|
|
// Leave string empty if addrLocal invalid (not filled in yet)
|
|
|
|
stats.addrLocal = addrLocal.IsValid() ? addrLocal.ToString() : "";
|
|
|
|
CService addrLocalUnlocked = GetAddrLocal();
|
|
|
|
|
|
|
|
stats.addrLocal = addrLocalUnlocked.IsValid() ? addrLocalUnlocked.ToString() : "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#undef X
|
|
|
|
#undef X
|
|
|
|
|
|
|
|
|
|
|
|