mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
merge bitcoin#20018: ProcessAddrFetch(-seednode) is unnecessary if -connect is specified
This commit is contained in:
parent
0c243ab4f5
commit
c0e6792e27
@ -2439,6 +2439,13 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
if (connect.size() != 1 || connect[0] != "0") {
|
if (connect.size() != 1 || connect[0] != "0") {
|
||||||
connOptions.m_specified_outgoing = connect;
|
connOptions.m_specified_outgoing = connect;
|
||||||
}
|
}
|
||||||
|
if (!connOptions.m_specified_outgoing.empty() && !connOptions.vSeedNodes.empty()) {
|
||||||
|
LogPrintf("-seednode is ignored when -connect is used\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.IsArgSet("-dnsseed") && args.GetBoolArg("-dnsseed", DEFAULT_DNSSEED) && args.IsArgSet("-proxy")) {
|
||||||
|
LogPrintf("-dnsseed is ignored when -connect is used and -proxy is specified\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string sem_str = args.GetArg("-socketevents", DEFAULT_SOCKETEVENTS);
|
std::string sem_str = args.GetArg("-socketevents", DEFAULT_SOCKETEVENTS);
|
||||||
|
@ -2471,6 +2471,8 @@ void CConnman::ThreadDNSAddressSeed()
|
|||||||
}
|
}
|
||||||
|
|
||||||
LogPrintf("Loading addresses from DNS seed %s\n", seed);
|
LogPrintf("Loading addresses from DNS seed %s\n", seed);
|
||||||
|
// If -proxy is in use, we make an ADDR_FETCH connection to the DNS resolved peer address
|
||||||
|
// for the base dns seed domain in chainparams
|
||||||
if (HaveNameProxy()) {
|
if (HaveNameProxy()) {
|
||||||
AddAddrFetch(seed);
|
AddAddrFetch(seed);
|
||||||
} else {
|
} else {
|
||||||
@ -2493,8 +2495,9 @@ void CConnman::ThreadDNSAddressSeed()
|
|||||||
}
|
}
|
||||||
addrman.Add(vAdd, resolveSource);
|
addrman.Add(vAdd, resolveSource);
|
||||||
} else {
|
} else {
|
||||||
// We now avoid directly using results from DNS Seeds which do not support service bit filtering,
|
// If the seed does not support a subdomain with our desired service bits,
|
||||||
// instead using them as a addrfetch to get nodes with our desired service bits.
|
// we make an ADDR_FETCH connection to the DNS resolved peer address for the
|
||||||
|
// base dns seed domain in chainparams
|
||||||
AddAddrFetch(seed);
|
AddAddrFetch(seed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2589,7 +2592,6 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect, CDe
|
|||||||
{
|
{
|
||||||
for (int64_t nLoop = 0;; nLoop++)
|
for (int64_t nLoop = 0;; nLoop++)
|
||||||
{
|
{
|
||||||
ProcessAddrFetch();
|
|
||||||
for (const std::string& strAddr : connect)
|
for (const std::string& strAddr : connect)
|
||||||
{
|
{
|
||||||
CAddress addr(CService(), NODE_NONE);
|
CAddress addr(CService(), NODE_NONE);
|
||||||
|
@ -215,11 +215,43 @@ class ConfArgsTest(BitcoinTestFramework):
|
|||||||
]):
|
]):
|
||||||
self.nodes[0].setmocktime(start + 65)
|
self.nodes[0].setmocktime(start + 65)
|
||||||
|
|
||||||
|
def test_connect_with_seednode(self):
|
||||||
|
self.log.info('Test -connect with -seednode')
|
||||||
|
seednode_ignored = ['-seednode is ignored when -connect is used\n']
|
||||||
|
dnsseed_ignored = ['-dnsseed is ignored when -connect is used and -proxy is specified\n']
|
||||||
|
addcon_thread_started = ['addcon thread start\n']
|
||||||
|
self.stop_node(0)
|
||||||
|
|
||||||
|
# When -connect is supplied, expanding addrman via getaddr calls to ADDR_FETCH(-seednode)
|
||||||
|
# nodes is irrelevant and -seednode is ignored.
|
||||||
|
with self.nodes[0].assert_debug_log(expected_msgs=seednode_ignored):
|
||||||
|
self.start_node(0, extra_args=['-connect=fakeaddress1', '-seednode=fakeaddress2'])
|
||||||
|
|
||||||
|
# With -proxy, an ADDR_FETCH connection is made to a peer that the dns seed resolves to.
|
||||||
|
# ADDR_FETCH connections are not used when -connect is used.
|
||||||
|
with self.nodes[0].assert_debug_log(expected_msgs=dnsseed_ignored):
|
||||||
|
self.restart_node(0, extra_args=['-connect=fakeaddress1', '-dnsseed=1', '-proxy=1.2.3.4'])
|
||||||
|
|
||||||
|
# If the user did not disable -dnsseed, but it was soft-disabled because they provided -connect,
|
||||||
|
# they shouldn't see a warning about -dnsseed being ignored.
|
||||||
|
with self.nodes[0].assert_debug_log(expected_msgs=addcon_thread_started,
|
||||||
|
unexpected_msgs=dnsseed_ignored):
|
||||||
|
self.restart_node(0, extra_args=['-connect=fakeaddress1', '-proxy=1.2.3.4'])
|
||||||
|
|
||||||
|
# We have to supply expected_msgs as it's a required argument
|
||||||
|
# The expected_msg must be something we are confident will be logged after the unexpected_msg
|
||||||
|
# These cases test for -connect being supplied but only to disable it
|
||||||
|
for connect_arg in ['-connect=0', '-noconnect']:
|
||||||
|
with self.nodes[0].assert_debug_log(expected_msgs=addcon_thread_started,
|
||||||
|
unexpected_msgs=seednode_ignored):
|
||||||
|
self.restart_node(0, extra_args=[connect_arg, '-seednode=fakeaddress2'])
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self.test_log_buffer()
|
self.test_log_buffer()
|
||||||
self.test_args_log()
|
self.test_args_log()
|
||||||
self.test_seed_peers()
|
self.test_seed_peers()
|
||||||
self.test_networkactive()
|
self.test_networkactive()
|
||||||
|
self.test_connect_with_seednode()
|
||||||
|
|
||||||
|
|
||||||
self.test_config_file_parser()
|
self.test_config_file_parser()
|
||||||
|
Loading…
Reference in New Issue
Block a user