MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / get_inbound_pp_header

Function get_inbound_pp_header

gateway/src/pp.rs:32–42  ·  view source on GitHub ↗

Read or synthesize the inbound proxy protocol header. When `inbound_pp_enabled` is true, reads a PP header from the stream (e.g. from an upstream load balancer). When false, synthesizes one from the TCP peer address.

(
    inbound: TcpStream,
    config: &ProxyConfig,
)

Source from the content-addressed store, hash-verified

30/// When `inbound_pp_enabled` is true, reads a PP header from the stream (e.g. from an upstream
31/// load balancer). When false, synthesizes one from the TCP peer address.
32pub(crate) async fn get_inbound_pp_header(
33 inbound: TcpStream,
34 config: &ProxyConfig,
35) -> Result<(TcpStream, ProxyHeader)> {
36 if config.inbound_pp_enabled {
37 read_proxy_header(inbound).await
38 } else {
39 let header = create_inbound_pp_header(&inbound);
40 Ok((inbound, header))
41 }
42}
43
44pub struct DisplayAddr<'a>(pub &'a ProxyHeader);
45

Callers 1

handle_connectionFunction · 0.85

Calls 2

read_proxy_headerFunction · 0.85
create_inbound_pp_headerFunction · 0.85

Tested by

no test coverage detected