/// /// /// import { EventEmitter } from 'events'; import { AddressInfo, Socket } from 'net'; import { NoiseServerListenOptions } from './noise-server-listen-options'; import { NoiseServerOptions } from './noise-server-options'; import { NoiseSocket } from './noise-socket'; export declare class NoiseServer extends EventEmitter { /** * Local private key as a 32-byte private key for elliptic curve * secp256k1 used by the server */ ls: Buffer; /** * Function for creating the ephemeral private key used by each * connection */ esFactory: () => Buffer; /** * Socket server that is created */ private _server; /** * NoiseServer is a TCP server that wraps socket instances * with the NoiseSocket class. This class is an event emitter * with the same interface as net.Server. * * The constructor take arguments that will be used by the * NoiseState. */ constructor(opts: NoiseServerOptions, connListener?: (socket: NoiseSocket) => void); /** * Called when the socket receives a new socket connection. * Emits the `connection` event. */ _onConnection(socket: Socket): void; /** * Returns the address the server is listeening on. If the server is * not listening, it will return undefined. */ address(): string | AddressInfo; /** * Stops the server from accepting new connections and keeps existing connections open. * This function is asynchronous, the server is fully closed when all connections are * ended and the server emits a `close` event. The optional `cb` event will be called * once the `close` event occurs. */ close(cb?: (err?: Error) => void): void; /** * Asynchronously get the number of concurrent connections on the server. Works when sockets were sent to forks. */ getConnections(cb: (error: Error, count: number) => void): void; /** * Start a server listening for connections. This method is asyncrhonous, * once the server has started listening, the `listening` event will be * emitted. * @param callback Called when the server is listening. Automatically binds * the function to the `listening` event. */ listen(opts: NoiseServerListenOptions, callback?: () => void): this; /** * Indicates whether or not the server is listening for connections. */ get listening(): boolean; /** * Set this property to reject connections when the server's connection count gets high. */ get maxConnections(): number; set maxConnections(val: number); }