-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathsocks4_no_auth.rs
69 lines (62 loc) · 2.22 KB
/
socks4_no_auth.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
mod common;
use common::*;
#[cfg(feature = "futures-io")]
use tokio_socks::io::Compat;
use tokio_socks::{
tcp::socks4::{Socks4Listener, Socks4Stream},
Result,
};
#[cfg(feature = "tokio")]
#[test]
fn connect_no_auth() -> Result<()> {
let runtime = runtime().lock().unwrap();
let conn = runtime.block_on(Socks4Stream::connect(SOCKS4_PROXY_ADDR, ECHO_SERVER_ADDR))?;
runtime.block_on(test_connect(conn))
}
#[cfg(feature = "tokio")]
#[test]
fn bind_no_auth() -> Result<()> {
let bind = {
let runtime = runtime().lock().unwrap();
runtime.block_on(Socks4Listener::bind(SOCKS4_PROXY_ADDR, ECHO_SERVER_ADDR))
}?;
test_bind_socks4(bind)
}
#[cfg(feature = "tokio")]
#[test]
fn connect_with_socket_no_auth() -> Result<()> {
let runtime = runtime().lock().unwrap();
let socket = runtime.block_on(connect_unix(UNIX_SOCKS4_PROXY_ADDR))?;
println!("socket connected");
let conn = runtime.block_on(Socks4Stream::connect_with_socket(socket, ECHO_SERVER_ADDR))?;
runtime.block_on(test_connect(conn))
}
#[cfg(feature = "tokio")]
#[test]
fn bind_with_socket_no_auth() -> Result<()> {
let bind = {
let runtime = runtime().lock().unwrap();
let socket = runtime.block_on(connect_unix(UNIX_SOCKS4_PROXY_ADDR))?;
runtime.block_on(Socks4Listener::bind_with_socket(socket, ECHO_SERVER_ADDR))
}?;
test_bind_socks4(bind)
}
#[cfg(feature = "futures-io")]
#[test]
fn connect_with_socket_no_auth_futures_io() -> Result<()> {
let runtime = futures_utils::runtime().lock().unwrap();
let socket = Compat::new(runtime.block_on(futures_utils::connect_unix(UNIX_SOCKS4_PROXY_ADDR))?);
println!("socket connected");
let conn = runtime.block_on(Socks4Stream::connect_with_socket(socket, ECHO_SERVER_ADDR))?;
runtime.block_on(futures_utils::test_connect(conn))
}
#[cfg(feature = "futures-io")]
#[test]
fn bind_with_socket_no_auth_futures_io() -> Result<()> {
let bind = {
let runtime = futures_utils::runtime().lock().unwrap();
let socket = Compat::new(runtime.block_on(futures_utils::connect_unix(UNIX_SOCKS4_PROXY_ADDR))?);
runtime.block_on(Socks4Listener::bind_with_socket(socket, ECHO_SERVER_ADDR))
}?;
futures_utils::test_bind_socks4(bind)
}