From 9fbc498615be08e8c066e95d20e263efc07eff1b Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Fri, 26 Aug 2022 00:33:40 +0800 Subject: [PATCH] feat: v0.3.1, fix panic --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/client.rs | 27 ++++++++++++++++++++++++--- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f5176f..7f4548e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -718,7 +718,7 @@ dependencies = [ [[package]] name = "simple-rust-http3-proxy" -version = "0.3.0" +version = "0.3.1" dependencies = [ "clap", "deser-hjson", diff --git a/Cargo.toml b/Cargo.toml index a784010..bebaf48 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "simple-rust-http3-proxy" -version = "0.3.0" +version = "0.3.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/client.rs b/src/client.rs index d3d17a1..5810b7f 100644 --- a/src/client.rs +++ b/src/client.rs @@ -69,9 +69,30 @@ pub async fn run(listen_config: &ListenConfig) -> XResult<()> { let endpoint = endpoint_opt.as_mut().unwrap(); - let connect = endpoint.connect(addr, &server_name).unwrap(); - let quinn::NewConnection { connection, .. } = connect.await.unwrap(); - let (send, recv) = connection.open_bi().await.unwrap(); + let connect = match endpoint.connect(addr, &server_name) { + Ok(connect) => connect, + Err(e) => { + failure!("Connect failed: {:?}", e); + endpoint_opt = None; + continue; + } + }; + let quinn::NewConnection { connection, .. } = match connect.await { + Ok(connection) => connection, + Err(e) => { + failure!("Connect failed: {:?}", e); + endpoint_opt = None; + continue; + } + }; + let (send, recv) = match connection.open_bi().await { + Ok(stream) => stream, + Err(e) => { + failure!("Connect failed: {:?}", e); + endpoint_opt = None; + continue; + } + }; let remote_addr = format!("{}", connection.remote_address()); let local_addr = connection.local_ip().map(|ip| format!("{}", ip)).unwrap_or_else(|| "".to_string()); tokio::spawn(async move {