Format Rust code using rustfmt

This commit is contained in:
github-actions[bot] 2023-10-31 19:41:48 +00:00 committed by GitHub
parent b318e57d5e
commit 878be1b51e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 24 deletions

View File

@ -715,8 +715,7 @@ async fn recv_connection_via_router(
let Ok(ws_url) = make_ws_url(our_ip, ip, port) else {
return Err(anyhow!("failed to parse websocket url"));
};
let Ok(Ok((websocket, _response))) = time::timeout(TIMEOUT, connect_async(ws_url)).await
else {
let Ok(Ok((websocket, _response))) = time::timeout(TIMEOUT, connect_async(ws_url)).await else {
return Err(anyhow!("failed to connect to target"));
};
let (mut write_stream, mut read_stream) = websocket.split();
@ -798,7 +797,8 @@ async fn init_connection(
let Ok(ws_url) = make_ws_url(our_ip, ip, port) else {
return Err(anyhow!("failed to parse websocket url"));
};
let Ok(Ok((websocket, _response))) = time::timeout(TIMEOUT, connect_async(ws_url)).await
let Ok(Ok((websocket, _response))) =
time::timeout(TIMEOUT, connect_async(ws_url)).await
else {
return Err(anyhow!("failed to connect to target"));
};
@ -811,7 +811,8 @@ async fn init_connection(
let Ok(ws_url) = make_ws_url(our_ip, ip, port) else {
return Err(anyhow!("failed to parse websocket url"));
};
let Ok(Ok((websocket, _response))) = time::timeout(TIMEOUT, connect_async(ws_url)).await
let Ok(Ok((websocket, _response))) =
time::timeout(TIMEOUT, connect_async(ws_url)).await
else {
return Err(anyhow!("failed to connect to target"));
};
@ -930,20 +931,24 @@ async fn handle_local_message(
// respond by attempting to init a matching passthrough.
// TODO can discriminate more here..
if our.allowed_routers.contains(&km.source.node) {
let Ok((peer_id, peer_conn)) = time::timeout(TIMEOUT,
recv_connection_via_router(
our,
our_ip,
&from,
pki,
keypair,
&peers
.get(&km.source.node)
.ok_or(anyhow!("unknown router"))?
.identity,
)).await? else {
return Err(anyhow!("someone tried to connect to us but it timed out"))
};
let Ok((peer_id, peer_conn)) = time::timeout(
TIMEOUT,
recv_connection_via_router(
our,
our_ip,
&from,
pki,
keypair,
&peers
.get(&km.source.node)
.ok_or(anyhow!("unknown router"))?
.identity,
),
)
.await?
else {
return Err(anyhow!("someone tried to connect to us but it timed out"));
};
let (peer_tx, peer_rx) = unbounded_channel::<KernelMessage>();
let peer = Arc::new(Peer {
identity: peer_id,

View File

@ -46,16 +46,24 @@ pub async fn create_passthrough(
let Some((ref ip, ref port)) = to_id.ws_routing else {
// create passthrough to indirect node that we do routing for
//
let target_peer = peers.get(&to_name).ok_or(anyhow!("can't route to that indirect node"))?;
let target_peer = peers
.get(&to_name)
.ok_or(anyhow!("can't route to that indirect node"))?;
if !target_peer.routing_for {
return Err(anyhow!("we don't route for that indirect node"))
return Err(anyhow!("we don't route for that indirect node"));
}
// send their net:sys:uqbar process a message, notifying it to create a *matching*
// passthrough request, which we can pair with this pending one.
target_peer.sender.send(KernelMessage {
id: rand::random(),
source: Address { node: our.name.clone(), process: ProcessId::from_str("net:sys:uqbar").unwrap() },
target: Address { node: to_name.clone(), process: ProcessId::from_str("net:sys:uqbar").unwrap() },
source: Address {
node: our.name.clone(),
process: ProcessId::from_str("net:sys:uqbar").unwrap(),
},
target: Address {
node: to_name.clone(),
process: ProcessId::from_str("net:sys:uqbar").unwrap(),
},
rsvp: None,
message: Message::Request(Request {
inherit: false,
@ -73,7 +81,7 @@ pub async fn create_passthrough(
target: to_name,
write_stream: write_stream_1,
read_stream: read_stream_1,
})
}),
));
};
// create passthrough to direct node
@ -117,7 +125,7 @@ pub fn validate_routing_request(
&routing_request.signature,
)?;
if routing_request.target == routing_request.source {
return Err(anyhow!("can't route to self"))
return Err(anyhow!("can't route to self"));
}
Ok((their_id.clone(), routing_request.target))
}