Merge pull request #1609

4cdf0a35 p2p: always recreate a new peer id on startup (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2017-01-22 11:47:43 -05:00
commit add98edfc3
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
3 changed files with 19 additions and 2 deletions

View file

@ -110,7 +110,12 @@ namespace nodetool
void serialize(Archive &a, const t_version_type ver) void serialize(Archive &a, const t_version_type ver)
{ {
a & m_peerlist; a & m_peerlist;
a & m_config.m_peer_id; if (ver == 0)
{
// from v1, we do not store the peer id anymore
peerid_type peer_id;
a & peer_id;
}
} }
// debug functions // debug functions
bool log_peerlist(); bool log_peerlist();
@ -162,6 +167,7 @@ namespace nodetool
#endif #endif
int handle_get_support_flags(int command, COMMAND_REQUEST_SUPPORT_FLAGS::request& arg, COMMAND_REQUEST_SUPPORT_FLAGS::response& rsp, p2p_connection_context& context); int handle_get_support_flags(int command, COMMAND_REQUEST_SUPPORT_FLAGS::request& arg, COMMAND_REQUEST_SUPPORT_FLAGS::response& rsp, p2p_connection_context& context);
bool init_config(); bool init_config();
bool make_default_peer_id();
bool make_default_config(); bool make_default_config();
bool store_config(); bool store_config();
bool check_trust(const proof_of_trust& tr); bool check_trust(const proof_of_trust& tr);

View file

@ -173,6 +173,9 @@ namespace nodetool
make_default_config(); make_default_config();
} }
// always recreate a new peer id
make_default_peer_id();
//at this moment we have hardcoded config //at this moment we have hardcoded config
m_config.m_net_config.handshake_interval = P2P_DEFAULT_HANDSHAKE_INTERVAL; m_config.m_net_config.handshake_interval = P2P_DEFAULT_HANDSHAKE_INTERVAL;
m_config.m_net_config.packet_max_size = P2P_DEFAULT_PACKET_MAX_SIZE; //20 MB limit m_config.m_net_config.packet_max_size = P2P_DEFAULT_PACKET_MAX_SIZE; //20 MB limit
@ -212,13 +215,19 @@ namespace nodetool
} }
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
template<class t_payload_net_handler> template<class t_payload_net_handler>
bool node_server<t_payload_net_handler>::make_default_config() bool node_server<t_payload_net_handler>::make_default_peer_id()
{ {
m_config.m_peer_id = crypto::rand<uint64_t>(); m_config.m_peer_id = crypto::rand<uint64_t>();
return true; return true;
} }
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
template<class t_payload_net_handler> template<class t_payload_net_handler>
bool node_server<t_payload_net_handler>::make_default_config()
{
return make_default_peer_id();
}
//-----------------------------------------------------------------------------------
template<class t_payload_net_handler>
bool node_server<t_payload_net_handler>::block_ip(uint32_t addr, time_t seconds) bool node_server<t_payload_net_handler>::block_ip(uint32_t addr, time_t seconds)
{ {
CRITICAL_REGION_LOCAL(m_blocked_ips_lock); CRITICAL_REGION_LOCAL(m_blocked_ips_lock);

View file

@ -194,3 +194,5 @@ private:
bool m_restricted; bool m_restricted;
}; };
} }
BOOST_CLASS_VERSION(nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> >, 1);