ssh_tunnel_proxy 2.1.3 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -3
- package/MIGRATION.md +227 -0
- package/README.md +360 -212
- package/build/bridge.d.ts +14 -0
- package/build/bridge.d.ts.map +1 -0
- package/build/bridge.js +12 -0
- package/build/bridge.js.map +1 -0
- package/build/connection.d.ts +60 -0
- package/build/connection.d.ts.map +1 -0
- package/build/connection.js +198 -0
- package/build/connection.js.map +1 -0
- package/build/credentials.d.ts +24 -0
- package/build/credentials.d.ts.map +1 -0
- package/build/credentials.js +102 -0
- package/build/credentials.js.map +1 -0
- package/build/errors.d.ts +19 -0
- package/build/errors.d.ts.map +1 -0
- package/build/errors.js +64 -0
- package/build/errors.js.map +1 -0
- package/build/forward-spec.d.ts +34 -0
- package/build/forward-spec.d.ts.map +1 -0
- package/build/forward-spec.js +175 -0
- package/build/forward-spec.js.map +1 -0
- package/build/index.d.ts +19 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +71 -0
- package/build/index.js.map +1 -0
- package/build/legacy.d.ts +70 -0
- package/build/legacy.d.ts.map +1 -0
- package/build/legacy.js +188 -0
- package/build/legacy.js.map +1 -0
- package/build/local-forward.d.ts +31 -0
- package/build/local-forward.d.ts.map +1 -0
- package/build/local-forward.js +231 -0
- package/build/local-forward.js.map +1 -0
- package/build/model.d.ts +126 -0
- package/build/model.d.ts.map +1 -0
- package/build/model.js +55 -0
- package/build/model.js.map +1 -0
- package/build/port-policy.d.ts +43 -0
- package/build/port-policy.d.ts.map +1 -0
- package/build/port-policy.js +138 -0
- package/build/port-policy.js.map +1 -0
- package/build/remote-forward.d.ts +40 -0
- package/build/remote-forward.d.ts.map +1 -0
- package/build/remote-forward.js +226 -0
- package/build/remote-forward.js.map +1 -0
- package/build/tunnel.d.ts +121 -0
- package/build/tunnel.d.ts.map +1 -0
- package/build/tunnel.js +599 -0
- package/build/tunnel.js.map +1 -0
- package/examples/config.example.json +86 -0
- package/examples/setup_ssh.sh +12 -0
- package/examples/tunnel-cli.js +461 -0
- package/examples/tunnel-worker.js +98 -0
- package/examples/zrok-termux.ts +147 -0
- package/package.json +43 -53
- package/proto/sshtunnel/v1/tunnel.proto +343 -0
- package/dist/TestMessage.d.ts +0 -13
- package/dist/TestMessage.js +0 -32
- package/dist/TestMessage.js.map +0 -1
- package/dist/cjs/TestMessage.d.ts +0 -13
- package/dist/cjs/TestMessage.js +0 -32
- package/dist/cjs/TestMessage.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -73
- package/dist/cjs/index.js +0 -621
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/keypair_storage.d.ts +0 -12
- package/dist/cjs/keypair_storage.js +0 -143
- package/dist/cjs/keypair_storage.js.map +0 -1
- package/dist/cjs/ngrok_service.d.ts +0 -11
- package/dist/cjs/ngrok_service.js +0 -40
- package/dist/cjs/ngrok_service.js.map +0 -1
- package/dist/cjs/ssh2-node.d.ts +0 -1
- package/dist/cjs/ssh2-node.js +0 -221
- package/dist/cjs/ssh2-node.js.map +0 -1
- package/dist/esm/TestMessage.d.ts +0 -13
- package/dist/esm/TestMessage.js +0 -29
- package/dist/esm/TestMessage.js.map +0 -1
- package/dist/esm/index.d.ts +0 -73
- package/dist/esm/index.js +0 -616
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/keypair_storage.d.ts +0 -12
- package/dist/esm/keypair_storage.js +0 -117
- package/dist/esm/keypair_storage.js.map +0 -1
- package/dist/esm/ngrok_service.d.ts +0 -11
- package/dist/esm/ngrok_service.js +0 -37
- package/dist/esm/ngrok_service.js.map +0 -1
- package/dist/esm/ssh2-node.d.ts +0 -1
- package/dist/esm/ssh2-node.js +0 -194
- package/dist/esm/ssh2-node.js.map +0 -1
- package/dist/index.d.ts +0 -73
- package/dist/index.js +0 -620
- package/dist/index.js.map +0 -1
- package/dist/keypair_storage.d.ts +0 -12
- package/dist/keypair_storage.js +0 -120
- package/dist/keypair_storage.js.map +0 -1
- package/dist/ngrok_service.d.ts +0 -11
- package/dist/ngrok_service.js +0 -40
- package/dist/ngrok_service.js.map +0 -1
- package/dist/ssh2-node.d.ts +0 -1
- package/dist/ssh2-node.js +0 -188
- package/dist/ssh2-node.js.map +0 -1
- package/dist/types/TestMessage.d.ts +0 -13
- package/dist/types/index.d.ts +0 -73
- package/dist/types/keypair_storage.d.ts +0 -12
- package/dist/types/ngrok_service.d.ts +0 -11
- package/dist/types/ssh2-node.d.ts +0 -1
- package/ssh2-node +0 -2
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* forward-spec.ts — pure parsing of the OpenSSH-style forward strings.
|
|
4
|
+
*
|
|
5
|
+
* The v1 configuration syntax is preserved so existing config.json files keep
|
|
6
|
+
* working, but the parsing rules are now explicit: field counts are checked
|
|
7
|
+
* before destructuring, and ports must be bare decimal integers.
|
|
8
|
+
*
|
|
9
|
+
* Local forward (ssh -L):
|
|
10
|
+
* "localPort:remoteHost:remotePort"
|
|
11
|
+
* "bindAddress:localPort:remoteHost:remotePort"
|
|
12
|
+
*
|
|
13
|
+
* Remote forward (ssh -R):
|
|
14
|
+
* "bindPort:targetHost:targetPort"
|
|
15
|
+
* "bindAddress:bindPort:targetHost:targetPort"
|
|
16
|
+
*
|
|
17
|
+
* Note the v1 3-field remote form was "localPort:host:remotePort" with the
|
|
18
|
+
* fields in an order that read backwards relative to OpenSSH. See MIGRATION.md;
|
|
19
|
+
* `parseRemoteForwardSpec` documents the mapping it applies.
|
|
20
|
+
*
|
|
21
|
+
* License: MIT
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.DEFAULT_REMOTE_BIND_ADDRESS = exports.DEFAULT_LISTEN_ADDRESS = void 0;
|
|
25
|
+
exports.parseLocalForwardSpec = parseLocalForwardSpec;
|
|
26
|
+
exports.parseRemoteForwardSpec = parseRemoteForwardSpec;
|
|
27
|
+
exports.validateLocalForward = validateLocalForward;
|
|
28
|
+
exports.validateRemoteForward = validateRemoteForward;
|
|
29
|
+
exports.parseAndValidateLocalForward = parseAndValidateLocalForward;
|
|
30
|
+
exports.parseAndValidateRemoteForward = parseAndValidateRemoteForward;
|
|
31
|
+
exports.describeLocalForward = describeLocalForward;
|
|
32
|
+
exports.describeRemoteForward = describeRemoteForward;
|
|
33
|
+
const errors_1 = require("./errors");
|
|
34
|
+
const port_policy_1 = require("./port-policy");
|
|
35
|
+
exports.DEFAULT_LISTEN_ADDRESS = '127.0.0.1';
|
|
36
|
+
exports.DEFAULT_REMOTE_BIND_ADDRESS = 'localhost';
|
|
37
|
+
const LOCAL_FORWARD_SHAPE = 'localPort:remoteHost:remotePort or bindAddress:localPort:remoteHost:remotePort';
|
|
38
|
+
const REMOTE_FORWARD_SHAPE = 'bindPort:targetHost:targetPort or bindAddress:bindPort:targetHost:targetPort';
|
|
39
|
+
function invalid(spec, shape, detail) {
|
|
40
|
+
const suffix = detail ? ` (${detail})` : '';
|
|
41
|
+
return new errors_1.TunnelError('INVALID_FORWARD_SPEC', `Invalid forward "${spec}"; expected ${shape}${suffix}`);
|
|
42
|
+
}
|
|
43
|
+
function splitSpec(spec, shape) {
|
|
44
|
+
if (typeof spec !== 'string' || spec.trim().length === 0) {
|
|
45
|
+
throw new errors_1.TunnelError('INVALID_FORWARD_SPEC', `Invalid forward ${JSON.stringify(spec)}; expected ${shape}`);
|
|
46
|
+
}
|
|
47
|
+
const fields = spec.split(':');
|
|
48
|
+
if (fields.length < 3 || fields.length > 4) {
|
|
49
|
+
throw invalid(spec, shape, `got ${fields.length} colon-separated fields`);
|
|
50
|
+
}
|
|
51
|
+
return fields;
|
|
52
|
+
}
|
|
53
|
+
function requirePort(spec, text, shape, label) {
|
|
54
|
+
const port = (0, port_policy_1.parsePort)(text);
|
|
55
|
+
if (port === undefined) {
|
|
56
|
+
throw invalid(spec, shape, `${label} "${text}" is not a decimal port in 1-65535`);
|
|
57
|
+
}
|
|
58
|
+
return port;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Parse a local-forward string into a structured {@link LocalForward}.
|
|
62
|
+
* Syntax only — call {@link validateLocalForward} to apply a {@link PortPolicy}.
|
|
63
|
+
*/
|
|
64
|
+
function parseLocalForwardSpec(spec) {
|
|
65
|
+
const fields = splitSpec(spec, LOCAL_FORWARD_SHAPE);
|
|
66
|
+
const [listenHost, listenPortText, targetHostText, targetPortText] = fields.length === 4
|
|
67
|
+
? fields
|
|
68
|
+
: [exports.DEFAULT_LISTEN_ADDRESS, fields[0], fields[1], fields[2]];
|
|
69
|
+
if (listenHost.trim().length === 0) {
|
|
70
|
+
throw invalid(spec, LOCAL_FORWARD_SHAPE, 'bind address is empty');
|
|
71
|
+
}
|
|
72
|
+
if (targetHostText.trim().length === 0) {
|
|
73
|
+
throw invalid(spec, LOCAL_FORWARD_SHAPE, 'remote host is required');
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
id: spec,
|
|
77
|
+
listen: {
|
|
78
|
+
host: listenHost,
|
|
79
|
+
port: requirePort(spec, listenPortText, LOCAL_FORWARD_SHAPE, 'local listen port'),
|
|
80
|
+
},
|
|
81
|
+
target: {
|
|
82
|
+
host: targetHostText,
|
|
83
|
+
port: requirePort(spec, targetPortText, LOCAL_FORWARD_SHAPE, 'remote target port'),
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Parse a remote-forward string into a structured {@link RemoteForward}.
|
|
89
|
+
*
|
|
90
|
+
* Field mapping, matching v1 behaviour:
|
|
91
|
+
* 3 fields: bindPort : targetHost : targetPort, bind address defaults to
|
|
92
|
+
* "localhost" on the peer.
|
|
93
|
+
* 4 fields: bindAddress : bindPort : targetHost : targetPort.
|
|
94
|
+
*
|
|
95
|
+
* A bind port of 0 asks the SSH peer to assign one; the assigned value is
|
|
96
|
+
* reported in ForwardStatus.assignedPort.
|
|
97
|
+
*/
|
|
98
|
+
function parseRemoteForwardSpec(spec) {
|
|
99
|
+
const fields = splitSpec(spec, REMOTE_FORWARD_SHAPE);
|
|
100
|
+
const [bindHost, bindPortText, targetHostText, targetPortText] = fields.length === 4
|
|
101
|
+
? fields
|
|
102
|
+
: [exports.DEFAULT_REMOTE_BIND_ADDRESS, fields[0], fields[1], fields[2]];
|
|
103
|
+
if (bindHost.trim().length === 0) {
|
|
104
|
+
throw invalid(spec, REMOTE_FORWARD_SHAPE, 'bind address is empty');
|
|
105
|
+
}
|
|
106
|
+
if (targetHostText.trim().length === 0) {
|
|
107
|
+
throw invalid(spec, REMOTE_FORWARD_SHAPE, 'target host is required');
|
|
108
|
+
}
|
|
109
|
+
const bindPort = bindPortText === '0' ? 0 : (0, port_policy_1.parsePort)(bindPortText);
|
|
110
|
+
if (!(0, port_policy_1.isValidBindPort)(bindPort)) {
|
|
111
|
+
throw invalid(spec, REMOTE_FORWARD_SHAPE, `bind port "${bindPortText}" is not 0-65535`);
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
id: spec,
|
|
115
|
+
bind: { host: bindHost, port: bindPort },
|
|
116
|
+
target: {
|
|
117
|
+
host: targetHostText,
|
|
118
|
+
port: requirePort(spec, targetPortText, REMOTE_FORWARD_SHAPE, 'target port'),
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Apply a {@link PortPolicy} to a structured local forward and return a
|
|
124
|
+
* normalized copy. Throws a {@link TunnelError} on the first violation.
|
|
125
|
+
*/
|
|
126
|
+
function validateLocalForward(forward, policy = {}) {
|
|
127
|
+
const id = forward.id ?? describeLocalForward(forward);
|
|
128
|
+
const listenHost = forward.listen?.host ?? exports.DEFAULT_LISTEN_ADDRESS;
|
|
129
|
+
(0, port_policy_1.assertHostAllowed)(listenHost, {}, id);
|
|
130
|
+
const loopbackListen = new Set(['127.0.0.1', 'localhost', '::1', '[::1]']);
|
|
131
|
+
if (!loopbackListen.has(listenHost)) {
|
|
132
|
+
throw new errors_1.TunnelError('HOST_NOT_PERMITTED', `Local listen host ${listenHost} is not loopback; bind 127.0.0.1 or ::1`, { forwardId: id });
|
|
133
|
+
}
|
|
134
|
+
(0, port_policy_1.assertPortAllowed)(forward.listen?.port, 'local-listen', policy, id);
|
|
135
|
+
(0, port_policy_1.assertHostAllowed)(forward.target?.host, policy, id);
|
|
136
|
+
(0, port_policy_1.assertPortAllowed)(forward.target?.port, 'remote-target', policy, id);
|
|
137
|
+
return {
|
|
138
|
+
...forward,
|
|
139
|
+
id,
|
|
140
|
+
listen: { host: listenHost, port: forward.listen.port },
|
|
141
|
+
target: { host: forward.target.host, port: forward.target.port },
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/** Apply a {@link PortPolicy} to a structured remote forward. */
|
|
145
|
+
function validateRemoteForward(forward, policy = {}) {
|
|
146
|
+
const id = forward.id ?? describeRemoteForward(forward);
|
|
147
|
+
const bindHost = forward.bind?.host ?? exports.DEFAULT_REMOTE_BIND_ADDRESS;
|
|
148
|
+
(0, port_policy_1.assertHostAllowed)(bindHost, {}, id);
|
|
149
|
+
(0, port_policy_1.assertPortAllowed)(forward.bind?.port, 'remote-bind', policy, id);
|
|
150
|
+
(0, port_policy_1.assertHostAllowed)(forward.target?.host, {}, id);
|
|
151
|
+
(0, port_policy_1.assertPortAllowed)(forward.target?.port, 'local-listen', policy, id);
|
|
152
|
+
return {
|
|
153
|
+
...forward,
|
|
154
|
+
id,
|
|
155
|
+
bind: { host: bindHost, port: forward.bind.port },
|
|
156
|
+
target: { host: forward.target.host, port: forward.target.port },
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/** Parse and validate in one step. */
|
|
160
|
+
function parseAndValidateLocalForward(spec, policy = {}) {
|
|
161
|
+
return validateLocalForward(parseLocalForwardSpec(spec), policy);
|
|
162
|
+
}
|
|
163
|
+
/** Parse and validate in one step. */
|
|
164
|
+
function parseAndValidateRemoteForward(spec, policy = {}) {
|
|
165
|
+
return validateRemoteForward(parseRemoteForwardSpec(spec), policy);
|
|
166
|
+
}
|
|
167
|
+
function describeLocalForward(forward) {
|
|
168
|
+
const host = forward.listen?.host ?? exports.DEFAULT_LISTEN_ADDRESS;
|
|
169
|
+
return `L:${host}:${forward.listen?.port}->${forward.target?.host}:${forward.target?.port}`;
|
|
170
|
+
}
|
|
171
|
+
function describeRemoteForward(forward) {
|
|
172
|
+
const host = forward.bind?.host ?? exports.DEFAULT_REMOTE_BIND_ADDRESS;
|
|
173
|
+
return `R:${host}:${forward.bind?.port}->${forward.target?.host}:${forward.target?.port}`;
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=forward-spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forward-spec.js","sourceRoot":"","sources":["../src/forward-spec.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AA8CH,sDA+BC;AAaD,wDAiCC;AAMD,oDA0BC;AAGD,sDAkBC;AAGD,oEAEC;AAGD,sEAEC;AAED,oDAGC;AAED,sDAGC;AAlMD,qCAAuC;AAEvC,+CAAiG;AAEpF,QAAA,sBAAsB,GAAG,WAAW,CAAC;AACrC,QAAA,2BAA2B,GAAG,WAAW,CAAC;AAEvD,MAAM,mBAAmB,GAAG,gFAAgF,CAAC;AAC7G,MAAM,oBAAoB,GAAG,8EAA8E,CAAC;AAE5G,SAAS,OAAO,CAAC,IAAY,EAAE,KAAa,EAAE,MAAe;IAC3D,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5C,OAAO,IAAI,oBAAW,CACpB,sBAAsB,EACtB,oBAAoB,IAAI,eAAe,KAAK,GAAG,MAAM,EAAE,CACxD,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,IAAa,EAAE,KAAa;IAC7C,IAAI,OAAO,IAAI,KAAK,QAAQ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O,CAAC,IAAI,CAAC,IAAI,EAAE;QACjD,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE;KACjE,CAAC;AACJ,CAAC;AAED,sCAAsC;AACtC,SAAgB,4BAA4B,CAAC,IAAY,EAAE,SAAqB,EAAE;IAChF,OAAO,oBAAoB,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;AACnE,CAAC;AAED,sCAAsC;AACtC,SAAgB,6BAA6B,CAAC,IAAY,EAAE,SAAqB,EAAE;IACjF,OAAO,qBAAqB,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;AACrE,CAAC;AAED,SAAgB,oBAAoB,CAAC,OAAqB;IACxD,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,IAAI,IAAI,8BAAsB,CAAC;IAC5D,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,EAAE,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;AAC9F,CAAC;AAED,SAAgB,qBAAqB,CAAC,OAAsB;IAC1D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,IAAI,IAAI,mCAA2B,CAAC;IAC/D,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,EAAE,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;AAC5F,CAAC"}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { SSHTunnel } from './tunnel';
|
|
2
|
+
export type { SSHTunnelOptions, TunnelEvents } from './tunnel';
|
|
3
|
+
export { LocalForwardHandle } from './local-forward';
|
|
4
|
+
export { RemoteForwardHandle } from './remote-forward';
|
|
5
|
+
export { ProxiedConnection } from './connection';
|
|
6
|
+
export type { ProxiedConnectionOptions } from './connection';
|
|
7
|
+
export type { TransportBridge } from './bridge';
|
|
8
|
+
export { TUNNEL_ERROR_CODES, TunnelError, isTunnelError, asTunnelError } from './errors';
|
|
9
|
+
export type { TunnelErrorCode, TunnelErrorDetails } from './errors';
|
|
10
|
+
export { DEFAULT_LISTEN_ADDRESS, DEFAULT_REMOTE_BIND_ADDRESS, describeLocalForward, describeRemoteForward, parseAndValidateLocalForward, parseAndValidateRemoteForward, parseLocalForwardSpec, parseRemoteForwardSpec, validateLocalForward, validateRemoteForward, } from './forward-spec';
|
|
11
|
+
export { FIRST_UNPRIVILEGED_PORT, MAX_PORT, MIN_PORT, assertHostAllowed, assertPortAllowed, checkPort, isValidBindPort, isValidHost, isValidPort, parsePort, } from './port-policy';
|
|
12
|
+
export type { PortCheckResult, PortRole } from './port-policy';
|
|
13
|
+
export { credential, expandHome, resolveAgentSocket, resolveCredential } from './credentials';
|
|
14
|
+
export type { CredentialResolver, ResolveOptions } from './credentials';
|
|
15
|
+
export { CONNECTION_STATES, CREDENTIAL_SOURCES, FORWARD_DIRECTIONS, FORWARD_STATES, REACHABILITY_VALUES, TUNNEL_STATES, DEFAULT_KEEPALIVE_COUNT_MAX, DEFAULT_KEEPALIVE_INTERVAL_MS, DEFAULT_READY_TIMEOUT_MS, DEFAULT_RECONNECT_POLICY, MODEL_VERSION, } from './model';
|
|
16
|
+
export type { ConnectionState, ConnectionStatus, CredentialRef, CredentialSource, Endpoint, ForwardDirection, ForwardState, ForwardStatus, LocalForward, PortPolicy, Reachability, ReconnectPolicy, RemoteForward, SshTransport, TunnelConfig, TunnelState, TunnelStatus, } from './model';
|
|
17
|
+
export { SSHTunnelProxy, legacyConfigToTunnelConfig, whitelistToPortPolicy, } from './legacy';
|
|
18
|
+
export type { LegacySSHConfig } from './legacy';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1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a,EACb,2BAA2B,EAC3B,6BAA6B,EAC7B,wBAAwB,EACxB,wBAAwB,EACxB,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,eAAe,EACf,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,GACb,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,cAAc,EACd,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* ssh_tunnel_proxy v2
|
|
4
|
+
*
|
|
5
|
+
* Programmatic local and reverse TCP port forwarding over SSH for Node.js,
|
|
6
|
+
* built for services and devices that only have an outbound SSH transport.
|
|
7
|
+
*
|
|
8
|
+
* Author: Autonomous
|
|
9
|
+
* First release: 1-29-2023
|
|
10
|
+
* License: MIT
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.whitelistToPortPolicy = exports.legacyConfigToTunnelConfig = exports.SSHTunnelProxy = exports.MODEL_VERSION = exports.DEFAULT_RECONNECT_POLICY = exports.DEFAULT_READY_TIMEOUT_MS = exports.DEFAULT_KEEPALIVE_INTERVAL_MS = exports.DEFAULT_KEEPALIVE_COUNT_MAX = exports.TUNNEL_STATES = exports.REACHABILITY_VALUES = exports.FORWARD_STATES = exports.FORWARD_DIRECTIONS = exports.CREDENTIAL_SOURCES = exports.CONNECTION_STATES = exports.resolveCredential = exports.resolveAgentSocket = exports.expandHome = exports.credential = exports.parsePort = exports.isValidPort = exports.isValidHost = exports.isValidBindPort = exports.checkPort = exports.assertPortAllowed = exports.assertHostAllowed = exports.MIN_PORT = exports.MAX_PORT = exports.FIRST_UNPRIVILEGED_PORT = exports.validateRemoteForward = exports.validateLocalForward = exports.parseRemoteForwardSpec = exports.parseLocalForwardSpec = exports.parseAndValidateRemoteForward = exports.parseAndValidateLocalForward = exports.describeRemoteForward = exports.describeLocalForward = exports.DEFAULT_REMOTE_BIND_ADDRESS = exports.DEFAULT_LISTEN_ADDRESS = exports.asTunnelError = exports.isTunnelError = exports.TunnelError = exports.TUNNEL_ERROR_CODES = exports.ProxiedConnection = exports.RemoteForwardHandle = exports.LocalForwardHandle = exports.SSHTunnel = void 0;
|
|
14
|
+
var tunnel_1 = require("./tunnel");
|
|
15
|
+
Object.defineProperty(exports, "SSHTunnel", { enumerable: true, get: function () { return tunnel_1.SSHTunnel; } });
|
|
16
|
+
var local_forward_1 = require("./local-forward");
|
|
17
|
+
Object.defineProperty(exports, "LocalForwardHandle", { enumerable: true, get: function () { return local_forward_1.LocalForwardHandle; } });
|
|
18
|
+
var remote_forward_1 = require("./remote-forward");
|
|
19
|
+
Object.defineProperty(exports, "RemoteForwardHandle", { enumerable: true, get: function () { return remote_forward_1.RemoteForwardHandle; } });
|
|
20
|
+
var connection_1 = require("./connection");
|
|
21
|
+
Object.defineProperty(exports, "ProxiedConnection", { enumerable: true, get: function () { return connection_1.ProxiedConnection; } });
|
|
22
|
+
var errors_1 = require("./errors");
|
|
23
|
+
Object.defineProperty(exports, "TUNNEL_ERROR_CODES", { enumerable: true, get: function () { return errors_1.TUNNEL_ERROR_CODES; } });
|
|
24
|
+
Object.defineProperty(exports, "TunnelError", { enumerable: true, get: function () { return errors_1.TunnelError; } });
|
|
25
|
+
Object.defineProperty(exports, "isTunnelError", { enumerable: true, get: function () { return errors_1.isTunnelError; } });
|
|
26
|
+
Object.defineProperty(exports, "asTunnelError", { enumerable: true, get: function () { return errors_1.asTunnelError; } });
|
|
27
|
+
var forward_spec_1 = require("./forward-spec");
|
|
28
|
+
Object.defineProperty(exports, "DEFAULT_LISTEN_ADDRESS", { enumerable: true, get: function () { return forward_spec_1.DEFAULT_LISTEN_ADDRESS; } });
|
|
29
|
+
Object.defineProperty(exports, "DEFAULT_REMOTE_BIND_ADDRESS", { enumerable: true, get: function () { return forward_spec_1.DEFAULT_REMOTE_BIND_ADDRESS; } });
|
|
30
|
+
Object.defineProperty(exports, "describeLocalForward", { enumerable: true, get: function () { return forward_spec_1.describeLocalForward; } });
|
|
31
|
+
Object.defineProperty(exports, "describeRemoteForward", { enumerable: true, get: function () { return forward_spec_1.describeRemoteForward; } });
|
|
32
|
+
Object.defineProperty(exports, "parseAndValidateLocalForward", { enumerable: true, get: function () { return forward_spec_1.parseAndValidateLocalForward; } });
|
|
33
|
+
Object.defineProperty(exports, "parseAndValidateRemoteForward", { enumerable: true, get: function () { return forward_spec_1.parseAndValidateRemoteForward; } });
|
|
34
|
+
Object.defineProperty(exports, "parseLocalForwardSpec", { enumerable: true, get: function () { return forward_spec_1.parseLocalForwardSpec; } });
|
|
35
|
+
Object.defineProperty(exports, "parseRemoteForwardSpec", { enumerable: true, get: function () { return forward_spec_1.parseRemoteForwardSpec; } });
|
|
36
|
+
Object.defineProperty(exports, "validateLocalForward", { enumerable: true, get: function () { return forward_spec_1.validateLocalForward; } });
|
|
37
|
+
Object.defineProperty(exports, "validateRemoteForward", { enumerable: true, get: function () { return forward_spec_1.validateRemoteForward; } });
|
|
38
|
+
var port_policy_1 = require("./port-policy");
|
|
39
|
+
Object.defineProperty(exports, "FIRST_UNPRIVILEGED_PORT", { enumerable: true, get: function () { return port_policy_1.FIRST_UNPRIVILEGED_PORT; } });
|
|
40
|
+
Object.defineProperty(exports, "MAX_PORT", { enumerable: true, get: function () { return port_policy_1.MAX_PORT; } });
|
|
41
|
+
Object.defineProperty(exports, "MIN_PORT", { enumerable: true, get: function () { return port_policy_1.MIN_PORT; } });
|
|
42
|
+
Object.defineProperty(exports, "assertHostAllowed", { enumerable: true, get: function () { return port_policy_1.assertHostAllowed; } });
|
|
43
|
+
Object.defineProperty(exports, "assertPortAllowed", { enumerable: true, get: function () { return port_policy_1.assertPortAllowed; } });
|
|
44
|
+
Object.defineProperty(exports, "checkPort", { enumerable: true, get: function () { return port_policy_1.checkPort; } });
|
|
45
|
+
Object.defineProperty(exports, "isValidBindPort", { enumerable: true, get: function () { return port_policy_1.isValidBindPort; } });
|
|
46
|
+
Object.defineProperty(exports, "isValidHost", { enumerable: true, get: function () { return port_policy_1.isValidHost; } });
|
|
47
|
+
Object.defineProperty(exports, "isValidPort", { enumerable: true, get: function () { return port_policy_1.isValidPort; } });
|
|
48
|
+
Object.defineProperty(exports, "parsePort", { enumerable: true, get: function () { return port_policy_1.parsePort; } });
|
|
49
|
+
var credentials_1 = require("./credentials");
|
|
50
|
+
Object.defineProperty(exports, "credential", { enumerable: true, get: function () { return credentials_1.credential; } });
|
|
51
|
+
Object.defineProperty(exports, "expandHome", { enumerable: true, get: function () { return credentials_1.expandHome; } });
|
|
52
|
+
Object.defineProperty(exports, "resolveAgentSocket", { enumerable: true, get: function () { return credentials_1.resolveAgentSocket; } });
|
|
53
|
+
Object.defineProperty(exports, "resolveCredential", { enumerable: true, get: function () { return credentials_1.resolveCredential; } });
|
|
54
|
+
var model_1 = require("./model");
|
|
55
|
+
Object.defineProperty(exports, "CONNECTION_STATES", { enumerable: true, get: function () { return model_1.CONNECTION_STATES; } });
|
|
56
|
+
Object.defineProperty(exports, "CREDENTIAL_SOURCES", { enumerable: true, get: function () { return model_1.CREDENTIAL_SOURCES; } });
|
|
57
|
+
Object.defineProperty(exports, "FORWARD_DIRECTIONS", { enumerable: true, get: function () { return model_1.FORWARD_DIRECTIONS; } });
|
|
58
|
+
Object.defineProperty(exports, "FORWARD_STATES", { enumerable: true, get: function () { return model_1.FORWARD_STATES; } });
|
|
59
|
+
Object.defineProperty(exports, "REACHABILITY_VALUES", { enumerable: true, get: function () { return model_1.REACHABILITY_VALUES; } });
|
|
60
|
+
Object.defineProperty(exports, "TUNNEL_STATES", { enumerable: true, get: function () { return model_1.TUNNEL_STATES; } });
|
|
61
|
+
Object.defineProperty(exports, "DEFAULT_KEEPALIVE_COUNT_MAX", { enumerable: true, get: function () { return model_1.DEFAULT_KEEPALIVE_COUNT_MAX; } });
|
|
62
|
+
Object.defineProperty(exports, "DEFAULT_KEEPALIVE_INTERVAL_MS", { enumerable: true, get: function () { return model_1.DEFAULT_KEEPALIVE_INTERVAL_MS; } });
|
|
63
|
+
Object.defineProperty(exports, "DEFAULT_READY_TIMEOUT_MS", { enumerable: true, get: function () { return model_1.DEFAULT_READY_TIMEOUT_MS; } });
|
|
64
|
+
Object.defineProperty(exports, "DEFAULT_RECONNECT_POLICY", { enumerable: true, get: function () { return model_1.DEFAULT_RECONNECT_POLICY; } });
|
|
65
|
+
Object.defineProperty(exports, "MODEL_VERSION", { enumerable: true, get: function () { return model_1.MODEL_VERSION; } });
|
|
66
|
+
// v1 compatibility. New code should use SSHTunnel.
|
|
67
|
+
var legacy_1 = require("./legacy");
|
|
68
|
+
Object.defineProperty(exports, "SSHTunnelProxy", { enumerable: true, get: function () { return legacy_1.SSHTunnelProxy; } });
|
|
69
|
+
Object.defineProperty(exports, "legacyConfigToTunnelConfig", { enumerable: true, get: function () { return legacy_1.legacyConfigToTunnelConfig; } });
|
|
70
|
+
Object.defineProperty(exports, "whitelistToPortPolicy", { enumerable: true, get: function () { return legacy_1.whitelistToPortPolicy; } });
|
|
71
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,mCAAqC;AAA5B,mGAAA,SAAS,OAAA;AAGlB,iDAAqD;AAA5C,mHAAA,kBAAkB,OAAA;AAC3B,mDAAuD;AAA9C,qHAAA,mBAAmB,OAAA;AAC5B,2CAAiD;AAAxC,+GAAA,iBAAiB,OAAA;AAI1B,mCAAyF;AAAhF,4GAA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
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import type { Writable } from 'node:stream';
|
|
3
|
+
import type { Client } from 'ssh2';
|
|
4
|
+
import type { ForwardStatus, PortPolicy, TunnelConfig, TunnelStatus } from './model';
|
|
5
|
+
import { SSHTunnel } from './tunnel';
|
|
6
|
+
/** The v1 configuration object, minus the options that v2 removed. */
|
|
7
|
+
export interface LegacySSHConfig {
|
|
8
|
+
hostname?: string;
|
|
9
|
+
username: string;
|
|
10
|
+
password?: string;
|
|
11
|
+
host?: string;
|
|
12
|
+
port?: string | number;
|
|
13
|
+
proxy_ports?: string[];
|
|
14
|
+
remote_ports?: string[];
|
|
15
|
+
private_key?: string | null;
|
|
16
|
+
private_key_filename?: string | null;
|
|
17
|
+
whitelist?: Record<string, unknown> | null;
|
|
18
|
+
keepaliveInterval?: number;
|
|
19
|
+
server_name?: string;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** Commands to run once the tunnel is up, as in v1. */
|
|
22
|
+
exec?: string[];
|
|
23
|
+
ngrok_api?: string;
|
|
24
|
+
service_name?: string;
|
|
25
|
+
shell?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function whitelistToPortPolicy(whitelist?: Record<string, unknown> | null): PortPolicy;
|
|
28
|
+
/** Translate a v1 config into a v2 {@link TunnelConfig}. */
|
|
29
|
+
export declare function legacyConfigToTunnelConfig(opts: LegacySSHConfig, whitelist?: Record<string, unknown> | null): TunnelConfig;
|
|
30
|
+
/**
|
|
31
|
+
* Drop-in replacement for the v1 class, implemented on top of {@link SSHTunnel}.
|
|
32
|
+
*
|
|
33
|
+
* New code should use SSHTunnel directly: it exposes forward ids, per-connection
|
|
34
|
+
* state, atomic multi-forward setup, and typed lifecycle events, none of which
|
|
35
|
+
* the v1 method names can express.
|
|
36
|
+
*/
|
|
37
|
+
export declare class SSHTunnelProxy extends EventEmitter {
|
|
38
|
+
debug_en: boolean;
|
|
39
|
+
debug_ssh: boolean;
|
|
40
|
+
private tunnel?;
|
|
41
|
+
/** Kept for source compatibility; port policy is now explicit. */
|
|
42
|
+
validate_port_number(port: number, whitelist?: Record<string, unknown> | null): boolean;
|
|
43
|
+
/** Kept for source compatibility; throws a TunnelError on the first bad spec. */
|
|
44
|
+
validate_local_forward(proxy_ports?: string[] | null, whitelist?: Record<string, unknown> | null): boolean;
|
|
45
|
+
private announcedReady;
|
|
46
|
+
connectSSH(opts: LegacySSHConfig, whitelist?: Record<string, unknown> | null): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* v1 returned nothing here. v2 returns the resulting forward statuses, which is
|
|
49
|
+
* a superset: existing callers that ignore the return value are unaffected, and
|
|
50
|
+
* new code can read back the port a `0` bind was actually given.
|
|
51
|
+
*/
|
|
52
|
+
setupProxyPorts(proxy_ports: string[]): Promise<ForwardStatus[]>;
|
|
53
|
+
setupRemotePorts(remote_ports: string[]): Promise<ForwardStatus[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Like v1: with no streams supplied the output goes to this process's stdout and
|
|
56
|
+
* stderr. Unlike v1, the collected stdout is also returned.
|
|
57
|
+
*/
|
|
58
|
+
execCmd(cmd: string, dataStream?: Writable, errStream?: Writable): Promise<string>;
|
|
59
|
+
getStatus(): TunnelStatus;
|
|
60
|
+
/** Escape hatch for code that reached into the ssh2 client directly. */
|
|
61
|
+
getClient(): Client;
|
|
62
|
+
/** The v2 tunnel behind this shim, for incremental migration. */
|
|
63
|
+
getTunnel(): SSHTunnel;
|
|
64
|
+
close(): Promise<void>;
|
|
65
|
+
/** v1 no-ops retained so existing Electron wiring keeps compiling. */
|
|
66
|
+
onNetworkOnline(): void;
|
|
67
|
+
onNetworkOffline(): void;
|
|
68
|
+
private requireTunnel;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=legacy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../src/legacy.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE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B,OAAO,CAAC,aAAa;CAMtB"}
|
package/build/legacy.js
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* legacy.ts — v1 compatibility surface.
|
|
4
|
+
*
|
|
5
|
+
* Existing callers keep `proxy_ports` / `remote_ports` string arrays, the
|
|
6
|
+
* `whitelist` object, and the `ssh_tunnel_ready` / `status` events. Everything is
|
|
7
|
+
* translated into the v2 model and executed by SSHTunnel.
|
|
8
|
+
*
|
|
9
|
+
* Options that were removed rather than renamed throw immediately with a pointer
|
|
10
|
+
* to MIGRATION.md, so nobody silently loses key management or ngrok resolution.
|
|
11
|
+
*
|
|
12
|
+
* License: MIT
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SSHTunnelProxy = void 0;
|
|
16
|
+
exports.whitelistToPortPolicy = whitelistToPortPolicy;
|
|
17
|
+
exports.legacyConfigToTunnelConfig = legacyConfigToTunnelConfig;
|
|
18
|
+
const node_events_1 = require("node:events");
|
|
19
|
+
const credentials_1 = require("./credentials");
|
|
20
|
+
const errors_1 = require("./errors");
|
|
21
|
+
const forward_spec_1 = require("./forward-spec");
|
|
22
|
+
const port_policy_1 = require("./port-policy");
|
|
23
|
+
const tunnel_1 = require("./tunnel");
|
|
24
|
+
const REMOVED_OPTIONS = [
|
|
25
|
+
['ngrok_api', 'ngrok resolution was removed; point transport.endpoint at an existing SSH listener'],
|
|
26
|
+
['service_name', 'system-keychain key storage was removed; use transport.privateKey with a file/env/callback ref'],
|
|
27
|
+
['shell', 'interactive shell support was removed; use a terminal client'],
|
|
28
|
+
];
|
|
29
|
+
function whitelistToPortPolicy(whitelist) {
|
|
30
|
+
if (!whitelist)
|
|
31
|
+
return {};
|
|
32
|
+
const ports = Object.keys(whitelist)
|
|
33
|
+
.map((key) => Number(key))
|
|
34
|
+
.filter((port) => Number.isInteger(port) && port > 0 && port < 1024);
|
|
35
|
+
return ports.length > 0 ? { allowedPrivilegedPorts: ports } : {};
|
|
36
|
+
}
|
|
37
|
+
/** Translate a v1 config into a v2 {@link TunnelConfig}. */
|
|
38
|
+
function legacyConfigToTunnelConfig(opts, whitelist) {
|
|
39
|
+
for (const [key, advice] of REMOVED_OPTIONS) {
|
|
40
|
+
if (opts[key] !== undefined && opts[key] !== null && opts[key] !== false) {
|
|
41
|
+
throw new errors_1.TunnelError('INVALID_FORWARD_SPEC', `Option "${String(key)}" is no longer supported in ssh_tunnel_proxy v2: ${advice}. See MIGRATION.md.`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const host = opts.host ?? opts.hostname;
|
|
45
|
+
if (!host) {
|
|
46
|
+
throw new errors_1.TunnelError('INVALID_FORWARD_SPEC', 'A host (or hostname) is required');
|
|
47
|
+
}
|
|
48
|
+
const port = Number(opts.port ?? 22);
|
|
49
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
50
|
+
throw new errors_1.TunnelError('INVALID_FORWARD_SPEC', `Invalid SSH port: ${String(opts.port)}`);
|
|
51
|
+
}
|
|
52
|
+
const config = {
|
|
53
|
+
id: opts.server_name ?? `${host}:${port}`,
|
|
54
|
+
transport: {
|
|
55
|
+
endpoint: { host, port },
|
|
56
|
+
username: opts.username,
|
|
57
|
+
keepaliveIntervalMs: opts.keepaliveInterval,
|
|
58
|
+
},
|
|
59
|
+
portPolicy: whitelistToPortPolicy(whitelist ?? opts.whitelist),
|
|
60
|
+
};
|
|
61
|
+
// proxy_ports / remote_ports stay as spec strings and are handed to
|
|
62
|
+
// SSHTunnel.addLocalForwards / addRemoteForwards after connect, so the v1
|
|
63
|
+
// string syntax has exactly one parser.
|
|
64
|
+
if (opts.private_key_filename) {
|
|
65
|
+
config.transport.privateKey = credentials_1.credential.file(opts.private_key_filename);
|
|
66
|
+
}
|
|
67
|
+
else if (opts.private_key) {
|
|
68
|
+
config.transport.privateKey = credentials_1.credential.inline(opts.private_key);
|
|
69
|
+
}
|
|
70
|
+
if (opts.password && opts.password.length > 0) {
|
|
71
|
+
config.transport.password = credentials_1.credential.inline(opts.password);
|
|
72
|
+
}
|
|
73
|
+
return config;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Drop-in replacement for the v1 class, implemented on top of {@link SSHTunnel}.
|
|
77
|
+
*
|
|
78
|
+
* New code should use SSHTunnel directly: it exposes forward ids, per-connection
|
|
79
|
+
* state, atomic multi-forward setup, and typed lifecycle events, none of which
|
|
80
|
+
* the v1 method names can express.
|
|
81
|
+
*/
|
|
82
|
+
class SSHTunnelProxy extends node_events_1.EventEmitter {
|
|
83
|
+
debug_en = false;
|
|
84
|
+
debug_ssh = false;
|
|
85
|
+
tunnel;
|
|
86
|
+
/** Kept for source compatibility; port policy is now explicit. */
|
|
87
|
+
validate_port_number(port, whitelist) {
|
|
88
|
+
return (0, port_policy_1.checkPort)(port, 'remote-target', whitelistToPortPolicy(whitelist)).allowed;
|
|
89
|
+
}
|
|
90
|
+
/** Kept for source compatibility; throws a TunnelError on the first bad spec. */
|
|
91
|
+
validate_local_forward(proxy_ports, whitelist) {
|
|
92
|
+
if (!proxy_ports)
|
|
93
|
+
return true;
|
|
94
|
+
const policy = whitelistToPortPolicy(whitelist);
|
|
95
|
+
for (const spec of proxy_ports) {
|
|
96
|
+
(0, forward_spec_1.parseAndValidateLocalForward)(spec, policy);
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
announcedReady = false;
|
|
101
|
+
async connectSSH(opts, whitelist) {
|
|
102
|
+
const config = legacyConfigToTunnelConfig(opts, whitelist);
|
|
103
|
+
const tunnel = new tunnel_1.SSHTunnel(config, { debugSsh: this.debug_ssh });
|
|
104
|
+
this.tunnel = tunnel;
|
|
105
|
+
tunnel.on('debug', (message, ...args) => {
|
|
106
|
+
if (this.debug_en)
|
|
107
|
+
console.log(message, ...args);
|
|
108
|
+
this.emit('debug', message, ...args);
|
|
109
|
+
});
|
|
110
|
+
tunnel.on('error', (error) => this.emit('error', error));
|
|
111
|
+
tunnel.on('ready', (status) => {
|
|
112
|
+
this.emit('status', '', 'ready', `${status.endpoint.host}:${status.endpoint.port}`);
|
|
113
|
+
// v1 signalled readiness once the forwards were usable. On the first connect
|
|
114
|
+
// that happens below, after the ports are set up; on a reconnect the forwards
|
|
115
|
+
// are re-established before `ready`, so signal again here.
|
|
116
|
+
if (this.announcedReady)
|
|
117
|
+
this.emit('ssh_tunnel_ready', {});
|
|
118
|
+
});
|
|
119
|
+
tunnel.on('close', () => this.emit('status', '', 'closed', ''));
|
|
120
|
+
await tunnel.connect();
|
|
121
|
+
if (opts.proxy_ports && opts.proxy_ports.length > 0) {
|
|
122
|
+
await tunnel.addLocalForwards(opts.proxy_ports);
|
|
123
|
+
}
|
|
124
|
+
if (opts.remote_ports && opts.remote_ports.length > 0) {
|
|
125
|
+
await tunnel.addRemoteForwards(opts.remote_ports);
|
|
126
|
+
}
|
|
127
|
+
this.announcedReady = true;
|
|
128
|
+
this.emit('ssh_tunnel_ready', {});
|
|
129
|
+
// v1 ran `opts.exec` commands once the tunnel was up.
|
|
130
|
+
for (const cmd of opts.exec ?? []) {
|
|
131
|
+
await this.execCmd(cmd);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* v1 returned nothing here. v2 returns the resulting forward statuses, which is
|
|
136
|
+
* a superset: existing callers that ignore the return value are unaffected, and
|
|
137
|
+
* new code can read back the port a `0` bind was actually given.
|
|
138
|
+
*/
|
|
139
|
+
async setupProxyPorts(proxy_ports) {
|
|
140
|
+
return this.requireTunnel().addLocalForwards(proxy_ports);
|
|
141
|
+
}
|
|
142
|
+
async setupRemotePorts(remote_ports) {
|
|
143
|
+
return this.requireTunnel().addRemoteForwards(remote_ports);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Like v1: with no streams supplied the output goes to this process's stdout and
|
|
147
|
+
* stderr. Unlike v1, the collected stdout is also returned.
|
|
148
|
+
*/
|
|
149
|
+
async execCmd(cmd, dataStream, errStream) {
|
|
150
|
+
const result = await this.requireTunnel().exec(cmd, {
|
|
151
|
+
stdout: dataStream ?? process.stdout,
|
|
152
|
+
stderr: errStream ?? process.stderr,
|
|
153
|
+
});
|
|
154
|
+
return result.stdout;
|
|
155
|
+
}
|
|
156
|
+
getStatus() {
|
|
157
|
+
return this.requireTunnel().getStatus();
|
|
158
|
+
}
|
|
159
|
+
/** Escape hatch for code that reached into the ssh2 client directly. */
|
|
160
|
+
getClient() {
|
|
161
|
+
const tunnel = this.requireTunnel();
|
|
162
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
163
|
+
const client = tunnel.client;
|
|
164
|
+
if (!client) {
|
|
165
|
+
throw new errors_1.TunnelError('TRANSPORT_NOT_READY', 'No SSH client; call connectSSH first');
|
|
166
|
+
}
|
|
167
|
+
return client;
|
|
168
|
+
}
|
|
169
|
+
/** The v2 tunnel behind this shim, for incremental migration. */
|
|
170
|
+
getTunnel() {
|
|
171
|
+
return this.requireTunnel();
|
|
172
|
+
}
|
|
173
|
+
async close() {
|
|
174
|
+
if (this.tunnel)
|
|
175
|
+
await this.tunnel.close();
|
|
176
|
+
}
|
|
177
|
+
/** v1 no-ops retained so existing Electron wiring keeps compiling. */
|
|
178
|
+
onNetworkOnline() { }
|
|
179
|
+
onNetworkOffline() { }
|
|
180
|
+
requireTunnel() {
|
|
181
|
+
if (!this.tunnel) {
|
|
182
|
+
throw new errors_1.TunnelError('TRANSPORT_NOT_READY', 'Call connectSSH before using the tunnel');
|
|
183
|
+
}
|
|
184
|
+
return this.tunnel;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
exports.SSHTunnelProxy = SSHTunnelProxy;
|
|
188
|
+
//# sourceMappingURL=legacy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy.js","sourceRoot":"","sources":["../src/legacy.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AA4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AI,CAAC,aAAa,EAAE,CAAC;IAC9B,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,IAAI,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC7C,CAAC;IAED,sEAAsE;IAC/D,eAAe,KAAU,CAAC;IAC1B,gBAAgB,KAAU,CAAC;IAE1B,aAAa;QACnB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,IAAI,oBAAW,CAAC,qBAAqB,EAAE,yCAAyC,CAAC,CAAC;QAC1F,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AA7HD,wCA6HC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { TransportBridge } from './bridge';
|
|
2
|
+
import type { ForwardState, ForwardStatus, LocalForward } from './model';
|
|
3
|
+
export declare class LocalForwardHandle {
|
|
4
|
+
readonly forwardId: string;
|
|
5
|
+
readonly spec: LocalForward;
|
|
6
|
+
private state;
|
|
7
|
+
private server?;
|
|
8
|
+
private lastError?;
|
|
9
|
+
private totalConnections;
|
|
10
|
+
private readonly connections;
|
|
11
|
+
private readonly bridge;
|
|
12
|
+
private readonly idleTimeoutMs;
|
|
13
|
+
constructor(spec: LocalForward, bridge: TransportBridge, idleTimeoutMs?: number);
|
|
14
|
+
getState(): ForwardState;
|
|
15
|
+
getStatus(): ForwardStatus;
|
|
16
|
+
listConnections(): import("./model").ConnectionStatus[];
|
|
17
|
+
/** Bind the local listener. Resolves once the port is actually listening. */
|
|
18
|
+
open(): Promise<ForwardStatus>;
|
|
19
|
+
/**
|
|
20
|
+
* Mark the forward as degraded: the listener stays bound so callers do not see
|
|
21
|
+
* connection-refused during a reconnect, but new connections fail fast until
|
|
22
|
+
* the transport returns.
|
|
23
|
+
*/
|
|
24
|
+
markDegraded(reason: string): void;
|
|
25
|
+
markActive(): void;
|
|
26
|
+
close(): Promise<ForwardStatus>;
|
|
27
|
+
private closeConnections;
|
|
28
|
+
private handleSocket;
|
|
29
|
+
private transition;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=local-forward.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-forward.d.ts","sourceRoot":"","sources":["../src/local-forward.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAIhD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEzE,qBAAa,kBAAkB;IAC7B,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,IAAI,EAAE,YAAY,CAAC;IAEnC,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,gBAAgB,CAAK;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAwC;IACpE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;gBAE3B,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,aAAa,SAAI;IAOnE,QAAQ,IAAI,YAAY;IAIxB,SAAS,IAAI,aAAa;IAc1B,eAAe;IAItB,6EAA6E;IAChE,IAAI,IAAI,OAAO,CAAC,aAAa,CAAC;IAkE3C;;;;OAIG;IACI,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAOlC,UAAU,IAAI,IAAI;IAOZ,KAAK,IAAI,OAAO,CAAC,aAAa,CAAC;IAmB5C,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,YAAY;IA+GpB,OAAO,CAAC,UAAU;CAMnB"}
|