net: disable v1 connections, reconnections on clearnet

if `-v2onlyclearnet` is turned on,
- v1 addresses from addrman aren't selected and manual connections
aren't attempted for outbound connections if it's from IPV4/IPV6
networks.
- v1 downgrade mechainm is not attempted if v2 connection wasn't
successful
This commit is contained in:
stratospher 2024-08-23 12:57:42 +05:30
parent d166ed79e5
commit 19d1bc2328

View file

@ -463,6 +463,9 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
std::unique_ptr<i2p::sam::Session> i2p_transient_session;
for (auto& target_addr: connect_to) {
if (DisableV1OnClearnet(target_addr.GetNetClass()) && !use_v2transport) {
continue;
}
if (target_addr.IsValid()) {
const bool use_proxy{GetProxy(target_addr.GetNetwork(), proxy)};
bool proxyConnectionFailed = false;
@ -1935,7 +1938,7 @@ void CConnman::DisconnectNodes()
// Add to reconnection list if appropriate. We don't reconnect right here, because
// the creation of a connection is a blocking operation (up to several seconds),
// and we don't want to hold up the socket handler thread for that long.
if (network_active && pnode->m_transport->ShouldReconnectV1()) {
if (network_active && pnode->m_transport->ShouldReconnectV1() && !DisableV1OnClearnet(pnode->addr.GetNetClass())) {
reconnections_to_add.push_back({
.addr_connect = pnode->addr,
.grant = std::move(pnode->grantOutbound),