diff --git a/tuic-client/src/connection.rs b/tuic-client/src/connection.rs index dfb7bb3..81f94c6 100644 --- a/tuic-client/src/connection.rs +++ b/tuic-client/src/connection.rs @@ -1,8 +1,8 @@ use crate::{ config::Relay, - error::Error, socks5::Server as Socks5Server, utils::{self, CongestionControl, ServerAddr, UdpRelayMode}, + Error, }; use bytes::Bytes; use crossbeam_utils::atomic::AtomicCell; diff --git a/tuic-client/src/error.rs b/tuic-client/src/error.rs deleted file mode 100644 index c541e32..0000000 --- a/tuic-client/src/error.rs +++ /dev/null @@ -1,27 +0,0 @@ -use quinn::{ConnectError, ConnectionError}; -use std::io::Error as IoError; -use thiserror::Error; -use tuic_quinn::Error as ModelError; -use webpki::Error as WebpkiError; - -#[derive(Debug, Error)] -pub enum Error { - #[error(transparent)] - Io(#[from] IoError), - #[error(transparent)] - Connect(#[from] ConnectError), - #[error(transparent)] - Connection(#[from] ConnectionError), - #[error(transparent)] - Model(#[from] ModelError), - #[error(transparent)] - Webpki(#[from] WebpkiError), - #[error("timeout establishing connection")] - Timeout, - #[error("cannot resolve the server name")] - DnsResolve, - #[error("received packet from an unexpected source")] - WrongPacketSource, - #[error("invalid socks5 authentication")] - InvalidSocks5Auth, -} diff --git a/tuic-client/src/main.rs b/tuic-client/src/main.rs index cc06f30..b1ef3a9 100644 --- a/tuic-client/src/main.rs +++ b/tuic-client/src/main.rs @@ -1,14 +1,16 @@ -use socks5::Server; - use self::{ config::{Config, ConfigError}, connection::Endpoint, + socks5::Server, }; -use std::{env, process}; +use quinn::{ConnectError, ConnectionError}; +use std::{env, io::Error as IoError, process}; +use thiserror::Error; +use tuic_quinn::Error as ModelError; +use webpki::Error as WebpkiError; mod config; mod connection; -mod error; mod socks5; mod utils; @@ -44,3 +46,25 @@ async fn main() { Server::start().await; } + +#[derive(Debug, Error)] +pub enum Error { + #[error(transparent)] + Io(#[from] IoError), + #[error(transparent)] + Connect(#[from] ConnectError), + #[error(transparent)] + Connection(#[from] ConnectionError), + #[error(transparent)] + Model(#[from] ModelError), + #[error(transparent)] + Webpki(#[from] WebpkiError), + #[error("timeout establishing connection")] + Timeout, + #[error("cannot resolve the server name")] + DnsResolve, + #[error("received packet from an unexpected source")] + WrongPacketSource, + #[error("invalid socks5 authentication")] + InvalidSocks5Auth, +} diff --git a/tuic-client/src/socks5.rs b/tuic-client/src/socks5.rs index d44b58a..2b88217 100644 --- a/tuic-client/src/socks5.rs +++ b/tuic-client/src/socks5.rs @@ -1,4 +1,4 @@ -use crate::{config::Local, connection::Connection as TuicConnection, error::Error}; +use crate::{config::Local, connection::Connection as TuicConnection, Error}; use bytes::Bytes; use once_cell::sync::OnceCell; use parking_lot::Mutex; diff --git a/tuic-client/src/utils.rs b/tuic-client/src/utils.rs index afa7695..752184a 100644 --- a/tuic-client/src/utils.rs +++ b/tuic-client/src/utils.rs @@ -1,4 +1,4 @@ -use crate::error::Error; +use crate::Error; use rustls::{Certificate, RootCertStore}; use rustls_pemfile::Item; use std::{