mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 15:19:07 +01:00
Merge pull request #5161
845c86d Do not use third party services for IP detection. (Gregory Maxwell)
This commit is contained in:
41
src/main.cpp
41
src/main.cpp
@@ -3478,12 +3478,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
else
|
||||
pfrom->fRelayTxes = true;
|
||||
|
||||
if (pfrom->fInbound && addrMe.IsRoutable())
|
||||
{
|
||||
pfrom->addrLocal = addrMe;
|
||||
SeenLocal(addrMe);
|
||||
}
|
||||
|
||||
// Disconnect if we connected to ourself
|
||||
if (nNonce == nLocalHostNonce && nNonce > 1)
|
||||
{
|
||||
@@ -3492,6 +3486,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
return true;
|
||||
}
|
||||
|
||||
pfrom->addrLocal = addrMe;
|
||||
if (pfrom->fInbound && addrMe.IsRoutable())
|
||||
{
|
||||
SeenLocal(addrMe);
|
||||
}
|
||||
|
||||
// Be shy and don't send version until we hear
|
||||
if (pfrom->fInbound)
|
||||
pfrom->PushVersion();
|
||||
@@ -3512,7 +3512,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
{
|
||||
CAddress addr = GetLocalAddress(&pfrom->addr);
|
||||
if (addr.IsRoutable())
|
||||
{
|
||||
pfrom->PushAddress(addr);
|
||||
} else if (IsPeerAddrLocalGood(pfrom)) {
|
||||
addr.SetIP(pfrom->addrLocal);
|
||||
pfrom->PushAddress(addr);
|
||||
}
|
||||
}
|
||||
|
||||
// Get recent addresses
|
||||
@@ -4375,24 +4380,18 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
||||
static int64_t nLastRebroadcast;
|
||||
if (!IsInitialBlockDownload() && (GetTime() - nLastRebroadcast > 24 * 60 * 60))
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
||||
{
|
||||
// Periodically clear setAddrKnown to allow refresh broadcasts
|
||||
if (nLastRebroadcast)
|
||||
pnode->setAddrKnown.clear();
|
||||
// Periodically clear setAddrKnown to allow refresh broadcasts
|
||||
if (nLastRebroadcast)
|
||||
pnode->setAddrKnown.clear();
|
||||
|
||||
// Rebroadcast our address
|
||||
if (fListen)
|
||||
{
|
||||
CAddress addr = GetLocalAddress(&pnode->addr);
|
||||
if (addr.IsRoutable())
|
||||
pnode->PushAddress(addr);
|
||||
}
|
||||
}
|
||||
// Rebroadcast our address
|
||||
AdvertizeLocal(pnode);
|
||||
}
|
||||
nLastRebroadcast = GetTime();
|
||||
if (!vNodes.empty())
|
||||
nLastRebroadcast = GetTime();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user