mirror of
https://github.com/monero-project/monero.git
synced 2025-07-28 04:15:27 -04:00
Merge pull request #5933
3455efa
ban peers sending bad pow outright (moneromooo-monero)
This commit is contained in:
commit
dc48cdc998
9 changed files with 25 additions and 15 deletions
|
@ -139,6 +139,7 @@ namespace cryptonote
|
|||
bool should_download_next_span(cryptonote_connection_context& context, bool standby);
|
||||
bool should_ask_for_pruned_data(cryptonote_connection_context& context, uint64_t first_block_height, uint64_t nblocks, bool check_block_weights) const;
|
||||
void drop_connection(cryptonote_connection_context &context, bool add_fail, bool flush_all_spans);
|
||||
void drop_connection_with_score(cryptonote_connection_context &context, unsigned int score, bool flush_all_spans);
|
||||
bool kick_idle_peers();
|
||||
bool check_standby_peers();
|
||||
bool update_sync_search();
|
||||
|
|
|
@ -477,7 +477,7 @@ namespace cryptonote
|
|||
if(bvc.m_verifivation_failed)
|
||||
{
|
||||
LOG_PRINT_CCONTEXT_L0("Block verification failed, dropping connection");
|
||||
drop_connection(context, true, false);
|
||||
drop_connection_with_score(context, bvc.m_bad_pow ? P2P_IP_FAILS_BEFORE_BLOCK : 1, false);
|
||||
return 1;
|
||||
}
|
||||
if(bvc.m_added_to_main_chain)
|
||||
|
@ -751,7 +751,7 @@ namespace cryptonote
|
|||
if( bvc.m_verifivation_failed )
|
||||
{
|
||||
LOG_PRINT_CCONTEXT_L0("Block verification failed, dropping connection");
|
||||
drop_connection(context, true, false);
|
||||
drop_connection_with_score(context, bvc.m_bad_pow ? P2P_IP_FAILS_BEFORE_BLOCK : 1, false);
|
||||
return 1;
|
||||
}
|
||||
if( bvc.m_added_to_main_chain )
|
||||
|
@ -1374,7 +1374,7 @@ namespace cryptonote
|
|||
{
|
||||
if (!m_p2p->for_connection(span_connection_id, [&](cryptonote_connection_context& context, nodetool::peerid_type peer_id, uint32_t f)->bool{
|
||||
LOG_PRINT_CCONTEXT_L1("Block verification failed, dropping connection");
|
||||
drop_connection(context, true, true);
|
||||
drop_connection_with_score(context, bvc.m_bad_pow ? P2P_IP_FAILS_BEFORE_BLOCK : 1, true);
|
||||
return 1;
|
||||
}))
|
||||
LOG_ERROR_CCONTEXT("span connection id not found");
|
||||
|
@ -2428,14 +2428,14 @@ skip:
|
|||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
template<class t_core>
|
||||
void t_cryptonote_protocol_handler<t_core>::drop_connection(cryptonote_connection_context &context, bool add_fail, bool flush_all_spans)
|
||||
void t_cryptonote_protocol_handler<t_core>::drop_connection_with_score(cryptonote_connection_context &context, unsigned score, bool flush_all_spans)
|
||||
{
|
||||
LOG_DEBUG_CC(context, "dropping connection id " << context.m_connection_id << " (pruning seed " <<
|
||||
epee::string_tools::to_string_hex(context.m_pruning_seed) <<
|
||||
"), add_fail " << add_fail << ", flush_all_spans " << flush_all_spans);
|
||||
"), score " << score << ", flush_all_spans " << flush_all_spans);
|
||||
|
||||
if (add_fail)
|
||||
m_p2p->add_host_fail(context.m_remote_address);
|
||||
if (score > 0)
|
||||
m_p2p->add_host_fail(context.m_remote_address, score);
|
||||
|
||||
m_block_queue.flush_spans(context.m_connection_id, flush_all_spans);
|
||||
|
||||
|
@ -2443,6 +2443,12 @@ skip:
|
|||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
template<class t_core>
|
||||
void t_cryptonote_protocol_handler<t_core>::drop_connection(cryptonote_connection_context &context, bool add_fail, bool flush_all_spans)
|
||||
{
|
||||
return drop_connection_with_score(context, add_fail ? 1 : 0, flush_all_spans);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
template<class t_core>
|
||||
void t_cryptonote_protocol_handler<t_core>::on_connection_close(cryptonote_connection_context &context)
|
||||
{
|
||||
uint64_t target = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue