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

Function should_send_pp

gateway/src/proxy/port_policy.rs:129–136  ·  view source on GitHub ↗

Decide whether the gateway should send a PROXY protocol header on the outbound connection to (`instance_id`, `port`). Cache hit returns the declared value. Cache miss returns `false` (no PP) — `is_port_allowed` runs first under fail-close and would have rejected the connection if the policy were truly unknown, so by the time we get here the cache is normally populated. The default-false fallback

(state: &Proxy, instance_id: &str, port: u16)

Source from the content-addressed store, hash-verified

127/// cache is normally populated. The default-false fallback is conservative
128/// because a missing PP header is safer than a forged one.
129pub(crate) fn should_send_pp(state: &Proxy, instance_id: &str, port: u16) -> bool {
130 state
131 .lock()
132 .instance_port_policy(instance_id)
133 .and_then(|p| p.ports.get(&port))
134 .map(|f| f.pp)
135 .unwrap_or(false)
136}
137
138/// Spawn the background lazy-fetch worker. Should be called once at startup.
139pub(crate) fn spawn_fetcher(state: Proxy, mut rx: UnboundedReceiver<String>) {

Callers 2

proxy_to_appFunction · 0.85
proxyMethod · 0.85

Calls 3

instance_port_policyMethod · 0.80
lockMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected