freertc 0.1.11 → 0.1.12
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/README.md +1 -1
- package/package.json +1 -1
- package/scripts/non-cloudflare-server.mjs +1 -1
- package/src/index.js +10 -3
package/README.md
CHANGED
|
@@ -216,7 +216,7 @@ Quick checks:
|
|
|
216
216
|
Expected `/health` response includes JSON like:
|
|
217
217
|
|
|
218
218
|
```json
|
|
219
|
-
{"ok":true,"version":"0.1.
|
|
219
|
+
{"ok":true,"version":"0.1.12","protocol_version":"1.0","peers":0}
|
|
220
220
|
```
|
|
221
221
|
|
|
222
222
|
## Auto WebRTC two-tab test
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
7
7
|
import { WebSocketServer } from 'ws';
|
|
8
8
|
|
|
9
9
|
const PSP_VERSION = '1.0';
|
|
10
|
-
const WORKER_VERSION = '0.1.
|
|
10
|
+
const WORKER_VERSION = '0.1.12';
|
|
11
11
|
const DEFAULT_TTL_MS = 30_000;
|
|
12
12
|
const MAX_TTL_MS = 120_000;
|
|
13
13
|
const MAX_MESSAGE_SIZE = 64 * 1024;
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const PSP_VERSION = "1.0";
|
|
2
|
-
const WORKER_VERSION = "0.1.
|
|
2
|
+
const WORKER_VERSION = "0.1.12";
|
|
3
3
|
|
|
4
4
|
const DISCOVERY_TYPES = new Set(["announce", "withdraw", "discover", "peer_list", "redirect"]);
|
|
5
5
|
const NEGOTIATION_TYPES = new Set(["connect_request", "connect_accept", "connect_reject", "offer", "answer", "ice_candidate", "ice_end", "renegotiate"]);
|
|
@@ -173,11 +173,19 @@ async function queryRelayForPeers(relayUrl, network, selfRelayId, db, selfKnownR
|
|
|
173
173
|
return await new Promise((resolve) => {
|
|
174
174
|
const timer = setTimeout(() => { try { ws.close(); } catch {} resolve([]); }, 4000);
|
|
175
175
|
let gotPeerList = false;
|
|
176
|
+
const relayPeerId = selfRelayId || "relay-bridge";
|
|
176
177
|
|
|
177
178
|
ws.addEventListener("message", async (ev) => {
|
|
178
179
|
try {
|
|
179
180
|
const msg = JSON.parse(ev.data);
|
|
180
|
-
|
|
181
|
+
// Ignore broadcast peer_list updates triggered by announce heartbeats.
|
|
182
|
+
// We only want the direct discover response addressed to this bridge peer.
|
|
183
|
+
if (
|
|
184
|
+
msg.type === "peer_list" &&
|
|
185
|
+
msg.network === network &&
|
|
186
|
+
msg.to === relayPeerId &&
|
|
187
|
+
!gotPeerList
|
|
188
|
+
) {
|
|
181
189
|
gotPeerList = true;
|
|
182
190
|
clearTimeout(timer);
|
|
183
191
|
ws.close();
|
|
@@ -196,7 +204,6 @@ async function queryRelayForPeers(relayUrl, network, selfRelayId, db, selfKnownR
|
|
|
196
204
|
ws.addEventListener("error", () => { clearTimeout(timer); resolve([]); });
|
|
197
205
|
ws.addEventListener("close", () => { if (!gotPeerList) { clearTimeout(timer); resolve([]); } });
|
|
198
206
|
|
|
199
|
-
const relayPeerId = selfRelayId || "relay-bridge";
|
|
200
207
|
// Announce as relay bridge
|
|
201
208
|
ws.send(JSON.stringify({
|
|
202
209
|
psp_version: PSP_VERSION, type: "announce", network,
|