1 |
|
2 | import { EventEmitter } from 'events';
|
3 | import { Socket, SocketConnectOpts } from 'net';
|
4 | import { Callback, Stream } from './utils';
|
5 | export declare type TelnetState = null | 'end' | 'failedlogin' | 'getprompt' | 'login' | 'ready' | 'response' | 'standby' | 'start';
|
6 | export declare type EscapeHandler = (escapeSequence: string) => string | null;
|
7 | export interface ExecOptions {
|
8 | echoLines?: number;
|
9 | execTimeout?: number;
|
10 | failedLoginMatch?: string | RegExp;
|
11 | irs?: string;
|
12 | loginPrompt?: string | RegExp;
|
13 | maxBufferLength?: number;
|
14 | newlineReplace?: string;
|
15 | ors?: string;
|
16 | shellPrompt?: string | RegExp;
|
17 | stripControls?: boolean;
|
18 | timeout?: number;
|
19 | }
|
20 | export interface SendOptions {
|
21 | maxBufferLength?: number;
|
22 | newlineReplace?: string;
|
23 | ors?: string;
|
24 | shellPrompt?: string | RegExp;
|
25 | stripControls?: boolean;
|
26 | timeout?: number;
|
27 | waitFor?: string | RegExp | false;
|
28 |
|
29 | waitfor?: string | RegExp | false;
|
30 | sendTimeout?: number;
|
31 | }
|
32 | export interface ConnectOptions extends SendOptions {
|
33 | debug?: boolean;
|
34 | echoLines?: number;
|
35 | encoding?: BufferEncoding;
|
36 | escapeHandler?: EscapeHandler;
|
37 | execTimeout?: number;
|
38 | extSock?: any;
|
39 | failedLoginMatch?: string | RegExp;
|
40 | host?: string;
|
41 |
|
42 | initialCTRLC?: boolean;
|
43 | initialCtrlC?: boolean;
|
44 | initialLFCR?: boolean;
|
45 | irs?: string;
|
46 | localAddress?: string;
|
47 | loginPrompt?: string | RegExp;
|
48 | maxEndWait?: number;
|
49 | negotiationMandatory?: boolean;
|
50 | pageSeparator?: string | RegExp;
|
51 | password?: string;
|
52 | passwordPrompt?: string | RegExp;
|
53 | port?: number;
|
54 | sock?: Socket;
|
55 | socketConnectOptions?: SocketConnectOpts;
|
56 | stripShellPrompt?: boolean;
|
57 | terminalHeight?: number;
|
58 | terminalWidth?: number;
|
59 | username?: string;
|
60 | disableLogon?: boolean;
|
61 | }
|
62 | export declare class Telnet extends EventEmitter {
|
63 | private dataResolver;
|
64 | private endEmitted;
|
65 | private inputBuffer;
|
66 | private loginPromptReceived;
|
67 | private opts;
|
68 | private pendingData;
|
69 | private response;
|
70 | private socket;
|
71 | private state;
|
72 | private decoder;
|
73 | constructor();
|
74 | private pushNextData;
|
75 | nextData(): Promise<string | null>;
|
76 | connect(opts: any): Promise<void>;
|
77 | shell(callback?: Callback<Stream>): Promise<Stream>;
|
78 | exec(cmd: string, opts?: ExecOptions | Callback<string>, callback?: Callback<string>): Promise<string>;
|
79 | send(data: Buffer | string, opts?: SendOptions | Callback<string>, callback?: Callback<string>): Promise<string>;
|
80 | write(data: Buffer | string, opts?: SendOptions, callback?: Callback<string>): Promise<string>;
|
81 | getSocket(): Socket | null;
|
82 | end(): Promise<void>;
|
83 | destroy(): Promise<void>;
|
84 | parseData(chunk: Buffer, isReady?: boolean[]): Buffer;
|
85 | private login;
|
86 | negotiate(chunk: Buffer): Buffer;
|
87 | private static checkSocket;
|
88 | private decode;
|
89 | }
|