@dev-anywhere/relay 0.4.81 → 0.4.83
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/{chunk-XJZ3HOPH.js → chunk-46NK2URF.js} +47 -14
- package/dist/chunk-46NK2URF.js.map +1 -0
- package/dist/handlers/client.d.ts.map +1 -1
- package/dist/handlers/proxy.d.ts.map +1 -1
- package/dist/heartbeat.d.ts +9 -2
- package/dist/heartbeat.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-XJZ3HOPH.js.map +0 -1
|
@@ -1007,6 +1007,10 @@ var RelayCloseCode = {
|
|
|
1007
1007
|
CLIENT_PROTOCOL_REJECTED: 4402
|
|
1008
1008
|
};
|
|
1009
1009
|
|
|
1010
|
+
// ../../packages/shared/dist/constants/wire-limits.js
|
|
1011
|
+
var RELAY_JSON_MESSAGE_MAX_BYTES = 8 * 1024 * 1024;
|
|
1012
|
+
var RELAY_BINARY_FRAME_MAX_BYTES = 10 * 1024 * 1024;
|
|
1013
|
+
|
|
1010
1014
|
// ../../packages/shared/dist/binary-frame.js
|
|
1011
1015
|
var SID_LEN_BYTES = 1;
|
|
1012
1016
|
var SEQ_BYTES = 4;
|
|
@@ -1635,8 +1639,6 @@ function completeRelayProxyLatencyProbe({
|
|
|
1635
1639
|
}
|
|
1636
1640
|
|
|
1637
1641
|
// src/handlers/proxy.ts
|
|
1638
|
-
var MAX_BINARY_FRAME_SIZE = 10 * 1024 * 1024;
|
|
1639
|
-
var MAX_JSON_MESSAGE_SIZE = 1 * 1024 * 1024;
|
|
1640
1642
|
function notifyClientsProxyOffline(proxyId, registry, logger, chaos) {
|
|
1641
1643
|
const clients = registry.getClientsForProxy(proxyId);
|
|
1642
1644
|
const msg = JSON.stringify({ type: "proxy_offline", proxyId });
|
|
@@ -1684,7 +1686,7 @@ function handleProxyConnection(ws, registry, logger, chaos, remoteFileBridge) {
|
|
|
1684
1686
|
});
|
|
1685
1687
|
proxyWs.on("message", (data, isBinary) => {
|
|
1686
1688
|
if (isBinary) {
|
|
1687
|
-
if (data.length < 2 || data.length >
|
|
1689
|
+
if (data.length < 2 || data.length > RELAY_BINARY_FRAME_MAX_BYTES) {
|
|
1688
1690
|
logger.warn({ size: data.length }, "Binary frame rejected: invalid size");
|
|
1689
1691
|
return;
|
|
1690
1692
|
}
|
|
@@ -1711,7 +1713,7 @@ function handleProxyConnection(ws, registry, logger, chaos, remoteFileBridge) {
|
|
|
1711
1713
|
}
|
|
1712
1714
|
return;
|
|
1713
1715
|
}
|
|
1714
|
-
if (data.length >
|
|
1716
|
+
if (data.length > RELAY_JSON_MESSAGE_MAX_BYTES) {
|
|
1715
1717
|
logger.warn(
|
|
1716
1718
|
{ size: data.length, proxyId: proxyWs.proxyId },
|
|
1717
1719
|
"JSON message rejected: exceeds max size"
|
|
@@ -2523,7 +2525,6 @@ function handleVoiceConfigControl(msg, ws, store, logger, providers) {
|
|
|
2523
2525
|
}
|
|
2524
2526
|
|
|
2525
2527
|
// src/handlers/client.ts
|
|
2526
|
-
var MAX_JSON_MESSAGE_SIZE2 = 1 * 1024 * 1024;
|
|
2527
2528
|
function isMalformedClientRegister(raw) {
|
|
2528
2529
|
try {
|
|
2529
2530
|
const parsed = JSON.parse(raw);
|
|
@@ -2728,7 +2729,7 @@ function handleClientConnection(ws, registry, logger, chaos, voiceConfigStore, v
|
|
|
2728
2729
|
if (isBinary) {
|
|
2729
2730
|
return;
|
|
2730
2731
|
}
|
|
2731
|
-
if (data.length >
|
|
2732
|
+
if (data.length > RELAY_JSON_MESSAGE_MAX_BYTES) {
|
|
2732
2733
|
logger.warn(
|
|
2733
2734
|
{ size: data.length, clientId: clientWs.clientId },
|
|
2734
2735
|
"JSON message rejected: exceeds max size"
|
|
@@ -3032,12 +3033,20 @@ function handleClientConnection(ws, registry, logger, chaos, voiceConfigStore, v
|
|
|
3032
3033
|
closeRejectedClientProtocol(clientWs);
|
|
3033
3034
|
}
|
|
3034
3035
|
});
|
|
3035
|
-
clientWs.on("close", () => {
|
|
3036
|
+
clientWs.on("close", (code, reason) => {
|
|
3036
3037
|
registry.removeClientWs(clientWs);
|
|
3037
3038
|
if (clientWs.clientId) {
|
|
3038
3039
|
registry.unbindClientById(clientWs.clientId);
|
|
3039
3040
|
}
|
|
3040
|
-
logger.info(
|
|
3041
|
+
logger.info(
|
|
3042
|
+
{
|
|
3043
|
+
clientId: clientWs.clientId,
|
|
3044
|
+
boundProxyId: clientWs.boundProxyId,
|
|
3045
|
+
code,
|
|
3046
|
+
reason: reason.toString() || void 0
|
|
3047
|
+
},
|
|
3048
|
+
"Client disconnected"
|
|
3049
|
+
);
|
|
3041
3050
|
});
|
|
3042
3051
|
clientWs.on("error", (err) => {
|
|
3043
3052
|
logger.error({ err }, "Client WebSocket error");
|
|
@@ -3048,7 +3057,7 @@ function handleClientConnection(ws, registry, logger, chaos, voiceConfigStore, v
|
|
|
3048
3057
|
function markAlive(ws) {
|
|
3049
3058
|
ws.isAlive = true;
|
|
3050
3059
|
}
|
|
3051
|
-
function setupHeartbeat(wss, interval = 3e4) {
|
|
3060
|
+
function setupHeartbeat(wss, interval = 3e4, options = {}) {
|
|
3052
3061
|
wss.on("connection", (ws) => {
|
|
3053
3062
|
markAlive(ws);
|
|
3054
3063
|
ws.on("pong", () => {
|
|
@@ -3059,6 +3068,13 @@ function setupHeartbeat(wss, interval = 3e4) {
|
|
|
3059
3068
|
for (const ws of wss.clients) {
|
|
3060
3069
|
const sock = ws;
|
|
3061
3070
|
if (sock.isAlive === false) {
|
|
3071
|
+
options.logger?.warn(
|
|
3072
|
+
{
|
|
3073
|
+
peerType: options.peerType,
|
|
3074
|
+
...options.describePeer?.(ws) ?? {}
|
|
3075
|
+
},
|
|
3076
|
+
"WebSocket heartbeat timeout"
|
|
3077
|
+
);
|
|
3062
3078
|
sock.terminate();
|
|
3063
3079
|
continue;
|
|
3064
3080
|
}
|
|
@@ -4211,10 +4227,27 @@ function createRelayServer(options) {
|
|
|
4211
4227
|
voiceTtsWss.on("connection", (ws) => {
|
|
4212
4228
|
handleVoiceTtsConnection(ws, voiceConfigStore, logger, voiceProviders);
|
|
4213
4229
|
});
|
|
4214
|
-
const proxyHeartbeat = setupHeartbeat(proxyWss, heartbeatInterval
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4230
|
+
const proxyHeartbeat = setupHeartbeat(proxyWss, heartbeatInterval, {
|
|
4231
|
+
logger,
|
|
4232
|
+
peerType: "proxy",
|
|
4233
|
+
describePeer: (ws) => ({ proxyId: ws.proxyId })
|
|
4234
|
+
});
|
|
4235
|
+
const clientHeartbeat = setupHeartbeat(clientWss, heartbeatInterval, {
|
|
4236
|
+
logger,
|
|
4237
|
+
peerType: "client",
|
|
4238
|
+
describePeer: (ws) => ({
|
|
4239
|
+
clientId: ws.clientId,
|
|
4240
|
+
boundProxyId: ws.boundProxyId
|
|
4241
|
+
})
|
|
4242
|
+
});
|
|
4243
|
+
const voiceAsrHeartbeat = setupHeartbeat(voiceAsrWss, heartbeatInterval, {
|
|
4244
|
+
logger,
|
|
4245
|
+
peerType: "voice-asr"
|
|
4246
|
+
});
|
|
4247
|
+
const voiceTtsHeartbeat = setupHeartbeat(voiceTtsWss, heartbeatInterval, {
|
|
4248
|
+
logger,
|
|
4249
|
+
peerType: "voice-tts"
|
|
4250
|
+
});
|
|
4218
4251
|
async function close() {
|
|
4219
4252
|
clearInterval(proxyHeartbeat);
|
|
4220
4253
|
clearInterval(clientHeartbeat);
|
|
@@ -4273,4 +4306,4 @@ export {
|
|
|
4273
4306
|
parseRelayChaosFromEnv,
|
|
4274
4307
|
createRelayServer
|
|
4275
4308
|
};
|
|
4276
|
-
//# sourceMappingURL=chunk-
|
|
4309
|
+
//# sourceMappingURL=chunk-46NK2URF.js.map
|