mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-10-01 01:26:08 -04:00
commit with debug code
This commit is contained in:
parent
126bf28070
commit
53ae04aff9
@ -125,6 +125,7 @@ pub(crate) enum ContactMethod {
|
||||
pub enum SendDataKind {
|
||||
Direct(ConnectionDescriptor),
|
||||
Indirect,
|
||||
Existing(ConnectionDescriptor),
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Hash)]
|
||||
@ -1260,7 +1261,7 @@ impl NetworkManager {
|
||||
// Update timestamp for this last connection since we just sent to it
|
||||
node_ref.set_last_connection(connection_descriptor, intf::get_timestamp());
|
||||
|
||||
return Ok(NetworkResult::value(SendDataKind::Direct(
|
||||
return Ok(NetworkResult::value(SendDataKind::Existing(
|
||||
connection_descriptor,
|
||||
)));
|
||||
}
|
||||
@ -1411,7 +1412,7 @@ impl NetworkManager {
|
||||
|
||||
// Ensure we can read the magic number
|
||||
if data.len() < 4 {
|
||||
log_net!(debug "short packet".green());
|
||||
log_net!(debug "short packet");
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
@ -1428,7 +1429,13 @@ impl NetworkManager {
|
||||
}
|
||||
|
||||
// Decode envelope header (may fail signature validation)
|
||||
let envelope = Envelope::from_signed_data(data).wrap_err("envelope failed to decode")?;
|
||||
let envelope = match Envelope::from_signed_data(data) {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
log_net!(debug "envelope failed to decode: {}", e);
|
||||
return Ok(false);
|
||||
}
|
||||
};
|
||||
|
||||
// Get routing table and rpc processor
|
||||
let (routing_table, rpc) = {
|
||||
@ -1453,18 +1460,20 @@ impl NetworkManager {
|
||||
let ets = envelope.get_timestamp();
|
||||
if let Some(tsbehind) = tsbehind {
|
||||
if tsbehind > 0 && (ts > ets && ts - ets > tsbehind) {
|
||||
bail!(
|
||||
log_net!(debug
|
||||
"envelope time was too far in the past: {}ms ",
|
||||
timestamp_to_secs(ts - ets) * 1000f64
|
||||
);
|
||||
return Ok(false);
|
||||
}
|
||||
}
|
||||
if let Some(tsahead) = tsahead {
|
||||
if tsahead > 0 && (ts < ets && ets - ts > tsahead) {
|
||||
bail!(
|
||||
log_net!(debug
|
||||
"envelope time was too far in the future: {}ms",
|
||||
timestamp_to_secs(ets - ts) * 1000f64
|
||||
);
|
||||
return Ok(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1633,6 +1642,9 @@ impl NetworkManager {
|
||||
connection_descriptor: ConnectionDescriptor, // the connection descriptor used
|
||||
reporting_peer: NodeRef, // the peer's noderef reporting the socket address
|
||||
) {
|
||||
// xxx debug code
|
||||
info!("report_global_socket_address\nsocket_address: {:#?}\nconnection_descriptor: {:#?}\nreporting_peer: {:#?}", socket_address, connection_descriptor, reporting_peer);
|
||||
|
||||
let key = PublicAddressCheckCacheKey(
|
||||
connection_descriptor.protocol_type(),
|
||||
connection_descriptor.address_type(),
|
||||
@ -1659,8 +1671,10 @@ impl NetworkManager {
|
||||
let network_class = net.get_network_class().unwrap_or(NetworkClass::Invalid);
|
||||
|
||||
// Determine if our external address has likely changed
|
||||
let needs_public_address_detection =
|
||||
if matches!(network_class, NetworkClass::InboundCapable) {
|
||||
let needs_public_address_detection = if matches!(
|
||||
network_class,
|
||||
NetworkClass::InboundCapable
|
||||
) {
|
||||
// Get the dial info filter for this connection so we can check if we have any public dialinfo that may have changed
|
||||
let dial_info_filter = connection_descriptor.make_dial_info_filter();
|
||||
|
||||
@ -1693,6 +1707,13 @@ impl NetworkManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// xxx debug code
|
||||
if changed {
|
||||
info!("XXX\npublic_address_check_cache: {:#?}\ncurrent_addresses: {:#?}\ninconsistencies: {}", inner
|
||||
.public_address_check_cache, current_addresses, inconsistencies);
|
||||
}
|
||||
|
||||
changed
|
||||
} else {
|
||||
// If we are currently outbound only, we don't have any public dial info
|
||||
|
@ -88,6 +88,7 @@ struct RPCMessageEncoded {
|
||||
data: RPCMessageData,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct RPCMessage {
|
||||
header: RPCMessageHeader,
|
||||
operation: RPCOperation,
|
||||
@ -336,7 +337,10 @@ impl RPCProcessor {
|
||||
inner
|
||||
.waiting_rpc_table
|
||||
.remove(&op_id)
|
||||
.ok_or_else(RPCError::else_internal("Unmatched operation id"))?
|
||||
.ok_or_else(RPCError::else_internal(format!(
|
||||
"Unmatched operation id: {:#?}",
|
||||
msg
|
||||
)))?
|
||||
};
|
||||
eventual.resolve((Span::current().id(), msg)).await;
|
||||
Ok(())
|
||||
|
@ -70,6 +70,9 @@ impl RPCProcessor {
|
||||
SendDataKind::Indirect => {
|
||||
// Do nothing in this case, as the socket address returned here would be for any node other than ours
|
||||
}
|
||||
SendDataKind::Existing(_) => {
|
||||
// Do nothing in this case, as an existing connection could not have a different public address or it would have been reset
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user