-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtelnet-stream.d.ts
334 lines (325 loc) · 11.9 KB
/
telnet-stream.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
/**
* Type definitions for telnet-stream 1.0.5
* Author: Voakie <contact@voakie.com>
*/
declare module "telnet-stream" {
import { Socket, SocketConnectOpts, AddressInfo } from "net";
import { Transform, TransformOptions } from "stream";
export interface TelnetSocketOptions {
bufferSize?: number;
errorPolicy?: "keepBoth" | "keepData" | "discardBoth";
}
export interface TelnetInputOptions
extends TransformOptions,
TelnetSocketOptions {}
/**
* TelnetSocket is a decorator for a net.Socket object. Incoming TELNET commands, options, and negotiations are emitted as events. Non-TELNET data is passed through without changes.
*/
export class TelnetSocket {
constructor(socket: Socket, options?: TelnetSocketOptions);
/**
* When the remote system issues a TELNET command that is not option
* negotiation, TelnetSocket will emit a 'command' event.
*
* ```js
* var tSocket = new TelnetSocket(socket);
* tSocket.on('command', function(command) {
* // Received: IAC <command> - See RFC 854
* });
* ```
*/
on(name: "command", callback: (command: number) => void): void;
/**
* When the remote system wants to request that the local system
* perform some function or obey some protocol, TelnetSocket will
* emit a 'do' event:
*
* ```js
* var tSocket = new TelnetSocket(socket);
* tSocket.on('do', function(option) {
* // Received: IAC DO <option> - See RFC 854
* });
* ```
*/
on(name: "do", callback: (option: number) => void): void;
/**
* When the remote system wants to request that the local system
* NOT perform some function or NOT obey some protocol, TelnetSocket
* will emit a 'dont' event:
*
* ```js
* var tSocket = new TelnetSocket(socket);
* tSocket.on('dont', function(option) {
* // Received: IAC DONT <option> - See RFC 854
* });
* ```
*/
on(name: "dont", callback: (option: number) => void): void;
/**
* After negotiating an option, either the local or remote system
* may engage in a more complex subnegotiation. For example, the
* server and client may agree to use encryption, and then use
* subnegotiation to agree on the parameters of that encryption.
*
* ```js
* var tSocket = new TelnetSocket(socket);
* tSocket.on('sub', function(option, buffer) {
* // Received: IAC SB <option> <buffer> IAC SE - See RFC 855
* });
* ```
*/
on(name: "sub", callback: (option: number, buffer: Buffer) => void): void;
/**
* When the remote system wants to offer that it will perform some
* function or obey some protocol for the local system, TelnetSocket
* will emit a 'will' event:
*
* ```js
* var tSocket = new TelnetSocket(socket);
* tSocket.on('will', function(option) {
* // Received: IAC WILL <option> - See RFC 854
* });
* ```
*/
on(name: "will", callback: (option: number) => void): void;
/**
* When the remote system wants to refuse to perform some function
* or obey some protocol for the local system, TelnetSocket will
* emit a 'wont' event:
*
* ```js
* var tSocket = new TelnetSocket(socket);
* tSocket.on('wont', function(option) {
* // Received: IAC WONT <option> - See RFC 854
* });
* ```
*/
on(name: "wont", callback: (option: number) => void): void;
/**
* Call this method to send a TELNET command to the remote system.
*
* ```js
* var NOP = 241; // No operation. -- See RFC 854
* var tSocket = new TelnetSocket(socket);
* // Sends: IAC NOP
* tSocket.writeCommand(NOP);
* ```
*
* @param command The command byte to send
*/
writeCommand(command: number): void;
/**
* Call this method to send a TELNET DO option negotiation to the remote
* system. A DO request is sent when the local system wants the remote
* system to perform some function or obey some protocol.
*
* ```js
* var NAWS = 31; // Negotiate About Window Size -- See RFC 1073
* var tSocket = new TelnetSocket(socket);
* // Sends: IAC DO NAWS
* tSocket.writeDo(NAWS);
* ```
*
* @param option The option byte to request of the remote system
*/
writeDo(option: number): void;
/**
* Call this method to send a TELNET DONT option negotiation to the remote
* system. A DONT request is sent when the local system wants the remote
* system to NOT perform some function or NOT obey some protocol.
*
* ```js
* var NAWS = 31; // Negotiate About Window Size -- See RFC 1073
* var tSocket = new TelnetSocket(socket);
* // Sends: IAC DONT NAWS
* tSocket.writeDont(NAWS);
* ```
*
* @param option The option byte to request of the remote system
*/
writeDont(option: number): void;
/**
* Call this method to send a TELNET WILL option negotiation to the remote
* system. A WILL offer is sent when the local system wants to inform the
* remote system that it will perform some function or obey some protocol.
*
* ```js
* var NAWS = 31; // Negotiate About Window Size -- See RFC 1073
* var tSocket = new TelnetSocket(socket);
* // Sends: IAC WILL NAWS
* tSocket.writeWill(NAWS);
* ```
*
* @param option The option byte to offer to the remote system
*/
writeWill(option: number): void;
/**
* Call this method to send a TELNET WONT option negotiation to the remote
* system. A WONT refusal is sent when the remote system has requested that
* the local system perform some function or obey some protocol, and the
* local system is refusing to do so.
*
* ```js
* var NAWS = 31; // Negotiate About Window Size -- See RFC 1073
* var tSocket = new TelnetSocket(socket);
* // Sends: IAC WONT NAWS
* tSocket.writeWont(NAWS);
* ```
*
* @param option The option byte to refuse to the remote system
*/
writeWont(option: number): void;
/**
* Call this method to send a TELNET subnegotiation to the remote system.
* After the local and remote system have negotiated and agreed to use
* an option, then subnegotiation information can be sent.
*
* See Example #2: Negotiate About Window Size (NAWS) in the README.
*
* @param option The option byte; identifies what the subnegotiation is about
* @param buffer The buffer containing the subnegotiation data to send
*/
writeSub(option: number, buffer: any): void;
/** Inherited from `net` */
on(name: "close", callback: (hadError: boolean) => void): void;
/** Inherited from `net` */
on(name: "connect", callback: () => void): void;
/** Inherited from `net` */
on(name: "data", callback: (data: Buffer | string) => void): void;
/** Inherited from `net` */
on(name: "drain", callback: () => void): void;
/** Inherited from `net` */
on(name: "end", callback: () => void): void;
/** Inherited from `net` */
on(name: "error", callback: (e: Error) => void): void;
/** Inherited from `net` */
on(name: "lookup", callback: () => void): void;
/** Inherited from `net` */
on(name: "timeout", callback: () => void): void;
/** Inherited from `net` */
address(): AddressInfo | string | null;
/** Inherited from `net` */
connect(opts: SocketConnectOpts, listener?: () => void): Socket;
/** Inherited from `net` */
connect(path: string, listener?: () => void): Socket;
/** Inherited from `net` */
connect(port: number, host?: string, listener?: () => void): Socket;
/** Inherited from `net` */
destroy(error?: Error): Socket;
/** Inherited from `net` */
end(data?: string, encoding?: string, callback?: () => void): Socket;
/** Inherited from `net` */
end(data?: Buffer | Uint8Array, callback?: () => void): Socket;
/** Inherited from `net` */
pause(): Socket;
/** Inherited from `net` */
ref(): Socket;
/** Inherited from `net` */
resume(): Socket;
/** Inherited from `net` */
setEncoding(encoding?: string): Socket;
/** Inherited from `net` */
setKeepAlive(enable?: boolean, initialDelay?: number): Socket;
/** Inherited from `net` */
setNoDelay(noDelay?: boolean): Socket;
/** Inherited from `net` */
setTimeout(timeout: number, callback: () => void): Socket;
/** Inherited from `net` */
unref(): Socket;
/** Inherited from `net` */
write(data: string, encoding?: string, callback?: () => void): boolean;
/** Inherited from `net` */
write(data: Buffer | Uint8Array, callback?: () => void): boolean;
}
export class TelnetInput extends Transform {
constructor(options?: TelnetInputOptions);
}
export class TelnetOutput extends Transform {
constructor(options?: TransformOptions);
/**
* Call this method to send a TELNET command to the remote system.
*
* ```js
* var NOP = 241; // No operation. -- See RFC 854
* var tSocket = new TelnetSocket(socket);
* // Sends: IAC NOP
* tSocket.writeCommand(NOP);
* ```
*
* @param command The command byte to send
*/
writeCommand(command: number): void;
/**
* Call this method to send a TELNET DO option negotiation to the remote
* system. A DO request is sent when the local system wants the remote
* system to perform some function or obey some protocol.
*
* ```js
* var NAWS = 31; // Negotiate About Window Size -- See RFC 1073
* var tSocket = new TelnetSocket(socket);
* // Sends: IAC DO NAWS
* tSocket.writeDo(NAWS);
* ```
*
* @param option The option byte to request of the remote system
*/
writeDo(option: number): void;
/**
* Call this method to send a TELNET DONT option negotiation to the remote
* system. A DONT request is sent when the local system wants the remote
* system to NOT perform some function or NOT obey some protocol.
*
* ```js
* var NAWS = 31; // Negotiate About Window Size -- See RFC 1073
* var tSocket = new TelnetSocket(socket);
* // Sends: IAC DONT NAWS
* tSocket.writeDont(NAWS);
* ```
*
* @param option The option byte to request of the remote system
*/
writeDont(option: number): void;
/**
* Call this method to send a TELNET WILL option negotiation to the remote
* system. A WILL offer is sent when the local system wants to inform the
* remote system that it will perform some function or obey some protocol.
*
* ```js
* var NAWS = 31; // Negotiate About Window Size -- See RFC 1073
* var tSocket = new TelnetSocket(socket);
* // Sends: IAC WILL NAWS
* tSocket.writeWill(NAWS);
* ```
*
* @param option The option byte to offer to the remote system
*/
writeWill(option: number): void;
/**
* Call this method to send a TELNET WONT option negotiation to the remote
* system. A WONT refusal is sent when the remote system has requested that
* the local system perform some function or obey some protocol, and the
* local system is refusing to do so.
*
* ```js
* var NAWS = 31; // Negotiate About Window Size -- See RFC 1073
* var tSocket = new TelnetSocket(socket);
* // Sends: IAC WONT NAWS
* tSocket.writeWont(NAWS);
* ```
*
* @param option The option byte to refuse to the remote system
*/
writeWont(option: number): void;
/**
* Call this method to send a TELNET subnegotiation to the remote system.
* After the local and remote system have negotiated and agreed to use
* an option, then subnegotiation information can be sent.
*
* See Example #2: Negotiate About Window Size (NAWS) in the README.
*
* @param option The option byte; identifies what the subnegotiation is about
* @param buffer The buffer containing the subnegotiation data to send
*/
writeSub(option: number, buffer: any): void;
}
}