@@ -4,19 +4,16 @@ pub use errors::*;
44mod messages;
55use messages:: * ;
66
7- use std:: future:: Future ;
8- use std:: pin:: Pin ;
9- use std:: task:: { Context , Poll } ;
10- 117use std:: net:: { IpAddr , SocketAddr , SocketAddrV4 , ToSocketAddrs } ;
8+ use std:: task:: { Context , Poll } ;
129
1310use http:: Uri ;
1411use hyper:: rt:: { Read , Write } ;
1512use tower_service:: Service ;
1613
1714use bytes:: BytesMut ;
1815
19- use pin_project_lite :: pin_project ;
16+ use super :: { Handshaking , SocksError } ;
2017
2118/// Tunnel Proxy via SOCKSv4
2219///
@@ -35,23 +32,6 @@ struct SocksConfig {
3532 local_dns : bool ,
3633}
3734
38- pin_project ! {
39- // Not publicly exported (so missing_docs doesn't trigger).
40- //
41- // We return this `Future` instead of the `Pin<Box<dyn Future>>` directly
42- // so that users don't rely on it fitting in a `Pin<Box<dyn Future>>` slot
43- // (and thus we can change the type in the future).
44- #[ must_use = "futures do nothing unless polled" ]
45- #[ allow( missing_debug_implementations) ]
46- pub struct Handshaking <F , T , E > {
47- #[ pin]
48- fut: BoxHandshaking <T , E >,
49- _marker: std:: marker:: PhantomData <F >
50- }
51- }
52- 53- type BoxHandshaking < T , E > = Pin < Box < dyn Future < Output = Result < T , super :: SocksError < E > > > + Send > > ;
54- 5535impl < C > SocksV4 < C > {
5636 /// Create a new SOCKSv4 handshake service
5737 ///
@@ -86,12 +66,7 @@ impl SocksConfig {
8666 }
8767 }
8868
89- async fn execute < T , E > (
90- self ,
91- mut conn : T ,
92- host : String ,
93- port : u16 ,
94- ) -> Result < T , super :: SocksError < E > >
69+ async fn execute < T , E > ( self , mut conn : T , host : String , port : u16 ) -> Result < T , SocksError < E > >
9570 where
9671 T : Read + Write + Unpin ,
9772 {
@@ -109,7 +84,7 @@ impl SocksConfig {
10984 None
11085 }
11186 } )
112- . ok_or ( super :: SocksError :: DnsFailure ) ?
87+ . ok_or ( SocksError :: DnsFailure ) ?
11388 } else {
11489 Address :: Domain ( host, port)
11590 }
@@ -142,11 +117,11 @@ where
142117 C :: Error : Send + ' static ,
143118{
144119 type Response = C :: Response ;
145- type Error = super :: SocksError < C :: Error > ;
120+ type Error = SocksError < C :: Error > ;
146121 type Future = Handshaking < C :: Future , C :: Response , C :: Error > ;
147122
148123 fn poll_ready ( & mut self , cx : & mut Context < ' _ > ) -> Poll < Result < ( ) , Self :: Error > > {
149- self . inner . poll_ready ( cx) . map_err ( super :: SocksError :: Inner )
124+ self . inner . poll_ready ( cx) . map_err ( SocksError :: Inner )
150125 }
151126
152127 fn call ( & mut self , dst : Uri ) -> Self :: Future {
@@ -155,12 +130,9 @@ where
155130
156131 let fut = async move {
157132 let port = dst. port ( ) . map ( |p| p. as_u16 ( ) ) . unwrap_or ( 443 ) ;
158- let host = dst
159- . host ( )
160- . ok_or ( super :: SocksError :: MissingHost ) ?
161- . to_string ( ) ;
133+ let host = dst. host ( ) . ok_or ( SocksError :: MissingHost ) ?. to_string ( ) ;
162134
163- let conn = connecting. await . map_err ( super :: SocksError :: Inner ) ?;
135+ let conn = connecting. await . map_err ( SocksError :: Inner ) ?;
164136 config. execute ( conn, host, port) . await
165137 } ;
166138
@@ -170,14 +142,3 @@ where
170142 }
171143 }
172144}
173- 174- impl < F , T , E > Future for Handshaking < F , T , E >
175- where
176- F : Future < Output = Result < T , E > > ,
177- {
178- type Output = Result < T , super :: SocksError < E > > ;
179- 180- fn poll ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
181- self . project ( ) . fut . poll ( cx)
182- }
183- }
0 commit comments