From 8a5d89885a855576072e539304bdd097ed4810ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=A3rebe=20-=20Romain=20GERARD?= Date: Tue, 31 Oct 2023 08:43:24 +0100 Subject: [PATCH] fmt --- Cargo.toml | 2 +- src/tunnel/server.rs | 4 ++-- src/udp.rs | 20 +++++--------------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9f742f7..580ba1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wstunnel" -version = "7.8.1" +version = "7.8.2" edition = "2021" repository = "https://github.com/erebe/wstunnel.git" diff --git a/src/tunnel/server.rs b/src/tunnel/server.rs index 70e5b41..5f683a6 100644 --- a/src/tunnel/server.rs +++ b/src/tunnel/server.rs @@ -5,14 +5,14 @@ use std::sync::Arc; use std::time::Duration; use super::{JwtTunnelConfig, JWT_DECODE}; -use crate::{tcp, tls, LocalProtocol, WsServerConfig, udp}; +use crate::{tcp, tls, udp, LocalProtocol, WsServerConfig}; use hyper::server::conn::Http; use hyper::service::service_fn; use hyper::{http, Body, Request, Response, StatusCode}; use jsonwebtoken::TokenData; use tokio::io::{AsyncRead, AsyncWrite}; -use tokio::net::{TcpListener}; +use tokio::net::TcpListener; use tokio::sync::oneshot; use tracing::{error, info, span, warn, Instrument, Level, Span}; use url::Host; diff --git a/src/udp.rs b/src/udp.rs index 66f54c8..6f07bdf 100644 --- a/src/udp.rs +++ b/src/udp.rs @@ -9,17 +9,17 @@ use std::io; use std::io::{Error, ErrorKind}; use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; +use log::warn; use std::pin::{pin, Pin}; use std::sync::{Arc, Weak}; use std::task::{ready, Poll}; use std::time::Duration; -use log::warn; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tokio::net::UdpSocket; use tokio::sync::futures::Notified; use tokio::sync::Notify; -use tokio::time::{Sleep, timeout}; +use tokio::time::{timeout, Sleep}; use tracing::{debug, error, info}; use url::Host; @@ -248,11 +248,7 @@ impl AsyncWrite for MyUdpSocket { } } -pub async fn connect( - host: &Host, - port: u16, - connect_timeout: Duration, -) -> anyhow::Result { +pub async fn connect(host: &Host, port: u16, connect_timeout: Duration) -> anyhow::Result { info!("Opening UDP connection to {}:{}", host, port); let socket_addrs: Vec = match host { @@ -264,7 +260,6 @@ pub async fn connect( Host::Ipv6(ip) => vec![SocketAddr::V6(SocketAddrV6::new(*ip, port, 0, 0))], }; - let mut cnx = None; let mut last_err = None; for addr in socket_addrs { @@ -280,7 +275,7 @@ pub async fn connect( Err(err) => { warn!("cannot bind udp socket {:?}", err); continue; - }, + } }; match timeout(connect_timeout, socket.connect(addr)).await { @@ -304,12 +299,7 @@ pub async fn connect( if let Some(cnx) = cnx { Ok(MyUdpSocket::new(Arc::new(cnx))) } else { - Err(anyhow!( - "Cannot connect to udp peer {}:{} reason {:?}", - host, - port, - last_err - )) + Err(anyhow!("Cannot connect to udp peer {}:{} reason {:?}", host, port, last_err)) } }