aboutsummaryrefslogtreecommitdiff
path: root/src/p2p/p2p_protocol_defs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/p2p/p2p_protocol_defs.h')
-rw-r--r--src/p2p/p2p_protocol_defs.h193
1 files changed, 3 insertions, 190 deletions
diff --git a/src/p2p/p2p_protocol_defs.h b/src/p2p/p2p_protocol_defs.h
index 393bddd05..609661871 100644
--- a/src/p2p/p2p_protocol_defs.h
+++ b/src/p2p/p2p_protocol_defs.h
@@ -40,9 +40,6 @@
#include "string_tools.h"
#include "time_helper.h"
#include "cryptonote_config.h"
-#ifdef ALLOW_DEBUG_COMMANDS
-#include "crypto/crypto.h"
-#endif
namespace nodetool
{
@@ -82,8 +79,7 @@ namespace nodetool
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(adr)
KV_SERIALIZE(id)
- if (!is_store || this_ref.last_seen != 0)
- KV_SERIALIZE_OPT(last_seen, (int64_t)0)
+ KV_SERIALIZE_OPT(last_seen, (int64_t)0)
KV_SERIALIZE_OPT(pruning_seed, (uint32_t)0)
KV_SERIALIZE_OPT(rpc_port, (uint16_t)0)
KV_SERIALIZE_OPT(rpc_credits_per_hash, (uint32_t)0)
@@ -166,7 +162,6 @@ namespace nodetool
struct basic_node_data
{
uuid network_id;
- uint64_t local_time;
uint32_t my_port;
uint16_t rpc_port;
uint32_t rpc_credits_per_hash;
@@ -175,7 +170,6 @@ namespace nodetool
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_VAL_POD_AS_BLOB(network_id)
KV_SERIALIZE(peer_id)
- KV_SERIALIZE(local_time)
KV_SERIALIZE(my_port)
KV_SERIALIZE_OPT(rpc_port, (uint16_t)(0))
KV_SERIALIZE_OPT(rpc_credits_per_hash, (uint32_t)0)
@@ -214,35 +208,7 @@ namespace nodetool
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(node_data)
KV_SERIALIZE(payload_data)
- if (is_store)
- {
- // saving: save both, so old and new peers can understand it
- KV_SERIALIZE(local_peerlist_new)
- std::vector<peerlist_entry_base<network_address_old>> local_peerlist;
- for (const auto &p: this_ref.local_peerlist_new)
- {
- if (p.adr.get_type_id() == epee::net_utils::ipv4_network_address::get_type_id())
- {
- const epee::net_utils::network_address &na = p.adr;
- const epee::net_utils::ipv4_network_address &ipv4 = na.as<const epee::net_utils::ipv4_network_address>();
- local_peerlist.push_back(peerlist_entry_base<network_address_old>({{ipv4.ip(), ipv4.port()}, p.id, p.last_seen, p.pruning_seed, p.rpc_port, p.rpc_credits_per_hash}));
- }
- else
- MDEBUG("Not including in legacy peer list: " << p.adr.str());
- }
- epee::serialization::selector<is_store>::serialize_stl_container_pod_val_as_blob(local_peerlist, stg, hparent_section, "local_peerlist");
- }
- else
- {
- // loading: load old list only if there is no new one
- if (!epee::serialization::selector<is_store>::serialize(this_ref.local_peerlist_new, stg, hparent_section, "local_peerlist_new"))
- {
- std::vector<peerlist_entry_base<network_address_old>> local_peerlist;
- epee::serialization::selector<is_store>::serialize_stl_container_pod_val_as_blob(local_peerlist, stg, hparent_section, "local_peerlist");
- for (const auto &p: local_peerlist)
- ((response&)this_ref).local_peerlist_new.push_back(peerlist_entry({epee::net_utils::ipv4_network_address(p.adr.ip, p.adr.port), p.id, p.last_seen, p.pruning_seed, p.rpc_port, p.rpc_credits_per_hash}));
- }
- }
+ KV_SERIALIZE(local_peerlist_new)
END_KV_SERIALIZE_MAP()
};
typedef epee::misc_utils::struct_init<response_t> response;
@@ -268,42 +234,12 @@ namespace nodetool
struct response_t
{
- uint64_t local_time;
t_playload_type payload_data;
std::vector<peerlist_entry> local_peerlist_new;
BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(local_time)
KV_SERIALIZE(payload_data)
- if (is_store)
- {
- // saving: save both, so old and new peers can understand it
- KV_SERIALIZE(local_peerlist_new)
- std::vector<peerlist_entry_base<network_address_old>> local_peerlist;
- for (const auto &p: this_ref.local_peerlist_new)
- {
- if (p.adr.get_type_id() == epee::net_utils::ipv4_network_address::get_type_id())
- {
- const epee::net_utils::network_address &na = p.adr;
- const epee::net_utils::ipv4_network_address &ipv4 = na.as<const epee::net_utils::ipv4_network_address>();
- local_peerlist.push_back(peerlist_entry_base<network_address_old>({{ipv4.ip(), ipv4.port()}, p.id, p.last_seen}));
- }
- else
- MDEBUG("Not including in legacy peer list: " << p.adr.str());
- }
- epee::serialization::selector<is_store>::serialize_stl_container_pod_val_as_blob(local_peerlist, stg, hparent_section, "local_peerlist");
- }
- else
- {
- // loading: load old list only if there is no new one
- if (!epee::serialization::selector<is_store>::serialize(this_ref.local_peerlist_new, stg, hparent_section, "local_peerlist_new"))
- {
- std::vector<peerlist_entry_base<network_address_old>> local_peerlist;
- epee::serialization::selector<is_store>::serialize_stl_container_pod_val_as_blob(local_peerlist, stg, hparent_section, "local_peerlist");
- for (const auto &p: local_peerlist)
- ((response&)this_ref).local_peerlist_new.push_back(peerlist_entry({epee::net_utils::ipv4_network_address(p.adr.ip, p.adr.port), p.id, p.last_seen}));
- }
- }
+ KV_SERIALIZE(local_peerlist_new)
END_KV_SERIALIZE_MAP()
};
typedef epee::misc_utils::struct_init<response_t> response;
@@ -347,117 +283,6 @@ namespace nodetool
};
-#ifdef ALLOW_DEBUG_COMMANDS
- //These commands are considered as insecure, and made in debug purposes for a limited lifetime.
- //Anyone who feel unsafe with this commands can disable the ALLOW_GET_STAT_COMMAND macro.
-
- struct proof_of_trust
- {
- peerid_type peer_id;
- uint64_t time;
- crypto::signature sign;
-
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(peer_id)
- KV_SERIALIZE(time)
- KV_SERIALIZE_VAL_POD_AS_BLOB(sign)
- END_KV_SERIALIZE_MAP()
- };
-
-
- template<class payload_stat_info>
- struct COMMAND_REQUEST_STAT_INFO_T
- {
- const static int ID = P2P_COMMANDS_POOL_BASE + 4;
-
- struct request_t
- {
- proof_of_trust tr;
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(tr)
- END_KV_SERIALIZE_MAP()
- };
- typedef epee::misc_utils::struct_init<request_t> request;
-
- struct response_t
- {
- std::string version;
- std::string os_version;
- uint64_t connections_count;
- uint64_t incoming_connections_count;
- payload_stat_info payload_info;
-
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(version)
- KV_SERIALIZE(os_version)
- KV_SERIALIZE(connections_count)
- KV_SERIALIZE(incoming_connections_count)
- KV_SERIALIZE(payload_info)
- END_KV_SERIALIZE_MAP()
- };
- typedef epee::misc_utils::struct_init<response_t> response;
- };
-
-
- /************************************************************************/
- /* */
- /************************************************************************/
- struct COMMAND_REQUEST_NETWORK_STATE
- {
- const static int ID = P2P_COMMANDS_POOL_BASE + 5;
-
- struct request_t
- {
- proof_of_trust tr;
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(tr)
- END_KV_SERIALIZE_MAP()
- };
- typedef epee::misc_utils::struct_init<request_t> request;
-
- struct response_t
- {
- std::vector<peerlist_entry> local_peerlist_white;
- std::vector<peerlist_entry> local_peerlist_gray;
- std::vector<connection_entry> connections_list;
- peerid_type my_id;
- uint64_t local_time;
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE_CONTAINER_POD_AS_BLOB(local_peerlist_white)
- KV_SERIALIZE_CONTAINER_POD_AS_BLOB(local_peerlist_gray)
- KV_SERIALIZE_CONTAINER_POD_AS_BLOB(connections_list)
- KV_SERIALIZE(my_id)
- KV_SERIALIZE(local_time)
- END_KV_SERIALIZE_MAP()
- };
- typedef epee::misc_utils::struct_init<response_t> response;
- };
-
- /************************************************************************/
- /* */
- /************************************************************************/
- struct COMMAND_REQUEST_PEER_ID
- {
- const static int ID = P2P_COMMANDS_POOL_BASE + 6;
-
- struct request_t
- {
- BEGIN_KV_SERIALIZE_MAP()
- END_KV_SERIALIZE_MAP()
- };
- typedef epee::misc_utils::struct_init<request_t> request;
-
- struct response_t
- {
- peerid_type my_id;
-
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(my_id)
- END_KV_SERIALIZE_MAP()
- };
- typedef epee::misc_utils::struct_init<response_t> response;
- };
-
/************************************************************************/
/* */
/************************************************************************/
@@ -482,16 +307,4 @@ namespace nodetool
};
typedef epee::misc_utils::struct_init<response_t> response;
};
-
-#endif
-
-
- inline crypto::hash get_proof_of_trust_hash(const nodetool::proof_of_trust& pot)
- {
- std::string s;
- s.append(reinterpret_cast<const char*>(&pot.peer_id), sizeof(pot.peer_id));
- s.append(reinterpret_cast<const char*>(&pot.time), sizeof(pot.time));
- return crypto::cn_fast_hash(s.data(), s.size());
- }
-
}