diff --git a/capacitor/src/webtorrent.js b/capacitor/src/webtorrent.js index 269e0f0..0ee9de8 100644 --- a/capacitor/src/webtorrent.js +++ b/capacitor/src/webtorrent.js @@ -25,4 +25,4 @@ async function storageQuota () { return quota - usage } -globalThis.client = new TorrentClient(ipcRendererWebTorrent, storageQuota, 'browser', controller) +globalThis.client = new TorrentClient(ipcRendererWebTorrent, storageQuota, 'browser', controller, { torrentPort: Math.random() * 65535 + 1 }) diff --git a/common/modules/webtorrent.js b/common/modules/webtorrent.js index a7552fc..6ef2e5f 100644 --- a/common/modules/webtorrent.js +++ b/common/modules/webtorrent.js @@ -9,8 +9,8 @@ const LARGE_FILESIZE = 32_000_000_000 export default class TorrentClient extends WebTorrent { static excludedErrorMessages = ['WebSocket', 'User-Initiated Abort, reason=', 'Connection failed.'] - constructor (ipc, storageQuota, serverMode, controller) { - const settings = { ...defaults, ...(JSON.parse(localStorage.getItem('settings')) || {}) } + constructor (ipc, storageQuota, serverMode, controller, settingOverrides = {}) { + const settings = { ...defaults, ...(JSON.parse(localStorage.getItem('settings')) || {}), ...settingOverrides } super({ dht: !settings.torrentDHT, maxConns: settings.maxConns,