Skip to content

Commit

Permalink
dont connect to 127.* and 0.0.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
madMAx43v3r committed Oct 28, 2022
1 parent 760fe61 commit 474b12c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,19 @@ std::pair<pubkey_t, signature_t> Router::sign_msg(const hash_t& msg) const
return std::make_pair(node_key, signature_t::sign(node_sk, hash_t(msg.bytes)));
}

static
bool is_valid_address(const std::string& addr)
{
if(addr.substr(0, 4) == "127." || addr == "0.0.0.0") {
return false;
}
return true;
}

static
bool is_public_address(const std::string& addr)
{
if(addr.substr(0, 3) == "10." || addr.substr(0, 4) == "127." || addr.substr(0, 8) == "192.168.") {
if(!is_valid_address(addr) || addr.substr(0, 3) == "10." || addr.substr(0, 8) == "192.168.") {
return false;
}
return true;
Expand Down Expand Up @@ -1450,7 +1459,9 @@ void Router::on_return(uint64_t client, std::shared_ptr<const Return> msg)
case Router_get_peers_return::VNX_TYPE_ID:
if(auto value = std::dynamic_pointer_cast<const Router_get_peers_return>(result)) {
for(const auto& address : value->_ret_0) {
peer_retry_map.emplace(address, 0);
if(is_valid_address(address)) {
peer_retry_map.emplace(address, 0);
}
}
}
break;
Expand Down

0 comments on commit 474b12c

Please sign in to comment.