pub struct SecretsHandler { /* private fields */ }Expand description
Handles secret placeholder substitution in TLS-intercepted plaintext.
Created from SecretsConfig and the destination SNI. Determines which
secrets are eligible for this connection based on host matching.
Implementations§
Source§impl SecretsHandler
impl SecretsHandler
Sourcepub fn new(config: &SecretsConfig, sni: &str, tls_intercepted: bool) -> Self
pub fn new(config: &SecretsConfig, sni: &str, tls_intercepted: bool) -> Self
Create a handler for a specific connection.
Filters secrets by host matching against the SNI. Only secrets
whose allowed_hosts match sni will be substituted.
tls_intercepted indicates whether this is a MITM connection
(true) or a bypass/plain connection (false).
Sourcepub fn new_tls_intercepted(
config: &SecretsConfig,
sni: &str,
guest_ip: IpAddr,
shared: &SharedState,
) -> Self
pub fn new_tls_intercepted( config: &SecretsConfig, sni: &str, guest_ip: IpAddr, shared: &SharedState, ) -> Self
Create a handler for a TLS-intercepted connection.
Host-scoped secrets require both an SNI match and a DNS cache binding from the original guest destination IP to the allowed host.
Sourcepub fn new_plain_http(
config: &SecretsConfig,
host: &str,
guest_ip: IpAddr,
shared: &SharedState,
) -> Self
pub fn new_plain_http( config: &SecretsConfig, host: &str, guest_ip: IpAddr, shared: &SharedState, ) -> Self
Create a handler for a plain-HTTP (non-TLS) connection.
Only substitutes secrets that have opted in with require_tls_identity(false).
Host matching and DNS-cache binding are still enforced.
Sourcepub fn new_plain_http_invalid_host(config: &SecretsConfig) -> Self
pub fn new_plain_http_invalid_host(config: &SecretsConfig) -> Self
Handler for a plain-HTTP connection with no usable Host header.
The host can’t be proven, so secrets are blocked unless every one is
host-agnostic (HostPattern::Any) — only then is substitution safe.
Sourcepub fn with_guest_dst(self, guest_dst: SocketAddr) -> Self
pub fn with_guest_dst(self, guest_dst: SocketAddr) -> Self
Attach the original guest destination for structured violation logs.
Sourcepub fn substitute<'a>(
&mut self,
data: &'a [u8],
) -> Result<Cow<'a, [u8]>, ViolationAction>
pub fn substitute<'a>( &mut self, data: &'a [u8], ) -> Result<Cow<'a, [u8]>, ViolationAction>
Substitute secrets in plaintext data (guest → server direction).
Splits the HTTP message on \r\n\r\n to scope substitution:
headers: substitutes in the header portion (before boundary)basic_auth: substitutes in Authorization headers specificallyquery_params: substitutes in the request line (first line, query portion)body: substitutes in the body portion (after boundary)
Returns the violation action if a placeholder is detected going to a disallowed host.