forked from lthn/blockchain
p2p: is_ip_good_for_adding_to_peerlist added
This commit is contained in:
parent
37755b5b1f
commit
ee222d96a7
2 changed files with 13 additions and 5 deletions
|
|
@ -215,6 +215,7 @@ namespace nodetool
|
|||
bool urgent_alert_worker();
|
||||
bool critical_alert_worker();
|
||||
bool remove_dead_connections();
|
||||
bool is_ip_good_for_adding_to_peerlist(uint32_t adress);
|
||||
|
||||
|
||||
//debug functions
|
||||
|
|
|
|||
|
|
@ -103,6 +103,16 @@ namespace nodetool
|
|||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
bool node_server<t_payload_net_handler>::is_remote_ip_allowed(uint32_t addr)
|
||||
{
|
||||
if (m_offline_mode)
|
||||
return false;
|
||||
|
||||
// blocking incoming connections by IP address is temporary disabled
|
||||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
bool node_server<t_payload_net_handler>::is_ip_good_for_adding_to_peerlist(uint32_t addr)
|
||||
{
|
||||
if (m_offline_mode)
|
||||
return false;
|
||||
|
|
@ -708,7 +718,7 @@ namespace nodetool
|
|||
return true;
|
||||
}
|
||||
|
||||
if (is_remote_ip_allowed(na.ip)) // additional check to avoid IP shown up in peers in the case of non-blocking incoming connections
|
||||
if (is_ip_good_for_adding_to_peerlist(na.ip)) // additional check to avoid IP shown up in peers in the case of non-blocking incoming connections
|
||||
{
|
||||
//update last seen and push it to peerlist manager
|
||||
peerlist_entry pe_local = AUTO_VAL_INIT(pe_local);
|
||||
|
|
@ -787,14 +797,11 @@ namespace nodetool
|
|||
continue;
|
||||
}
|
||||
|
||||
// IP blocking for incoming connections is temporary disabled
|
||||
/*
|
||||
if (!is_remote_ip_allowed(pe.adr.ip))
|
||||
{
|
||||
++peer_index;
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
|
||||
if (is_addr_recently_failed(pe.adr))
|
||||
{
|
||||
|
|
@ -1387,7 +1394,7 @@ namespace nodetool
|
|||
context.peer_id = arg.node_data.peer_id;
|
||||
|
||||
if(arg.node_data.peer_id != m_config.m_peer_id && arg.node_data.my_port
|
||||
&& is_remote_ip_allowed(context.m_remote_ip)) // additional check to avoid IP shown up in peers in the case of non-blocking incoming connections
|
||||
&& is_ip_good_for_adding_to_peerlist(context.m_remote_ip)) // additional check to avoid IP shown up in peers in the case of non-blocking incoming connections
|
||||
{
|
||||
peerid_type peer_id_l = arg.node_data.peer_id;
|
||||
uint32_t port_l = arg.node_data.my_port;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue