tabby-rdp 0.5.3 → 0.5.6
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/CHANGELOG.md +120 -0
- package/README.md +53 -11
- package/dist/desktop.service.js +160 -60
- package/dist/desktops.js +46 -11
- package/dist/drives.js +36 -2
- package/dist/h264.js +14 -0
- package/dist/hostCompat.js +2 -18
- package/dist/index.js +1 -1
- package/dist/ntlm.js +17 -12
- package/dist/rdcleanpath.js +40 -15
- package/dist/rdpProfile.js +14 -6
- package/dist/remoteSetup.js +42 -14
- package/dist/settingsPage.js +1 -1
- package/dist/signin.js +56 -31
- package/package.json +5 -26
- package/vendor/SHA256SUMS +33 -3
- package/vendor/iron-remote-desktop-rdp.js +696 -506
- package/vendor/ironrdp-factory.js +697 -507
- package/vendor/ironrdp_web_bg.wasm +0 -0
package/dist/desktops.js
CHANGED
|
@@ -19,8 +19,12 @@ exports.keyFields = keyFields;
|
|
|
19
19
|
exports.nestedKey = nestedKey;
|
|
20
20
|
exports.shownKey = shownKey;
|
|
21
21
|
exports.keyUser = keyUser;
|
|
22
|
+
exports.signsInAs = signsInAs;
|
|
23
|
+
exports.isLoginOf = isLoginOf;
|
|
24
|
+
exports.userScope = userScope;
|
|
22
25
|
exports.keyParts = keyParts;
|
|
23
26
|
exports.rekeyed = rekeyed;
|
|
27
|
+
const accounts_1 = require("./accounts");
|
|
24
28
|
const clipboard_1 = require("./clipboard");
|
|
25
29
|
const hyperv_1 = require("./hyperv");
|
|
26
30
|
const osd_1 = require("./osd");
|
|
@@ -274,36 +278,67 @@ function shownKey(key) {
|
|
|
274
278
|
function keyUser(key) {
|
|
275
279
|
return keyFields(key).user;
|
|
276
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* Who a direct desktop signs in as, as its saved password's key names it (see userScope): DOMAIN\user, or the user
|
|
283
|
+
* name as typed where it names its domain itself (as signInName has it); '' for one that names no user (its sign-in
|
|
284
|
+
* asks who, its domain or not), which keeps the address's password. From its own user name and domain: a saved
|
|
285
|
+
* account's password is the account's (see accountKey), not the desktop's.
|
|
286
|
+
*/
|
|
287
|
+
function signsInAs(extra) {
|
|
288
|
+
const username = configText(extra?.username);
|
|
289
|
+
return username ? (0, accounts_1.signInName)({ username, domain: configText(extra?.domain) }) : '';
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Whether a login saved with `username` (as typed at a sign-in, the desktop's domain going with one that names none)
|
|
293
|
+
* is for `who` (see signsInAs): how a password saved for an address alone, before each user had their own there, is
|
|
294
|
+
* told to be a profile's.
|
|
295
|
+
*/
|
|
296
|
+
function isLoginOf(username, who) {
|
|
297
|
+
const slash = who.indexOf('\\');
|
|
298
|
+
return !!who && (0, accounts_1.signInName)({ username, domain: slash > 0 ? who.slice(0, slash) : '' }) === who;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* What a direct desktop's saved password's key adds for who it signs in as (`@user#<who>`, see signsInAs), or '' for a
|
|
302
|
+
* desktop that doesn't say: several profiles can lead to one address, each signing in as someone else, and each finds
|
|
303
|
+
* the password of its own user there. The user is written as keyField writes a target's, so it has no `#`.
|
|
304
|
+
*/
|
|
305
|
+
function userScope(who) {
|
|
306
|
+
return who ? `@user#${keyField(who, ESCAPED_USER)}` : '';
|
|
307
|
+
}
|
|
277
308
|
/**
|
|
278
309
|
* A session, trust or credential key split into the target it belongs to and the desktop id after it, so matching is
|
|
279
310
|
* anchored on whole parts rather than an `endsWith('#'+id)` that a different key could also satisfy. A key is
|
|
280
311
|
* `<target>#<id>`: the target is `rdp` for a direct desktop, `gateway` for a gateway certificate, or `user@host:port`
|
|
281
312
|
* for a desktop behind an SSH host (`<tab's key>><user@host:port>` for a machine reached through one, see nestedKey;
|
|
282
313
|
* no target's key has a `#`, see keyField); the own desktop's key is the bare target, with no id. A credential key
|
|
283
|
-
* may carry a
|
|
284
|
-
*
|
|
314
|
+
* may carry a user suffix (`…@user#<who>`, see userScope), which names who a direct desktop's password is for, and then
|
|
315
|
+
* a gateway suffix (`…@gateway#<host:port>`), which names where it is sent; both are returned separately, so the id
|
|
316
|
+
* still compares equal. Neither the id nor the user has a `#`, so neither suffix can be taken for part of either.
|
|
285
317
|
*/
|
|
286
318
|
function keyParts(key) {
|
|
287
319
|
const hash = key.indexOf('#');
|
|
288
320
|
if (hash < 0) {
|
|
289
|
-
return { target: key, desktopId: '', gateway: '' };
|
|
321
|
+
return { target: key, desktopId: '', user: '', gateway: '' };
|
|
290
322
|
}
|
|
323
|
+
const target = key.slice(0, hash);
|
|
291
324
|
const rest = key.slice(hash + 1);
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
325
|
+
const scoped = /^([^#]*?)(@user#[^#]*?)?(@gateway#[^#]*)?$/.exec(rest);
|
|
326
|
+
if (scoped) {
|
|
327
|
+
return { target, desktopId: scoped[1], user: scoped[2] ?? '', gateway: scoped[3] ?? '' };
|
|
328
|
+
}
|
|
329
|
+
// More `#` than a key of the plugin's has: compared whole, so that it matches no desktop's.
|
|
330
|
+
return { target, desktopId: rest, user: '', gateway: '' };
|
|
296
331
|
}
|
|
297
332
|
/**
|
|
298
333
|
* A session, trust or credential key of the target `from`, as the same key of `to` (see RemoteTargets.keyChanged,
|
|
299
|
-
* which moves what was kept under a target's former key): `from` itself (its own desktop), or `from#<id>`, with a
|
|
300
|
-
* gateway suffix on a saved password's key. Null for any other key. Desktop ids have no `#` (see
|
|
301
|
-
* has more of them isn't one of `from`'s desktops, whatever it starts with.
|
|
334
|
+
* which moves what was kept under a target's former key): `from` itself (its own desktop), or `from#<id>`, with a user
|
|
335
|
+
* and a gateway suffix on a saved password's key (see keyParts). Null for any other key. Desktop ids have no `#` (see
|
|
336
|
+
* specOf), so a key that has more of them isn't one of `from`'s desktops, whatever it starts with.
|
|
302
337
|
*/
|
|
303
338
|
function rekeyed(key, from, to) {
|
|
304
339
|
if (key === from) {
|
|
305
340
|
return to;
|
|
306
341
|
}
|
|
307
342
|
const rest = key.startsWith(`${from}#`) ? key.slice(from.length + 1) : null;
|
|
308
|
-
return rest !== null && /^[^#]*(@gateway#[^#]*)?$/.test(rest) ? `${to}#${rest}` : null;
|
|
343
|
+
return rest !== null && /^[^#]*(@user#[^#]*)?(@gateway#[^#]*)?$/.test(rest) ? `${to}#${rest}` : null;
|
|
309
344
|
}
|
package/dist/drives.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SharedDrives = exports.WINDOW_OPEN_FILES = exports.MAX_OPEN_FILES = void 0;
|
|
3
|
+
exports.SharedDrives = exports.WINDOW_OPEN_FILES = exports.MAX_LISTED = exports.MAX_OPEN_FILES = void 0;
|
|
4
4
|
exports.sharedFolders = sharedFolders;
|
|
5
5
|
exports.driveName = driveName;
|
|
6
6
|
exports.openFilesInWindow = openFilesInWindow;
|
|
@@ -51,6 +51,17 @@ const READ_LIMIT = 4 * 1024 * 1024;
|
|
|
51
51
|
* far fewer open. More are refused (EMFILE) until the server closes some.
|
|
52
52
|
*/
|
|
53
53
|
exports.MAX_OPEN_FILES = 1024;
|
|
54
|
+
/**
|
|
55
|
+
* Names one folder's listing gives the server at most (security review, finding 4). IronRDP keeps a listing whole with
|
|
56
|
+
* each folder handle the server opens, and the server decides how many it opens and which folder each lists: a shared
|
|
57
|
+
* folder with a great many names, listed again and again, would have the desktop's memory fill with copies of it. A
|
|
58
|
+
* folder anyone browses has far fewer; past this many, the rest aren't listed, and the log says so. What is left out is
|
|
59
|
+
* still there to open by its path (an open is a lookup of its own), though not to find by a query of the folder: IronRDP
|
|
60
|
+
* answers a query for one name, a pattern or all of them from this listing (patch 0015), so a name left out isn't
|
|
61
|
+
* found that way. This caps what one handle holds, not how many handles the server may hold, which stays IronRDP's to
|
|
62
|
+
* bound: the server can still have the desktop keep as many listings as it opens handles.
|
|
63
|
+
*/
|
|
64
|
+
exports.MAX_LISTED = 10000;
|
|
54
65
|
/**
|
|
55
66
|
* Files all the desktops in a window may have open at once. The window's descriptors are one process's, so a limit per
|
|
56
67
|
* desktop alone would let several desktops together hold that many times more. The window may have 8192 open on
|
|
@@ -136,6 +147,8 @@ class SharedDrives {
|
|
|
136
147
|
this.full = false;
|
|
137
148
|
/** The connection ended (see dispose): nothing more is opened, and what was still opening is closed again. */
|
|
138
149
|
this.disposed = false;
|
|
150
|
+
/** A listing was cut short (see MAX_LISTED): said once. */
|
|
151
|
+
this.listCut = false;
|
|
139
152
|
// RDPDR device ids are the session's: the audio device, when there is one, takes 0 in IronRDP.
|
|
140
153
|
this.drives = folders.map((folder, i) => {
|
|
141
154
|
this.byId.set(i + 1, folder);
|
|
@@ -312,7 +325,28 @@ class SharedDrives {
|
|
|
312
325
|
}
|
|
313
326
|
async list(deviceId, remote) {
|
|
314
327
|
const { local } = await this.locate(deviceId, remote, true);
|
|
315
|
-
|
|
328
|
+
// Read a few names at a time, up to MAX_LISTED: not the whole folder first (readdir), only to cut it short. Which
|
|
329
|
+
// names those are is the file system's order to read them in, not one the user could tell (the remote shows
|
|
330
|
+
// them sorted).
|
|
331
|
+
const names = [];
|
|
332
|
+
const dir = await fsp.opendir(local);
|
|
333
|
+
try {
|
|
334
|
+
for await (const entry of dir) {
|
|
335
|
+
if (names.length === exports.MAX_LISTED) {
|
|
336
|
+
if (!this.listCut) {
|
|
337
|
+
this.listCut = true;
|
|
338
|
+
this.log(`drives: a folder of more than ${exports.MAX_LISTED} names was listed: the remote gets ${exports.MAX_LISTED} of them, in no particular order (the rest are still there to open by path)`);
|
|
339
|
+
}
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
names.push(entry.name);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
finally {
|
|
346
|
+
// Closed by the loop as it ends, but for a read that throws.
|
|
347
|
+
await dir.close().catch(() => null);
|
|
348
|
+
}
|
|
349
|
+
return names;
|
|
316
350
|
}
|
|
317
351
|
async open(deviceId, remote, mode) {
|
|
318
352
|
if (this.disposed) {
|
package/dist/h264.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_H264_DECODERS = void 0;
|
|
4
|
+
exports.createH264Decoder = createH264Decoder;
|
|
5
|
+
/** Active and retiring browser decoders together, within one desktop session. */
|
|
6
|
+
exports.MAX_H264_DECODERS = 16;
|
|
7
|
+
/**
|
|
8
|
+
* Keep the vendor instance intact: IronRDP calls its endSurfaces hook even without another video frame, and the
|
|
9
|
+
* decoder owns pending-byte accounting, retiring decoders, readbacks and statistics. Capacity exhaustion follows
|
|
10
|
+
* its normal failure path, which reconnects without H.264; the plugin must not evict its private surface state.
|
|
11
|
+
*/
|
|
12
|
+
function createH264Decoder(Decoder, options = {}) {
|
|
13
|
+
return new Decoder({ ...options, maxDecoders: exports.MAX_H264_DECODERS });
|
|
14
|
+
}
|
package/dist/hostCompat.js
CHANGED
|
@@ -27,7 +27,6 @@ function terminalInputs(container) {
|
|
|
27
27
|
/** An Angular factory provides one instance per plugin window; this module itself needs no Angular runtime. */
|
|
28
28
|
class HostCompatibility {
|
|
29
29
|
constructor(sources) {
|
|
30
|
-
this.nativeModalDragRegion = null;
|
|
31
30
|
const xtermDeclaration = text(read(() => {
|
|
32
31
|
const terminal = sources.terminalPackage?.();
|
|
33
32
|
return text(terminal?.dependencies?.['@xterm/xterm']) ?? text(terminal?.devDependencies?.['@xterm/xterm']);
|
|
@@ -37,25 +36,11 @@ class HostCompatibility {
|
|
|
37
36
|
electron: text(sources.electron), node: text(sources.node), xtermDeclaration,
|
|
38
37
|
xtermMajor: declaredMajor(xtermDeclaration),
|
|
39
38
|
});
|
|
40
|
-
this.modalStyle = sources.modalStyle ?? ((element, pseudo) => getComputedStyle(element, pseudo));
|
|
41
|
-
}
|
|
42
|
-
/** Probe each modal; themes and UI scale can change while the application is running. */
|
|
43
|
-
hasNativeModalDragRegion(modal) {
|
|
44
|
-
let supported = false;
|
|
45
|
-
try {
|
|
46
|
-
const style = this.modalStyle(modal, '::before');
|
|
47
|
-
supported = style.content !== 'none' && style.content !== 'normal' && style.display !== 'none' &&
|
|
48
|
-
style.getPropertyValue('-webkit-app-region') === 'drag' && parseFloat(style.height) > 0;
|
|
49
|
-
}
|
|
50
|
-
catch { }
|
|
51
|
-
this.nativeModalDragRegion = supported;
|
|
52
|
-
return supported;
|
|
53
39
|
}
|
|
54
40
|
snapshot(pane) {
|
|
55
41
|
return {
|
|
56
42
|
...this.info,
|
|
57
43
|
capabilities: {
|
|
58
|
-
nativeModalDragRegion: this.nativeModalDragRegion,
|
|
59
44
|
terminalInput: pane ? terminalInputs(pane).length > 0 : null,
|
|
60
45
|
},
|
|
61
46
|
};
|
|
@@ -63,14 +48,13 @@ class HostCompatibility {
|
|
|
63
48
|
/** Local build information and observed capabilities only; no config, accounts, paths or connection details. */
|
|
64
49
|
diagnosticLines(pane) {
|
|
65
50
|
const info = this.snapshot(pane);
|
|
66
|
-
const {
|
|
67
|
-
const drag = nativeModalDragRegion === null ? 'unobserved' : nativeModalDragRegion ? 'host' : 'plugin fallback';
|
|
51
|
+
const { terminalInput } = info.capabilities;
|
|
68
52
|
const input = terminalInput === null ? 'unobserved' : terminalInput ? 'available' : 'unavailable';
|
|
69
53
|
return [
|
|
70
54
|
`Host: ${info.name ?? 'unknown'} ${info.version ?? 'unknown'} on ${info.platform ?? 'unknown'}`,
|
|
71
55
|
`Runtime: Electron ${info.electron ?? 'unknown'}, Node ${info.node ?? 'unknown'}`,
|
|
72
56
|
`Terminal: xterm ${info.xtermDeclaration ?? 'unknown'} (host declaration)`,
|
|
73
|
-
`Compatibility:
|
|
57
|
+
`Compatibility: terminal input ${input}`,
|
|
74
58
|
];
|
|
75
59
|
}
|
|
76
60
|
}
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ const ui_1 = require("./ui");
|
|
|
30
30
|
let RemoteDesktopModule = class RemoteDesktopModule {
|
|
31
31
|
constructor(app, hotkeys, desktop, header, targets, keyboard, injector) {
|
|
32
32
|
const compat = injector.get(hostCompat_1.HostCompatibility);
|
|
33
|
-
(0, desktop_service_1.installStyle)(
|
|
33
|
+
(0, desktop_service_1.installStyle)();
|
|
34
34
|
header.install();
|
|
35
35
|
// Passwords go to Tabby's Vault while it is enabled (as Tabby's SSH passwords do), else to the system keychain.
|
|
36
36
|
try {
|
package/dist/ntlm.js
CHANGED
|
@@ -190,18 +190,25 @@ function ntlmV2Response(hash, serverChallenge, targetInfo, time, clientChallenge
|
|
|
190
190
|
*/
|
|
191
191
|
function authenticateMessage(negotiate, challenge, account) {
|
|
192
192
|
const server = parseChallenge(challenge);
|
|
193
|
+
// The sign-in is bound to the TLS connection and the service it is for by the pairs the client adds to the server's
|
|
194
|
+
// target information (see clientTargetInfo), and covered whole by the integrity code, which goes with the server's
|
|
195
|
+
// time among those pairs. A challenge without target information, or without the time, would have the answer go
|
|
196
|
+
// out bound to neither, with an LMv2 response besides that binds nothing either: one a gateway could pass on to
|
|
197
|
+
// another service that only checks the binding when it is there. Every Windows since Vista sends both, and an RD
|
|
198
|
+
// Gateway is a Windows Server 2012 R2 or later: such a challenge is refused (security review, finding 5).
|
|
199
|
+
if (!server.targetInfo.length) {
|
|
200
|
+
throw new Error('the gateway\'s NTLM challenge has no target information, so the sign-in couldn\'t be bound to this connection: not answered');
|
|
201
|
+
}
|
|
202
|
+
if (!avPair(server.targetInfo, AV_TIMESTAMP)) {
|
|
203
|
+
throw new Error('the gateway\'s NTLM challenge doesn\'t say when it is, so the sign-in couldn\'t be bound to this connection: not answered');
|
|
204
|
+
}
|
|
193
205
|
const split = /^([^\\]+)\\(.+)$/.exec(account.username);
|
|
194
206
|
const [domain, username] = split ? [split[1], split[2]] : [account.domain ?? '', account.username];
|
|
195
|
-
|
|
196
|
-
// carries an integrity code, and the LM response is left empty.
|
|
197
|
-
const timed = !!avPair(server.targetInfo, AV_TIMESTAMP);
|
|
198
|
-
const targetInfo = server.targetInfo.length
|
|
199
|
-
? clientTargetInfo(server.targetInfo, { mic: timed, channelBinding: account.channelBinding, targetName: account.targetName })
|
|
200
|
-
: server.targetInfo;
|
|
207
|
+
const targetInfo = clientTargetInfo(server.targetInfo, { mic: true, channelBinding: account.channelBinding, targetName: account.targetName });
|
|
201
208
|
const hash = ntlmV2Hash(username, domain, account.password);
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
const lm =
|
|
209
|
+
const { response, sessionKey } = ntlmV2Response(hash, server.challenge, targetInfo);
|
|
210
|
+
// No LM response next to the server's time: the NT response and the integrity code are the proof.
|
|
211
|
+
const lm = Buffer.alloc(24);
|
|
205
212
|
const fields = [lm, response, utf16(domain), utf16(username), utf16(account.workstation ?? ''), Buffer.alloc(0)];
|
|
206
213
|
// 64 bytes of fields and flags, 8 of version (none), 16 of integrity code, then what the fields point at.
|
|
207
214
|
const header = Buffer.alloc(88);
|
|
@@ -218,8 +225,6 @@ function authenticateMessage(negotiate, challenge, account) {
|
|
|
218
225
|
NEGOTIATE_128 | NEGOTIATE_56;
|
|
219
226
|
header.writeUInt32LE((server.flags & ours & ~NEGOTIATE_VERSION) >>> 0, 60);
|
|
220
227
|
const message = Buffer.concat([header, ...fields]);
|
|
221
|
-
|
|
222
|
-
hmacMd5(sessionKey, negotiate, challenge, message).copy(message, 72);
|
|
223
|
-
}
|
|
228
|
+
hmacMd5(sessionKey, negotiate, challenge, message).copy(message, 72);
|
|
224
229
|
return message;
|
|
225
230
|
}
|
package/dist/rdcleanpath.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FLOW_WINDOW = void 0;
|
|
3
|
+
exports.SERVER_BACKLOG = exports.FLOW_WINDOW = void 0;
|
|
4
4
|
exports.normalizeFingerprint = normalizeFingerprint;
|
|
5
5
|
exports.preconnectionPdu = preconnectionPdu;
|
|
6
6
|
exports.offersNla = offersNla;
|
|
@@ -32,9 +32,8 @@ function fingerprintOf(der) {
|
|
|
32
32
|
return normalizeFingerprint((0, crypto_1.createHash)('sha256').update(der).digest('hex'));
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* What answers to the remote's requests may have taken of the window's memory, read for it
|
|
36
|
-
*
|
|
37
|
-
* gets. A link stays busy with far less, as the proxy lets no more than HIGH_WATER wait for the server.
|
|
35
|
+
* What answers to the remote's requests may have taken of the window's memory, read for it, handed to the connection
|
|
36
|
+
* or waiting in the proxy for the server (see ServerFlow): four of the largest parts of files a request gets.
|
|
38
37
|
*/
|
|
39
38
|
exports.FLOW_WINDOW = 64 * 1024 * 1024;
|
|
40
39
|
/** The answer to a server without Network Level Authentication where nobody decides otherwise: refused. */
|
|
@@ -509,8 +508,15 @@ const MAX_EARLY = 256 * 1024;
|
|
|
509
508
|
const MAX_CLIENTS = 4;
|
|
510
509
|
/** A WebSocket message from the client: RDP PDUs, at most a few megabytes for a shared drive's read. */
|
|
511
510
|
const MAX_MESSAGE = 32 * 1024 * 1024;
|
|
512
|
-
/** Data waiting for the
|
|
511
|
+
/** Data waiting for the client past this pauses the server, until half of it is gone. */
|
|
513
512
|
const HIGH_WATER = 8 * 1024 * 1024;
|
|
513
|
+
/**
|
|
514
|
+
* What may wait in the proxy for a server that doesn't take it, before the connection ends (see send). Answers keep
|
|
515
|
+
* within FLOW_WINDOW of it and one message more (see ServerFlow), so the rest of what the client sends (input, sound,
|
|
516
|
+
* and the clipboard's answers, which nothing else bounds) always has HIGH_WATER at least: far more than it needs while
|
|
517
|
+
* the server reads.
|
|
518
|
+
*/
|
|
519
|
+
exports.SERVER_BACKLOG = exports.FLOW_WINDOW + MAX_MESSAGE + HIGH_WATER;
|
|
514
520
|
/**
|
|
515
521
|
* Sends the client's X.224 request upstream, reads the confirm, then does TLS there. With a pre-connection blob, that
|
|
516
522
|
* goes first; without an X.224 request (a Hyper-V VM's console), TLS follows the blob at once and X.224 is the
|
|
@@ -625,13 +631,16 @@ async function startRDCleanPathProxy(openUpstream, checkCertificate, log = () =>
|
|
|
625
631
|
let legacyTls = false;
|
|
626
632
|
const stats = { bytesIn: 0, bytesOut: 0 };
|
|
627
633
|
// The room (see ServerFlow): what was taken for answers and not read from the connection since, the client whose
|
|
628
|
-
// connection that is (the latest to reach the relay: a reconnect can overlap the connection it replaces),
|
|
629
|
-
//
|
|
634
|
+
// connection that is (the latest to reach the relay: a reconnect can overlap the connection it replaces), the
|
|
635
|
+
// stream to its server, where what the proxy read waits for the server, and what waits for room. Once the proxy is
|
|
636
|
+
// closed there is room for good: nothing more goes anywhere.
|
|
630
637
|
let owed = 0;
|
|
631
638
|
let flowClient = null;
|
|
639
|
+
let flowUpstream = null;
|
|
632
640
|
let roomWaiters = [];
|
|
633
641
|
let shut = false;
|
|
634
|
-
const
|
|
642
|
+
const backlog = () => flowUpstream?.writableLength ?? 0;
|
|
643
|
+
const hasRoom = () => shut || owed + backlog() < exports.FLOW_WINDOW;
|
|
635
644
|
const roomMade = () => {
|
|
636
645
|
if (roomWaiters.length && hasRoom()) {
|
|
637
646
|
const go = roomWaiters;
|
|
@@ -685,19 +694,32 @@ async function startRDCleanPathProxy(openUpstream, checkCertificate, log = () =>
|
|
|
685
694
|
// What was handed to this connection went with it: the next starts with all the room.
|
|
686
695
|
if (flowClient === ws) {
|
|
687
696
|
flowClient = null;
|
|
697
|
+
flowUpstream = null;
|
|
688
698
|
owed = 0;
|
|
689
699
|
roomMade();
|
|
690
700
|
}
|
|
691
701
|
};
|
|
692
702
|
let deadline = setTimeout(() => stage === 'hello' && ws.terminate(), HELLO_TIMEOUT_MS);
|
|
693
703
|
const toServer = options.autologon ? autologon() : (data) => data;
|
|
704
|
+
// The proxy reads the client whatever the server does: what the server doesn't take yet waits here, where it is
|
|
705
|
+
// counted, and not in the client's own queue to send, where nothing is (IronRDP's WebSocket sends without
|
|
706
|
+
// looking at it). The room keeps answers within bounds (see ServerFlow); the clipboard's answers, which the
|
|
707
|
+
// remote can ask for again and again, aren't counted there, so the connection ends once more waits than
|
|
708
|
+
// SERVER_BACKLOG. Each write taken by the server makes room again. A server that reads, slowly, can end up
|
|
709
|
+
// there too: what is pasted there from here goes as it is, however large (nothing bounds it), and more of it
|
|
710
|
+
// than SERVER_BACKLOG on a link that takes long to carry it waits here meanwhile. So the failure says how much
|
|
711
|
+
// waited, not only that the server stopped taking it.
|
|
694
712
|
const send = (data) => {
|
|
695
713
|
const out = toServer(data);
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
714
|
+
if (closed || !out.length) {
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
upstream.write(out, roomMade);
|
|
718
|
+
if (upstream.writableLength > exports.SERVER_BACKLOG) {
|
|
719
|
+
failure = `more than ${Math.round(exports.SERVER_BACKLOG / 1024 / 1024)} MB sent to the server waited for it to take them (${Math.round(upstream.writableLength / 1024 / 1024)} MB): it stopped reading, or the link is too slow for what was sent`;
|
|
720
|
+
log(`RDCleanPath relay ended: ${failure}`);
|
|
721
|
+
ws.terminate();
|
|
722
|
+
end();
|
|
701
723
|
}
|
|
702
724
|
};
|
|
703
725
|
failure = null;
|
|
@@ -719,12 +741,13 @@ async function startRDCleanPathProxy(openUpstream, checkCertificate, log = () =>
|
|
|
719
741
|
ws.on('message', async (data) => {
|
|
720
742
|
if (stage === 'relay') {
|
|
721
743
|
stats.bytesOut += data.length;
|
|
722
|
-
// Read from the connection: as
|
|
744
|
+
// Read from the connection: no longer waiting there, but in the proxy, for as long as the server doesn't
|
|
745
|
+
// take it (see ServerFlow).
|
|
723
746
|
if (flowClient === ws) {
|
|
724
747
|
owed = Math.max(0, owed - data.length);
|
|
725
|
-
roomMade();
|
|
726
748
|
}
|
|
727
749
|
send(data);
|
|
750
|
+
roomMade();
|
|
728
751
|
return;
|
|
729
752
|
}
|
|
730
753
|
if (stage === 'handshake') {
|
|
@@ -825,6 +848,7 @@ async function startRDCleanPathProxy(openUpstream, checkCertificate, log = () =>
|
|
|
825
848
|
stage = 'relay';
|
|
826
849
|
// The room is this connection's from now on, all of it (see ServerFlow).
|
|
827
850
|
flowClient = ws;
|
|
851
|
+
flowUpstream = upstream;
|
|
828
852
|
owed = 0;
|
|
829
853
|
roomMade();
|
|
830
854
|
// PROTOCOL_HYBRID_EX in the server's negotiation response: an Early User Authorization Result follows CredSSP.
|
|
@@ -885,6 +909,7 @@ async function startRDCleanPathProxy(openUpstream, checkCertificate, log = () =>
|
|
|
885
909
|
token,
|
|
886
910
|
stats,
|
|
887
911
|
get failure() { return failure; },
|
|
912
|
+
get backlog() { return backlog(); },
|
|
888
913
|
close: () => {
|
|
889
914
|
// Stops listening, and ends the clients there are: close() alone waits for them.
|
|
890
915
|
wss.close();
|
package/dist/rdpProfile.js
CHANGED
|
@@ -135,7 +135,7 @@ let RDPProfileSettingsComponent = class RDPProfileSettingsComponent {
|
|
|
135
135
|
const o = this.profile.options;
|
|
136
136
|
const account = () => `${o.username ?? ''}\n${o.domain ?? ''}\n${o.account ?? ''}`;
|
|
137
137
|
// No id for a new profile (no address yet): it has nothing saved to take along.
|
|
138
|
-
this.before = { id: o.host ? (0, desktops_1.desktopIdOf)(o) : '', account: account(), via: o.via ?? '', gateway: o.gateway ?? '' };
|
|
138
|
+
this.before = { id: o.host ? (0, desktops_1.desktopIdOf)(o) : '', account: account(), user: (0, desktops_1.signsInAs)(o), via: o.via ?? '', gateway: o.gateway ?? '' };
|
|
139
139
|
const root = this.element.nativeElement;
|
|
140
140
|
root.innerHTML = `
|
|
141
141
|
<div class="mb-3">
|
|
@@ -285,7 +285,9 @@ let RDPProfileSettingsComponent = class RDPProfileSettingsComponent {
|
|
|
285
285
|
}
|
|
286
286
|
o.gateway = gatewayText;
|
|
287
287
|
}
|
|
288
|
-
const { id, account, via, gateway } = this.before;
|
|
288
|
+
const { id, account, user, via, gateway } = this.before;
|
|
289
|
+
// Another profile for the same address keeps what it signs in with there (see RemoteDesktopService.directInUse).
|
|
290
|
+
const users = { user, except: this.profile.id };
|
|
289
291
|
if (!id) {
|
|
290
292
|
return;
|
|
291
293
|
}
|
|
@@ -294,7 +296,7 @@ let RDPProfileSettingsComponent = class RDPProfileSettingsComponent {
|
|
|
294
296
|
// (see RDPProfilesService.deleteProfile). Not for the type's or a group's defaults, which have no id of
|
|
295
297
|
// their own (an empty address is useful there): profiles that name that address keep what is saved for it.
|
|
296
298
|
if (!via && this.profile.id) {
|
|
297
|
-
this.injector.get(desktop_service_1.RemoteDesktopService).forgetDesktop(id, true, `"${this.profile.name}"
|
|
299
|
+
this.injector.get(desktop_service_1.RemoteDesktopService).forgetDesktop(id, true, `"${this.profile.name}"`, users).catch(() => null);
|
|
298
300
|
}
|
|
299
301
|
return;
|
|
300
302
|
}
|
|
@@ -303,13 +305,13 @@ let RDPProfileSettingsComponent = class RDPProfileSettingsComponent {
|
|
|
303
305
|
// it had before included) and certificate were its own; one behind a host shares them with that host's
|
|
304
306
|
// desktop at the same address, so they stay.
|
|
305
307
|
if (!via) {
|
|
306
|
-
this.injector.get(desktop_service_1.RemoteDesktopService).forgetDesktop(id, true, `"${this.profile.name}"
|
|
308
|
+
this.injector.get(desktop_service_1.RemoteDesktopService).forgetDesktop(id, true, `"${this.profile.name}"`, users).catch(() => null);
|
|
307
309
|
}
|
|
308
310
|
return;
|
|
309
311
|
}
|
|
310
312
|
// Its saved password goes with its way there (see desktopEdited): another gateway is asked for again.
|
|
311
313
|
const accountChanged = `${o.username ?? ''}\n${o.domain ?? ''}\n${o.account ?? ''}` !== account;
|
|
312
|
-
this.injector.get(desktop_service_1.RemoteDesktopService).desktopEdited(id, (0, desktops_1.desktopIdOf)(o), accountChanged, !via, { from: gateway, to: o.gateway }).catch(() => null);
|
|
314
|
+
this.injector.get(desktop_service_1.RemoteDesktopService).desktopEdited(id, (0, desktops_1.desktopIdOf)(o), accountChanged, !via, { from: gateway, to: o.gateway }, via ? undefined : { from: user, to: (0, desktops_1.signsInAs)(o), except: this.profile.id }).catch(() => null);
|
|
313
315
|
}
|
|
314
316
|
};
|
|
315
317
|
exports.RDPProfileSettingsComponent = RDPProfileSettingsComponent;
|
|
@@ -406,7 +408,13 @@ let RDPProfilesService = class RDPProfilesService extends tabby_core_1.QuickConn
|
|
|
406
408
|
// its own; one behind a host shares them with that host's desktop at the same address. A profile without an
|
|
407
409
|
// address of its own leads to no desktop of its own: desktopIdOf would name 127.0.0.1:3389 for it.
|
|
408
410
|
if (!profile.options.via && (0, desktops_1.configText)(profile.options.host)) {
|
|
409
|
-
|
|
411
|
+
// Its user as it signed in, its group's defaults included; other profiles for the address keep theirs.
|
|
412
|
+
let options = profile.options;
|
|
413
|
+
try {
|
|
414
|
+
options = this.injector.get(tabby_core_1.ProfilesService).getConfigProxyForProfile(profile).options;
|
|
415
|
+
}
|
|
416
|
+
catch { }
|
|
417
|
+
this.injector.get(desktop_service_1.RemoteDesktopService).forgetDesktop((0, desktops_1.desktopIdOf)(profile.options), true, `"${profile.name}"`, { user: (0, desktops_1.signsInAs)(options), except: profile.id }).catch(() => null);
|
|
410
418
|
}
|
|
411
419
|
}
|
|
412
420
|
};
|
package/dist/remoteSetup.js
CHANGED
|
@@ -10,7 +10,7 @@ const rdcleanpath_1 = require("./rdcleanpath");
|
|
|
10
10
|
// with RD_OK, also an RD_XRDP line when xrdp runs besides GNOME, `RD_CLIENTS N`, the clients connected already,
|
|
11
11
|
// `RD_TAKEN_OVER <client> <seconds ago>` after a recent take-over, `RD_DESK <key>` with 'desk' on, and an `RD_NOTE <text>`
|
|
12
12
|
// for each rc file it couldn't change.
|
|
13
|
-
// The RDP password is generated once per remote user and kept in a 0600 file; grd reads credentials only
|
|
13
|
+
// The RDP password is generated once per remote user and machine and kept in a 0600 file; grd reads credentials only
|
|
14
14
|
// at startup, so grd is restarted only when its configuration actually changes (that drops live sessions).
|
|
15
15
|
// Secrets never go on a command line, which any user there can see in the process list, except where grdctl can't
|
|
16
16
|
// read the password from its input: then it is an argument once, when the credentials are set.
|
|
@@ -63,6 +63,17 @@ if [ -d "$OLD" ] && [ ! -e "$D" ]; then
|
|
|
63
63
|
mv "$OLD" "$D" || fail "could not move $OLD to $D"
|
|
64
64
|
fi
|
|
65
65
|
mkdir -p "$D" && chmod 700 "$D" || fail "could not create $D"
|
|
66
|
+
# A home can be mounted on several machines. Never reuse the old home-wide RDP password or TLS key.
|
|
67
|
+
# Machine ids are fixed-format path components; a missing, uninitialized or malformed id is an error.
|
|
68
|
+
MACHINE=$(cat /etc/machine-id 2>/dev/null)
|
|
69
|
+
case $MACHINE in ''|*[!0-9a-f]*|00000000000000000000000000000000) fail "a valid /etc/machine-id is required for private RDP credentials" ;; esac
|
|
70
|
+
[ ${"$"}{#MACHINE} = 32 ] || fail "a valid /etc/machine-id is required for private RDP credentials"
|
|
71
|
+
SECRETS="$D/hosts/$MACHINE"
|
|
72
|
+
for private_dir in "$D/hosts" "$SECRETS"; do
|
|
73
|
+
[ ! -L "$private_dir" ] || fail "credential directory must not be a symbolic link"
|
|
74
|
+
if [ ! -d "$private_dir" ]; then ( umask 077; mkdir "$private_dir" ) 2>/dev/null || [ -d "$private_dir" ] || fail "could not create credential directory"; fi
|
|
75
|
+
[ -O "$private_dir" ] && chmod 700 "$private_dir" || fail "credential directory must belong to this user"
|
|
76
|
+
done
|
|
66
77
|
# The login hook ('desk'): this one line in ~/.bashrc and ~/.zshrc, added and removed exactly, so that a line of the
|
|
67
78
|
# user's own that only looks like it stays.
|
|
68
79
|
HOOK='[ -f "$HOME/.local/share/tabby-rdp/login.sh" ] && . "$HOME/.local/share/tabby-rdp/login.sh" # tabby-rdp'
|
|
@@ -106,14 +117,37 @@ for rc in "$HOME/.bashrc" "$HOME/.zshrc"; do
|
|
|
106
117
|
done
|
|
107
118
|
rm -f "$OLD/login.sh"
|
|
108
119
|
NEW_CERT=0
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
120
|
+
# Serialize the first setup so concurrent panes see the same key pair and password.
|
|
121
|
+
i=0
|
|
122
|
+
until mkdir "$SECRETS/setup.lock" 2>/dev/null; do
|
|
123
|
+
i=$((i+1)); [ $i -lt 100 ] || fail "credential setup is busy; check $SECRETS/setup.lock if a previous setup was interrupted"
|
|
124
|
+
sleep 0.1
|
|
125
|
+
done
|
|
126
|
+
trap 'rmdir "$SECRETS/setup.lock" 2>/dev/null' 0
|
|
127
|
+
trap 'exit 1' HUP INT TERM
|
|
128
|
+
for secret in tls.key tls.crt rdp-password; do
|
|
129
|
+
[ ! -L "$SECRETS/$secret" ] || fail "credential file must not be a symbolic link"
|
|
130
|
+
if [ -e "$SECRETS/$secret" ]; then
|
|
131
|
+
[ -f "$SECRETS/$secret" ] && [ -O "$SECRETS/$secret" ] && chmod 600 "$SECRETS/$secret" || fail "credential file must belong to this user"
|
|
132
|
+
fi
|
|
133
|
+
done
|
|
134
|
+
if [ ! -s "$SECRETS/tls.key" ] || [ ! -s "$SECRETS/tls.crt" ]; then
|
|
135
|
+
( umask 077; openssl req -new -newkey rsa:3072 -days 3650 -nodes -x509 -subj "/CN=$(hostname)" \
|
|
136
|
+
-keyout "$SECRETS/tls.key" -out "$SECRETS/tls.crt" >/dev/null 2>&1 ) || fail "could not create a TLS certificate"
|
|
112
137
|
NEW_CERT=1
|
|
113
138
|
fi
|
|
114
139
|
# The plugin accepts only this certificate on grd's port.
|
|
115
|
-
CERT=$(openssl x509 -in "$
|
|
116
|
-
[ -n "$CERT" ] || fail "could not read the TLS certificate $
|
|
140
|
+
CERT=$(openssl x509 -in "$SECRETS/tls.crt" -noout -fingerprint -sha256 2>/dev/null | sed 's/^[^=]*=//')
|
|
141
|
+
[ -n "$CERT" ] || fail "could not read the TLS certificate $SECRETS/tls.crt (openssl x509)"
|
|
142
|
+
if [ ! -s "$SECRETS/rdp-password" ]; then
|
|
143
|
+
( umask 077; od -An -N18 -tx1 /dev/urandom | tr -d ' \n' > "$SECRETS/rdp-password" ) || fail "could not create credentials"
|
|
144
|
+
fi
|
|
145
|
+
RD_USER=tabby
|
|
146
|
+
RD_PASS=$(cat "$SECRETS/rdp-password")
|
|
147
|
+
case $RD_PASS in ''|*[!0-9a-f]*) fail "invalid stored RDP password" ;; esac
|
|
148
|
+
[ ${"$"}{#RD_PASS} = 36 ] || fail "invalid stored RDP password"
|
|
149
|
+
rmdir "$SECRETS/setup.lock" || fail "could not release credential setup lock"
|
|
150
|
+
trap - 0 HUP INT TERM
|
|
117
151
|
# 'desk' support (setting, off by default): interactive SSH logins start inside a shareable session (trd-pty,
|
|
118
152
|
# or tmux), so 'desk' can attach this exact console to a terminal on the desktop. Rewritten on every connect;
|
|
119
153
|
# opt out per login with TABBY_NO_SESSION=1. When the setting is off, the hook and helpers are removed.
|
|
@@ -219,12 +253,6 @@ else
|
|
|
219
253
|
# Sessions already running keep going; new logins are plain again.
|
|
220
254
|
rm -f "$D/login.sh" "$D/tmux.conf" "$D/backend" "$D/bin/desk" "$D/bin/trd-pty" "$D/desk-key"
|
|
221
255
|
fi
|
|
222
|
-
if [ ! -s "$D/rdp-password" ]; then
|
|
223
|
-
( umask 077; od -An -N18 -tx1 /dev/urandom | tr -d ' \n' > "$D/rdp-password" ) || fail "could not create credentials"
|
|
224
|
-
fi
|
|
225
|
-
RD_USER=tabby
|
|
226
|
-
RD_PASS=$(cat "$D/rdp-password")
|
|
227
|
-
|
|
228
256
|
STATUS=$(grdctl --headless status --show-credentials 2>/dev/null)
|
|
229
257
|
TAB=$(printf '\t') NL='
|
|
230
258
|
'
|
|
@@ -235,8 +263,8 @@ g () { grdctl --headless rdp "$@" >/dev/null 2>&1; }
|
|
|
235
263
|
RESTART=0
|
|
236
264
|
# grd reads the certificate at startup: a new one at the same path needs a restart too, or grd would keep serving
|
|
237
265
|
# the old one, which the plugin would then refuse.
|
|
238
|
-
if [ $NEW_CERT = 1 ] || ! has "TLS key: $
|
|
239
|
-
g set-tls-key "$
|
|
266
|
+
if [ $NEW_CERT = 1 ] || ! has "TLS key: $SECRETS/tls.key" || ! has "TLS certificate: $SECRETS/tls.crt"; then
|
|
267
|
+
g set-tls-key "$SECRETS/tls.key" && g set-tls-cert "$SECRETS/tls.crt" || fail "grdctl could not set the TLS certificate"
|
|
240
268
|
RESTART=1
|
|
241
269
|
fi
|
|
242
270
|
if ! has "View-only: no"; then g disable-view-only || fail "grdctl could not disable view-only"; RESTART=1; fi
|
package/dist/settingsPage.js
CHANGED
|
@@ -120,7 +120,7 @@ const STYLE = `
|
|
|
120
120
|
.trd-settings .trd-row .trd-folder-readonly input { margin: 0; position: static; float: none; }
|
|
121
121
|
.trd-settings .trd-row a[data-profile], .trd-settings .trd-row a[data-desktop] { cursor: pointer; text-decoration: underline; }
|
|
122
122
|
.trd-settings .trd-form-overlay { position: fixed; inset: 0; z-index: 1050; background: rgba(0, 0, 0, 0.55); }
|
|
123
|
-
/*
|
|
123
|
+
/* These plain-DOM overlays are not .modal elements, so Tabby's native dialog drag region does not cover them. */
|
|
124
124
|
.trd-settings .trd-form-overlay .trd-form-dragbar, .trd-capture .trd-form-dragbar { display: block; position: absolute; left: 0; right: 0; top: 0;
|
|
125
125
|
height: var(--tabs-height, 38px); -webkit-app-region: drag; }
|
|
126
126
|
.trd-settings .trd-form-overlay .trd-signin { top: var(--tabs-height, 38px); }
|