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.
Auto Trait Implementations§
impl Freeze for SecretsHandler
impl RefUnwindSafe for SecretsHandler
impl Send for SecretsHandler
impl Sync for SecretsHandler
impl Unpin for SecretsHandler
impl UnsafeUnpin for SecretsHandler
impl UnwindSafe for SecretsHandler
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more