dsh-remote-deck 0.0.0-stage → 1.46.0
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 +21 -0
- package/README.md +227 -2
- package/README.zh-CN.md +201 -0
- package/client.js +8645 -0
- package/cordis.patch.yml +6 -0
- package/icon.svg +19 -0
- package/index.js +701 -0
- package/lib/api.js +1452 -0
- package/lib/bash-result.js +93 -0
- package/lib/connection.js +1133 -0
- package/lib/delete.js +199 -0
- package/lib/drafts.js +299 -0
- package/lib/encoding.js +247 -0
- package/lib/file-edit.js +339 -0
- package/lib/file-ops.js +402 -0
- package/lib/forwards.js +186 -0
- package/lib/fs-actions.js +235 -0
- package/lib/guide.js +162 -0
- package/lib/metrics.js +523 -0
- package/lib/remote-shells.js +320 -0
- package/lib/remote-terminal.js +427 -0
- package/lib/routing.js +695 -0
- package/lib/ssh-config.js +118 -0
- package/lib/terminal.js +123 -0
- package/lib/tool-forward.js +185 -0
- package/lib/transfer.js +235 -0
- package/lib/upload-chunks.js +306 -0
- package/lib/util.js +154 -0
- package/locale/README.md +160 -0
- package/locale/en-ui.json +477 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +63 -4
- package/vendor/codemirror/LICENSE +21 -0
- package/vendor/codemirror/README.md +18 -0
- package/vendor/codemirror/addon/edit/closebrackets.min.js +8 -0
- package/vendor/codemirror/addon/edit/matchbrackets.min.js +8 -0
- package/vendor/codemirror/addon/search/search.min.js +8 -0
- package/vendor/codemirror/addon/search/searchcursor.min.js +8 -0
- package/vendor/codemirror/addon/selection/active-line.min.js +8 -0
- package/vendor/codemirror/lib/codemirror.css +344 -0
- package/vendor/codemirror/lib/codemirror.min.js +8 -0
- package/vendor/codemirror/mode/clike/clike.min.js +8 -0
- package/vendor/codemirror/mode/css/css.min.js +8 -0
- package/vendor/codemirror/mode/go/go.min.js +8 -0
- package/vendor/codemirror/mode/htmlmixed/htmlmixed.min.js +8 -0
- package/vendor/codemirror/mode/javascript/javascript.min.js +8 -0
- package/vendor/codemirror/mode/markdown/markdown.min.js +8 -0
- package/vendor/codemirror/mode/python/python.min.js +8 -0
- package/vendor/codemirror/mode/rust/rust.min.js +8 -0
- package/vendor/codemirror/mode/shell/shell.min.js +8 -0
- package/vendor/codemirror/mode/xml/xml.min.js +8 -0
- package/vendor/codemirror/mode/yaml/yaml.min.js +8 -0
- package/vendor/node_modules/asn1/Jenkinsfile +65 -0
- package/vendor/node_modules/asn1/LICENSE +19 -0
- package/vendor/node_modules/asn1/README.md +50 -0
- package/vendor/node_modules/asn1/lib/ber/errors.js +13 -0
- package/vendor/node_modules/asn1/lib/ber/index.js +27 -0
- package/vendor/node_modules/asn1/lib/ber/reader.js +262 -0
- package/vendor/node_modules/asn1/lib/ber/types.js +36 -0
- package/vendor/node_modules/asn1/lib/ber/writer.js +317 -0
- package/vendor/node_modules/asn1/lib/index.js +20 -0
- package/vendor/node_modules/asn1/package.json +31 -0
- package/vendor/node_modules/bcrypt-pbkdf/CONTRIBUTING.md +13 -0
- package/vendor/node_modules/bcrypt-pbkdf/LICENSE +66 -0
- package/vendor/node_modules/bcrypt-pbkdf/README.md +45 -0
- package/vendor/node_modules/bcrypt-pbkdf/index.js +556 -0
- package/vendor/node_modules/bcrypt-pbkdf/package.json +15 -0
- package/vendor/node_modules/safer-buffer/LICENSE +21 -0
- package/vendor/node_modules/safer-buffer/Porting-Buffer.md +268 -0
- package/vendor/node_modules/safer-buffer/Readme.md +156 -0
- package/vendor/node_modules/safer-buffer/dangerous.js +58 -0
- package/vendor/node_modules/safer-buffer/package.json +34 -0
- package/vendor/node_modules/safer-buffer/safer.js +77 -0
- package/vendor/node_modules/safer-buffer/tests.js +406 -0
- package/vendor/node_modules/ssh2/LICENSE +19 -0
- package/vendor/node_modules/ssh2/README.md +1529 -0
- package/vendor/node_modules/ssh2/SFTP.md +413 -0
- package/vendor/node_modules/ssh2/lib/Channel.js +295 -0
- package/vendor/node_modules/ssh2/lib/agent.js +1123 -0
- package/vendor/node_modules/ssh2/lib/client.js +2176 -0
- package/vendor/node_modules/ssh2/lib/http-agents.js +84 -0
- package/vendor/node_modules/ssh2/lib/index.js +44 -0
- package/vendor/node_modules/ssh2/lib/keygen.js +582 -0
- package/vendor/node_modules/ssh2/lib/protocol/Protocol.js +2136 -0
- package/vendor/node_modules/ssh2/lib/protocol/SFTP.js +4052 -0
- package/vendor/node_modules/ssh2/lib/protocol/constants.js +356 -0
- package/vendor/node_modules/ssh2/lib/protocol/crypto/binding.gyp +23 -0
- package/vendor/node_modules/ssh2/lib/protocol/crypto/poly1305.js +43 -0
- package/vendor/node_modules/ssh2/lib/protocol/crypto/src/binding.cc +2300 -0
- package/vendor/node_modules/ssh2/lib/protocol/crypto.js +1602 -0
- package/vendor/node_modules/ssh2/lib/protocol/handlers.js +16 -0
- package/vendor/node_modules/ssh2/lib/protocol/handlers.misc.js +1285 -0
- package/vendor/node_modules/ssh2/lib/protocol/kex.js +1908 -0
- package/vendor/node_modules/ssh2/lib/protocol/keyParser.js +1484 -0
- package/vendor/node_modules/ssh2/lib/protocol/node-fs-compat.js +115 -0
- package/vendor/node_modules/ssh2/lib/protocol/utils.js +356 -0
- package/vendor/node_modules/ssh2/lib/protocol/zlib.js +255 -0
- package/vendor/node_modules/ssh2/lib/server.js +1380 -0
- package/vendor/node_modules/ssh2/lib/utils.js +336 -0
- package/vendor/node_modules/ssh2/package.json +49 -0
- package/vendor/node_modules/tweetnacl/AUTHORS.md +28 -0
- package/vendor/node_modules/tweetnacl/CHANGELOG.md +221 -0
- package/vendor/node_modules/tweetnacl/LICENSE +24 -0
- package/vendor/node_modules/tweetnacl/PULL_REQUEST_TEMPLATE.md +20 -0
- package/vendor/node_modules/tweetnacl/README.md +459 -0
- package/vendor/node_modules/tweetnacl/nacl-fast.js +2388 -0
- package/vendor/node_modules/tweetnacl/nacl-fast.min.js +2 -0
- package/vendor/node_modules/tweetnacl/nacl.d.ts +98 -0
- package/vendor/node_modules/tweetnacl/nacl.js +1175 -0
- package/vendor/node_modules/tweetnacl/nacl.min.js +1 -0
- package/vendor/node_modules/tweetnacl/package.json +58 -0
- package/vendor/xterm/LICENSE.addon-fit +19 -0
- package/vendor/xterm/LICENSE.xterm +21 -0
- package/vendor/xterm/README.md +9 -0
- package/vendor/xterm/addon-fit.js +2 -0
- package/vendor/xterm/xterm.css +218 -0
- package/vendor/xterm/xterm.js +2 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
Duplex: DuplexStream,
|
|
5
|
+
Readable: ReadableStream,
|
|
6
|
+
Writable: WritableStream,
|
|
7
|
+
} = require('stream');
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
CHANNEL_EXTENDED_DATATYPE: { STDERR },
|
|
11
|
+
} = require('./protocol/constants.js');
|
|
12
|
+
const { bufferSlice } = require('./protocol/utils.js');
|
|
13
|
+
|
|
14
|
+
const PACKET_SIZE = 32 * 1024;
|
|
15
|
+
const MAX_WINDOW = 2 * 1024 * 1024;
|
|
16
|
+
const WINDOW_THRESHOLD = MAX_WINDOW / 2;
|
|
17
|
+
|
|
18
|
+
class ClientStderr extends ReadableStream {
|
|
19
|
+
constructor(channel, streamOpts) {
|
|
20
|
+
super(streamOpts);
|
|
21
|
+
|
|
22
|
+
this._channel = channel;
|
|
23
|
+
}
|
|
24
|
+
_read(n) {
|
|
25
|
+
if (this._channel._waitChanDrain) {
|
|
26
|
+
this._channel._waitChanDrain = false;
|
|
27
|
+
if (this._channel.incoming.window <= WINDOW_THRESHOLD)
|
|
28
|
+
windowAdjust(this._channel);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class ServerStderr extends WritableStream {
|
|
34
|
+
constructor(channel) {
|
|
35
|
+
super({ highWaterMark: MAX_WINDOW });
|
|
36
|
+
|
|
37
|
+
this._channel = channel;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
_write(data, encoding, cb) {
|
|
41
|
+
const channel = this._channel;
|
|
42
|
+
const protocol = channel._client._protocol;
|
|
43
|
+
const outgoing = channel.outgoing;
|
|
44
|
+
const packetSize = outgoing.packetSize;
|
|
45
|
+
const id = outgoing.id;
|
|
46
|
+
let window = outgoing.window;
|
|
47
|
+
const len = data.length;
|
|
48
|
+
let p = 0;
|
|
49
|
+
|
|
50
|
+
if (outgoing.state !== 'open')
|
|
51
|
+
return;
|
|
52
|
+
|
|
53
|
+
while (len - p > 0 && window > 0) {
|
|
54
|
+
let sliceLen = len - p;
|
|
55
|
+
if (sliceLen > window)
|
|
56
|
+
sliceLen = window;
|
|
57
|
+
if (sliceLen > packetSize)
|
|
58
|
+
sliceLen = packetSize;
|
|
59
|
+
|
|
60
|
+
if (p === 0 && sliceLen === len)
|
|
61
|
+
protocol.channelExtData(id, data, STDERR);
|
|
62
|
+
else
|
|
63
|
+
protocol.channelExtData(id, bufferSlice(data, p, p + sliceLen), STDERR);
|
|
64
|
+
|
|
65
|
+
p += sliceLen;
|
|
66
|
+
window -= sliceLen;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
outgoing.window = window;
|
|
70
|
+
|
|
71
|
+
if (len - p > 0) {
|
|
72
|
+
if (window === 0)
|
|
73
|
+
channel._waitWindow = true;
|
|
74
|
+
if (p > 0)
|
|
75
|
+
channel._chunkErr = bufferSlice(data, p, len);
|
|
76
|
+
else
|
|
77
|
+
channel._chunkErr = data;
|
|
78
|
+
channel._chunkcbErr = cb;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
cb();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
class Channel extends DuplexStream {
|
|
87
|
+
constructor(client, info, opts) {
|
|
88
|
+
const streamOpts = {
|
|
89
|
+
highWaterMark: MAX_WINDOW,
|
|
90
|
+
allowHalfOpen: (!opts || (opts && opts.allowHalfOpen !== false)),
|
|
91
|
+
emitClose: false,
|
|
92
|
+
};
|
|
93
|
+
super(streamOpts);
|
|
94
|
+
this.allowHalfOpen = streamOpts.allowHalfOpen;
|
|
95
|
+
|
|
96
|
+
const server = !!(opts && opts.server);
|
|
97
|
+
|
|
98
|
+
this.server = server;
|
|
99
|
+
this.type = info.type;
|
|
100
|
+
this.subtype = undefined;
|
|
101
|
+
|
|
102
|
+
/*
|
|
103
|
+
incoming and outgoing contain these properties:
|
|
104
|
+
{
|
|
105
|
+
id: undefined,
|
|
106
|
+
window: undefined,
|
|
107
|
+
packetSize: undefined,
|
|
108
|
+
state: 'closed'
|
|
109
|
+
}
|
|
110
|
+
*/
|
|
111
|
+
this.incoming = info.incoming;
|
|
112
|
+
this.outgoing = info.outgoing;
|
|
113
|
+
this._callbacks = [];
|
|
114
|
+
|
|
115
|
+
this._client = client;
|
|
116
|
+
this._hasX11 = false;
|
|
117
|
+
this._exit = {
|
|
118
|
+
code: undefined,
|
|
119
|
+
signal: undefined,
|
|
120
|
+
dump: undefined,
|
|
121
|
+
desc: undefined,
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
this.stdin = this.stdout = this;
|
|
125
|
+
|
|
126
|
+
if (server)
|
|
127
|
+
this.stderr = new ServerStderr(this);
|
|
128
|
+
else
|
|
129
|
+
this.stderr = new ClientStderr(this, streamOpts);
|
|
130
|
+
|
|
131
|
+
// Outgoing data
|
|
132
|
+
this._waitWindow = false; // SSH-level backpressure
|
|
133
|
+
|
|
134
|
+
// Incoming data
|
|
135
|
+
this._waitChanDrain = false; // Channel Readable side backpressure
|
|
136
|
+
|
|
137
|
+
this._chunk = undefined;
|
|
138
|
+
this._chunkcb = undefined;
|
|
139
|
+
this._chunkErr = undefined;
|
|
140
|
+
this._chunkcbErr = undefined;
|
|
141
|
+
|
|
142
|
+
this.on('finish', onFinish)
|
|
143
|
+
.on('prefinish', onFinish); // For node v0.11+
|
|
144
|
+
|
|
145
|
+
this.on('end', onEnd).on('close', onEnd);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
_read(n) {
|
|
149
|
+
if (this._waitChanDrain) {
|
|
150
|
+
this._waitChanDrain = false;
|
|
151
|
+
if (this.incoming.window <= WINDOW_THRESHOLD)
|
|
152
|
+
windowAdjust(this);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
_write(data, encoding, cb) {
|
|
157
|
+
const protocol = this._client._protocol;
|
|
158
|
+
const outgoing = this.outgoing;
|
|
159
|
+
const packetSize = outgoing.packetSize;
|
|
160
|
+
const id = outgoing.id;
|
|
161
|
+
let window = outgoing.window;
|
|
162
|
+
const len = data.length;
|
|
163
|
+
let p = 0;
|
|
164
|
+
|
|
165
|
+
if (outgoing.state !== 'open')
|
|
166
|
+
return;
|
|
167
|
+
|
|
168
|
+
while (len - p > 0 && window > 0) {
|
|
169
|
+
let sliceLen = len - p;
|
|
170
|
+
if (sliceLen > window)
|
|
171
|
+
sliceLen = window;
|
|
172
|
+
if (sliceLen > packetSize)
|
|
173
|
+
sliceLen = packetSize;
|
|
174
|
+
|
|
175
|
+
if (p === 0 && sliceLen === len)
|
|
176
|
+
protocol.channelData(id, data);
|
|
177
|
+
else
|
|
178
|
+
protocol.channelData(id, bufferSlice(data, p, p + sliceLen));
|
|
179
|
+
|
|
180
|
+
p += sliceLen;
|
|
181
|
+
window -= sliceLen;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
outgoing.window = window;
|
|
185
|
+
|
|
186
|
+
if (len - p > 0) {
|
|
187
|
+
if (window === 0)
|
|
188
|
+
this._waitWindow = true;
|
|
189
|
+
if (p > 0)
|
|
190
|
+
this._chunk = bufferSlice(data, p, len);
|
|
191
|
+
else
|
|
192
|
+
this._chunk = data;
|
|
193
|
+
this._chunkcb = cb;
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
cb();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
eof() {
|
|
201
|
+
if (this.outgoing.state === 'open') {
|
|
202
|
+
this.outgoing.state = 'eof';
|
|
203
|
+
this._client._protocol.channelEOF(this.outgoing.id);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
close() {
|
|
208
|
+
if (this.outgoing.state === 'open' || this.outgoing.state === 'eof') {
|
|
209
|
+
this.outgoing.state = 'closing';
|
|
210
|
+
this._client._protocol.channelClose(this.outgoing.id);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
destroy() {
|
|
215
|
+
this.end();
|
|
216
|
+
this.close();
|
|
217
|
+
return this;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Session type-specific methods =============================================
|
|
221
|
+
setWindow(rows, cols, height, width) {
|
|
222
|
+
if (this.server)
|
|
223
|
+
throw new Error('Client-only method called in server mode');
|
|
224
|
+
|
|
225
|
+
if (this.type === 'session'
|
|
226
|
+
&& (this.subtype === 'shell' || this.subtype === 'exec')
|
|
227
|
+
&& this.writable
|
|
228
|
+
&& this.outgoing.state === 'open') {
|
|
229
|
+
this._client._protocol.windowChange(this.outgoing.id,
|
|
230
|
+
rows,
|
|
231
|
+
cols,
|
|
232
|
+
height,
|
|
233
|
+
width);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
signal(signalName) {
|
|
238
|
+
if (this.server)
|
|
239
|
+
throw new Error('Client-only method called in server mode');
|
|
240
|
+
|
|
241
|
+
if (this.type === 'session'
|
|
242
|
+
&& this.writable
|
|
243
|
+
&& this.outgoing.state === 'open') {
|
|
244
|
+
this._client._protocol.signal(this.outgoing.id, signalName);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
exit(statusOrSignal, coreDumped, msg) {
|
|
249
|
+
if (!this.server)
|
|
250
|
+
throw new Error('Server-only method called in client mode');
|
|
251
|
+
|
|
252
|
+
if (this.type === 'session'
|
|
253
|
+
&& this.writable
|
|
254
|
+
&& this.outgoing.state === 'open') {
|
|
255
|
+
if (typeof statusOrSignal === 'number') {
|
|
256
|
+
this._client._protocol.exitStatus(this.outgoing.id, statusOrSignal);
|
|
257
|
+
} else {
|
|
258
|
+
this._client._protocol.exitSignal(this.outgoing.id,
|
|
259
|
+
statusOrSignal,
|
|
260
|
+
coreDumped,
|
|
261
|
+
msg);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function onFinish() {
|
|
269
|
+
this.eof();
|
|
270
|
+
if (this.server || !this.allowHalfOpen)
|
|
271
|
+
this.close();
|
|
272
|
+
this.writable = false;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function onEnd() {
|
|
276
|
+
this.readable = false;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function windowAdjust(self) {
|
|
280
|
+
if (self.outgoing.state === 'closed')
|
|
281
|
+
return;
|
|
282
|
+
const amt = MAX_WINDOW - self.incoming.window;
|
|
283
|
+
if (amt <= 0)
|
|
284
|
+
return;
|
|
285
|
+
self.incoming.window += amt;
|
|
286
|
+
self._client._protocol.channelWindowAdjust(self.outgoing.id, amt);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
module.exports = {
|
|
290
|
+
Channel,
|
|
291
|
+
MAX_WINDOW,
|
|
292
|
+
PACKET_SIZE,
|
|
293
|
+
windowAdjust,
|
|
294
|
+
WINDOW_THRESHOLD,
|
|
295
|
+
};
|