From 878be1b51ea5e84633aa85f28936a6352828c2ae Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 31 Oct 2023 19:41:48 +0000 Subject: [PATCH] Format Rust code using rustfmt --- src/net2/mod.rs | 41 +++++++++++++++++++++++------------------ src/net2/utils.rs | 20 ++++++++++++++------ 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/net2/mod.rs b/src/net2/mod.rs index 97e668df..7894c041 100644 --- a/src/net2/mod.rs +++ b/src/net2/mod.rs @@ -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::(); let peer = Arc::new(Peer { identity: peer_id, diff --git a/src/net2/utils.rs b/src/net2/utils.rs index d5d4a7d1..addf5bbb 100644 --- a/src/net2/utils.rs +++ b/src/net2/utils.rs @@ -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)) }