rdsh-gateway 0.2.0 → 0.2.2

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/join.js CHANGED
@@ -105,6 +105,9 @@ export async function join(opts) {
105
105
  process.on("SIGINT", () => void shutdown("SIGINT"));
106
106
  process.on("SIGTERM", () => void shutdown("SIGTERM"));
107
107
  process.on("SIGHUP", () => void shutdown("SIGHUP"));
108
+ // 常驻:进程靠信号退出(shutdown 里 process.exit);防止函数返回后
109
+ // CLI 的 main().then(exit) 误退出服务进程
110
+ const keepAlive = new Promise(() => { });
108
111
  function handleFrame(frame, client) {
109
112
  switch (frame.type) {
110
113
  case FRAME_TYPE.PING: {
@@ -121,7 +124,7 @@ export async function join(opts) {
121
124
  const ws = wsStreams.get(frame.streamId);
122
125
  if (ws !== undefined) {
123
126
  if (ws.upstream.readyState === ws.upstream.OPEN) {
124
- ws.upstream.send(frame.payload, { binary: true });
127
+ ws.upstream.send(frame.payload, { binary: false }); // DSH WS 为 text(JSON),保持文本帧
125
128
  }
126
129
  else {
127
130
  ws.queue.push(frame.payload);
@@ -240,7 +243,7 @@ export async function join(opts) {
240
243
  wsStreams.set(streamId, { upstream, queue });
241
244
  upstream.on("open", () => {
242
245
  for (const q of queue)
243
- upstream.send(q, { binary: true });
246
+ upstream.send(q, { binary: false });
244
247
  queue.length = 0;
245
248
  });
246
249
  upstream.on("message", (data, isBinary) => {
@@ -336,6 +339,7 @@ export async function join(opts) {
336
339
  });
337
340
  }
338
341
  connect();
342
+ await keepAlive;
339
343
  }
340
344
  function normalizeRespHeaders(headers) {
341
345
  const out = {};
package/dist/serve.js CHANGED
@@ -96,6 +96,9 @@ export async function serve(opts) {
96
96
  process.on("SIGINT", () => void shutdown("SIGINT"));
97
97
  process.on("SIGTERM", () => void shutdown("SIGTERM"));
98
98
  process.on("SIGHUP", () => void shutdown("SIGHUP"));
99
+ // 常驻:进程靠信号退出(shutdown 里 process.exit);防止函数返回后
100
+ // CLI 的 main().then(exit) 误退出服务进程
101
+ await new Promise(() => { });
99
102
  }
100
103
  function lanAddresses() {
101
104
  return Object.values(networkInterfaces())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rdsh-gateway",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "rdsh host-side component: LAN auth gateway + outbound tunnel endpoint (spawns dsh web)",
5
5
  "license": "MIT",
6
6
  "type": "module",