@hive-p2p/server 1.0.25 → 1.0.26
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/core/config.mjs +2 -0
- package/core/node-services.mjs +6 -6
- package/core/topologist.mjs +2 -1
- package/package.json +1 -1
package/core/config.mjs
CHANGED
|
@@ -97,6 +97,8 @@ export const IDENTITY = {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export const TRANSPORTS = {
|
|
100
|
+
/** If true, we always add centralized STUN servers (Google) to the STUN URLs list */
|
|
101
|
+
CENTRALIZED_STUN_SERVERS: false,
|
|
100
102
|
/** Maximum SDP offers to create in advance to be ready for new connections | Default: 2 */
|
|
101
103
|
MAX_SDP_OFFERS: 2,
|
|
102
104
|
/** Time to wait for ICE gathering to complete | Default: 1_000 (1 second) */
|
package/core/node-services.mjs
CHANGED
|
@@ -118,7 +118,7 @@ export class NodeServices {
|
|
|
118
118
|
return response;
|
|
119
119
|
}
|
|
120
120
|
/** @param {string[]} bootstraps */
|
|
121
|
-
static deriveSTUNServers(bootstraps
|
|
121
|
+
static deriveSTUNServers(bootstraps) {
|
|
122
122
|
/** @type {Array<{urls: string}>} */
|
|
123
123
|
const stunUrls = [];
|
|
124
124
|
for (const b of bootstraps) {
|
|
@@ -126,13 +126,13 @@ export class NodeServices {
|
|
|
126
126
|
const port = parseInt(b.split(':')[2]) + 1;
|
|
127
127
|
stunUrls.push({ urls: `stun:${domain}:${port}` });
|
|
128
128
|
}
|
|
129
|
-
if (!
|
|
129
|
+
if (!TRANSPORTS.CENTRALIZED_STUN_SERVERS) return stunUrls;
|
|
130
130
|
|
|
131
131
|
// CENTRALIZED STUN SERVERS FALLBACK (GOOGLE) - OPTIONAL
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
stunUrls.push({ urls: 'stun:stun.l.google.com:5349' });
|
|
133
|
+
stunUrls.push({ urls: 'stun:stun.l.google.com:19302' });
|
|
134
|
+
stunUrls.push({ urls: 'stun:stun1.l.google.com:3478' });
|
|
135
|
+
stunUrls.push({ urls: 'stun:stun1.l.google.com:5349' });
|
|
136
136
|
return stunUrls;
|
|
137
137
|
}
|
|
138
138
|
}
|
package/core/topologist.mjs
CHANGED
|
@@ -149,9 +149,10 @@ export class Topologist {
|
|
|
149
149
|
const isBrowser = typeof window !== 'undefined';
|
|
150
150
|
const isSecure = isBrowser && window.location.protocol === 'https:';
|
|
151
151
|
const protocol = isSecure ? 'wss://' : 'ws://';
|
|
152
|
+
const host = isBrowser ? window.location.host : url; // Récupère le host du browser
|
|
152
153
|
|
|
153
154
|
// Build full URL if not already prefixed
|
|
154
|
-
return url.startsWith('ws') ? url : `${protocol}${
|
|
155
|
+
return url.startsWith('ws') ? url : `${protocol}${urlhost}`;
|
|
155
156
|
}
|
|
156
157
|
#connectToPublicNode(publicUrl = 'localhost:8080') {
|
|
157
158
|
let remoteId = null;
|