Skip to content

Commit fdbb43e

Browse files
authored
Merge pull request #2002 from Tetrix42/dynIP
Don't rely on external IP resolvers.
2 parents 7ec249b + 0985fdd commit fdbb43e

File tree

5 files changed

+133
-389
lines changed

5 files changed

+133
-389
lines changed

src/init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ bool AppInit2(ThreadHandlerPtr threads)
781781
for (int n = 0; n < NET_MAX; n++) {
782782
enum Network net = (enum Network)n;
783783
if (!nets.count(net))
784-
SetLimited(net);
784+
SetReachable(net, false);
785785
}
786786
}
787787

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

818818
// see Step 2: parameter interactions for more information about these

src/main.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3872,9 +3872,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
38723872

38733873

38743874

3875+
pfrom->addrLocal = addrMe;
38753876
if (pfrom->fInbound && addrMe.IsRoutable())
38763877
{
3877-
pfrom->addrLocal = addrMe;
38783878
SeenLocal(addrMe);
38793879
}
38803880

@@ -3912,9 +3912,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
39123912
// Advertise our address
39133913
if (!fNoListen && !IsInitialBlockDownload())
39143914
{
3915-
CAddress addr = GetLocalAddress(&pfrom->addr);
3916-
if (addr.IsRoutable())
3917-
pfrom->PushAddress(addr);
3915+
AdvertiseLocal(pfrom);
39183916
}
39193917

39203918
// Get recent addresses
@@ -4737,27 +4735,19 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
47374735
ResendWalletTransactions();
47384736

47394737
// Address refresh broadcast
4740-
static int64_t nLastRebroadcast;
4741-
if (!IsInitialBlockDownload() && ( GetAdjustedTime() - nLastRebroadcast > 24 * 60 * 60))
4738+
if (!IsInitialBlockDownload())
47424739
{
4740+
if (GetAdjustedTime() > pto->nNextRebroadcastTime)
47434741
{
4744-
LOCK(cs_vNodes);
4745-
for (auto const& pnode : vNodes)
4742+
// Periodically clear setAddrKnown to allow refresh broadcasts
4743+
//pnode->setAddrKnown.clear();
4744+
// Rebroadcast our address
4745+
if (!fNoListen)
47464746
{
4747-
// Periodically clear setAddrKnown to allow refresh broadcasts
4748-
if (nLastRebroadcast)
4749-
pnode->setAddrKnown.clear();
4750-
4751-
// Rebroadcast our address
4752-
if (!fNoListen)
4753-
{
4754-
CAddress addr = GetLocalAddress(&pnode->addr);
4755-
if (addr.IsRoutable())
4756-
pnode->PushAddress(addr);
4757-
}
4747+
AdvertiseLocal(pto);
4748+
pto->nNextRebroadcastTime = GetAdjustedTime() + 12*60*60 + GetRand(12*60*60);
47584749
}
47594750
}
4760-
nLastRebroadcast = GetAdjustedTime();
47614751
}
47624752

47634753
//

0 commit comments

Comments
 (0)