private route loopbacks

This commit is contained in:
John Smith
2022-11-24 16:23:33 -05:00
parent 0b2ecd53c7
commit 4d573a966f
4 changed files with 175 additions and 138 deletions
+20 -9
View File
@@ -228,18 +228,29 @@ impl RPCProcessor {
)))
}
SafetySelection::Safe(safety_spec) => {
// Sent directly but with a safety route, respond to private route
let avoid_node_id = match &pr_first_hop.node {
RouteNode::NodeId(n) => n.key,
RouteNode::PeerInfo(p) => p.node_id.key,
};
// Sent to a private route via a safety route, respond to private route
let Some(pr_key) = rss
.get_private_route_for_safety_spec(safety_spec, &[avoid_node_id])
.map_err(RPCError::internal)? else {
return Ok(NetworkResult::no_connection_other("no private route for response at this time"));
// Check for loopback test
let pr_key = if safety_spec.preferred_route
== Some(private_route.public_key)
{
// Private route is also safety route during loopback test
private_route.public_key
} else {
// Get the privat route to respond to that matches the safety route spec we sent the request with
let avoid_node_id = match &pr_first_hop.node {
RouteNode::NodeId(n) => n.key,
RouteNode::PeerInfo(p) => p.node_id.key,
};
let Some(pr_key) = rss
.get_private_route_for_safety_spec(safety_spec, &[avoid_node_id])
.map_err(RPCError::internal)? else {
return Ok(NetworkResult::no_connection_other("no private route for response at this time"));
};
pr_key
};
// Get the assembled route for response
let private_route = rss
.assemble_private_route(&pr_key, None)