import type { TunnelProvider, TunnelConfig, TunnelSetupOptions, TunnelStatus } from './TunnelProvider'; /** * Local Tunnel Provider 配置 * 仅用于启动 cloudflared,不涉及 Cloudflare API 操作 */ export interface LocalTunnelProviderOptions { /** Cloudflare Tunnel Token (从环境变量 CLOUDFLARE_TUNNEL_TOKEN 获取) */ tunnelToken: string; /** Active profile public endpoint, shown in status and DDNS diagnostics. */ publicUrl?: string; /** cloudflared 可执行文件路径 (默认 'cloudflared') */ cloudflaredPath?: string; /** 等待代理发布的毫秒数;超时后状态为 failed,而不是"仍在连接" */ connectTimeoutMs?: number; } /** * Local Tunnel Provider * * 专为 Local 模式设计的简化版 Tunnel Provider * 只负责启动 cloudflared,不涉及 Cloudflare API 操作(创建 Tunnel、DNS 记录等) * * 使用场景: * - 用户已在 Cloudflare Dashboard 创建好 Tunnel * - 用户通过环境变量 CLOUDFLARE_TUNNEL_TOKEN 传入 Token * - 服务启动时自动启动 cloudflared */ export declare class LocalTunnelProvider implements TunnelProvider { readonly name = "cloudflare-local"; private readonly logger; private readonly tunnelToken; private readonly publicUrl?; private readonly cloudflaredPath; private readonly connectTimeoutMs; private process; private status; private currentConfig; /** 标记隧道进程是否由我们启动和管理 */ private managedByUs; constructor(options: LocalTunnelProviderOptions); /** * Local 模式不需要 setup,直接返回基于 Token 的配置 */ setup(options: TunnelSetupOptions): Promise; /** * 启动隧道客户端 * 如果当前 provider 已经启动过进程,则跳过启动 */ start(config?: TunnelConfig): Promise; /** * 解析并打印 cloudflared 日志 */ /** Set when the dashboard's origin port and this runtime's ingress port disagree. */ private originMismatch?; private logOutput; /** * 停止隧道 * 只有当隧道是由我们启动时才会停止 */ stop(): Promise; /** * 获取隧道状态 */ getStatus(): TunnelStatus; /** * 获取公网端点 */ getEndpoint(): string | undefined; /** * Local 模式不需要 cleanup(不涉及 Cloudflare API 操作) */ cleanup(_config: TunnelConfig): Promise; /** * 检测 cloudflared 是否已经在运行 * 通过进程检测 + metrics 端口检测 */ isCloudflaredRunning(): Promise; /** * 检测 cloudflared 进程是否存在 */ private isCloudflaredProcessRunning; /** * 检测 cloudflared metrics 端口是否开放 */ private isMetricsPortOpen; /** * 等待连接建立 */ private waitForConnection; /** * 获取是否由我们管理 */ isManagedByUs(): boolean; } /** * The origin a remotely-managed tunnel declares for its hostname. * * Both halves are reported: pointing the dashboard at `https://localhost:` while this * runtime serves plain HTTP there fails the TLS handshake, and the edge shows only a 502. */ export declare function readDashboardOrigin(output: string): { scheme: string; port: number; } | undefined;