1
0

moving Error to root

This commit is contained in:
EAimTY 2023-02-03 15:23:04 +09:00
parent d08945844b
commit 443252c2ca
5 changed files with 31 additions and 34 deletions

View File

@ -1,8 +1,8 @@
use crate::{ use crate::{
config::Relay, config::Relay,
error::Error,
socks5::Server as Socks5Server, socks5::Server as Socks5Server,
utils::{self, CongestionControl, ServerAddr, UdpRelayMode}, utils::{self, CongestionControl, ServerAddr, UdpRelayMode},
Error,
}; };
use bytes::Bytes; use bytes::Bytes;
use crossbeam_utils::atomic::AtomicCell; use crossbeam_utils::atomic::AtomicCell;

View File

@ -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,
}

View File

@ -1,14 +1,16 @@
use socks5::Server;
use self::{ use self::{
config::{Config, ConfigError}, config::{Config, ConfigError},
connection::Endpoint, 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 config;
mod connection; mod connection;
mod error;
mod socks5; mod socks5;
mod utils; mod utils;
@ -44,3 +46,25 @@ async fn main() {
Server::start().await; 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,
}

View File

@ -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 bytes::Bytes;
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
use parking_lot::Mutex; use parking_lot::Mutex;

View File

@ -1,4 +1,4 @@
use crate::error::Error; use crate::Error;
use rustls::{Certificate, RootCertStore}; use rustls::{Certificate, RootCertStore};
use rustls_pemfile::Item; use rustls_pemfile::Item;
use std::{ use std::{