aboutsummaryrefslogtreecommitdiff
path: root/src/p2p
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-09-24 13:08:25 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-09-25 16:00:43 +0000
commit3455efafa812d646f2eea42db14b761f34975147 (patch)
treedffe8ec81dc709f86bbb004017aca3dfa77efa30 /src/p2p
parentMerge pull request #5928 (diff)
downloadmonero-3455efafa812d646f2eea42db14b761f34975147.tar.xz
ban peers sending bad pow outright
PoW is expensive to verify, so be strict
Diffstat (limited to 'src/p2p')
-rw-r--r--src/p2p/net_node.h2
-rw-r--r--src/p2p/net_node.inl4
-rw-r--r--src/p2p/net_node_common.h4
3 files changed, 5 insertions, 5 deletions
diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h
index d7e2e91f5..3a5d980ab 100644
--- a/src/p2p/net_node.h
+++ b/src/p2p/net_node.h
@@ -342,7 +342,7 @@ namespace nodetool
virtual void request_callback(const epee::net_utils::connection_context_base& context);
virtual void for_each_connection(std::function<bool(typename t_payload_net_handler::connection_context&, peerid_type, uint32_t)> f);
virtual bool for_connection(const boost::uuids::uuid&, std::function<bool(typename t_payload_net_handler::connection_context&, peerid_type, uint32_t)> f);
- virtual bool add_host_fail(const epee::net_utils::network_address &address);
+ virtual bool add_host_fail(const epee::net_utils::network_address &address, unsigned int score = 1);
//----------------- i_connection_filter --------------------------------------------------------
virtual bool is_remote_host_allowed(const epee::net_utils::network_address &address, time_t *t = NULL);
//-----------------------------------------------------------------------------------------------
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 24c87cef8..e8e19905a 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -315,13 +315,13 @@ namespace nodetool
}
//-----------------------------------------------------------------------------------
template<class t_payload_net_handler>
- bool node_server<t_payload_net_handler>::add_host_fail(const epee::net_utils::network_address &address)
+ bool node_server<t_payload_net_handler>::add_host_fail(const epee::net_utils::network_address &address, unsigned int score)
{
if(!address.is_blockable())
return false;
CRITICAL_REGION_LOCAL(m_host_fails_score_lock);
- uint64_t fails = ++m_host_fails_score[address.host_str()];
+ uint64_t fails = m_host_fails_score[address.host_str()] += score;
MDEBUG("Host " << address.host_str() << " fail score=" << fails);
if(fails > P2P_IP_FAILS_BEFORE_BLOCK)
{
diff --git a/src/p2p/net_node_common.h b/src/p2p/net_node_common.h
index e0046cd86..752873666 100644
--- a/src/p2p/net_node_common.h
+++ b/src/p2p/net_node_common.h
@@ -60,7 +60,7 @@ namespace nodetool
virtual bool unblock_host(const epee::net_utils::network_address &address)=0;
virtual std::map<std::string, time_t> get_blocked_hosts()=0;
virtual std::map<epee::net_utils::ipv4_network_subnet, time_t> get_blocked_subnets()=0;
- virtual bool add_host_fail(const epee::net_utils::network_address &address)=0;
+ virtual bool add_host_fail(const epee::net_utils::network_address &address, unsigned int score = 1)=0;
virtual void add_used_stripe_peer(const t_connection_context &context)=0;
virtual void remove_used_stripe_peer(const t_connection_context &context)=0;
virtual void clear_used_stripe_peers()=0;
@@ -122,7 +122,7 @@ namespace nodetool
{
return std::map<epee::net_utils::ipv4_network_subnet, time_t>();
}
- virtual bool add_host_fail(const epee::net_utils::network_address &address)
+ virtual bool add_host_fail(const epee::net_utils::network_address &address, unsigned int score)
{
return true;
}