freertc 0.1.9 → 0.1.11
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 +18 -6
- package/package.json +1 -1
- 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.11","protocol_version":"1.0","peers":0}
|
|
220
220
|
```
|
|
221
221
|
|
|
222
222
|
## Auto WebRTC two-tab test
|
package/bin/freertc.mjs
CHANGED
|
@@ -106,16 +106,27 @@ function extractRelayUrlHost(configText) {
|
|
|
106
106
|
const relayUrlMatch = configText.match(/"RELAY_URL"\s*:\s*"([^"]*)"/);
|
|
107
107
|
if (!relayUrlMatch) return null;
|
|
108
108
|
const raw = relayUrlMatch[1];
|
|
109
|
-
if (/your-domain\.example/i.test(raw)) return null;
|
|
109
|
+
if (/your-domain\.example|your[-_]?domain/i.test(raw)) return null;
|
|
110
110
|
return normalizeHost(raw);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
function extractDatabaseDomainHost(configText) {
|
|
114
|
+
const dbMatch = configText.match(/"database_name"\s*:\s*"([^"]+)"/);
|
|
115
|
+
if (!dbMatch) return null;
|
|
116
|
+
const dbName = dbMatch[1];
|
|
117
|
+
const slugMatch = dbName.match(/^freertc-signal-(.+)$/i);
|
|
118
|
+
if (!slugMatch) return null;
|
|
119
|
+
const slug = (slugMatch[1] || '').trim();
|
|
120
|
+
if (!slug || /your[-_]?domain/i.test(slug)) return null;
|
|
121
|
+
return normalizeHost(slug.replace(/-/g, '.'));
|
|
122
|
+
}
|
|
123
|
+
|
|
113
124
|
function autoPatchWranglerConfig(configPath) {
|
|
114
125
|
let text = fs.readFileSync(configPath, 'utf8');
|
|
115
126
|
|
|
116
127
|
const routeHost = extractRouteHost(text);
|
|
117
128
|
const envDomainHost = normalizeHost(process.env.CF_DOMAIN || process.env.CLOUD_FLARE_DOMAIN || '');
|
|
118
|
-
const relayHost = routeHost || envDomainHost || extractRelayUrlHost(text);
|
|
129
|
+
const relayHost = routeHost || envDomainHost || extractRelayUrlHost(text) || extractDatabaseDomainHost(text);
|
|
119
130
|
|
|
120
131
|
if (!relayHost) {
|
|
121
132
|
return;
|
|
@@ -128,7 +139,7 @@ function autoPatchWranglerConfig(configPath) {
|
|
|
128
139
|
const before = text;
|
|
129
140
|
text = patchJsoncVar(text, 'RELAY_URL', relayWsUrl);
|
|
130
141
|
text = patchJsoncVar(text, 'RELAY_NAME', relayName);
|
|
131
|
-
text = text.replace(/("database_name"\s*:\s*)"freertc-signal(?:-your-domain)?"/
|
|
142
|
+
text = text.replace(/("database_name"\s*:\s*)"freertc-signal(?:-your[-_]?domain)?"/gi, `$1"${dbName}"`);
|
|
132
143
|
|
|
133
144
|
if (text !== before) {
|
|
134
145
|
fs.writeFileSync(configPath, text, 'utf8');
|
|
@@ -143,7 +154,8 @@ function validateWranglerConfigForDeploy(configPath) {
|
|
|
143
154
|
const placeholderChecks = [
|
|
144
155
|
{ test: /YOUR_D1_DATABASE_ID/, message: 'Replace YOUR_D1_DATABASE_ID in wrangler.jsonc.' },
|
|
145
156
|
{ test: /Your App Relay/, message: 'Set vars.RELAY_NAME to your actual relay name.' },
|
|
146
|
-
{ test: /wss:\/\/your-domain\.example\/ws/i, message: 'Set vars.RELAY_URL to your real deployed relay WebSocket URL.' },
|
|
157
|
+
{ test: /wss:\/\/(?:your-domain\.example|your[-_]?domain)\/ws/i, message: 'Set vars.RELAY_URL to your real deployed relay WebSocket URL.' },
|
|
158
|
+
{ test: /"database_name"\s*:\s*"freertc-signal(?:-your[-_]?domain)?"/i, message: 'Set d1_databases.database_name to a real database name (freertc-signal-<your-domain-slug>).' },
|
|
147
159
|
{ test: /"main"\s*:\s*"build\/worker\/shim\.mjs"/, message: 'Switch wrangler.jsonc main to src/index.js unless you intentionally use the Rust/WASM worker path.' },
|
|
148
160
|
{ test: /"command"\s*:\s*"worker-build --release"/, message: 'Remove the worker-build step unless you intentionally deploy the Rust/WASM worker path.' }
|
|
149
161
|
];
|
|
@@ -155,7 +167,7 @@ function validateWranglerConfigForDeploy(configPath) {
|
|
|
155
167
|
}
|
|
156
168
|
|
|
157
169
|
const relayUrlMatch = configText.match(/"RELAY_URL"\s*:\s*"([^"]*)"/);
|
|
158
|
-
if (!relayUrlMatch || !/^wss:\/\/[
|
|
170
|
+
if (!relayUrlMatch || !/^wss:\/\/[a-z0-9.-]+\/ws$/i.test(relayUrlMatch[1])) {
|
|
159
171
|
failures.push('Set vars.RELAY_URL to a valid wss://<host>/ws URL.');
|
|
160
172
|
}
|
|
161
173
|
|
|
@@ -256,7 +268,7 @@ async function main() {
|
|
|
256
268
|
autoPatchWranglerConfig(configPath);
|
|
257
269
|
validateWranglerConfigForDeploy(configPath);
|
|
258
270
|
const wrangler = resolveWranglerCommand(PROJECT_ROOT);
|
|
259
|
-
runInProject(wrangler.command, [...wrangler.baseArgs, 'deploy', '--env', 'production', ...rest]);
|
|
271
|
+
runInProject(wrangler.command, [...wrangler.baseArgs, 'deploy', '--config', configPath, '--env', 'production', ...rest]);
|
|
260
272
|
}
|
|
261
273
|
|
|
262
274
|
if (subcommand === 'dev') {
|
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.11';
|
|
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.11";
|
|
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"]);
|