@factiii/runner 0.9.5 → 0.9.7
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/cli.js +26 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -23834,14 +23834,26 @@ function toRtcIceServers(servers) {
|
|
|
23834
23834
|
for (const server of servers) {
|
|
23835
23835
|
const urls = Array.isArray(server.urls) ? server.urls : [server.urls];
|
|
23836
23836
|
for (const url2 of urls) {
|
|
23837
|
-
const turn = /^(turns?):(
|
|
23837
|
+
const turn = /^(turns?):([^:?]+)(?::(\d+))?(?:\?transport=(udp|tcp))?$/.exec(
|
|
23838
|
+
url2
|
|
23839
|
+
);
|
|
23838
23840
|
if (!turn || !server.username || !server.credential) {
|
|
23839
23841
|
out.push(url2);
|
|
23840
23842
|
continue;
|
|
23841
23843
|
}
|
|
23842
|
-
const
|
|
23843
|
-
|
|
23844
|
-
|
|
23844
|
+
const [, scheme, hostname, port, transport] = turn;
|
|
23845
|
+
out.push({
|
|
23846
|
+
hostname,
|
|
23847
|
+
port: Number(port ?? (scheme === "turns" ? 5349 : 3478)),
|
|
23848
|
+
username: server.username,
|
|
23849
|
+
password: server.credential,
|
|
23850
|
+
// String literals, not the RelayType members: it is a `const enum`,
|
|
23851
|
+
// so it is erased at compile time and has no runtime object to read —
|
|
23852
|
+
// `RelayType.TurnUdp` threw, which killed the offer handler before it
|
|
23853
|
+
// could answer and made every connection fail, not just the relayed
|
|
23854
|
+
// ones. The enum's values are exactly these strings.
|
|
23855
|
+
relayType: scheme === "turns" ? "TurnTls" : transport === "tcp" ? "TurnTcp" : "TurnUdp"
|
|
23856
|
+
});
|
|
23845
23857
|
}
|
|
23846
23858
|
}
|
|
23847
23859
|
return out.length > 0 ? out : fallback;
|
|
@@ -24126,9 +24138,17 @@ async function startDaemon(config) {
|
|
|
24126
24138
|
console.log(`Received WebRTC offer from ${data.fromSocketId}`);
|
|
24127
24139
|
const scope = toChannelScope(data.scope);
|
|
24128
24140
|
try {
|
|
24129
|
-
|
|
24141
|
+
let iceServers;
|
|
24142
|
+
try {
|
|
24143
|
+
iceServers = toRtcIceServers(data.iceServers);
|
|
24144
|
+
} catch (error) {
|
|
24145
|
+
console.error("[webrtc] ICE server list unusable, using STUN:", error);
|
|
24146
|
+
iceServers = ["stun:stun.l.google.com:19302"];
|
|
24147
|
+
}
|
|
24130
24148
|
console.log(
|
|
24131
|
-
`[webrtc] ICE servers: ${iceServers.map(
|
|
24149
|
+
`[webrtc] ICE servers: ${iceServers.map(
|
|
24150
|
+
(u) => typeof u === "string" ? u : `${u.relayType}:${u.hostname}:${u.port} user=${u.username?.slice(0, 8)}\u2026`
|
|
24151
|
+
).join(", ")}`
|
|
24132
24152
|
);
|
|
24133
24153
|
const peer = new import_node_datachannel.PeerConnection("runner", { iceServers });
|
|
24134
24154
|
const iceCandidateHandler = (msg) => {
|
package/package.json
CHANGED