near / nearcore

Reference client for NEAR Protocol
https://near.org
GNU General Public License v3.0
2.33k stars 629 forks source link

Fix handling of blacklisted IPs read from storage #6521

Closed mina86 closed 2 years ago

mina86 commented 2 years ago

I’ve recently submitted a change which causes peers read from the database to become banned if their IP address matches entry in a blacklist. There are still two outstanding issues:

mooori commented 2 years ago

I'm interested in working on the second item. Is std::net::Ipv4Addr::to_ipv6_mapped() a valid approach for the conversion?

mina86 commented 2 years ago

Yep.

mooori commented 2 years ago

Is there a preference regarding the first item (never unban or remove)?

Removing the peer from PeerStore might make things easier, since then there is no need for extra logic to handle peers which are banned and blacklisted. It should be safe since new connections from blacklisted peers are rejected: https://github.com/near/nearcore/blob/55d0e03b52d1eece08ce4ba91cc726c9134087e9/chain/network/src/peer_manager/peer_manager_actor.rs#L2081-L2085

mina86 commented 2 years ago

Yeah, I think deleting the nodes from the database should be fine.