Skip to content

Commit eb2fba9

Browse files
committed
net: add option in CConman to disable v1 clearnet connections
a boolean option `disable_v1conn_clearnet` is introduced in CConman which will (in a later commit) store if the user wishes to disable outbound v1 connections on IPV4 and IPV6 networks since they are unencrypted. this option is accessible outside CConman using `DisableV1OnClearnet()` function with the network we're trying to connect to passed as an argument.
1 parent 2a52718 commit eb2fba9

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/net.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -2435,6 +2435,11 @@ bool CConnman::MultipleManualOrFullOutboundConns(Network net) const
24352435
return m_network_conn_counts[net] > 1;
24362436
}
24372437

2438+
bool CConnman::DisableV1OnClearnet(Network net) const
2439+
{
2440+
return disable_v1conn_clearnet && (net == NET_IPV4 || net == NET_IPV6);
2441+
}
2442+
24382443
bool CConnman::MaybePickPreferredNetwork(std::optional<Network>& network)
24392444
{
24402445
std::array<Network, 5> nets{NET_IPV4, NET_IPV6, NET_ONION, NET_I2P, NET_CJDNS};

src/net.h

+12
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,7 @@ class CConnman
10591059
bool m_i2p_accept_incoming;
10601060
bool whitelist_forcerelay = DEFAULT_WHITELISTFORCERELAY;
10611061
bool whitelist_relay = DEFAULT_WHITELISTRELAY;
1062+
bool disable_v1conn_clearnet = false;
10621063
};
10631064

10641065
void Init(const Options& connOptions) EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex, !m_total_bytes_sent_mutex)
@@ -1096,6 +1097,7 @@ class CConnman
10961097
m_onion_binds = connOptions.onion_binds;
10971098
whitelist_forcerelay = connOptions.whitelist_forcerelay;
10981099
whitelist_relay = connOptions.whitelist_relay;
1100+
disable_v1conn_clearnet = connOptions.disable_v1conn_clearnet;
10991101
}
11001102

11011103
CConnman(uint64_t seed0, uint64_t seed1, AddrMan& addrman, const NetGroupManager& netgroupman,
@@ -1253,6 +1255,9 @@ class CConnman
12531255

12541256
bool MultipleManualOrFullOutboundConns(Network net) const EXCLUSIVE_LOCKS_REQUIRED(m_nodes_mutex);
12551257

1258+
/* Disables outbound v1 connections on IPV4/IPV6 network. */
1259+
bool DisableV1OnClearnet(Network net) const;
1260+
12561261
private:
12571262
struct ListenSocket {
12581263
public:
@@ -1572,6 +1577,13 @@ class CConnman
15721577
*/
15731578
bool whitelist_relay;
15741579

1580+
/**
1581+
* option for disabling outbound v1 connections on IPV4 and IPV6.
1582+
* outbound connections on IPV4/IPV6 need to be v2 connections.
1583+
* outbound connections on Tor/I2P/CJDNS can be v1 or v2 connections.
1584+
*/
1585+
bool disable_v1conn_clearnet;
1586+
15751587
/**
15761588
* Mutex protecting m_i2p_sam_sessions.
15771589
*/

0 commit comments

Comments
 (0)