feat: v0.3.1, fix panic

This commit is contained in:
2022-08-26 00:33:40 +08:00
parent 3037464c03
commit 9fbc498615
3 changed files with 26 additions and 5 deletions

View File

@@ -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 {