UNPKG

@push.rocks/smartproxy

Version:

A powerful proxy package with unified route-based configuration for high traffic management. Features include SSL/TLS support, flexible routing patterns, WebSocket handling, advanced security options, and automatic ACME certificate management.

48 lines (47 loc) 1.46 kB
import type { RoutePreprocessor } from './route-preprocessor.js'; /** * Server that receives UDP datagrams from Rust via Unix stream socket * and dispatches them to TypeScript datagramHandler callbacks. * * Protocol: length-prefixed JSON frames over a persistent Unix stream socket. * - Rust→TS: { type: "datagram", routeKey, sourceIp, sourcePort, destPort, payloadBase64 } * - TS→Rust: { type: "reply", sourceIp, sourcePort, destPort, payloadBase64 } */ export declare class DatagramHandlerServer { private static readonly MAX_BUFFER_SIZE; private server; private connection; private socketPath; private preprocessor; private readBuffer; constructor(socketPath: string, preprocessor: RoutePreprocessor); /** * Start listening on the Unix socket. */ start(): Promise<void>; /** * Stop the server and clean up. */ stop(): Promise<void>; /** * Handle a new connection from Rust. * Only one connection at a time (Rust maintains a persistent connection). */ private handleConnection; /** * Process length-prefixed frames from the read buffer. */ private processFrames; /** * Handle a received datagram message from Rust. */ private handleMessage; /** * Send a reply frame back to Rust. */ private sendReply; /** * Get the socket path for passing to Rust via IPC. */ getSocketPath(): string; }