fix status response
This commit is contained in:
parent
317db3cf44
commit
1bd22bf6ba
@ -1383,25 +1383,28 @@ impl NetworkManager {
|
||||
async fn on_recv_envelope(
|
||||
&self,
|
||||
data: &[u8],
|
||||
descriptor: ConnectionDescriptor,
|
||||
connection_descriptor: ConnectionDescriptor,
|
||||
) -> EyreResult<bool> {
|
||||
let root = span!(
|
||||
parent: None,
|
||||
Level::TRACE,
|
||||
"on_recv_envelope",
|
||||
"data.len" = data.len(),
|
||||
"descriptor" = ?descriptor
|
||||
"descriptor" = ?connection_descriptor
|
||||
);
|
||||
let _root_enter = root.enter();
|
||||
|
||||
log_net!(
|
||||
"envelope of {} bytes received from {:?}",
|
||||
data.len(),
|
||||
descriptor
|
||||
connection_descriptor
|
||||
);
|
||||
|
||||
// Network accounting
|
||||
self.stats_packet_rcvd(descriptor.remote_address().to_ip_addr(), data.len() as u64);
|
||||
self.stats_packet_rcvd(
|
||||
connection_descriptor.remote_address().to_ip_addr(),
|
||||
data.len() as u64,
|
||||
);
|
||||
|
||||
// If this is a zero length packet, just drop it, because these are used for hole punching
|
||||
// and possibly other low-level network connectivity tasks and will never require
|
||||
@ -1418,7 +1421,7 @@ impl NetworkManager {
|
||||
|
||||
// Is this a direct bootstrap request instead of an envelope?
|
||||
if data[0..4] == *BOOT_MAGIC {
|
||||
network_result_value_or_log!(debug self.handle_boot_request(descriptor).await? => {});
|
||||
network_result_value_or_log!(debug self.handle_boot_request(connection_descriptor).await? => {});
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
@ -1528,7 +1531,7 @@ impl NetworkManager {
|
||||
// Cache the envelope information in the routing table
|
||||
let source_noderef = match routing_table.register_node_with_existing_connection(
|
||||
envelope.get_sender_id(),
|
||||
descriptor,
|
||||
connection_descriptor,
|
||||
ts,
|
||||
) {
|
||||
None => {
|
||||
@ -1543,7 +1546,7 @@ impl NetworkManager {
|
||||
// xxx: deal with spoofing and flooding here?
|
||||
|
||||
// Pass message to RPC system
|
||||
rpc.enqueue_message(envelope, body, source_noderef)?;
|
||||
rpc.enqueue_message(envelope, body, source_noderef, connection_descriptor)?;
|
||||
|
||||
// Inform caller that we dealt with the envelope locally
|
||||
Ok(true)
|
||||
@ -1756,7 +1759,13 @@ impl NetworkManager {
|
||||
routing_table.clear_dial_info_details(RoutingDomain::PublicInternet);
|
||||
net.reset_network_class();
|
||||
} else {
|
||||
let inner = self.inner.lock();
|
||||
warn!("Public address may have changed. Restarting the server may be required.");
|
||||
info!("report_global_socket_address\nsocket_address: {:#?}\nconnection_descriptor: {:#?}\nreporting_peer: {:#?}", socket_address, connection_descriptor, reporting_peer);
|
||||
info!(
|
||||
"public_address_check_cache: {:#?}",
|
||||
inner.public_address_check_cache
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,11 +36,15 @@ use stop_token::future::FutureExt;
|
||||
|
||||
type OperationId = u64;
|
||||
|
||||
/// Where to send an RPC message
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Destination {
|
||||
Direct(NodeRef), // Send to node (target noderef)
|
||||
Relay(NodeRef, DHTKey), // Send to node for relay purposes (relay noderef, target nodeid)
|
||||
PrivateRoute(PrivateRoute), // Send to private route (privateroute)
|
||||
/// Send to node (target noderef)
|
||||
Direct(NodeRef),
|
||||
/// Send to node for relay purposes (relay noderef, target nodeid)
|
||||
Relay(NodeRef, DHTKey),
|
||||
/// Send to private route (privateroute)
|
||||
PrivateRoute(PrivateRoute),
|
||||
}
|
||||
|
||||
impl fmt::Display for Destination {
|
||||
@ -59,12 +63,19 @@ impl fmt::Display for Destination {
|
||||
}
|
||||
}
|
||||
|
||||
/// The decoded header of an RPC message
|
||||
#[derive(Debug, Clone)]
|
||||
struct RPCMessageHeader {
|
||||
timestamp: u64, // time the message was received, not sent
|
||||
/// Time the message was received, not sent
|
||||
timestamp: u64,
|
||||
/// The decoded header of the envelope
|
||||
envelope: Envelope,
|
||||
/// The length in bytes of the rpc message body
|
||||
body_len: u64,
|
||||
peer_noderef: NodeRef, // ensures node doesn't get evicted from routing table until we're done with it
|
||||
/// The noderef of the peer that sent the message (not the original sender). Ensures node doesn't get evicted from routing table until we're done with it
|
||||
peer_noderef: NodeRef,
|
||||
/// The connection from the peer sent the message (not the original sender)
|
||||
connection_descriptor: ConnectionDescriptor,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -993,6 +1004,7 @@ impl RPCProcessor {
|
||||
envelope: Envelope,
|
||||
body: Vec<u8>,
|
||||
peer_noderef: NodeRef,
|
||||
connection_descriptor: ConnectionDescriptor,
|
||||
) -> EyreResult<()> {
|
||||
let msg = RPCMessageEncoded {
|
||||
header: RPCMessageHeader {
|
||||
@ -1000,6 +1012,7 @@ impl RPCProcessor {
|
||||
envelope,
|
||||
body_len: body.len() as u64,
|
||||
peer_noderef,
|
||||
connection_descriptor,
|
||||
},
|
||||
data: RPCMessageData { contents: body },
|
||||
};
|
||||
|
@ -85,6 +85,7 @@ impl RPCProcessor {
|
||||
#[instrument(level = "trace", skip(self, msg), fields(msg.operation.op_id, res), err)]
|
||||
pub(crate) async fn process_status_q(&self, msg: RPCMessage) -> Result<(), RPCError> {
|
||||
let peer_noderef = msg.header.peer_noderef.clone();
|
||||
let connection_descriptor = msg.header.connection_descriptor;
|
||||
|
||||
// Get the question
|
||||
let status_q = match msg.operation.kind() {
|
||||
@ -105,7 +106,12 @@ impl RPCProcessor {
|
||||
|
||||
// Make status answer
|
||||
let node_status = self.network_manager().generate_node_status();
|
||||
let sender_info = Self::generate_sender_info(peer_noderef).await;
|
||||
// Filter the noderef down to the protocol used by the incoming connection
|
||||
let filtered_peer_noderef =
|
||||
peer_noderef.filtered_clone(connection_descriptor.make_dial_info_filter());
|
||||
// Get the peer address in the returned sender info
|
||||
let sender_info = Self::generate_sender_info(filtered_peer_noderef).await;
|
||||
|
||||
let status_a = RPCOperationStatusA {
|
||||
node_status,
|
||||
sender_info,
|
||||
|
Loading…
Reference in New Issue
Block a user