@@ -38,6 +38,10 @@ pub(crate) enum AsyncStream {
3838 /// A Unix domain socket connection.
3939 #[ cfg( unix) ]
4040 Unix ( tokio:: net:: UnixStream ) ,
41+
42+ /// A connection to a SOCKS5 proxy.
43+ #[ cfg( feature = "socks5-proxy" ) ]
44+ Socks5 ( fast_socks5:: client:: Socks5Stream < TcpStream > ) ,
4145}
4246
4347impl AsyncStream {
@@ -175,6 +179,10 @@ impl tokio::io::AsyncRead for AsyncStream {
175179 Self :: Tls ( ref mut inner) => tokio:: io:: AsyncRead :: poll_read ( Pin :: new ( inner) , cx, buf) ,
176180 #[ cfg( unix) ]
177181 Self :: Unix ( ref mut inner) => tokio:: io:: AsyncRead :: poll_read ( Pin :: new ( inner) , cx, buf) ,
182+ #[ cfg( feature = "socks5-proxy" ) ]
183+ Self :: Socks5 ( ref mut inner) => {
184+ tokio:: io:: AsyncRead :: poll_read ( Pin :: new ( inner) , cx, buf)
185+ }
178186 }
179187 }
180188}
@@ -191,6 +199,8 @@ impl AsyncWrite for AsyncStream {
191199 Self :: Tls ( ref mut inner) => Pin :: new ( inner) . poll_write ( cx, buf) ,
192200 #[ cfg( unix) ]
193201 Self :: Unix ( ref mut inner) => AsyncWrite :: poll_write ( Pin :: new ( inner) , cx, buf) ,
202+ #[ cfg( feature = "socks5-proxy" ) ]
203+ Self :: Socks5 ( ref mut inner) => AsyncWrite :: poll_write ( Pin :: new ( inner) , cx, buf) ,
194204 }
195205 }
196206
@@ -201,6 +211,8 @@ impl AsyncWrite for AsyncStream {
201211 Self :: Tls ( ref mut inner) => Pin :: new ( inner) . poll_flush ( cx) ,
202212 #[ cfg( unix) ]
203213 Self :: Unix ( ref mut inner) => AsyncWrite :: poll_flush ( Pin :: new ( inner) , cx) ,
214+ #[ cfg( feature = "socks5-proxy" ) ]
215+ Self :: Socks5 ( ref mut inner) => AsyncWrite :: poll_flush ( Pin :: new ( inner) , cx) ,
204216 }
205217 }
206218
@@ -211,6 +223,8 @@ impl AsyncWrite for AsyncStream {
211223 Self :: Tls ( ref mut inner) => Pin :: new ( inner) . poll_shutdown ( cx) ,
212224 #[ cfg( unix) ]
213225 Self :: Unix ( ref mut inner) => Pin :: new ( inner) . poll_shutdown ( cx) ,
226+ #[ cfg( feature = "socks5-proxy" ) ]
227+ Self :: Socks5 ( ref mut inner) => Pin :: new ( inner) . poll_shutdown ( cx) ,
214228 }
215229 }
216230
@@ -225,6 +239,8 @@ impl AsyncWrite for AsyncStream {
225239 Self :: Tls ( ref mut inner) => Pin :: new ( inner) . poll_write_vectored ( cx, bufs) ,
226240 #[ cfg( unix) ]
227241 Self :: Unix ( ref mut inner) => Pin :: new ( inner) . poll_write_vectored ( cx, bufs) ,
242+ #[ cfg( feature = "socks5-proxy" ) ]
243+ Self :: Socks5 ( ref mut inner) => Pin :: new ( inner) . poll_write_vectored ( cx, bufs) ,
228244 }
229245 }
230246
@@ -235,6 +251,8 @@ impl AsyncWrite for AsyncStream {
235251 Self :: Tls ( ref inner) => inner. is_write_vectored ( ) ,
236252 #[ cfg( unix) ]
237253 Self :: Unix ( ref inner) => inner. is_write_vectored ( ) ,
254+ #[ cfg( feature = "socks5-proxy" ) ]
255+ Self :: Socks5 ( ref inner) => inner. is_write_vectored ( ) ,
238256 }
239257 }
240258}
0 commit comments