@hive-p2p/server 1.0.25 → 1.0.27
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 +8 -7
- 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,21 +118,22 @@ 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) {
|
|
125
|
-
const domain = b.split(':')[1].replace('//', '');
|
|
125
|
+
const domain = b.split(':')[1] ? b : b.split(':')[1].replace('//', '');
|
|
126
|
+
domain.replace('/ws', '/signal'); // in case someone put domain/ws
|
|
126
127
|
const port = parseInt(b.split(':')[2]) + 1;
|
|
127
128
|
stunUrls.push({ urls: `stun:${domain}:${port}` });
|
|
128
129
|
}
|
|
129
|
-
if (!
|
|
130
|
+
if (!TRANSPORTS.CENTRALIZED_STUN_SERVERS) return stunUrls;
|
|
130
131
|
|
|
131
132
|
// CENTRALIZED STUN SERVERS FALLBACK (GOOGLE) - OPTIONAL
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
stunUrls.push({ urls: 'stun:stun.l.google.com:5349' });
|
|
134
|
+
stunUrls.push({ urls: 'stun:stun.l.google.com:19302' });
|
|
135
|
+
stunUrls.push({ urls: 'stun:stun1.l.google.com:3478' });
|
|
136
|
+
stunUrls.push({ urls: 'stun:stun1.l.google.com:5349' });
|
|
136
137
|
return stunUrls;
|
|
137
138
|
}
|
|
138
139
|
}
|
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;
|