/** * Builds the question about a blind strike, and reads the answer * * The strike names a way to find its target, not the target itself. This * module turns those ways into one request — what would be hit, and does it * look like something in use — and reads the reply back into records. * * The server is asked for raw material only: `/proc` files as they are, the * container listing as one line each. Deciding what a hexadecimal socket * state means is done here, where it can be tested without a machine. */ import type { BlindStrike } from './blind-target.js'; /** A container the strike would stop */ export interface PreviewedContainer { kind: 'container'; name: string; image: string; /** As the engine says it: `Up 34 days` */ status: string; /** As the engine says it: `0.0.0.0:443->443/tcp` */ ports: string; } /** A process the strike would signal */ export interface PreviewedProcess { kind: 'process'; pid: number; /** The command line it runs, whole */ command: string; /** Seconds since it started, or null when the server did not say */ age: number | null; /** Ports it accepts connections on */ listening: number[]; /** Connections it is carrying right now */ established: number; } export type PreviewedTarget = PreviewedContainer | PreviewedProcess; /** What one strike turned out to mean */ export interface StrikePreview { strike: BlindStrike; /** What would be hit; empty means the expansion named nothing */ targets: PreviewedTarget[]; /** Why the question could not be answered — the outcome that is neither hit nor empty */ unavailable?: string; } /** * Build one request that answers every strike at once. * * Strikes with nothing to expand are left out: there is no question to ask * about them, and their outcome is decided without the server. */ export declare function buildPreviewCommand(strikes: BlindStrike[]): string; /** * Read the reply into one record per strike. * * Three outcomes stay apart: the strike has targets, the strike found * nothing, or the machine could not be asked. The last one is why the reply * carries a marker for a missing program instead of an empty listing. */ export declare function readPreview(strikes: BlindStrike[], stdout: string): StrikePreview[];