@@ -130,6 +130,7 @@ impl Authentication<'_> {
130130#[ cfg( feature = "client" ) ]
131131pub mod client {
132132 use crate :: {
133+ tcp_stream_connect,
133134 v5:: { read_response, write_addr, Authentication , MAX_ADDR_LEN } ,
134135 Error , TargetAddr , ToTargetAddr ,
135136 } ;
@@ -150,6 +151,14 @@ pub mod client {
150151 impl Socks5Stream {
151152 /// Connects to a target server through a SOCKS5 proxy.
152153 ///
154+ /// # Notes
155+ /// If `target` is a `TargetAddr::Domain`, the domain name will be forwarded
156+ /// to the proxy server to be resolved there.
157+ ///
158+ /// When using `connect_timeout` the duration will apply to every socket address
159+ /// tried. Only the last connection error will be returned or
160+ /// `io::Error(Error::NoResolveSocketAddrs)`.
161+ ///
153162 /// # Errors
154163 /// - `io::Error(std::io::ErrorKind::*, socks2::Error::*?)`
155164 pub fn connect < T , U > (
@@ -167,6 +176,9 @@ pub mod client {
167176 /// Connects to a target server through a SOCKS5 proxy using given
168177 /// username and password.
169178 ///
179+ /// # Notes
180+ /// See `Socks5Stream::connect()`.
181+ ///
170182 /// # Errors
171183 /// - `io::Error(std::io::ErrorKind::*, socks2::Error::*?)`
172184 pub fn connect_with_password < T , U > (
@@ -195,17 +207,7 @@ pub mod client {
195207 T : ToSocketAddrs ,
196208 U : ToTargetAddr ,
197209 {
198- let mut socket = match connect_timeout {
199- None => TcpStream :: connect ( proxy) ?,
200- // TODO: Connect timeout for each address until one works?
201- Some ( t) => TcpStream :: connect_timeout (
202- & proxy
203- . to_socket_addrs ( ) ?
204- . next ( )
205- . ok_or_else ( || Error :: NoResolveSocketAddr { } . into_io ( ) ) ?,
206- t,
207- ) ?,
208- } ;
210+ let mut socket = tcp_stream_connect ( proxy, connect_timeout) ?;
209211
210212 let target = target. to_target_addr ( ) ?;
211213
@@ -390,6 +392,9 @@ pub mod bind {
390392 /// The proxy will filter incoming connections based on the value of
391393 /// `target`.
392394 ///
395+ /// # Notes
396+ /// See `Socks5Stream::connect()`.
397+ ///
393398 /// # Errors
394399 /// - `io::Error(std::io::ErrorKind::*, socks2::Error::*?)`
395400 pub fn bind < T , U > (
@@ -410,6 +415,9 @@ pub mod bind {
410415 /// The proxy will filter incoming connections based on the value of
411416 /// `target`.
412417 ///
418+ /// # Notes
419+ /// See `Socks5Stream::connect()`.
420+ ///
413421 /// # Errors
414422 /// - `io::Error(std::io::ErrorKind::*, socks2::Error::*?)`
415423 pub fn bind_with_password < T , U > (
@@ -481,6 +489,9 @@ pub mod udp {
481489 /// Creates a UDP socket bound to the specified address which will have its
482490 /// traffic routed through the specified proxy.
483491 ///
492+ /// # Notes
493+ /// See `Socks5Stream::connect()`.
494+ ///
484495 /// # Errors
485496 /// - `io::Error(std::io::ErrorKind::*, socks2::Error::*?)`
486497 pub fn bind < T , U > ( proxy : T , addr : U , connect_timeout : Option < Duration > ) -> io:: Result < Self >
@@ -495,6 +506,9 @@ pub mod udp {
495506 /// traffic routed through the specified proxy. The given username and password
496507 /// is used to authenticate to the SOCKS proxy.
497508 ///
509+ /// # Notes
510+ /// See `Socks5Stream::connect()`.
511+ ///
498512 /// # Errors
499513 /// - `io::Error(std::io::ErrorKind::*, socks2::Error::*?)`
500514 pub fn bind_with_password < T , U > (
0 commit comments