lunel-cli 0.1.39 → 0.1.40
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/index.js +37 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -198,6 +198,24 @@ function samePortSet(a, b) {
|
|
|
198
198
|
}
|
|
199
199
|
return true;
|
|
200
200
|
}
|
|
201
|
+
function isProtocolRequest(value) {
|
|
202
|
+
if (!value || typeof value !== "object")
|
|
203
|
+
return false;
|
|
204
|
+
const msg = value;
|
|
205
|
+
return (msg.v === 1 &&
|
|
206
|
+
typeof msg.id === "string" &&
|
|
207
|
+
typeof msg.ns === "string" &&
|
|
208
|
+
typeof msg.action === "string" &&
|
|
209
|
+
typeof msg.payload === "object" &&
|
|
210
|
+
msg.payload !== null &&
|
|
211
|
+
typeof msg.ok === "undefined");
|
|
212
|
+
}
|
|
213
|
+
function isProtocolResponse(value) {
|
|
214
|
+
if (!value || typeof value !== "object")
|
|
215
|
+
return false;
|
|
216
|
+
const msg = value;
|
|
217
|
+
return msg.v === 1 && typeof msg.id === "string" && typeof msg.ok === "boolean";
|
|
218
|
+
}
|
|
201
219
|
// ============================================================================
|
|
202
220
|
// Path Safety
|
|
203
221
|
// ============================================================================
|
|
@@ -2405,6 +2423,9 @@ async function processMessage(message) {
|
|
|
2405
2423
|
};
|
|
2406
2424
|
}
|
|
2407
2425
|
}
|
|
2426
|
+
function sendResponseOnData(response, dataWs) {
|
|
2427
|
+
dataWs.send(JSON.stringify(response));
|
|
2428
|
+
}
|
|
2408
2429
|
function normalizeGatewayUrl(input) {
|
|
2409
2430
|
if (/^https?:\/\//.test(input))
|
|
2410
2431
|
return input.replace(/\/+$/, "");
|
|
@@ -2561,10 +2582,16 @@ async function connectWebSocket() {
|
|
|
2561
2582
|
return;
|
|
2562
2583
|
}
|
|
2563
2584
|
}
|
|
2564
|
-
if (message
|
|
2585
|
+
if (isProtocolResponse(message)) {
|
|
2586
|
+
// Ignore server/app responses forwarded over WS; CLI only processes requests.
|
|
2587
|
+
return;
|
|
2588
|
+
}
|
|
2589
|
+
if (isProtocolRequest(message)) {
|
|
2565
2590
|
const response = await processMessage(message);
|
|
2566
|
-
|
|
2591
|
+
sendResponseOnData(response, dataWs);
|
|
2592
|
+
return;
|
|
2567
2593
|
}
|
|
2594
|
+
console.warn("[router] Ignoring non-request control frame");
|
|
2568
2595
|
}
|
|
2569
2596
|
catch (error) {
|
|
2570
2597
|
console.error("Error processing control message:", error);
|
|
@@ -2593,10 +2620,16 @@ async function connectWebSocket() {
|
|
|
2593
2620
|
const message = JSON.parse(data.toString());
|
|
2594
2621
|
if (message.type === "connected")
|
|
2595
2622
|
return;
|
|
2596
|
-
if (message
|
|
2623
|
+
if (isProtocolResponse(message)) {
|
|
2624
|
+
// Ignore server/app responses forwarded over WS; CLI only processes requests.
|
|
2625
|
+
return;
|
|
2626
|
+
}
|
|
2627
|
+
if (isProtocolRequest(message)) {
|
|
2597
2628
|
const response = await processMessage(message);
|
|
2598
|
-
|
|
2629
|
+
sendResponseOnData(response, dataWs);
|
|
2630
|
+
return;
|
|
2599
2631
|
}
|
|
2632
|
+
console.warn("[router] Ignoring non-request data frame");
|
|
2600
2633
|
}
|
|
2601
2634
|
catch (error) {
|
|
2602
2635
|
console.error("Error processing data message:", error);
|