mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-11-06 16:14:11 +00:00
Reformatted with nightly rustfmt
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
use std::env;
|
||||
use std::io::{self, Write};
|
||||
use std::{
|
||||
env,
|
||||
io::{self, Write},
|
||||
};
|
||||
|
||||
use env_logger::{fmt::Formatter, Builder};
|
||||
use log::{LevelFilter, Record};
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use futures::future::{self, Either, FutureExt};
|
||||
use futures::StreamExt;
|
||||
use futures::{
|
||||
future::{self, Either, FutureExt},
|
||||
StreamExt,
|
||||
};
|
||||
use log::info;
|
||||
use std::io;
|
||||
use tokio::signal::{ctrl_c, windows::ctrl_break};
|
||||
|
||||
+10
-3
@@ -13,9 +13,16 @@ use log::{debug, error, info};
|
||||
use std::net::SocketAddr;
|
||||
use tokio;
|
||||
|
||||
use shadowsocks::plugin::PluginConfig;
|
||||
use shadowsocks::relay::socks5::Address;
|
||||
use shadowsocks::{run_local, Config, ConfigType, Mode, ServerAddr, ServerConfig};
|
||||
use shadowsocks::{
|
||||
plugin::PluginConfig,
|
||||
relay::socks5::Address,
|
||||
run_local,
|
||||
Config,
|
||||
ConfigType,
|
||||
Mode,
|
||||
ServerAddr,
|
||||
ServerConfig,
|
||||
};
|
||||
|
||||
mod logging;
|
||||
mod monitor;
|
||||
|
||||
+16
-16
@@ -41,19 +41,21 @@
|
||||
//!
|
||||
//! These defined server will be used with a load balancing algorithm.
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::convert::From;
|
||||
use std::default::Default;
|
||||
use std::error;
|
||||
use std::fmt::{self, Debug, Display, Formatter};
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::Read;
|
||||
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
|
||||
use std::option::Option;
|
||||
use std::path::Path;
|
||||
use std::str::FromStr;
|
||||
use std::string::ToString;
|
||||
use std::time::Duration;
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
convert::From,
|
||||
default::Default,
|
||||
error,
|
||||
fmt::{self, Debug, Display, Formatter},
|
||||
fs::OpenOptions,
|
||||
io::Read,
|
||||
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6},
|
||||
option::Option,
|
||||
path::Path,
|
||||
str::FromStr,
|
||||
string::ToString,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use base64::{decode_config, encode_config, URL_SAFE_NO_PAD};
|
||||
use bytes::Bytes;
|
||||
@@ -65,9 +67,7 @@ use serde_urlencoded;
|
||||
use trust_dns_resolver::config::{NameServerConfigGroup, ResolverConfig};
|
||||
use url::{self, Url};
|
||||
|
||||
use crate::crypto::cipher::CipherType;
|
||||
use crate::plugin::PluginConfig;
|
||||
use crate::relay::socks5::Address;
|
||||
use crate::{crypto::cipher::CipherType, plugin::PluginConfig, relay::socks5::Address};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Default)]
|
||||
struct SSConfig {
|
||||
|
||||
+4
-2
@@ -1,7 +1,9 @@
|
||||
//! Shadowsocks Server Context
|
||||
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
};
|
||||
|
||||
#[cfg(futures = "trust-dns")]
|
||||
use trust_dns_resolver::AsyncResolver;
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
use std::{
|
||||
convert::From,
|
||||
fmt::{self, Debug, Display},
|
||||
io, mem,
|
||||
io,
|
||||
mem,
|
||||
str::{self, FromStr},
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
use crate::crypto::{
|
||||
digest::{self, Digest, DigestType},
|
||||
openssl::OpenSSLCrypto,
|
||||
CipherResult, CipherType, CryptoMode, StreamCipher,
|
||||
CipherResult,
|
||||
CipherType,
|
||||
CryptoMode,
|
||||
StreamCipher,
|
||||
};
|
||||
|
||||
use bytes::{BufMut, BytesMut};
|
||||
|
||||
+15
-3
@@ -2,8 +2,17 @@
|
||||
|
||||
use ring::{
|
||||
aead::{
|
||||
Aad, Algorithm, Nonce, NonceSequence, OpeningKey, SealingKey, UnboundKey, AES_128_GCM, AES_256_GCM,
|
||||
CHACHA20_POLY1305, NONCE_LEN,
|
||||
Aad,
|
||||
Algorithm,
|
||||
Nonce,
|
||||
NonceSequence,
|
||||
OpeningKey,
|
||||
SealingKey,
|
||||
UnboundKey,
|
||||
AES_128_GCM,
|
||||
AES_256_GCM,
|
||||
CHACHA20_POLY1305,
|
||||
NONCE_LEN,
|
||||
},
|
||||
error::Unspecified,
|
||||
};
|
||||
@@ -11,7 +20,10 @@ use ring::{
|
||||
use crate::crypto::{
|
||||
aead::{increase_nonce, make_skey},
|
||||
cipher::Error,
|
||||
AeadDecryptor, AeadEncryptor, CipherResult, CipherType,
|
||||
AeadDecryptor,
|
||||
AeadEncryptor,
|
||||
CipherResult,
|
||||
CipherType,
|
||||
};
|
||||
|
||||
use byte_string::ByteStr;
|
||||
|
||||
+4
-1
@@ -7,7 +7,10 @@ use miscreant::aead::{Aead, Aes128PmacSivAead, Aes256PmacSivAead};
|
||||
use crate::crypto::{
|
||||
aead::{increase_nonce, make_skey},
|
||||
cipher::Error,
|
||||
AeadDecryptor, AeadEncryptor, CipherResult, CipherType,
|
||||
AeadDecryptor,
|
||||
AeadEncryptor,
|
||||
CipherResult,
|
||||
CipherType,
|
||||
};
|
||||
|
||||
use byte_string::ByteStr;
|
||||
|
||||
+12
-4
@@ -6,15 +6,23 @@ use bytes::{BufMut, Bytes, BytesMut};
|
||||
|
||||
use libc::c_ulonglong;
|
||||
use libsodium_ffi::{
|
||||
crypto_aead_xchacha20poly1305_ietf_decrypt, crypto_aead_xchacha20poly1305_ietf_encrypt,
|
||||
crypto_stream_chacha20_ietf_xor_ic, crypto_stream_chacha20_xor_ic, crypto_stream_salsa20_xor_ic,
|
||||
crypto_stream_xsalsa20_xor_ic, sodium_init,
|
||||
crypto_aead_xchacha20poly1305_ietf_decrypt,
|
||||
crypto_aead_xchacha20poly1305_ietf_encrypt,
|
||||
crypto_stream_chacha20_ietf_xor_ic,
|
||||
crypto_stream_chacha20_xor_ic,
|
||||
crypto_stream_salsa20_xor_ic,
|
||||
crypto_stream_xsalsa20_xor_ic,
|
||||
sodium_init,
|
||||
};
|
||||
|
||||
use crate::crypto::{
|
||||
aead::{increase_nonce, make_skey},
|
||||
cipher::Error,
|
||||
AeadDecryptor, AeadEncryptor, CipherResult, CipherType, StreamCipher,
|
||||
AeadDecryptor,
|
||||
AeadEncryptor,
|
||||
CipherResult,
|
||||
CipherType,
|
||||
StreamCipher,
|
||||
};
|
||||
|
||||
static SODIUM_INIT_FLAG: Once = Once::new();
|
||||
|
||||
@@ -8,7 +8,9 @@ use crate::crypto::rc4_md5;
|
||||
use crate::crypto::sodium;
|
||||
use crate::crypto::{
|
||||
cipher::{CipherCategory, CipherResult, CipherType},
|
||||
dummy, table, CryptoMode,
|
||||
dummy,
|
||||
table,
|
||||
CryptoMode,
|
||||
};
|
||||
|
||||
use bytes::BufMut;
|
||||
|
||||
+3
-1
@@ -4,7 +4,9 @@ use std::io::Cursor;
|
||||
|
||||
use crate::crypto::{
|
||||
digest::{self, Digest, DigestType},
|
||||
CipherResult, CryptoMode, StreamCipher,
|
||||
CipherResult,
|
||||
CryptoMode,
|
||||
StreamCipher,
|
||||
};
|
||||
|
||||
use byteorder::{LittleEndian, ReadBytesExt};
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
|
||||
mod trust_dns_resolver;
|
||||
|
||||
pub use self::trust_dns_resolver::create_resolver;
|
||||
pub use self::trust_dns_resolver::resolve;
|
||||
pub use self::trust_dns_resolver::{create_resolver, resolve};
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
use std::collections::VecDeque;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::{
|
||||
collections::VecDeque,
|
||||
fmt,
|
||||
io,
|
||||
sync::{
|
||||
atomic::{AtomicU64, AtomicUsize, Ordering},
|
||||
Arc,
|
||||
Mutex,
|
||||
},
|
||||
};
|
||||
|
||||
use crate::config::ServerConfig;
|
||||
use crate::context::SharedContext;
|
||||
use crate::relay::loadbalancing::server::LoadBalancer;
|
||||
use crate::relay::socks5::Address;
|
||||
use crate::relay::tcprelay::client::ServerClient;
|
||||
use crate::{
|
||||
config::ServerConfig,
|
||||
context::SharedContext,
|
||||
relay::{loadbalancing::server::LoadBalancer, socks5::Address, tcprelay::client::ServerClient},
|
||||
};
|
||||
|
||||
use log::{debug, info};
|
||||
use tokio;
|
||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
use tokio::time::{self, Duration, Instant};
|
||||
use tokio::{
|
||||
self,
|
||||
io::{AsyncReadExt, AsyncWriteExt},
|
||||
time::{self, Duration, Instant},
|
||||
};
|
||||
|
||||
struct Server {
|
||||
config: Arc<ServerConfig>,
|
||||
|
||||
+15
-11
@@ -2,22 +2,26 @@
|
||||
//!
|
||||
//! Implements [SOCKS Protocol Version 5](https://www.ietf.org/rfc/rfc1928.txt) proxy protocol
|
||||
|
||||
use std::convert::From;
|
||||
use std::error;
|
||||
use std::fmt::{self, Debug, Formatter};
|
||||
use std::io::{self, Cursor};
|
||||
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs};
|
||||
use std::str::FromStr;
|
||||
use std::u8;
|
||||
use std::vec;
|
||||
use std::{
|
||||
convert::From,
|
||||
error,
|
||||
fmt::{self, Debug, Formatter},
|
||||
io::{self, Cursor},
|
||||
net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs},
|
||||
str::FromStr,
|
||||
u8,
|
||||
vec,
|
||||
};
|
||||
|
||||
use bytes::buf::BufExt;
|
||||
use bytes::{Buf, BufMut, BytesMut};
|
||||
use bytes::{buf::BufExt, Buf, BufMut, BytesMut};
|
||||
use log::error;
|
||||
use tokio::prelude::*;
|
||||
|
||||
pub use self::consts::{
|
||||
SOCKS5_AUTH_METHOD_GSSAPI, SOCKS5_AUTH_METHOD_NONE, SOCKS5_AUTH_METHOD_NOT_ACCEPTABLE, SOCKS5_AUTH_METHOD_PASSWORD,
|
||||
SOCKS5_AUTH_METHOD_GSSAPI,
|
||||
SOCKS5_AUTH_METHOD_NONE,
|
||||
SOCKS5_AUTH_METHOD_NOT_ACCEPTABLE,
|
||||
SOCKS5_AUTH_METHOD_PASSWORD,
|
||||
};
|
||||
|
||||
#[rustfmt::skip]
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
//! ```
|
||||
|
||||
use std::{
|
||||
cmp, io,
|
||||
cmp,
|
||||
io,
|
||||
marker::Unpin,
|
||||
pin::Pin,
|
||||
slice,
|
||||
|
||||
@@ -12,7 +12,14 @@ use log::trace;
|
||||
use tokio::{net::TcpStream, prelude::*};
|
||||
|
||||
use crate::relay::socks5::{
|
||||
self, Address, Command, HandshakeRequest, HandshakeResponse, Reply, TcpRequestHeader, TcpResponseHeader,
|
||||
self,
|
||||
Address,
|
||||
Command,
|
||||
HandshakeRequest,
|
||||
HandshakeResponse,
|
||||
Reply,
|
||||
TcpRequestHeader,
|
||||
TcpResponseHeader,
|
||||
};
|
||||
|
||||
use super::{CryptoStream, STcpStream};
|
||||
|
||||
+21
-17
@@ -4,27 +4,31 @@
|
||||
// Maybe removed in the future
|
||||
#![allow(clippy::unnecessary_mut_passed)]
|
||||
|
||||
use std::io;
|
||||
use std::marker::Unpin;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
use std::task::{Context, Poll};
|
||||
use std::time::Duration;
|
||||
use std::{
|
||||
io,
|
||||
marker::Unpin,
|
||||
ops::{Deref, DerefMut},
|
||||
pin::Pin,
|
||||
sync::Arc,
|
||||
task::{Context, Poll},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use crate::config::{ConfigType, ServerAddr, ServerConfig};
|
||||
use crate::context::SharedContext;
|
||||
use crate::relay::socks5::Address;
|
||||
use crate::relay::utils::try_timeout;
|
||||
use crate::{
|
||||
config::{ConfigType, ServerAddr, ServerConfig},
|
||||
context::SharedContext,
|
||||
relay::{socks5::Address, utils::try_timeout},
|
||||
};
|
||||
|
||||
use bytes::BytesMut;
|
||||
use futures::future::FusedFuture;
|
||||
use futures::{ready, select, Future};
|
||||
use futures::{future::FusedFuture, ready, select, Future};
|
||||
use log::trace;
|
||||
use tokio::io::{BufReader, ReadHalf, WriteHalf};
|
||||
use tokio::net::TcpStream;
|
||||
use tokio::prelude::*;
|
||||
use tokio::time::{self, Delay};
|
||||
use tokio::{
|
||||
io::{BufReader, ReadHalf, WriteHalf},
|
||||
net::TcpStream,
|
||||
prelude::*,
|
||||
time::{self, Delay},
|
||||
};
|
||||
|
||||
mod aead;
|
||||
pub mod client;
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
//! Relay for TCP server that running on the server side
|
||||
|
||||
use std::io;
|
||||
use std::net::SocketAddr;
|
||||
use std::sync::Arc;
|
||||
use std::{io, net::SocketAddr, sync::Arc};
|
||||
|
||||
use futures::future::{self, Either};
|
||||
use futures::stream::{FuturesUnordered, StreamExt};
|
||||
use futures::{
|
||||
future::{self, Either},
|
||||
stream::{FuturesUnordered, StreamExt},
|
||||
};
|
||||
use log::{debug, error, info, trace};
|
||||
use tokio;
|
||||
use tokio::net::{TcpListener, TcpStream};
|
||||
use tokio::{
|
||||
self,
|
||||
net::{TcpListener, TcpStream},
|
||||
};
|
||||
|
||||
use crate::context::SharedContext;
|
||||
use crate::relay::socks5::Address;
|
||||
use crate::{context::SharedContext, relay::socks5::Address};
|
||||
|
||||
use super::context::{SharedTcpServerContext, TcpServerContext};
|
||||
use super::monitor::TcpMonStream;
|
||||
use super::{CryptoStream, STcpStream};
|
||||
use super::{
|
||||
context::{SharedTcpServerContext, TcpServerContext},
|
||||
monitor::TcpMonStream,
|
||||
CryptoStream,
|
||||
STcpStream,
|
||||
};
|
||||
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
async fn handle_client(
|
||||
|
||||
@@ -8,7 +8,8 @@ use tokio::{
|
||||
self,
|
||||
net::{
|
||||
tcp::{ReadHalf, WriteHalf},
|
||||
TcpListener, TcpStream,
|
||||
TcpListener,
|
||||
TcpStream,
|
||||
},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
//! Stream protocol implementation
|
||||
|
||||
use std::{
|
||||
cmp, io,
|
||||
cmp,
|
||||
io,
|
||||
marker::Unpin,
|
||||
pin::Pin,
|
||||
task::{Context, Poll},
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
//! Local server that establish a TCP tunnel with server
|
||||
|
||||
use std::io;
|
||||
use std::net::SocketAddr;
|
||||
use std::sync::Arc;
|
||||
use std::{io, net::SocketAddr, sync::Arc};
|
||||
|
||||
use futures::future::{self, Either};
|
||||
use log::{debug, error, info, trace};
|
||||
use tokio::net::{TcpListener, TcpStream};
|
||||
|
||||
use crate::config::ServerConfig;
|
||||
use crate::context::SharedContext;
|
||||
use crate::relay::loadbalancing::server::{LoadBalancer, PingBalancer};
|
||||
use crate::relay::socks5::Address;
|
||||
use crate::{
|
||||
config::ServerConfig,
|
||||
context::SharedContext,
|
||||
relay::{
|
||||
loadbalancing::server::{LoadBalancer, PingBalancer},
|
||||
socks5::Address,
|
||||
},
|
||||
};
|
||||
|
||||
/// Established Client Tunnel
|
||||
///
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
//! +--------+-----------+-----------+
|
||||
//! ```
|
||||
|
||||
use std::io;
|
||||
use std::slice;
|
||||
use std::{io, slice};
|
||||
|
||||
use byte_string::ByteStr;
|
||||
use bytes::{BufMut, BytesMut};
|
||||
|
||||
@@ -1,26 +1,35 @@
|
||||
//! UDP relay proxy server
|
||||
|
||||
use std::io::{self, Cursor};
|
||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use std::{
|
||||
io::{self, Cursor},
|
||||
net::{IpAddr, Ipv4Addr, SocketAddr},
|
||||
sync::Arc,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use bytes::BytesMut;
|
||||
use futures::stream::FuturesUnordered;
|
||||
use futures::{self, StreamExt};
|
||||
use futures::{self, stream::FuturesUnordered, StreamExt};
|
||||
use log::{debug, error, info, trace};
|
||||
use lru_time_cache::{Entry, LruCache};
|
||||
use tokio;
|
||||
use tokio::net::udp::{RecvHalf, SendHalf};
|
||||
use tokio::net::UdpSocket;
|
||||
use tokio::sync::mpsc;
|
||||
use tokio::{
|
||||
self,
|
||||
net::{
|
||||
udp::{RecvHalf, SendHalf},
|
||||
UdpSocket,
|
||||
},
|
||||
sync::mpsc,
|
||||
};
|
||||
|
||||
use crate::config::ServerConfig;
|
||||
use crate::context::SharedContext;
|
||||
use crate::relay::{socks5::Address, utils::try_timeout};
|
||||
use crate::{
|
||||
config::ServerConfig,
|
||||
context::SharedContext,
|
||||
relay::{socks5::Address, utils::try_timeout},
|
||||
};
|
||||
|
||||
use super::crypto_io::{decrypt_payload, encrypt_payload};
|
||||
use super::MAXIMUM_UDP_PAYLOAD_SIZE;
|
||||
use super::{
|
||||
crypto_io::{decrypt_payload, encrypt_payload},
|
||||
MAXIMUM_UDP_PAYLOAD_SIZE,
|
||||
};
|
||||
|
||||
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
|
||||
|
||||
@@ -1,26 +1,38 @@
|
||||
//! UDP relay local server
|
||||
|
||||
use std::io::{self, Cursor, ErrorKind, Read};
|
||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use std::{
|
||||
io::{self, Cursor, ErrorKind, Read},
|
||||
net::{IpAddr, Ipv4Addr, SocketAddr},
|
||||
sync::Arc,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use bytes::BytesMut;
|
||||
use log::{debug, error, info, trace};
|
||||
use lru_time_cache::{Entry, LruCache};
|
||||
use tokio;
|
||||
use tokio::net::udp::{RecvHalf, SendHalf};
|
||||
use tokio::net::UdpSocket;
|
||||
use tokio::sync::mpsc;
|
||||
use tokio::{
|
||||
self,
|
||||
net::{
|
||||
udp::{RecvHalf, SendHalf},
|
||||
UdpSocket,
|
||||
},
|
||||
sync::mpsc,
|
||||
};
|
||||
|
||||
use crate::config::{ServerAddr, ServerConfig};
|
||||
use crate::context::SharedContext;
|
||||
use crate::relay::loadbalancing::server::{LoadBalancer, RoundRobin};
|
||||
use crate::relay::socks5::{Address, UdpAssociateHeader};
|
||||
use crate::relay::utils::try_timeout;
|
||||
use crate::{
|
||||
config::{ServerAddr, ServerConfig},
|
||||
context::SharedContext,
|
||||
relay::{
|
||||
loadbalancing::server::{LoadBalancer, RoundRobin},
|
||||
socks5::{Address, UdpAssociateHeader},
|
||||
utils::try_timeout,
|
||||
},
|
||||
};
|
||||
|
||||
use super::crypto_io::{decrypt_payload, encrypt_payload};
|
||||
use super::MAXIMUM_UDP_PAYLOAD_SIZE;
|
||||
use super::{
|
||||
crypto_io::{decrypt_payload, encrypt_payload},
|
||||
MAXIMUM_UDP_PAYLOAD_SIZE,
|
||||
};
|
||||
|
||||
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
|
||||
|
||||
@@ -1,26 +1,38 @@
|
||||
//! UDP relay local server
|
||||
|
||||
use std::io::{self, Cursor, Read};
|
||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use std::{
|
||||
io::{self, Cursor, Read},
|
||||
net::{IpAddr, Ipv4Addr, SocketAddr},
|
||||
sync::Arc,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use bytes::BytesMut;
|
||||
use log::{debug, error, info, trace};
|
||||
use lru_time_cache::{Entry, LruCache};
|
||||
use tokio;
|
||||
use tokio::net::udp::{RecvHalf, SendHalf};
|
||||
use tokio::net::UdpSocket;
|
||||
use tokio::sync::mpsc;
|
||||
use tokio::{
|
||||
self,
|
||||
net::{
|
||||
udp::{RecvHalf, SendHalf},
|
||||
UdpSocket,
|
||||
},
|
||||
sync::mpsc,
|
||||
};
|
||||
|
||||
use crate::config::{ServerAddr, ServerConfig};
|
||||
use crate::context::{Context, SharedContext};
|
||||
use crate::relay::loadbalancing::server::{LoadBalancer, RoundRobin};
|
||||
use crate::relay::socks5::Address;
|
||||
use crate::relay::utils::try_timeout;
|
||||
use crate::{
|
||||
config::{ServerAddr, ServerConfig},
|
||||
context::{Context, SharedContext},
|
||||
relay::{
|
||||
loadbalancing::server::{LoadBalancer, RoundRobin},
|
||||
socks5::Address,
|
||||
utils::try_timeout,
|
||||
},
|
||||
};
|
||||
|
||||
use super::crypto_io::{decrypt_payload, encrypt_payload};
|
||||
use super::MAXIMUM_UDP_PAYLOAD_SIZE;
|
||||
use super::{
|
||||
crypto_io::{decrypt_payload, encrypt_payload},
|
||||
MAXIMUM_UDP_PAYLOAD_SIZE,
|
||||
};
|
||||
|
||||
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
use std::future::Future;
|
||||
use std::{io, time::Duration};
|
||||
use std::{future::Future, io, time::Duration};
|
||||
|
||||
use tokio::time;
|
||||
|
||||
|
||||
+6
-3
@@ -1,13 +1,16 @@
|
||||
use std::net::{SocketAddr, ToSocketAddrs};
|
||||
|
||||
use tokio::prelude::*;
|
||||
use tokio::time::{self, Duration};
|
||||
use tokio::{
|
||||
prelude::*,
|
||||
time::{self, Duration},
|
||||
};
|
||||
|
||||
use shadowsocks::{
|
||||
config::{Config, ConfigType, Mode, ServerConfig},
|
||||
crypto::CipherType,
|
||||
relay::{socks5::Address, tcprelay::client::Socks5Client},
|
||||
run_local, run_server,
|
||||
run_local,
|
||||
run_server,
|
||||
};
|
||||
|
||||
pub struct Socks5TestServer {
|
||||
|
||||
+12
-7
@@ -1,12 +1,17 @@
|
||||
use env_logger;
|
||||
use tokio;
|
||||
use tokio::net::{TcpStream, UdpSocket};
|
||||
use tokio::prelude::*;
|
||||
use tokio::time::{self, Duration};
|
||||
use tokio::{
|
||||
self,
|
||||
net::{TcpStream, UdpSocket},
|
||||
prelude::*,
|
||||
time::{self, Duration},
|
||||
};
|
||||
|
||||
use shadowsocks::config::{Config, ConfigType};
|
||||
use shadowsocks::relay::socks5::Address;
|
||||
use shadowsocks::{run_local, run_server};
|
||||
use shadowsocks::{
|
||||
config::{Config, ConfigType},
|
||||
relay::socks5::Address,
|
||||
run_local,
|
||||
run_server,
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
async fn tcp_tunnel() {
|
||||
|
||||
+6
-3
@@ -7,8 +7,10 @@ use std::{
|
||||
|
||||
use bytes::{BufMut, BytesMut};
|
||||
use log::debug;
|
||||
use tokio::prelude::*;
|
||||
use tokio::time::{self, Duration};
|
||||
use tokio::{
|
||||
prelude::*,
|
||||
time::{self, Duration},
|
||||
};
|
||||
|
||||
use shadowsocks::{
|
||||
config::{Config, ConfigType, Mode, ServerConfig},
|
||||
@@ -17,7 +19,8 @@ use shadowsocks::{
|
||||
socks5::{Address, UdpAssociateHeader},
|
||||
tcprelay::client::Socks5Client,
|
||||
},
|
||||
run_local, run_server,
|
||||
run_local,
|
||||
run_server,
|
||||
};
|
||||
|
||||
const SERVER_ADDR: &str = "127.0.0.1:8093";
|
||||
|
||||
Reference in New Issue
Block a user