@@ -60,6 +60,8 @@ pub(crate) struct SniProxyServerConfig {
6060 pub ( crate ) client_tcp_portmap : ProtocolPortMap ,
6161 pub ( crate ) extra_metrics_tags : Option < Arc < MetricTagMap > > ,
6262 pub ( crate ) allowed_sites : Option < HostMatch < Arc < SniHostConfig > > > ,
63+ #[ cfg( target_os = "linux" ) ]
64+ listen_transparent : bool ,
6365}
6466
6567impl SniProxyServerConfig {
@@ -93,6 +95,7 @@ impl SniProxyServerConfig {
9395 client_tcp_portmap : ProtocolPortMap :: tcp_client ( ) ,
9496 extra_metrics_tags : None ,
9597 allowed_sites : None ,
98+ listen_transparent : false ,
9699 }
97100 }
98101
@@ -255,6 +258,10 @@ impl SniProxyServerConfig {
255258 self . allowed_sites = Some ( allowed_sites) ;
256259 Ok ( ( ) )
257260 }
261+ "listen_transparent" => {
262+ self . listen_transparent = g3_yaml:: value:: as_bool ( v) ?;
263+ Ok ( ( ) )
264+ }
258265 _ => Err ( anyhow ! ( "invalid key {k}" ) ) ,
259266 }
260267 }
@@ -285,6 +292,13 @@ impl SniProxyServerConfig {
285292 self . task_idle_check_interval = IDLE_CHECK_MAXIMUM_DURATION ;
286293 }
287294
295+ #[ cfg( target_os = "linux" ) ]
296+ if self . listen_transparent {
297+ if let Some ( listen) = & mut self . listen {
298+ listen. set_transparent ( ) ;
299+ }
300+ }
301+
288302 Ok ( ( ) )
289303 }
290304}
0 commit comments