Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: Don't rely on external IP resolvers. #2002

Merged
merged 1 commit into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ bool AppInit2(ThreadHandlerPtr threads)
for (int n = 0; n < NET_MAX; n++) {
enum Network net = (enum Network)n;
if (!nets.count(net))
SetLimited(net);
SetReachable(net, false);
}
}

Expand Down Expand Up @@ -812,7 +812,7 @@ bool AppInit2(ThreadHandlerPtr threads)
if (!addrOnion.IsValid())
return InitError(strprintf(_("Invalid -tor address: '%s'"), mapArgs["-tor"]));
SetProxy(NET_TOR, addrOnion, 5);
SetReachable(NET_TOR);
SetReachable(NET_TOR, true);
}

// see Step 2: parameter interactions for more information about these
Expand Down
30 changes: 10 additions & 20 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3872,9 +3872,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,



pfrom->addrLocal = addrMe;
if (pfrom->fInbound && addrMe.IsRoutable())
{
pfrom->addrLocal = addrMe;
SeenLocal(addrMe);
}

Expand Down Expand Up @@ -3912,9 +3912,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// Advertise our address
if (!fNoListen && !IsInitialBlockDownload())
{
CAddress addr = GetLocalAddress(&pfrom->addr);
if (addr.IsRoutable())
pfrom->PushAddress(addr);
AdvertiseLocal(pfrom);
}

// Get recent addresses
Expand Down Expand Up @@ -4737,27 +4735,19 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
ResendWalletTransactions();

// Address refresh broadcast
static int64_t nLastRebroadcast;
if (!IsInitialBlockDownload() && ( GetAdjustedTime() - nLastRebroadcast > 24 * 60 * 60))
if (!IsInitialBlockDownload())
{
if (GetAdjustedTime() > pto->nNextRebroadcastTime)
{
LOCK(cs_vNodes);
for (auto const& pnode : vNodes)
// Periodically clear setAddrKnown to allow refresh broadcasts
//pnode->setAddrKnown.clear();
// Rebroadcast our address
if (!fNoListen)
{
// Periodically clear setAddrKnown to allow refresh broadcasts
if (nLastRebroadcast)
pnode->setAddrKnown.clear();

// Rebroadcast our address
if (!fNoListen)
{
CAddress addr = GetLocalAddress(&pnode->addr);
if (addr.IsRoutable())
pnode->PushAddress(addr);
}
AdvertiseLocal(pto);
pto->nNextRebroadcastTime = GetAdjustedTime() + 12*60*60 + GetRand(12*60*60);
}
}
nLastRebroadcast = GetAdjustedTime();
}

//
Expand Down
Loading