dsh-lan-guard 0.3.6 → 0.4.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/lib/index.d.ts CHANGED
@@ -84,6 +84,41 @@ interface LanGuardConfigShape {
84
84
  * DSH), and writes stay bounded by this plugin's gate and admin policy.
85
85
  */
86
86
  settingsUnlock: boolean;
87
+ /**
88
+ * Whether the proxy answers DSH's WebSocket Ping frames itself (default true).
89
+ *
90
+ * Measured 2026-09-28: the host pings `/api/remote.mux` every 2 s and drops a
91
+ * socket after two unanswered pings, so a phone that is suspended (screen
92
+ * locked, switched away) loses the session socket after 6 s and the chat
93
+ * transcript — which is the only part of the UI that rides that socket — never
94
+ * finishes loading. Answering from the proxy hop keeps the tunnel alive; the
95
+ * visitor's own Pong, when it comes, is a harmless duplicate.
96
+ */
97
+ answerHeartbeat: boolean;
98
+ /**
99
+ * Whether the served index carries the client-side socket watchdog (default
100
+ * true). It closes sockets stuck in CONNECTING and, when a resume from the
101
+ * background leaves nothing open, reloads the page once — the only recovery
102
+ * from WebKit's "WebSocket never opens after resume" behaviour.
103
+ */
104
+ socketWatchdog: boolean;
105
+ /**
106
+ * Whether the served index carries mobile compatibility shims (default true):
107
+ * `AbortSignal.any`/`timeout`, `Promise.withResolvers`, the `Iterator` global
108
+ * and the mobile viewport/PWA metas. DSH's client throws inside its stream
109
+ * path on engines without them, which leaves the chat stuck on
110
+ * 「载入历史…」 with no error message at all.
111
+ */
112
+ mobileCompat: boolean;
113
+ /**
114
+ * Whether the served index carries the narrow-screen scroll correction
115
+ * (default true). Measured 2026-09-28: on a phone DSH's own shell clips the
116
+ * conversation column behind its fixed floats, so the chat cannot be dragged;
117
+ * desktop Chrome on the same viewport scrolls fine. The injected script only
118
+ * acts when the page as a whole cannot scroll and it finds a layer that is
119
+ * clipping overflowing content.
120
+ */
121
+ mobileScrollFix: boolean;
87
122
  /** Visitor-side gate configuration. */
88
123
  auth: AuthConfigShape;
89
124
  /** Transport security configuration. */
@@ -138,6 +173,14 @@ interface LiveSwitches {
138
173
  allowLoopback(): boolean;
139
174
  /** Whether LAN visitors get DSH's official settings surface. */
140
175
  settingsUnlock(): boolean;
176
+ /** Whether the proxy answers DSH's WebSocket heartbeat while a visitor is suspended. */
177
+ answerHeartbeat(): boolean;
178
+ /** Whether the served index carries the client-side socket watchdog. */
179
+ socketWatchdog(): boolean;
180
+ /** Whether the served index carries the mobile compatibility shims. */
181
+ mobileCompat(): boolean;
182
+ /** Whether the served index carries the narrow-screen scroll correction. */
183
+ mobileScrollFix(): boolean;
141
184
  /** Whether an unnamed device must pair before it is let in. */
142
185
  requirePairing(): boolean;
143
186
  /** Whether a paired device still needs the operator's approval (F9). */
@@ -481,6 +524,38 @@ declare class DeviceRegistry {
481
524
  }
482
525
  //#endregion
483
526
  //#region src/proxy.d.ts
527
+ /** One relayed WebSocket, as the management console sees it (P5). */
528
+ interface RelayEvent {
529
+ /** When the outcome was recorded, in epoch milliseconds. */
530
+ atMs: number;
531
+ /** The request target the tunnel was opened for. */
532
+ target: string;
533
+ /** Whether the upstream accepted the upgrade. */
534
+ upgraded: boolean;
535
+ /** Upstream or gate status when the upgrade was refused. */
536
+ status?: number;
537
+ /** Tunnel lifetime in milliseconds. */
538
+ durationMs: number;
539
+ /** Bytes relayed upstream → visitor. */
540
+ bytesToVisitor: number;
541
+ /** Bytes relayed visitor → upstream. */
542
+ bytesToUpstream: number;
543
+ /** Whether the upstream sent a WebSocket Close frame before the socket died. */
544
+ sawCloseFrame: boolean;
545
+ }
546
+ /** Live relay counters for the management console (P5). */
547
+ interface ProxyStats {
548
+ /** Upgraded tunnels currently open. */
549
+ wsActive: number;
550
+ /** Upgrades the upstream accepted since start. */
551
+ wsUpgrades: number;
552
+ /** Upgrades refused by the gate or the upstream since start. */
553
+ wsRefused: number;
554
+ /** Pongs written to the upstream on a visitor's behalf since start. */
555
+ heartbeatAnswered: number;
556
+ /** The last few outcomes, newest first. */
557
+ recent: readonly RelayEvent[];
558
+ }
484
559
  /** A running proxy listener. */
485
560
  interface RunningProxy {
486
561
  /** The address actually bound. */
@@ -493,6 +568,8 @@ interface RunningProxy {
493
568
  readonly portFallback: boolean;
494
569
  /** Stop listening and drop every live connection. */
495
570
  close(): Promise<void>;
571
+ /** Relay counters and the most recent outcomes (P5 "连接体检"). */
572
+ stats(): ProxyStats;
496
573
  }
497
574
  //#endregion
498
575
  //#region src/qrcode.d.ts
@@ -561,6 +638,10 @@ interface ManagementDeps {
561
638
  devices: DeviceRegistry;
562
639
  /** Update detection (F8). */
563
640
  updates: UpdateChecker;
641
+ /** Live WebSocket relay counters, for the health panel (P5). */
642
+ relay?: {
643
+ stats(): ProxyStats;
644
+ } | undefined;
564
645
  }
565
646
  /** The host capabilities this plugin needs, narrowed so it is testable without a real Context. */
566
647
  interface LanGuardHost {