aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2020-12-07 10:25:38 -0600
committerluigi1111 <luigi1111w@gmail.com>2020-12-07 10:25:38 -0600
commitf9a70e4260c40c56f648b57adbc5c161b308539c (patch)
tree84b9f920b1e89968ebd57262cffc5b78b032feae /src
parentMerge pull request #7071 (diff)
parentp2p: drop peers that spam peer lists (diff)
downloadmonero-f9a70e4260c40c56f648b57adbc5c161b308539c.tar.xz
Merge pull request #7073
446b3c8 p2p: drop peers that spam peer lists (moneromooo-monero)
Diffstat (limited to 'src')
-rw-r--r--src/cryptonote_config.h1
-rw-r--r--src/p2p/net_node.inl5
2 files changed, 6 insertions, 0 deletions
diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h
index 826cabe17..13f0c471b 100644
--- a/src/cryptonote_config.h
+++ b/src/cryptonote_config.h
@@ -132,6 +132,7 @@
#define P2P_DEFAULT_HANDSHAKE_INTERVAL 60 //secondes
#define P2P_DEFAULT_PACKET_MAX_SIZE 50000000 //50000000 bytes maximum packet size
#define P2P_DEFAULT_PEERS_IN_HANDSHAKE 250
+#define P2P_MAX_PEERS_IN_HANDSHAKE 250
#define P2P_DEFAULT_CONNECTION_TIMEOUT 5000 //5 seconds
#define P2P_DEFAULT_SOCKS_CONNECT_TIMEOUT 45 // seconds
#define P2P_DEFAULT_PING_CONNECTION_TIMEOUT 2000 //2 seconds
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 99090364c..cc1a6d641 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -2062,6 +2062,11 @@ namespace nodetool
template<class t_payload_net_handler>
bool node_server<t_payload_net_handler>::handle_remote_peerlist(const std::vector<peerlist_entry>& peerlist, const epee::net_utils::connection_context_base& context)
{
+ if (peerlist.size() > P2P_MAX_PEERS_IN_HANDSHAKE)
+ {
+ MWARNING(context << "peer sent " << peerlist.size() << " peers, considered spamming");
+ return false;
+ }
std::vector<peerlist_entry> peerlist_ = peerlist;
if(!sanitize_peerlist(peerlist_))
return false;