gossan-core 0.2.0

Core types, traits, and shared networking utilities for the gossan attack-surface scanner
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use tokio::net::TcpStream;

pub async fn connect_tcp(addr: &str, port: u16, proxy: Option<&str>) -> std::io::Result<TcpStream> {
    if let Some(p) = proxy {
        let p_addr = p
            .trim_start_matches("http://")
            .trim_start_matches("socks5://")
            .trim_start_matches("socks5h://");
        let stream = tokio_socks::tcp::Socks5Stream::connect(p_addr, (addr, port))
            .await
            .map_err(|e| std::io::Error::other(e.to_string()))?;
        Ok(stream.into_inner())
    } else {
        TcpStream::connect((addr, port)).await
    }
}