/** * What the interceptor saw, kept by the interceptor itself: for every * connection it placed, the destination and the protocol, counted, with the * bytes that crossed each way and the HTTP methods where the protocol showed * them; for every connection it refused, the reason. It is the report an * operator reads to learn what a workload actually reaches before any of it * is governed, and it is counts and names only: host names and ports, never * a path, a header, a body or an address of the caller. */ import type { DestinationRefusal, InterceptProtocol } from "./Destination.js"; export type InterceptRefusal = DestinationRefusal /** The client sent nothing decisive within the peek window. */ | "PEEK_TIMEOUT" /** The destination could not be reached from here. */ | "UPSTREAM_UNREACHABLE" /** The destination is this interceptor's own listener: a loop, refused. */ | "HOST_IS_INTERCEPTOR" /** The interceptor holds as many connections as it will. */ | "TOO_MANY_CONNECTIONS" /** The operator governs a list of destinations and refuses the rest; this was the rest. */ | "UNLISTED_DESTINATION" /** A governed connection could not be taken: no authority to mint with, a failed handshake, no gateway. */ | "GOVERN_UNAVAILABLE"; /** A destination whose connections were spliced through: what the hop itself measured. */ export interface SplicedCounts { readonly protocol: InterceptProtocol; readonly governed: false; readonly connections: number; readonly bytes_to_destination: number; readonly bytes_from_destination: number; /** HTTP methods seen in the clear; empty for TLS, whose requests are not read. */ readonly methods: Readonly>; } /** What the gateway for a governed destination did with the requests it was handed. */ export interface GovernedGatewayCounts { readonly mode: "SHADOW" | "ENFORCEMENT"; /** The gateway's own counts by name: `governed`, `interceptions`, `allows`, `blocks`, `escalations`, `shadow`, `passthrough`, ... */ readonly requests: Readonly>; } /** * A destination whose connections the gateway took: the hop counted the * connections and read the first request's method where it was in the clear, * and the requests themselves are the gateway's account, not a byte count. */ export interface GovernedCounts { readonly protocol: InterceptProtocol; readonly governed: true; readonly connections: number; readonly methods: Readonly>; /** Null until the report is written, or when no request reached the gateway. */ readonly gateway: GovernedGatewayCounts | null; } export type DestinationCounts = SplicedCounts | GovernedCounts; /** The gateway counts for a governed destination at report time, or null when none was created. */ export type GovernedCountsSource = (host: string, protocol: InterceptProtocol) => GovernedGatewayCounts | null; export interface InterceptSummary { readonly since: string | null; readonly until: string | null; readonly connections: number; readonly placed: number; readonly refused: Readonly>; /** By `host:port`, the destinations this workload reached. */ readonly destinations: Readonly>; } export interface InterceptReport { readonly event: "INTERCEPT_REPORT"; readonly at: string; readonly intercept: InterceptSummary; /** What an operator does with the list, in their own terms. */ readonly next: string; } export declare class InterceptLedger { private since; private until; private count; private spliced; private readonly refusals; private readonly destinations; /** A connection whose destination was read; returns the key `bytes` takes. */ record(host: string, port: number, protocol: InterceptProtocol, method: string | null, at: string, governed?: boolean): string; private fresh; /** Bytes that crossed for a spliced connection, by the key `record` returned; a governed destination has none to count. */ bytes(key: string, toDestination: number, fromDestination: number): void; /** A recorded connection whose destination answered: the splice is up. */ placed(): void; /** * A connection that was not placed, by the reason. A connection refused * before its destination was read has not been counted yet and is counted * here; one refused after `record` has. */ refuse(reason: InterceptRefusal, at: string, countConnection: boolean): void; /** * The summary so far. A governed destination's `gateway` is filled from * `governed`, the gateway's account of the requests it was handed, when one * is given; the key is `host:port`, and the port names the protocol. */ summary(governed?: GovernedCountsSource): InterceptSummary; report(at: string, governed?: GovernedCountsSource): InterceptReport; /** How many connections have been counted so far, placed or refused. */ get connections(): number; private touch; } //# sourceMappingURL=InterceptLedger.d.ts.map