2023-02-26 03:10:17 +00:00
|
|
|
/// <reference types="node" />
|
2023-01-12 17:50:38 +00:00
|
|
|
import { Duplex, DuplexEvents, Callback } from "streamx";
|
2023-02-26 03:10:17 +00:00
|
|
|
import { write } from "fs";
|
2023-01-12 17:50:38 +00:00
|
|
|
type AddressFamily = "IPv6" | "IPv4";
|
|
|
|
interface SocketOptions {
|
|
|
|
allowHalfOpen?: boolean;
|
|
|
|
remoteAddress?: string;
|
|
|
|
remotePort?: number;
|
2023-02-25 01:04:45 +00:00
|
|
|
remotePublicKey?: Uint8Array;
|
2023-01-12 17:50:38 +00:00
|
|
|
write?: (this: Duplex<any, any, any, any, true, true, DuplexEvents<any, any>>, data: any, cb: Callback) => void;
|
2023-02-26 03:10:17 +00:00
|
|
|
emulateWebsocket?: boolean;
|
2023-01-12 17:50:38 +00:00
|
|
|
}
|
|
|
|
export default class Socket extends Duplex {
|
|
|
|
private _allowHalfOpen;
|
|
|
|
remoteAddress: any;
|
|
|
|
remotePort: any;
|
|
|
|
remoteFamily: AddressFamily;
|
|
|
|
bufferSize: any;
|
2023-02-06 15:52:26 +00:00
|
|
|
readable: true;
|
|
|
|
writable: true;
|
2023-02-25 01:04:45 +00:00
|
|
|
remotePublicKey: Uint8Array;
|
2023-02-26 03:10:17 +00:00
|
|
|
private _emulateWebsocket;
|
|
|
|
constructor({ allowHalfOpen, remoteAddress, remotePort, remotePublicKey, write, emulateWebsocket, }?: SocketOptions);
|
2023-01-12 17:50:38 +00:00
|
|
|
private _connecting;
|
|
|
|
get connecting(): boolean;
|
|
|
|
get readyState(): string;
|
|
|
|
listen(): void;
|
|
|
|
setTimeout(msecs: any, callback: any): void;
|
|
|
|
_onTimeout(): void;
|
|
|
|
setNoDelay(enable: boolean): void;
|
|
|
|
setKeepAlive(setting: any, msecs: number): void;
|
|
|
|
address(): {
|
|
|
|
address: any;
|
|
|
|
port: any;
|
|
|
|
family: AddressFamily;
|
|
|
|
};
|
2023-02-25 06:51:50 +00:00
|
|
|
addEventListener: <TEvent extends "data" | "end" | "finish" | "pipe" | "readable" | "drain" | keyof import("streamx").StreamEvents | "piping">(event: TEvent, listener: TEvent extends "data" | "end" | "finish" | "pipe" | "readable" | "drain" | keyof import("streamx").StreamEvents | "piping" ? DuplexEvents<any, any>[TEvent] : (...args: any[]) => void) => this;
|
2023-02-25 17:07:21 +00:00
|
|
|
on: <TEvent extends "data" | "end" | "finish" | "pipe" | "readable" | "drain" | keyof import("streamx").StreamEvents | "piping">(event: TEvent, listener: TEvent extends "data" | "end" | "finish" | "pipe" | "readable" | "drain" | keyof import("streamx").StreamEvents | "piping" ? DuplexEvents<any, any>[TEvent] : (...args: any[]) => void) => this;
|
2023-02-25 06:51:50 +00:00
|
|
|
removeEventListener: <TEvent extends "data" | "end" | "finish" | "pipe" | "readable" | "drain" | keyof import("streamx").StreamEvents | "piping">(event: TEvent, listener: TEvent extends "data" | "end" | "finish" | "pipe" | "readable" | "drain" | keyof import("streamx").StreamEvents | "piping" ? DuplexEvents<any, any>[TEvent] : (...args: any[]) => void) => this;
|
2023-02-25 17:07:21 +00:00
|
|
|
off: <TEvent extends "data" | "end" | "finish" | "pipe" | "readable" | "drain" | keyof import("streamx").StreamEvents | "piping">(event: TEvent, listener: TEvent extends "data" | "end" | "finish" | "pipe" | "readable" | "drain" | keyof import("streamx").StreamEvents | "piping" ? DuplexEvents<any, any>[TEvent] : (...args: any[]) => void) => this;
|
2023-02-26 03:10:17 +00:00
|
|
|
send: typeof write;
|
2023-01-12 17:50:38 +00:00
|
|
|
static isIP(input: string): number;
|
|
|
|
static isIPv4(input: string): boolean;
|
|
|
|
static isIPv6(input: string): boolean;
|
|
|
|
}
|
|
|
|
export {};
|