remote-dsh 0.13.0 → 0.14.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/dist/bin.js +45 -11
- package/package.json +3 -3
package/dist/bin.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { createInterface } from "node:readline";
|
|
12
12
|
import { rm } from "node:fs/promises";
|
|
13
13
|
import { dirname } from "node:path";
|
|
14
|
-
import { serve, join, registerJoin, findDsh, selfRevoke, readPersistedToken, clearPersistedToken, UserManager, resolveConfigPath, loadConfig, saveConfig, installService, uninstallService, serviceStatus, startService, stopService, restartService, HOST_SERVICE_NAME, JOIN_SERVICE_NAME, HUB_SERVICE_NAME, } from "rdsh-gateway";
|
|
14
|
+
import { serve, join, registerJoin, findDsh, selfRevoke, readPersistedToken, clearPersistedToken, UserManager, resolveConfigPath, loadConfig, saveConfig, generateAccessCode, installService, uninstallService, serviceStatus, startService, stopService, restartService, HOST_SERVICE_NAME, JOIN_SERVICE_NAME, HUB_SERVICE_NAME, } from "rdsh-gateway";
|
|
15
15
|
import { loadHubConfig, resolveHubConfigPath, HubDb, hashPassword, serveHub, } from "rdsh-hub";
|
|
16
16
|
import { VERSION } from "./index.js";
|
|
17
17
|
const HELP = `rdsh — secure remote access for DeepSeek Harness
|
|
@@ -23,6 +23,7 @@ Usage:
|
|
|
23
23
|
rdsh host service ... Run as a systemd/launchd service
|
|
24
24
|
rdsh host leave Unregister this machine from the hub
|
|
25
25
|
rdsh host user ... Manage gateway users (LAN/cloud password auth)
|
|
26
|
+
rdsh host gate ... Set / clear the access code (LAN + tunnel gate)
|
|
26
27
|
rdsh hub serve Start the hub server (cloud, multi-host)
|
|
27
28
|
rdsh hub user add|passwd|rm|ls|unlock|reset-2fa|ban|unban
|
|
28
29
|
rdsh hub audit ls Audit log (login/2FA/sharing/email events)
|
|
@@ -42,15 +43,16 @@ const SUB_HELP = {
|
|
|
42
43
|
Configure and run this machine (the DSH host).
|
|
43
44
|
|
|
44
45
|
Subcommands:
|
|
45
|
-
setup lan Configure a LAN gateway (
|
|
46
|
+
setup lan Configure a LAN gateway (access-code auth, plain http)
|
|
46
47
|
setup cloud Configure a cloud HTTPS gateway (password + TLS + allowFrom)
|
|
47
48
|
join <hub-url> Connect to a hub (interactive token paste; --token for scripts)
|
|
48
49
|
serve Run the configured mode in the foreground
|
|
49
50
|
service install|status|start|stop|restart|uninstall Run as a systemd/launchd service
|
|
50
51
|
leave Unregister this machine from the hub
|
|
51
52
|
user add|passwd|ls|rm Manage gateway users
|
|
53
|
+
gate set|clear|status Set / clear the access code (LAN + tunnel gate)
|
|
52
54
|
|
|
53
|
-
Options (setup lan): --port <n>
|
|
55
|
+
Options (setup lan): --port <n>
|
|
54
56
|
Options (setup cloud): --tls-cert <path> --tls-key <path> [--port <n>] [--allow-from <cidr,...>]
|
|
55
57
|
Options (join): --token <t> --name <n> --dsh <path> --insecure
|
|
56
58
|
`,
|
|
@@ -171,8 +173,11 @@ async function handleHost(args, configPath) {
|
|
|
171
173
|
case "user":
|
|
172
174
|
await handleHostUser(rest, configPath);
|
|
173
175
|
return;
|
|
176
|
+
case "gate":
|
|
177
|
+
await handleHostGate(rest, configPath);
|
|
178
|
+
return;
|
|
174
179
|
default:
|
|
175
|
-
throw new Error("usage: rdsh host setup|join|serve|service|leave|user");
|
|
180
|
+
throw new Error("usage: rdsh host setup|join|serve|service|leave|user|gate");
|
|
176
181
|
}
|
|
177
182
|
}
|
|
178
183
|
/** `rdsh host setup lan|cloud`:写 host.json(mode + 预设字段),配置完退出。 */
|
|
@@ -182,13 +187,10 @@ async function handleHostSetup(args, configPath) {
|
|
|
182
187
|
const config = await loadConfig(target);
|
|
183
188
|
if (which === "lan") {
|
|
184
189
|
let port = config.port;
|
|
185
|
-
let pairCode = config.auth.pairCode;
|
|
186
190
|
for (let i = 1; i < args.length; i++) {
|
|
187
191
|
const flag = args[i];
|
|
188
192
|
if (flag === "--port")
|
|
189
193
|
port = parsePort(args[++i]);
|
|
190
|
-
else if (flag === "--pair-code")
|
|
191
|
-
pairCode = args[++i];
|
|
192
194
|
else
|
|
193
195
|
throw new Error(`unknown option '${flag}'`);
|
|
194
196
|
}
|
|
@@ -197,11 +199,14 @@ async function handleHostSetup(args, configPath) {
|
|
|
197
199
|
config.tls = undefined;
|
|
198
200
|
config.behindProxy = false;
|
|
199
201
|
config.allowFrom = [];
|
|
200
|
-
config.auth.mode = "
|
|
201
|
-
|
|
202
|
+
config.auth.mode = "none";
|
|
203
|
+
// 统一固定口令:LAN 直连的门禁(取代旧动态配对码)
|
|
204
|
+
const code = config.gateway?.accessCode ?? generateAccessCode();
|
|
205
|
+
config.gateway = { accessCode: code };
|
|
202
206
|
config.dshPath = config.dshPath ?? findDsh() ?? undefined;
|
|
203
207
|
await saveConfig(target, config);
|
|
204
|
-
console.log(`rdsh: host 配置为 LAN
|
|
208
|
+
console.log(`rdsh: host 配置为 LAN 网关(访问口令,端口 ${port})→ ${target}`);
|
|
209
|
+
console.log(`rdsh: 访问口令(请记录,可用 \`rdsh host gate set\` 修改):${code}`);
|
|
205
210
|
console.log("rdsh: 运行 `rdsh host serve` 前台启动,或 `rdsh host service install` 常驻。");
|
|
206
211
|
return;
|
|
207
212
|
}
|
|
@@ -299,7 +304,7 @@ async function handleHostServe(_args, configPath) {
|
|
|
299
304
|
if (config.mode === "join") {
|
|
300
305
|
if (config.hub === undefined)
|
|
301
306
|
throw new Error("host.json 缺 hub(join 模式);先 `rdsh host join <hub>`");
|
|
302
|
-
await join({ hubUrl: config.hub, name: config.name, insecure: config.insecure, dshPath: config.dshPath, dshUiCompat: config.dshUiCompat, gateway: config.gateway });
|
|
307
|
+
await join({ hubUrl: config.hub, name: config.name, insecure: config.insecure, dshPath: config.dshPath, dshUiCompat: config.dshUiCompat, gateway: config.gateway, direct: { host: config.host, port: config.port } });
|
|
303
308
|
return;
|
|
304
309
|
}
|
|
305
310
|
await serve({ configPath: target });
|
|
@@ -368,6 +373,35 @@ async function maybeRegisterForServiceInstall(args, target) {
|
|
|
368
373
|
cfg.dshPath = joinOpts.dshPath ?? findDsh() ?? cfg.dshPath;
|
|
369
374
|
await saveConfig(target, cfg);
|
|
370
375
|
}
|
|
376
|
+
/** `rdsh host gate set|clear|status`:访问口令(gateway.accessCode)——隧道与直连两条通道共用的门禁。 */
|
|
377
|
+
async function handleHostGate(args, configPath) {
|
|
378
|
+
const action = args[0];
|
|
379
|
+
const target = resolveConfigPath(configPath);
|
|
380
|
+
const config = await loadConfig(target);
|
|
381
|
+
if (action === "set") {
|
|
382
|
+
const code = await promptPassword("访问口令(≥4 位,留空取消): ");
|
|
383
|
+
if (code.trim() === "")
|
|
384
|
+
return;
|
|
385
|
+
if (code.length < 4)
|
|
386
|
+
throw new Error("访问口令至少 4 位");
|
|
387
|
+
config.gateway = { accessCode: code };
|
|
388
|
+
await saveConfig(target, config);
|
|
389
|
+
console.log("rdsh: 访问口令已设置(重启 host 生效;插件面板设置即时生效)。");
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
if (action === "clear") {
|
|
393
|
+
config.gateway = { accessCode: null };
|
|
394
|
+
await saveConfig(target, config);
|
|
395
|
+
console.log("rdsh: 访问口令已清除——直连口仍会监听,但只认一次性直连票(无票一律 403,不再有口令挑战页);隧道两条通道不再要求口令。");
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
if (action === "status") {
|
|
399
|
+
const code = config.gateway?.accessCode ?? null;
|
|
400
|
+
console.log(code === null ? "rdsh: 未设置访问口令(直连口仍监听,仅认一次性直连票;隧道无门禁)。" : "rdsh: 访问口令已设置(两条通道均需口令)。");
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
throw new Error("usage: rdsh host gate set|clear|status");
|
|
404
|
+
}
|
|
371
405
|
/** `rdsh host leave`:self-revoke + 清 session + 删 host.json → 未配置。 */
|
|
372
406
|
async function handleHostLeave(_args, configPath) {
|
|
373
407
|
const target = resolveConfigPath(configPath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remote-dsh",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Secure remote access for DeepSeek Harness: rdsh serve / rdsh join / rdsh hub",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"node": ">=22"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"rdsh-gateway": "0.
|
|
27
|
-
"rdsh-hub": "0.
|
|
26
|
+
"rdsh-gateway": "0.11.0",
|
|
27
|
+
"rdsh-hub": "0.9.0"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "tsc -p tsconfig.json",
|