/** The default instance name when `--name` is omitted. */ export declare const DEFAULT_INSTANCE = "default"; export declare function gateLogFile(name: string): string; export declare function cfdLogFile(name: string): string; export declare function providerLogFile(name: string, provider: TunnelProvider): string; export interface TunnelConfig { allowed_ips: string[]; } export type TunnelProvider = "cloudflare" | "tailscale"; export type TailscaleMode = "serve" | "funnel"; export interface TunnelState { name: string; provider: TunnelProvider; url: string; gate_pid: number; /** Present for Cloudflare quick tunnels; absent for Tailscale Serve/Funnel. */ cloudflared_pid?: number; /** Optional provider-side process when a provider owns one. */ provider_pid?: number; started_at: string; target: string; vhost: string; gate_port: number; tailscale_mode?: TailscaleMode; tailscale_path?: string; tailscale_https_port?: number; } export declare function readConfig(): TunnelConfig; export declare function writeConfig(cfg: TunnelConfig): void; export declare function readState(name?: string, root?: string): TunnelState | null; export declare function writeState(state: TunnelState, root?: string): void; export declare function clearState(name?: string, root?: string): void; /** * Every persisted tunnel instance, newest-started first. Reads every * `state*.json` under `.cache/tunnel/`; tolerates missing/corrupt files. */ export declare function listStates(root?: string): TunnelState[]; export declare function isProcessAlive(pid: number): boolean; export type ProcessAliveCheck = (pid: number) => boolean; /** True when both the local gate and its provider-side process are live. */ export declare function isTunnelStateLive(state: TunnelState, processAlive?: ProcessAliveCheck): boolean; /** * Newest live tunnel that serves `vhost` on the requested local web port. * * The port alone does not identify a tunnel. Several tunnels can forward to one * upstream port and be told apart only by the Host header they send, and a * server that routes on Host then serves each of them a different site. Picking * by port alone returns whichever such tunnel started last, so a caller that * builds a URL for one site can hand back a host that serves another and every * link 400s. Matching the vhost too keeps the returned tunnel the one that * actually serves the caller's origin. */ export declare function findLiveTunnelForOrigin(port: number, vhost: string, root?: string, processAlive?: ProcessAliveCheck): TunnelState | null; /** * Ensure cloudflared is on PATH or installed at ~/.local/bin/cloudflared. * Auto-downloads on Linux; throws on other platforms with brew hint. */ export declare function ensureCloudflared(): string; //# sourceMappingURL=state.d.ts.map