source: trip-planner-front/node_modules/socks/typings/client/socksclient.d.ts

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 5.8 KB
Line 
1/// <reference types="node" />
2import { EventEmitter } from 'events';
3import { SocksClientOptions, SocksClientChainOptions, SocksRemoteHost, SocksProxy, SocksClientBoundEvent, SocksClientEstablishedEvent, SocksUDPFrameDetails } from '../common/constants';
4import { SocksClientError } from '../common/util';
5import { Duplex } from 'stream';
6declare interface SocksClient {
7 on(event: 'error', listener: (err: SocksClientError) => void): this;
8 on(event: 'bound', listener: (info: SocksClientBoundEvent) => void): this;
9 on(event: 'established', listener: (info: SocksClientEstablishedEvent) => void): this;
10 once(event: string, listener: (...args: any[]) => void): this;
11 once(event: 'error', listener: (err: SocksClientError) => void): this;
12 once(event: 'bound', listener: (info: SocksClientBoundEvent) => void): this;
13 once(event: 'established', listener: (info: SocksClientEstablishedEvent) => void): this;
14 emit(event: string | symbol, ...args: any[]): boolean;
15 emit(event: 'error', err: SocksClientError): boolean;
16 emit(event: 'bound', info: SocksClientBoundEvent): boolean;
17 emit(event: 'established', info: SocksClientEstablishedEvent): boolean;
18}
19declare class SocksClient extends EventEmitter implements SocksClient {
20 private options;
21 private socket;
22 private state;
23 private receiveBuffer;
24 private nextRequiredPacketBufferSize;
25 private socks5ChosenAuthType;
26 private onDataReceived;
27 private onClose;
28 private onError;
29 private onConnect;
30 constructor(options: SocksClientOptions);
31 /**
32 * Creates a new SOCKS connection.
33 *
34 * Note: Supports callbacks and promises. Only supports the connect command.
35 * @param options { SocksClientOptions } Options.
36 * @param callback { Function } An optional callback function.
37 * @returns { Promise }
38 */
39 static createConnection(options: SocksClientOptions, callback?: Function): Promise<SocksClientEstablishedEvent>;
40 /**
41 * Creates a new SOCKS connection chain to a destination host through 2 or more SOCKS proxies.
42 *
43 * Note: Supports callbacks and promises. Only supports the connect method.
44 * Note: Implemented via createConnection() factory function.
45 * @param options { SocksClientChainOptions } Options
46 * @param callback { Function } An optional callback function.
47 * @returns { Promise }
48 */
49 static createConnectionChain(options: SocksClientChainOptions, callback?: Function): Promise<SocksClientEstablishedEvent>;
50 /**
51 * Creates a SOCKS UDP Frame.
52 * @param options
53 */
54 static createUDPFrame(options: SocksUDPFrameDetails): Buffer;
55 /**
56 * Parses a SOCKS UDP frame.
57 * @param data
58 */
59 static parseUDPFrame(data: Buffer): SocksUDPFrameDetails;
60 /**
61 * Internal state setter. If the SocksClient is in an error state, it cannot be changed to a non error state.
62 */
63 private setState;
64 /**
65 * Starts the connection establishment to the proxy and destination.
66 * @param existingSocket Connected socket to use instead of creating a new one (internal use).
67 */
68 connect(existingSocket?: Duplex): void;
69 private getSocketOptions;
70 /**
71 * Handles internal Socks timeout callback.
72 * Note: If the Socks client is not BoundWaitingForConnection or Established, the connection will be closed.
73 */
74 private onEstablishedTimeout;
75 /**
76 * Handles Socket connect event.
77 */
78 private onConnectHandler;
79 /**
80 * Handles Socket data event.
81 * @param data
82 */
83 private onDataReceivedHandler;
84 /**
85 * Handles processing of the data we have received.
86 */
87 private processData;
88 /**
89 * Handles Socket close event.
90 * @param had_error
91 */
92 private onCloseHandler;
93 /**
94 * Handles Socket error event.
95 * @param err
96 */
97 private onErrorHandler;
98 /**
99 * Removes internal event listeners on the underlying Socket.
100 */
101 private removeInternalSocketHandlers;
102 /**
103 * Closes and destroys the underlying Socket. Emits an error event.
104 * @param err { String } An error string to include in error event.
105 */
106 private closeSocket;
107 /**
108 * Sends initial Socks v4 handshake request.
109 */
110 private sendSocks4InitialHandshake;
111 /**
112 * Handles Socks v4 handshake response.
113 * @param data
114 */
115 private handleSocks4FinalHandshakeResponse;
116 /**
117 * Handles Socks v4 incoming connection request (BIND)
118 * @param data
119 */
120 private handleSocks4IncomingConnectionResponse;
121 /**
122 * Sends initial Socks v5 handshake request.
123 */
124 private sendSocks5InitialHandshake;
125 /**
126 * Handles initial Socks v5 handshake response.
127 * @param data
128 */
129 private handleInitialSocks5HandshakeResponse;
130 /**
131 * Sends Socks v5 user & password auth handshake.
132 *
133 * Note: No auth and user/pass are currently supported.
134 */
135 private sendSocks5UserPassAuthentication;
136 private sendSocks5CustomAuthentication;
137 private handleSocks5CustomAuthHandshakeResponse;
138 private handleSocks5AuthenticationNoAuthHandshakeResponse;
139 private handleSocks5AuthenticationUserPassHandshakeResponse;
140 /**
141 * Handles Socks v5 auth handshake response.
142 * @param data
143 */
144 private handleInitialSocks5AuthenticationHandshakeResponse;
145 /**
146 * Sends Socks v5 final handshake request.
147 */
148 private sendSocks5CommandRequest;
149 /**
150 * Handles Socks v5 final handshake response.
151 * @param data
152 */
153 private handleSocks5FinalHandshakeResponse;
154 /**
155 * Handles Socks v5 incoming connection request (BIND).
156 */
157 private handleSocks5IncomingConnectionResponse;
158 get socksClientOptions(): SocksClientOptions;
159}
160export { SocksClient, SocksClientOptions, SocksClientChainOptions, SocksClientError, SocksRemoteHost, SocksProxy, SocksUDPFrameDetails, };
Note: See TracBrowser for help on using the repository browser.