use clap::{Arg, App}; use async_proxies::proxies::socks4::general::{ Socks4General, ConnParams, Command, Timeouts }; use async_proxies::proxy::AsyncProxy; use std::time::Duration; #[tokio::main] async fn main() { let matches = App::new("Example program using async proxies") .version("0.1.0") .author("TonyGraim") .arg(Arg::with_name("proxy-address") .short("p") .long("proxy-addr") .takes_value(true) .required(true) .help("The address of the socks4-proxy in format `ip:port`")) .arg(Arg::with_name("destination") .short("d") .long("destination") .takes_value(true) .required(true) .help("The destination point in format `ipv4:port`")) .arg(Arg::with_name("ident") .short("i") .long("ident") .takes_value(true) .default_value("") .help("")) .get_matches(); let proxy_addr = matches.value_of("proxy-address").unwrap(); let destination = matches.value_of("destination").unwrap(); let ident = matches.value_of("ident").unwrap(); let timeouts = Timeouts::new( Duration::from_secs(8), Duration::from_secs(8), Duration::from_secs(8) ); let connection_params = ConnParams::new(proxy_addr.parse().unwrap(), destination.parse().unwrap(), String::from(ident), Command::TcpConnectionEstablishment, timeouts); println!("Starting connection to the destination `{}` throught socks4-proxy `{}`", destination, proxy_addr); let mut socks4 = Socks4General; match socks4.connect(connection_params).await { Ok(_) => println!("Succesfully connected to the destination!"), Err(e) => println!("Ooops! The program got an error: {}", e) }; }