pub async fn associate(proxy: &SocketAddr) -> io::Result<Socks5Client> {
        let local_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 0);
        let socket = create_udp_socket(&local_addr).await?;

        // The actual bind address, tell the proxy that I am going to send packets from this address
        let local_addr = socket.local_addr()?;

        let (assoc_client, proxy_addr) = Socks5TcpClient::udp_associate(local_addr, proxy).await?;
        match proxy_addr {
            Address::SocketAddress(sa) => socket.connect(sa).await?,
            // FIXME: `connect` will use tokio's builtin DNS resolver.
            // But if we want to use `trust-dns`, we have to initialize a `Context` instance (for the global `AsyncResolver` instance)
            Address::DomainNameAddress(ref dname, port) => socket.connect((dname.as_str(), port)).await?,
        }

        Ok(Socks5Client { socket, assoc_client })
    }
/// Create a new UDP associate to `proxy`
Create a new UDP associate to `proxy`
Create a new UDP associate to ` proxy `
pub async fn associate(proxy: &SocketAddr) -> io::Result<Socks5Client> {
        let local_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 0);
        let socket = create_udp_socket(&local_addr).await?;
        // The actual bind address, tell the proxy that I am going to send packets from this address
        let local_addr = socket.local_addr()?;
        let (assoc_client, proxy_addr) = Socks5TcpClient::udp_associate(local_addr, proxy).await?;
        match proxy_addr {
            Address::SocketAddress(sa) => socket.connect(sa).await?,
            // FIXME: `connect` will use tokio's builtin DNS resolver.
            // But if we want to use `trust-dns`, we have to initialize a `Context` instance (for the global `AsyncResolver` instance)
            Address::DomainNameAddress(ref dname, port) => socket.connect((dname.as_str(), port)).await?,
        }
        Ok(Socks5Client { socket, assoc_client })
    }
pub async fn associate ( proxy : & SocketAddr ) -> io :: Result < Socks5Client > { let local_addr = SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 0 , 0 , 0 , 0 ) ) , 0 ) ; let socket = create_udp_socket ( & local_addr ) . await ? ; // The actual bind address, tell the proxy that I am going to send packets from this address let local_addr = socket . local_addr ( ) ? ; let ( assoc_client , proxy_addr ) = Socks5TcpClient :: udp_associate ( local_addr , proxy ) . await ? ; match proxy_addr { Address :: SocketAddress ( sa ) => socket . connect ( sa ) . await ? , // FIXME: `connect` will use tokio's builtin DNS resolver. // But if we want to use `trust-dns`, we have to initialize a `Context` instance (for the global `AsyncResolver` instance) Address :: DomainNameAddress ( ref dname , port ) => socket . connect ( ( dname . as_str ( ) , port ) ) . await ? , } Ok ( Socks5Client { socket , assoc_client } ) }
Create a new UDP associate to `proxy`
Create a new UDP associate to ` proxy `
proxy
&SocketAddr