remote-dsh 0.10.7 → 0.12.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.
Files changed (2) hide show
  1. package/dist/bin.js +36 -21
  2. package/package.json +3 -3
package/dist/bin.js CHANGED
@@ -4,14 +4,14 @@
4
4
  *
5
5
  * rdsh host setup lan|cloud
6
6
  * rdsh host join <hub-url> [--token <t>] [--name <n>] [--dsh <p>] [--insecure]
7
- * rdsh host serve | service install|status|uninstall | leave | user ...
7
+ * rdsh host serve | service install|status|start|stop|restart|uninstall | leave | user ...
8
8
  * rdsh hub serve|user|host|service ... [--config <path>]
9
9
  * rdsh --version | --help
10
10
  */
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, 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, 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
@@ -46,7 +46,7 @@ Subcommands:
46
46
  setup cloud Configure a cloud HTTPS gateway (password + TLS + allowFrom)
47
47
  join <hub-url> Connect to a hub (interactive token paste; --token for scripts)
48
48
  serve Run the configured mode in the foreground
49
- service install|status|uninstall Run as a systemd/launchd service
49
+ service install|status|start|stop|restart|uninstall Run as a systemd/launchd service
50
50
  leave Unregister this machine from the hub
51
51
  user add|passwd|ls|rm Manage gateway users
52
52
 
@@ -63,7 +63,7 @@ Subcommands:
63
63
  user add|passwd|rm|ls|unlock|reset-2fa|ban|unban Manage users (admin creates accounts; unlock / reset-2fa / ban / unban)
64
64
  audit ls [--user <n>] [--event <e>] [--since 24h|7d] Query the audit log
65
65
  host ls|revoke List / revoke hosts (revoke drops the tunnel instantly)
66
- service install|status|uninstall Run hub as a systemd/launchd service
66
+ service install|status|start|stop|restart|uninstall Run hub as a systemd/launchd service
67
67
 
68
68
  Options (serve):
69
69
  --config <path> Hub config (default ~/.rdsh/hub.json; also $RDSH_HUB_CONFIG)
@@ -304,34 +304,40 @@ async function handleHostServe(_args, configPath) {
304
304
  }
305
305
  await serve({ configPath: target });
306
306
  }
307
- /** `rdsh host service install|status|uninstall`:读 host.json mode 装对应服务(unit 不含 token)。 */
307
+ /** `rdsh host service install|status|start|stop|restart|uninstall`:读 host.json mode 定位服务(unit 不含 token)。 */
308
308
  async function handleHostService(args, configPath) {
309
309
  const action = args[0];
310
310
  const target = resolveConfigPath(configPath);
311
+ const actions = ["install", "status", "start", "stop", "restart", "uninstall"];
312
+ if (action === undefined || !actions.includes(action)) {
313
+ throw new Error(`usage: rdsh host service ${actions.join("|")}`);
314
+ }
315
+ if (action === "install") {
316
+ await maybeRegisterForServiceInstall(args, target);
317
+ }
318
+ const config = await loadConfig(target);
319
+ const name = config.mode === "join" ? JOIN_SERVICE_NAME : HOST_SERVICE_NAME;
311
320
  switch (action) {
312
- case "install": {
313
- await maybeRegisterForServiceInstall(args, target);
314
- const config = await loadConfig(target);
315
- const name = config.mode === "join" ? JOIN_SERVICE_NAME : HOST_SERVICE_NAME;
321
+ case "install":
316
322
  // host 服务会 spawn dsh(shebang `#!/usr/bin/env node`),nvm/自装 node 下需补 node 目录到 PATH(防 127)
317
323
  console.log(await installService({ name, args: ["host", "serve"], configPath: target, pathEnv: nodePathEnv() }));
318
324
  console.log(`rdsh: host service installed (${name}) —— 开机自启 + 崩溃重启。`);
319
325
  return;
320
- }
321
- case "status": {
322
- const config = await loadConfig(target);
323
- const name = config.mode === "join" ? JOIN_SERVICE_NAME : HOST_SERVICE_NAME;
326
+ case "status":
324
327
  console.log(`rdsh host service (${name}): ${await serviceStatus(name)}`);
325
328
  return;
326
- }
327
- case "uninstall": {
328
- const config = await loadConfig(target);
329
- const name = config.mode === "join" ? JOIN_SERVICE_NAME : HOST_SERVICE_NAME;
329
+ case "start":
330
+ console.log(await startService(name));
331
+ return;
332
+ case "stop":
333
+ console.log(await stopService(name));
334
+ return;
335
+ case "restart":
336
+ console.log(await restartService(name));
337
+ return;
338
+ case "uninstall":
330
339
  console.log(await uninstallService(name));
331
340
  return;
332
- }
333
- default:
334
- throw new Error("usage: rdsh host service install|status|uninstall");
335
341
  }
336
342
  }
337
343
  /** 一行接入:`host service install <hub-url> --token <t> [--name <n>]` → 注册 + 写 host.json(再装服务)。 */
@@ -523,11 +529,20 @@ async function handleHub(args, configPath) {
523
529
  case "status":
524
530
  console.log(`rdsh hub service (${HUB_SERVICE_NAME}): ${await serviceStatus(HUB_SERVICE_NAME)}`);
525
531
  return;
532
+ case "start":
533
+ console.log(await startService(HUB_SERVICE_NAME));
534
+ return;
535
+ case "stop":
536
+ console.log(await stopService(HUB_SERVICE_NAME));
537
+ return;
538
+ case "restart":
539
+ console.log(await restartService(HUB_SERVICE_NAME));
540
+ return;
526
541
  case "uninstall":
527
542
  console.log(await uninstallService(HUB_SERVICE_NAME));
528
543
  return;
529
544
  default:
530
- throw new Error("usage: rdsh hub service install|status|uninstall");
545
+ throw new Error("usage: rdsh hub service install|status|start|stop|restart|uninstall");
531
546
  }
532
547
  }
533
548
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remote-dsh",
3
- "version": "0.10.7",
3
+ "version": "0.12.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.8.6",
27
- "rdsh-hub": "0.7.3"
26
+ "rdsh-gateway": "0.10.0",
27
+ "rdsh-hub": "0.7.4"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "tsc -p tsconfig.json",