dshost-plugin 0.1.19 → 0.1.21

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.
Files changed (2) hide show
  1. package/lib/core.js +35 -2
  2. package/package.json +1 -1
package/lib/core.js CHANGED
@@ -1397,6 +1397,27 @@ export function startAgent(opts) {
1397
1397
  async function loadWerift() {
1398
1398
  if (weriftModule) return weriftModule;
1399
1399
  try {
1400
+ try {
1401
+ const resolved = import.meta.resolve ? import.meta.resolve('werift') : null;
1402
+ if (resolved) {
1403
+ const weriftPkgPath = new URL(resolved).pathname;
1404
+ const weriftDir = path.dirname(weriftPkgPath);
1405
+ const targets = [
1406
+ path.join(weriftDir, 'index.mjs'),
1407
+ path.join(weriftDir, 'ice/src/internal/selectAddresses.js'),
1408
+ ];
1409
+ for (const f of targets) {
1410
+ if (fs.existsSync(f)) {
1411
+ let c = fs.readFileSync(f, 'utf8');
1412
+ if (c.includes('"tun"') || c.includes("'tun'")) {
1413
+ c = c.replace(/costlyNetworks\s*=\s*\[[^\]]+\]/g, 'costlyNetworks = ["ipsec"]');
1414
+ fs.writeFileSync(f, c);
1415
+ }
1416
+ }
1417
+ }
1418
+ }
1419
+ } catch (_) {}
1420
+
1400
1421
  weriftModule = await import('werift');
1401
1422
  return weriftModule;
1402
1423
  } catch (e) {
@@ -1435,9 +1456,21 @@ export function startAgent(opts) {
1435
1456
 
1436
1457
  const pc = new werift.RTCPeerConnection({
1437
1458
  iceServers: [
1438
- { urls: 'stun:stun.cloudflare.com:3478' },
1459
+ { urls: 'stun:39.106.35.187:3478' },
1460
+ { urls: 'stun:111.206.174.2:3478' },
1461
+ { urls: 'stun:111.206.174.3:3478' },
1462
+ { urls: 'stun:47.100.127.239:3478' },
1439
1463
  { urls: 'stun:stun.qq.com:3478' },
1440
1464
  { urls: 'stun:stun.miwifi.com:3478' },
1465
+ { urls: 'stun:stun.cloudflare.com:3478' },
1466
+ {
1467
+ urls: [
1468
+ 'turn:39.106.35.187:3478?transport=udp',
1469
+ 'turn:39.106.35.187:3478?transport=tcp',
1470
+ ],
1471
+ username: 'dshost',
1472
+ credential: 'dshost_p2p_secret',
1473
+ },
1441
1474
  ],
1442
1475
  });
1443
1476
 
@@ -1479,7 +1512,7 @@ export function startAgent(opts) {
1479
1512
  // 等待 ICE 候选收集(嵌入至 localDescription 中返回,单次 RTT 快速握手)
1480
1513
  await new Promise((resolve) => {
1481
1514
  if (pc.iceGatheringState === 'complete') return resolve();
1482
- const timer = setTimeout(resolve, 800);
1515
+ const timer = setTimeout(resolve, 1200);
1483
1516
  pc.onicegatheringstatechange = () => {
1484
1517
  if (pc.iceGatheringState === 'complete') {
1485
1518
  clearTimeout(timer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dshost-plugin",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "description": "Official remote cloud relay plugin for DSHost (dshost.me): securely access your dsh Web UI from anywhere",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",