UNPKG

@fluent-org/logger

Version:
107 lines (106 loc) 2.84 kB
/// <reference types="node" /> import * as net from "net"; import * as tls from "tls"; import { EventEmitter } from "events"; import * as protocol from "./protocol"; /** * The server security hardening options */ export declare type FluentServerSecurityOptions = { /** * The hostname of the server. Should be unique to this process */ serverHostname: string; /** * The shared key to authenticate clients with */ sharedKey: string; /** * Whether to use user authentication */ authorize: boolean; /** * A dict of users to their passwords */ userDict: Record<string, string>; }; /** * The server setup options */ export declare type FluentServerOptions = { /** * The security options. * * Defaults to undefined (no auth). */ security?: FluentServerSecurityOptions; /** * Whether or not to keep the sockets alive. Sent in HELO, but currently ignored * * Defaults to false */ keepalive?: boolean; /** * TLS setup options. * * See the [Node.js docs](https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener) for more info * * Defaults to undefined */ tlsOptions?: tls.TlsOptions; /** * Socket listen options * * See the [Node.js docs](https://nodejs.org/api/net.html#net_server_listen_options_callback) for more info * * Defaults to {port: 0} */ listenOptions?: net.ListenOptions; }; /** * A Fluent [Forward protocol](https://github.com/fluent/fluentd/wiki/Forward-Protocol-Specification-v1) compatible server */ export declare class FluentServer extends EventEmitter { private _port; private tlsOptions; private clients; private server; private security; private keepalive; private listenOptions; /** * Creates a new server * * @param options The server connection options */ constructor(options?: FluentServerOptions); /** * Handles a connection event on the server * @param socket */ private handleConnection; /** * Called for each entry received by the server. * * @param tag The tag of the entry * @param time The timestamp of the entry * @param record The entry record */ protected onEntry(tag: protocol.Tag, time: protocol.Time, record: protocol.EventRecord): void; /** * Returns the port the server is currently listening on */ get port(): number | undefined; /** * Start the server * * @returns A Promise which resolves once the server is listening */ listen(): Promise<void>; /** * Shutdown the server * * @returns A Promise, which resolves once the server has fully shut down. */ close(): Promise<void>; }