freertc 0.1.28 → 0.1.32
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/bin/freertc.mjs +15 -7
- package/package.json +1 -1
- package/public/app.js +25 -3
- package/scripts/non-cloudflare-server.mjs +1 -1
- package/src/index.js +1 -1
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.32","protocol_version":"1.0","peers":0}
|
|
220
220
|
```
|
|
221
221
|
|
|
222
222
|
## Auto WebRTC two-tab test
|
package/bin/freertc.mjs
CHANGED
|
@@ -149,7 +149,7 @@ function extractCurrentWorkerName(configText) {
|
|
|
149
149
|
|
|
150
150
|
function extractDeployHost(configPath) {
|
|
151
151
|
const text = fs.readFileSync(configPath, 'utf8');
|
|
152
|
-
return
|
|
152
|
+
return extractRouteHost(text) || extractDatabaseDomainHost(text) || extractRelayUrlHost(text) || extractGlobalRelayUrlHost(text);
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
function extractGlobalRelayUrlHost(configText) {
|
|
@@ -183,19 +183,24 @@ function extractDatabaseDomainHost(configText) {
|
|
|
183
183
|
function autoPatchWranglerConfig(configPath) {
|
|
184
184
|
let text = fs.readFileSync(configPath, 'utf8');
|
|
185
185
|
|
|
186
|
-
const
|
|
186
|
+
const dbDomainHost = extractDatabaseDomainHost(text);
|
|
187
187
|
const routeHost = extractRouteHost(text);
|
|
188
|
+
const relayUrlHost = extractRelayUrlHost(text);
|
|
189
|
+
const globalRelayHost = extractGlobalRelayUrlHost(text);
|
|
190
|
+
const publicHost = dbDomainHost || routeHost || relayUrlHost || globalRelayHost;
|
|
188
191
|
const envDomainCandidate = normalizeHost(process.env.CF_DOMAIN || process.env.CLOUD_FLARE_DOMAIN || '');
|
|
189
192
|
const envDomainHost = envDomainCandidate && !isPlaceholderHost(envDomainCandidate) ? envDomainCandidate : null;
|
|
190
|
-
const
|
|
193
|
+
const baseRelayDomain = dbDomainHost || routeHost || envDomainHost || relayUrlHost || globalRelayHost;
|
|
191
194
|
|
|
192
|
-
if (!
|
|
195
|
+
if (!baseRelayDomain) {
|
|
193
196
|
return;
|
|
194
197
|
}
|
|
195
198
|
|
|
199
|
+
const relayHost = baseRelayDomain;
|
|
200
|
+
|
|
196
201
|
const relayWsUrl = `wss://${relayHost}/ws`;
|
|
197
202
|
const relayName = relayHost;
|
|
198
|
-
const dbName = `freertc-signal-${sanitizeDomain(
|
|
203
|
+
const dbName = `freertc-signal-${sanitizeDomain(dbDomainHost || baseRelayDomain)}`;
|
|
199
204
|
|
|
200
205
|
const before = text;
|
|
201
206
|
text = patchJsoncVar(text, 'RELAY_URL', relayWsUrl);
|
|
@@ -250,8 +255,11 @@ function validateWranglerConfigForDeploy(configPath) {
|
|
|
250
255
|
|
|
251
256
|
function extractRouteConflictOwner(outputText) {
|
|
252
257
|
if (!outputText) return null;
|
|
253
|
-
const
|
|
254
|
-
|
|
258
|
+
const usedByMatch = outputText.match(/used by Worker:\s*([A-Za-z0-9._-]+)/i);
|
|
259
|
+
if (usedByMatch?.[1]) return usedByMatch[1];
|
|
260
|
+
|
|
261
|
+
const assignedMatch = outputText.match(/"([A-Za-z0-9._-]+)"\s+is already assigned to routes:/i);
|
|
262
|
+
return assignedMatch?.[1] || null;
|
|
255
263
|
}
|
|
256
264
|
|
|
257
265
|
function patchWranglerScriptName(configPath, workerName) {
|
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -120,6 +120,14 @@ function deriveNetworkFromSession(sessionIdValue) {
|
|
|
120
120
|
return `room:${session}`;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
function deriveSessionFromNetwork(networkValue) {
|
|
124
|
+
const network = normalizeText(networkValue);
|
|
125
|
+
if (!network || !isSpecToken(network)) {
|
|
126
|
+
return "room:test";
|
|
127
|
+
}
|
|
128
|
+
return network;
|
|
129
|
+
}
|
|
130
|
+
|
|
123
131
|
createApp({
|
|
124
132
|
setup() {
|
|
125
133
|
const host = window.location.host;
|
|
@@ -152,6 +160,7 @@ createApp({
|
|
|
152
160
|
const appliedFromPeer = ref(fromPeer.value);
|
|
153
161
|
const toPeer = ref("");
|
|
154
162
|
const sessionId = ref("");
|
|
163
|
+
let sessionIdExplicit = false;
|
|
155
164
|
const instanceId = ref("");
|
|
156
165
|
|
|
157
166
|
const activeView = ref("webrtc");
|
|
@@ -701,12 +710,12 @@ createApp({
|
|
|
701
710
|
pushLog("network:error", "Ignoring invalid URL network");
|
|
702
711
|
}
|
|
703
712
|
|
|
704
|
-
|
|
713
|
+
sessionIdExplicit = hasValidUrlSession;
|
|
705
714
|
instanceId.value = hasValidUrlInstance ? instanceParam : `inst-${Math.random().toString(36).slice(2, 10)}`;
|
|
706
715
|
|
|
707
716
|
// Cross-domain links should land in the same room even when each origin has
|
|
708
717
|
// different sessionStorage UI state. URL network wins; otherwise derive from session_id.
|
|
709
|
-
const derivedNetwork = deriveNetworkFromSession(
|
|
718
|
+
const derivedNetwork = hasValidUrlSession ? deriveNetworkFromSession(sessionParam) : "";
|
|
710
719
|
const nextNetwork = hasValidUrlNetwork ? networkParam : (derivedNetwork || normalizedNetworkValue());
|
|
711
720
|
if (nextNetwork && nextNetwork !== network.value) {
|
|
712
721
|
network.value = nextNetwork;
|
|
@@ -715,6 +724,8 @@ createApp({
|
|
|
715
724
|
appliedNetwork.value = nextNetwork;
|
|
716
725
|
}
|
|
717
726
|
|
|
727
|
+
sessionId.value = hasValidUrlSession ? sessionParam : deriveSessionFromNetwork(nextNetwork || normalizedNetworkValue());
|
|
728
|
+
|
|
718
729
|
persistSharedIds();
|
|
719
730
|
}
|
|
720
731
|
|
|
@@ -806,12 +817,18 @@ createApp({
|
|
|
806
817
|
}
|
|
807
818
|
|
|
808
819
|
function regenerateSharedIds() {
|
|
820
|
+
sessionIdExplicit = true;
|
|
809
821
|
sessionId.value = `sess-${Math.random().toString(36).slice(2, 10)}`;
|
|
810
822
|
instanceId.value = `inst-${Math.random().toString(36).slice(2, 10)}`;
|
|
811
823
|
persistSharedIds();
|
|
812
824
|
pushLog("ids", "Generated new shared session_id and instance_id");
|
|
813
825
|
}
|
|
814
826
|
|
|
827
|
+
function applySessionIdChange() {
|
|
828
|
+
sessionIdExplicit = true;
|
|
829
|
+
persistSharedIds();
|
|
830
|
+
}
|
|
831
|
+
|
|
815
832
|
function regeneratePeerId() {
|
|
816
833
|
fromPeer.value = randomHex();
|
|
817
834
|
appliedFromPeer.value = fromPeer.value;
|
|
@@ -835,6 +852,11 @@ createApp({
|
|
|
835
852
|
}
|
|
836
853
|
appliedNetwork.value = next;
|
|
837
854
|
|
|
855
|
+
if (!sessionIdExplicit) {
|
|
856
|
+
sessionId.value = deriveSessionFromNetwork(next);
|
|
857
|
+
persistSharedIds();
|
|
858
|
+
}
|
|
859
|
+
|
|
838
860
|
reconnectLockedByBye = false;
|
|
839
861
|
byeCooldowns.clear();
|
|
840
862
|
failedPeerCooldowns.clear();
|
|
@@ -2683,7 +2705,7 @@ createApp({
|
|
|
2683
2705
|
<div class="field-grid">
|
|
2684
2706
|
<label>
|
|
2685
2707
|
Session ID
|
|
2686
|
-
<input v-model="sessionId" @change="
|
|
2708
|
+
<input v-model="sessionId" @change="applySessionIdChange">
|
|
2687
2709
|
</label>
|
|
2688
2710
|
<label>
|
|
2689
2711
|
Instance ID
|
|
@@ -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.32';
|
|
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.32";
|
|
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"]);
|