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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
mod common;
use common::*;
#[cfg(feature = "futures-io")]
use tokio_socks::io::Compat;
use tokio_socks::{tcp::socks4::*, Result};
#[cfg(feature = "tokio")]
#[test]
fn connect_userid() -> Result<()> {
let runtime = runtime().lock().unwrap();
let conn = runtime.block_on(Socks4Stream::connect_with_userid(
SOCKS4_PROXY_ADDR,
ECHO_SERVER_ADDR,
"mylogin",
))?;
runtime.block_on(test_connect(conn))
}
#[cfg(feature = "tokio")]
#[test]
fn bind_userid() -> Result<()> {
let bind = {
let runtime = runtime().lock().unwrap();
runtime.block_on(Socks4Listener::bind_with_userid(
SOCKS4_PROXY_ADDR,
ECHO_SERVER_ADDR,
"mylogin",
))
}?;
test_bind_socks4(bind)
}
#[cfg(feature = "tokio")]
#[test]
fn connect_with_socket_userid() -> Result<()> {
let runtime = runtime().lock().unwrap();
let socket = runtime.block_on(connect_unix(UNIX_SOCKS4_PROXY_ADDR))?;
let conn = runtime.block_on(Socks4Stream::connect_with_userid_and_socket(
socket,
ECHO_SERVER_ADDR,
"mylogin",
))?;
runtime.block_on(test_connect(conn))
}
#[cfg(feature = "tokio")]
#[test]
fn bind_with_socket_userid() -> 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_user_and_socket(
socket,
ECHO_SERVER_ADDR,
"mylogin",
))
}?;
test_bind_socks4(bind)
}
#[cfg(feature = "futures-io")]
#[test]
fn connect_with_socket_userid_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))?);
let conn = runtime.block_on(Socks4Stream::connect_with_userid_and_socket(
socket,
ECHO_SERVER_ADDR,
"mylogin",
))?;
runtime.block_on(futures_utils::test_connect(conn))
}
#[cfg(feature = "futures-io")]
#[test]
fn bind_with_socket_userid_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_user_and_socket(
socket,
ECHO_SERVER_ADDR,
"mylogin",
))
}?;
futures_utils::test_bind_socks4(bind)
}
|