aboutsummaryrefslogtreecommitdiff
path: root/src/p2p
diff options
context:
space:
mode:
Diffstat (limited to 'src/p2p')
-rw-r--r--src/p2p/net_node.h8
-rw-r--r--src/p2p/net_node.inl11
-rw-r--r--src/p2p/net_peerlist.h5
-rw-r--r--src/p2p/net_peerlist_boost_serialization.h9
-rw-r--r--src/p2p/p2p_protocol_defs.h18
5 files changed, 39 insertions, 12 deletions
diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h
index 0e7016b27..7840e3832 100644
--- a/src/p2p/net_node.h
+++ b/src/p2p/net_node.h
@@ -211,6 +211,7 @@ namespace nodetool
node_server(t_payload_net_handler& payload_handler)
: m_payload_handler(payload_handler),
m_external_port(0),
+ m_rpc_port(0),
m_allow_local_ip(false),
m_hide_my_port(false),
m_no_igd(false),
@@ -400,6 +401,12 @@ namespace nodetool
m_save_graph = save_graph;
epee::net_utils::connection_basic::set_save_graph(save_graph);
}
+
+ void set_rpc_port(uint16_t rpc_port)
+ {
+ m_rpc_port = rpc_port;
+ }
+
private:
std::string m_config_folder;
@@ -407,6 +414,7 @@ namespace nodetool
bool m_first_connection_maker_call;
uint32_t m_listening_port;
uint32_t m_external_port;
+ uint16_t m_rpc_port;
bool m_allow_local_ip;
bool m_hide_my_port;
bool m_no_igd;
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index f32b9e990..3542357dc 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -865,7 +865,8 @@ namespace nodetool
}
pi = context.peer_id = rsp.node_data.peer_id;
- m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.set_peer_just_seen(rsp.node_data.peer_id, context.m_remote_address, context.m_pruning_seed);
+ context.m_rpc_port = rsp.node_data.rpc_port;
+ m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.set_peer_just_seen(rsp.node_data.peer_id, context.m_remote_address, context.m_pruning_seed, context.m_rpc_port);
// move
for (auto const& zone : m_network_zones)
@@ -931,7 +932,7 @@ namespace nodetool
add_host_fail(context.m_remote_address);
}
if(!context.m_is_income)
- m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.set_peer_just_seen(context.peer_id, context.m_remote_address, context.m_pruning_seed);
+ m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.set_peer_just_seen(context.peer_id, context.m_remote_address, context.m_pruning_seed, context.m_rpc_port);
m_payload_handler.process_payload_sync_data(rsp.payload_data, context, false);
});
@@ -1095,6 +1096,7 @@ namespace nodetool
time(&last_seen);
pe_local.last_seen = static_cast<int64_t>(last_seen);
pe_local.pruning_seed = con->m_pruning_seed;
+ pe_local.rpc_port = con->m_rpc_port;
zone.m_peerlist.append_with_peer_white(pe_local);
//update last seen and push it to peerlist manager
@@ -1657,6 +1659,7 @@ namespace nodetool
node_data.my_port = m_external_port ? m_external_port : m_listening_port;
else
node_data.my_port = 0;
+ node_data.rpc_port = zone.m_can_pingback ? m_rpc_port : 0;
node_data.network_id = m_network_id;
return true;
}
@@ -2012,6 +2015,7 @@ namespace nodetool
//associate peer_id with this connection
context.peer_id = arg.node_data.peer_id;
context.m_in_timedsync = false;
+ context.m_rpc_port = arg.node_data.rpc_port;
if(arg.node_data.peer_id != zone.m_config.m_peer_id && arg.node_data.my_port && zone.m_can_pingback)
{
@@ -2031,6 +2035,7 @@ namespace nodetool
pe.last_seen = static_cast<int64_t>(last_seen);
pe.id = peer_id_l;
pe.pruning_seed = context.m_pruning_seed;
+ pe.rpc_port = context.m_rpc_port;
this->m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.append_with_peer_white(pe);
LOG_DEBUG_CC(context, "PING SUCCESS " << context.m_remote_address.host_str() << ":" << port_l);
});
@@ -2331,7 +2336,7 @@ namespace nodetool
}
else
{
- zone.second.m_peerlist.set_peer_just_seen(pe.id, pe.adr, pe.pruning_seed);
+ zone.second.m_peerlist.set_peer_just_seen(pe.id, pe.adr, pe.pruning_seed, pe.rpc_port);
LOG_PRINT_L2("PEER PROMOTED TO WHITE PEER LIST IP address: " << pe.adr.host_str() << " Peer ID: " << peerid_type(pe.id));
}
}
diff --git a/src/p2p/net_peerlist.h b/src/p2p/net_peerlist.h
index 91d7fa2b3..ebe0268d8 100644
--- a/src/p2p/net_peerlist.h
+++ b/src/p2p/net_peerlist.h
@@ -111,7 +111,7 @@ namespace nodetool
bool append_with_peer_white(const peerlist_entry& pr);
bool append_with_peer_gray(const peerlist_entry& pr);
bool append_with_peer_anchor(const anchor_peerlist_entry& ple);
- bool set_peer_just_seen(peerid_type peer, const epee::net_utils::network_address& addr, uint32_t pruning_seed);
+ bool set_peer_just_seen(peerid_type peer, const epee::net_utils::network_address& addr, uint32_t pruning_seed, uint16_t rpc_port);
bool set_peer_unreachable(const peerlist_entry& pr);
bool is_host_allowed(const epee::net_utils::network_address &address);
bool get_random_gray_peer(peerlist_entry& pe);
@@ -295,7 +295,7 @@ namespace nodetool
}
//--------------------------------------------------------------------------------------------------
inline
- bool peerlist_manager::set_peer_just_seen(peerid_type peer, const epee::net_utils::network_address& addr, uint32_t pruning_seed)
+ bool peerlist_manager::set_peer_just_seen(peerid_type peer, const epee::net_utils::network_address& addr, uint32_t pruning_seed, uint16_t rpc_port)
{
TRY_ENTRY();
CRITICAL_REGION_LOCAL(m_peerlist_lock);
@@ -305,6 +305,7 @@ namespace nodetool
ple.id = peer;
ple.last_seen = time(NULL);
ple.pruning_seed = pruning_seed;
+ ple.rpc_port = rpc_port;
return append_with_peer_white(ple);
CATCH_ENTRY_L0("peerlist_manager::set_peer_just_seen()", false);
}
diff --git a/src/p2p/net_peerlist_boost_serialization.h b/src/p2p/net_peerlist_boost_serialization.h
index 1d6eb7690..40ef2ebcd 100644
--- a/src/p2p/net_peerlist_boost_serialization.h
+++ b/src/p2p/net_peerlist_boost_serialization.h
@@ -42,6 +42,8 @@
#include "common/pruning.h"
#endif
+BOOST_CLASS_VERSION(nodetool::peerlist_entry, 2)
+
namespace boost
{
namespace serialization
@@ -197,6 +199,13 @@ namespace boost
pl.pruning_seed = tools::make_pruning_seed(1+pl.adr.as<epee::net_utils::ipv4_network_address>().ip() % (1<<CRYPTONOTE_PRUNING_LOG_STRIPES), CRYPTONOTE_PRUNING_LOG_STRIPES);
}
#endif
+ if (ver < 2)
+ {
+ if (!typename Archive::is_saving())
+ pl.rpc_port = 0;
+ return;
+ }
+ a & pl.rpc_port;
}
template <class Archive, class ver_type>
diff --git a/src/p2p/p2p_protocol_defs.h b/src/p2p/p2p_protocol_defs.h
index b08fc7e83..59c6099d5 100644
--- a/src/p2p/p2p_protocol_defs.h
+++ b/src/p2p/p2p_protocol_defs.h
@@ -76,12 +76,14 @@ namespace nodetool
peerid_type id;
int64_t last_seen;
uint32_t pruning_seed;
+ uint16_t rpc_port;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(adr)
KV_SERIALIZE(id)
KV_SERIALIZE(last_seen)
KV_SERIALIZE_OPT(pruning_seed, (uint32_t)0)
+ KV_SERIALIZE_OPT(rpc_port, (uint16_t)0)
END_KV_SERIALIZE_MAP()
};
typedef peerlist_entry_base<epee::net_utils::network_address> peerlist_entry;
@@ -127,7 +129,11 @@ namespace nodetool
ss << std::setfill ('0') << std::setw (8) << std::hex << std::noshowbase;
for(const peerlist_entry& pe: pl)
{
- ss << pe.id << "\t" << pe.adr.str() << " \tpruning seed " << pe.pruning_seed << " \tlast_seen: " << epee::misc_utils::get_time_interval_string(now_time - pe.last_seen) << std::endl;
+ ss << pe.id << "\t" << pe.adr.str()
+ << " \trpc port " << (pe.rpc_port > 0 ? std::to_string(pe.rpc_port) : "-")
+ << " \tpruning seed " << pe.pruning_seed
+ << " \tlast_seen: " << epee::misc_utils::get_time_interval_string(now_time - pe.last_seen)
+ << std::endl;
}
return ss.str();
}
@@ -158,6 +164,7 @@ namespace nodetool
uuid network_id;
uint64_t local_time;
uint32_t my_port;
+ uint16_t rpc_port;
peerid_type peer_id;
BEGIN_KV_SERIALIZE_MAP()
@@ -165,6 +172,7 @@ namespace nodetool
KV_SERIALIZE(peer_id)
KV_SERIALIZE(local_time)
KV_SERIALIZE(my_port)
+ KV_SERIALIZE_OPT(rpc_port, (uint16_t)(0))
END_KV_SERIALIZE_MAP()
};
@@ -211,7 +219,7 @@ namespace nodetool
{
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}));
+ 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}));
}
else
MDEBUG("Not including in legacy peer list: " << p.adr.str());
@@ -226,7 +234,7 @@ namespace nodetool
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}));
+ ((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}));
}
}
END_KV_SERIALIZE_MAP()
@@ -481,7 +489,3 @@ namespace nodetool
}
}
-
-BOOST_CLASS_VERSION(nodetool::peerlist_entry, 1)
-
-