@@ -28,23 +28,20 @@ use linkerd_app_core::{
28
28
proxy:: tcp,
29
29
serve, svc, tls,
30
30
transport:: { self , listen:: Bind , ClientAddr , Local , OrigDstAddr , Remote , ServerAddr } ,
31
- Error , NameMatch , ProxyRuntime ,
31
+ Error , NameMatch , Never , ProxyRuntime ,
32
32
} ;
33
- use std:: { convert:: TryFrom , fmt:: Debug , future:: Future , time:: Duration } ;
33
+ use std:: { collections :: HashSet , convert:: TryFrom , fmt:: Debug , future:: Future , time:: Duration } ;
34
34
use tracing:: { debug_span, info_span} ;
35
35
36
36
#[ derive( Clone , Debug ) ]
37
37
pub struct Config {
38
38
pub allow_discovery : NameMatch ,
39
39
pub proxy : ProxyConfig ,
40
40
pub require_identity_for_inbound_ports : RequireIdentityForPorts ,
41
- pub disable_protocol_detection_for_ports : SkipByPort ,
41
+ pub disable_protocol_detection_for_ports : HashSet < u16 > ,
42
42
pub profile_idle_timeout : Duration ,
43
43
}
44
44
45
- #[ derive( Clone , Debug ) ]
46
- pub struct SkipByPort ( std:: sync:: Arc < indexmap:: IndexSet < u16 > > ) ;
47
-
48
45
#[ derive( Clone , Debug ) ]
49
46
pub struct Inbound < S > {
50
47
config : Config ,
@@ -230,6 +227,7 @@ where
230
227
let disable_detect = self . config . disable_protocol_detection_for_ports . clone ( ) ;
231
228
let require_id = self . config . require_identity_for_inbound_ports . clone ( ) ;
232
229
let config = self . config . proxy . clone ( ) ;
230
+
233
231
self . clone ( )
234
232
. push_http_router ( profiles)
235
233
. push_http_server ( )
@@ -262,15 +260,21 @@ where
262
260
) )
263
261
. instrument ( |_: & _ | debug_span ! ( "proxy" ) )
264
262
. push_switch (
265
- disable_detect,
263
+ move |t : T | {
264
+ let OrigDstAddr ( addr) = t. param ( ) ;
265
+ if !disable_detect. contains ( & addr. port ( ) ) {
266
+ Ok :: < _ , Never > ( svc:: Either :: A ( t) )
267
+ } else {
268
+ Ok ( svc:: Either :: B ( TcpAccept :: port_skipped ( t) ) )
269
+ }
270
+ } ,
266
271
self . clone ( )
267
272
. push_tcp_forward ( server_port)
268
273
. stack
269
274
. push_map_target ( TcpEndpoint :: from)
270
275
. push ( self . runtime . metrics . transport . layer_accept ( ) )
271
- . push_map_target ( TcpAccept :: port_skipped)
272
- . check_new_service :: < T , _ > ( )
273
- . instrument ( |_: & T | debug_span ! ( "forward" ) )
276
+ . check_new_service :: < TcpAccept , _ > ( )
277
+ . instrument ( |_: & TcpAccept | debug_span ! ( "forward" ) )
274
278
. into_inner ( ) ,
275
279
)
276
280
. check_new_service :: < T , I > ( )
@@ -294,30 +298,6 @@ where
294
298
}
295
299
}
296
300
297
- // === impl SkipByPort ===
298
-
299
- impl From < indexmap:: IndexSet < u16 > > for SkipByPort {
300
- fn from ( ports : indexmap:: IndexSet < u16 > ) -> Self {
301
- SkipByPort ( ports. into ( ) )
302
- }
303
- }
304
-
305
- impl < T > svc:: Predicate < T > for SkipByPort
306
- where
307
- T : svc:: Param < OrigDstAddr > ,
308
- {
309
- type Request = svc:: Either < T , T > ;
310
-
311
- fn check ( & mut self , t : T ) -> Result < Self :: Request , Error > {
312
- let OrigDstAddr ( addr) = t. param ( ) ;
313
- if !self . 0 . contains ( & addr. port ( ) ) {
314
- Ok ( svc:: Either :: A ( t) )
315
- } else {
316
- Ok ( svc:: Either :: B ( t) )
317
- }
318
- }
319
- }
320
-
321
301
fn stack_labels ( proto : & ' static str , name : & ' static str ) -> metrics:: StackLabels {
322
302
metrics:: StackLabels :: inbound ( proto, name)
323
303
}
0 commit comments