clone from github.com/sticnarf/tokio-socks

This commit is contained in:
2022-03-18 01:16:47 +08:00
parent e5544214bf
commit dc264fbcb2
19 changed files with 1685 additions and 2 deletions

42
tests/no_auth.rs Normal file
View File

@@ -0,0 +1,42 @@
mod common;
use crate::common::{runtime, test_bind};
use common::{connect_unix, test_connect, ECHO_SERVER_ADDR, PROXY_ADDR};
use tokio_socks::{
tcp::{Socks5Listener, Socks5Stream},
Result,
};
#[test]
fn connect_no_auth() -> Result<()> {
let runtime = runtime().lock().unwrap();
let conn = runtime.block_on(Socks5Stream::connect(PROXY_ADDR, ECHO_SERVER_ADDR))?;
runtime.block_on(test_connect(conn))
}
#[test]
fn bind_no_auth() -> Result<()> {
let bind = {
let runtime = runtime().lock().unwrap();
runtime.block_on(Socks5Listener::bind(PROXY_ADDR, ECHO_SERVER_ADDR))
}?;
test_bind(bind)
}
#[test]
fn connect_with_socket_no_auth() -> Result<()> {
let runtime = runtime().lock().unwrap();
let socket = runtime.block_on(connect_unix())?;
let conn = runtime.block_on(Socks5Stream::connect_with_socket(socket, ECHO_SERVER_ADDR))?;
runtime.block_on(test_connect(conn))
}
#[test]
fn bind_with_socket_no_auth() -> Result<()> {
let bind = {
let runtime = runtime().lock().unwrap();
let socket = runtime.block_on(connect_unix())?;
runtime.block_on(Socks5Listener::bind_with_socket(socket, ECHO_SERVER_ADDR))
}?;
test_bind(bind)
}