Skip to main content

ProxyHandle

Struct ProxyHandle 

Source
pub struct ProxyHandle {
    pub port: u16,
    pub token: Zeroizing<String>,
    /* private fields */
}
Expand description

Handle returned when the proxy server starts.

Contains the assigned port, session token, and a shutdown channel. Drop the handle or send to shutdown_tx to stop the proxy.

Fields§

§port: u16

The actual port the proxy is listening on

§token: Zeroizing<String>

Session token for client authentication

Implementations§

Source§

impl ProxyHandle

Source

pub fn shutdown(&self)

Signal the proxy to shut down gracefully.

Source

pub fn drain_audit_events(&self) -> Vec<NetworkAuditEvent>

Drain and return collected network audit events.

Source

pub fn intercept_ca_path(&self) -> Option<&Path>

Path to the TLS-intercept trust bundle, when interception is active.

The CLI uses this to:

  • point SSL_CERT_FILE / REQUESTS_CA_BUNDLE / NODE_EXTRA_CA_CERTS / CURL_CA_BUNDLE at the file in the child env;
  • grant the sandboxed child a Landlock / Seatbelt read capability on the file before applying the sandbox.

None when interception is not configured (no intercept_ca_dir in ProxyConfig) or when no configured route requires L7 visibility.

Source

pub fn route_diagnostics(&self, config: &ProxyConfig) -> Vec<(String, String)>

One-line-per-route diagnostic summary suitable for surfacing at session start. Returns (prefix, summary) pairs.

Each summary names: upstream URL, credential resolution status (✓ / ✗ + source label), TLS-intercept on/off, and endpoint_rules count. Designed to make silent credential-resolution failures noisy by default, addressing the common “I created the keychain entry but the warn at debug level got missed” footgun.

config is the same ProxyConfig that was passed to start(); the handle doesn’t keep a copy, so the CLI passes it back in.

Source

pub fn env_vars(&self) -> Vec<(String, String)>

Environment variables to inject into the child process.

The proxy URL includes nono:<token>@ userinfo so that standard HTTP clients (curl, Python requests, etc.) automatically send Proxy-Authorization: Basic ... on every request. The raw token is also provided via NONO_PROXY_TOKEN for nono-aware clients that prefer Bearer auth.

When TLS interception is active (intercept_ca_path() is Some), the standard runtime CA-trust env vars are also set so the agent trusts the proxy’s ephemeral CA when minted leaf certs are presented during interception.

Source

pub fn credential_env_vars(&self, config: &ProxyConfig) -> Vec<(String, String)>

Environment variables for reverse proxy credential routes.

Returns two types of env vars per route:

  1. SDK base URL overrides (e.g., OPENAI_BASE_URL=http://127.0.0.1:PORT/openai)
  2. SDK API key vars set to the session token (e.g., OPENAI_API_KEY=<token>)

The SDK sends the session token as its “API key” (phantom token pattern). The proxy validates this token and swaps it for the real credential.

Trait Implementations§

Source§

impl Drop for ProxyHandle

Source§

fn drop(&mut self)

Best-effort cleanup of the TLS-intercept trust bundle on shutdown.

The CA private key was never persisted to disk (it lives only in a Zeroizing<Vec<u8>> inside the running proxy task and is zeroized when that task drops). Here we remove the public certificate file so the next session doesn’t inherit a stale bundle path.

Errors are intentionally swallowed — Drop has no good way to surface them, and the file may already be gone if the user invoked shutdown() from another path.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more