reverse connect fix
This commit is contained in:
parent
113fb82469
commit
823db3adf2
@ -676,7 +676,11 @@ impl NetworkManager {
|
|||||||
|
|
||||||
// Process a received signal
|
// Process a received signal
|
||||||
#[instrument(level = "trace", skip(self), err)]
|
#[instrument(level = "trace", skip(self), err)]
|
||||||
pub async fn handle_signal(&self, signal_info: SignalInfo) -> EyreResult<NetworkResult<()>> {
|
pub async fn handle_signal(
|
||||||
|
&self,
|
||||||
|
connection_descriptor: ConnectionDescriptor,
|
||||||
|
signal_info: SignalInfo,
|
||||||
|
) -> EyreResult<NetworkResult<()>> {
|
||||||
match signal_info {
|
match signal_info {
|
||||||
SignalInfo::ReverseConnect { receipt, peer_info } => {
|
SignalInfo::ReverseConnect { receipt, peer_info } => {
|
||||||
let routing_table = self.routing_table();
|
let routing_table = self.routing_table();
|
||||||
@ -697,6 +701,10 @@ impl NetworkManager {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Restrict reverse connection to same protocol as inbound signal
|
||||||
|
let peer_nr = peer_nr
|
||||||
|
.filtered_clone(NodeRefFilter::from(connection_descriptor.protocol_type()));
|
||||||
|
|
||||||
// Make a reverse connection to the peer and send the receipt to it
|
// Make a reverse connection to the peer and send the receipt to it
|
||||||
rpc.rpc_call_return_receipt(Destination::direct(peer_nr), receipt)
|
rpc.rpc_call_return_receipt(Destination::direct(peer_nr), receipt)
|
||||||
.await
|
.await
|
||||||
@ -1038,16 +1046,11 @@ impl NetworkManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Some(relay_nr) = some_relay_nr {
|
if let Some(relay_nr) = some_relay_nr {
|
||||||
// Force sequencing if this came in sequenced.
|
// Ensure the protocol is forwarded exactly as is
|
||||||
// The sender did the prefer/ensure calculation when it did get_contact_method,
|
// Address type is allowed to change if connectivity is better
|
||||||
// so we don't need to do it here.
|
let relay_nr = relay_nr.filtered_clone(
|
||||||
let relay_nr = if connection_descriptor.remote().protocol_type().is_ordered() {
|
NodeRefFilter::new().with_protocol_type(connection_descriptor.protocol_type()),
|
||||||
let mut relay_nr = relay_nr.clone();
|
);
|
||||||
relay_nr.set_sequencing(Sequencing::EnsureOrdered);
|
|
||||||
relay_nr
|
|
||||||
} else {
|
|
||||||
relay_nr
|
|
||||||
};
|
|
||||||
|
|
||||||
// Relay the packet to the desired destination
|
// Relay the packet to the desired destination
|
||||||
log_net!("relaying {} bytes to {}", data.len(), relay_nr);
|
log_net!("relaying {} bytes to {}", data.len(), relay_nr);
|
||||||
|
@ -52,8 +52,8 @@ impl RPCProcessor {
|
|||||||
|
|
||||||
// Can't allow anything other than direct packets here, as handling reverse connections
|
// Can't allow anything other than direct packets here, as handling reverse connections
|
||||||
// or anything like via signals over private routes would deanonymize the route
|
// or anything like via signals over private routes would deanonymize the route
|
||||||
match &msg.header.detail {
|
let connection_descriptor = match &msg.header.detail {
|
||||||
RPCMessageHeaderDetail::Direct(_) => {}
|
RPCMessageHeaderDetail::Direct(d) => d.connection_descriptor,
|
||||||
RPCMessageHeaderDetail::SafetyRouted(_) | RPCMessageHeaderDetail::PrivateRouted(_) => {
|
RPCMessageHeaderDetail::SafetyRouted(_) | RPCMessageHeaderDetail::PrivateRouted(_) => {
|
||||||
return Ok(NetworkResult::invalid_message("signal must be direct"));
|
return Ok(NetworkResult::invalid_message("signal must be direct"));
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ impl RPCProcessor {
|
|||||||
let network_manager = self.network_manager();
|
let network_manager = self.network_manager();
|
||||||
let signal_info = signal.destructure();
|
let signal_info = signal.destructure();
|
||||||
network_manager
|
network_manager
|
||||||
.handle_signal(signal_info)
|
.handle_signal(connection_descriptor, signal_info)
|
||||||
.await
|
.await
|
||||||
.map_err(RPCError::network)
|
.map_err(RPCError::network)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user