@@ -24,19 +24,18 @@ pub use self::{
2424 detect:: MetricsFamilies as DetectMetrics , metrics:: InboundMetrics , policy:: DefaultPolicy ,
2525} ;
2626use linkerd_app_core:: {
27- config:: { ConnectConfig , ProxyConfig , QueueConfig } ,
27+ config:: { ProxyConfig , QueueConfig } ,
2828 drain,
2929 http_tracing:: SpanSink ,
30- identity, io ,
30+ identity,
3131 metrics:: prom,
32- proxy:: { tap, tcp } ,
32+ proxy:: tap,
3333 svc,
3434 transport:: { self , Remote , ServerAddr } ,
3535 Error , NameAddr , NameMatch , ProxyRuntime ,
3636} ;
3737use std:: { fmt:: Debug , time:: Duration } ;
3838use thiserror:: Error ;
39- use tracing:: debug_span;
4039
4140#[ derive( Clone , Debug ) ]
4241pub struct Config {
@@ -183,99 +182,12 @@ impl Inbound<()> {
183182 pub fn with_stack < S > ( self , stack : S ) -> Inbound < S > {
184183 self . map_stack ( move |_, _, _| svc:: stack ( stack) )
185184 }
186-
187- /// Readies the inbound stack to make TCP connections (for both TCP
188- // forwarding and HTTP proxying).
189- pub fn into_tcp_connect < T > (
190- self ,
191- proxy_port : u16 ,
192- ) -> Inbound <
193- impl svc:: MakeConnection <
194- T ,
195- Connection = impl Send + Unpin ,
196- Metadata = impl Send + Unpin ,
197- Error = Error ,
198- Future = impl Send ,
199- > + Clone ,
200- >
201- where
202- T : svc:: Param < Remote < ServerAddr > > + ' static ,
203- {
204- self . map_stack ( |config, _, _| {
205- // Establishes connections to remote peers (for both TCP
206- // forwarding and HTTP proxying).
207- let ConnectConfig {
208- ref keepalive,
209- ref user_timeout,
210- ref timeout,
211- ..
212- } = config. proxy . connect ;
213-
214- #[ derive( Debug , thiserror:: Error ) ]
215- #[ error( "inbound connection must not target port {0}" ) ]
216- struct Loop ( u16 ) ;
217-
218- svc:: stack ( transport:: ConnectTcp :: new ( * keepalive, * user_timeout) )
219- // Limits the time we wait for a connection to be established.
220- . push_connect_timeout ( * timeout)
221- // Prevent connections that would target the inbound proxy port from looping.
222- . push_filter ( move |t : T | {
223- let addr = t. param ( ) ;
224- let port = addr. port ( ) ;
225- if port == proxy_port {
226- return Err ( Loop ( port) ) ;
227- }
228- Ok ( addr)
229- } )
230- } )
231- }
232185}
233186
234187impl < S > Inbound < S > {
235188 pub fn push < L : svc:: layer:: Layer < S > > ( self , layer : L ) -> Inbound < L :: Service > {
236189 self . map_stack ( |_, _, stack| stack. push ( layer) )
237190 }
238-
239- // Forwards TCP streams that cannot be decoded as HTTP.
240- //
241- // Looping is always prevented.
242- pub fn push_tcp_forward < T , I > (
243- self ,
244- ) -> Inbound <
245- svc:: ArcNewService <
246- T ,
247- impl svc:: Service < I , Response = ( ) , Error = ForwardError , Future = impl Send > + Clone ,
248- > ,
249- >
250- where
251- T : svc:: Param < transport:: labels:: Key >
252- + svc:: Param < Remote < ServerAddr > >
253- + Clone
254- + Send
255- + Sync
256- + ' static ,
257- I : io:: AsyncRead + io:: AsyncWrite ,
258- I : Debug + Send + Unpin + ' static ,
259- S : svc:: MakeConnection < T > + Clone + Send + Sync + Unpin + ' static ,
260- S :: Connection : Send + Unpin ,
261- S :: Metadata : Send + Unpin ,
262- S :: Future : Send ,
263- {
264- self . map_stack ( |_, rt, connect| {
265- connect
266- . push ( transport:: metrics:: Client :: layer (
267- rt. metrics . proxy . transport . clone ( ) ,
268- ) )
269- . push ( svc:: stack:: WithoutConnectionMetadata :: layer ( ) )
270- . push_new_thunk ( )
271- . push_on_service ( tcp:: Forward :: layer ( ) )
272- . push_on_service ( drain:: Retain :: layer ( rt. drain . clone ( ) ) )
273- . instrument ( |_: & _ | debug_span ! ( "tcp" ) )
274- . push ( svc:: NewMapErr :: layer_from_target :: < ForwardError , _ > ( ) )
275- . push ( svc:: ArcNewService :: layer ( ) )
276- . check_new :: < T > ( )
277- } )
278- }
279191}
280192
281193fn stack_labels ( proto : & ' static str , name : & ' static str ) -> metrics:: StackLabels {
0 commit comments