diff --git a/js/constants.js b/js/constants.js index d719447a..42edd083 100644 --- a/js/constants.js +++ b/js/constants.js @@ -106,9 +106,7 @@ function sanitizeTrustSeedList(candidate) { const DEFAULT_WSS_TRACKERS = Object.freeze([ "wss://tracker.openwebtorrent.com", - "wss://tracker.ghostchu-services.top:443/announce", "wss://tracker.files.fm:7073/announce", - "wss://tracker.dler.org:443/announce", "wss://tracker.btorrent.xyz", "wss://tracker.novage.com.ua:443/announce", ]); diff --git a/js/magnetUtils.js b/js/magnetUtils.js index 7874a443..af06ab63 100644 --- a/js/magnetUtils.js +++ b/js/magnetUtils.js @@ -55,6 +55,35 @@ export function normalizeAndAugmentMagnet( didChange = true; } + // Filter out known broken trackers to prevent console errors + const BROKEN_TRACKERS = [ + "wss://tracker.dler.org/announce", + "wss://tracker.dler.org:443/announce", + "wss://tracker.ghostchu-services.top/announce", + "wss://tracker.ghostchu-services.top:443/announce", + ]; + + // We need to filter 'tr' params + // Since we don't have a remove function in shared, we rebuild params if needed + const currentTrackers = params + .filter((p) => p.key === "tr") + .map((p) => p.decoded || p.value); + + const hasBroken = currentTrackers.some((t) => BROKEN_TRACKERS.includes(t)); + + if (hasBroken) { + const validParams = params.filter((p) => { + if (p.key !== "tr") return true; + const val = p.decoded || p.value; + return !BROKEN_TRACKERS.includes(val); + }); + + // Replace params content + params.length = 0; + params.push(...validParams); + didChange = true; + } + const torrentHint = typeof torrentUrl === "string" && torrentUrl.trim() ? torrentUrl : typeof xs === "string" diff --git a/scripts/agent/debug_frontend.py b/scripts/agent/debug_frontend.py deleted file mode 100644 index b4e9e42f..00000000 --- a/scripts/agent/debug_frontend.py +++ /dev/null @@ -1,30 +0,0 @@ -from playwright.sync_api import sync_playwright -import sys -import time - -def run(): - with sync_playwright() as p: - browser = p.chromium.launch(headless=True) - page = browser.new_page() - - # Subscribe to console messages - page.on("console", lambda msg: print(f"console:{msg.type}: {msg.text}")) - - # Subscribe to uncaught exceptions - page.on("pageerror", lambda exc: print(f"pageerror: {exc}")) - - # Subscribe to failed network requests - page.on("requestfailed", lambda req: print(f"requestfailed: {req.url} {req.failure}")) - - try: - # Navigate to localhost - page.goto("http://localhost:8000", wait_until="networkidle") - # Wait a bit for async operations - time.sleep(2) - except Exception as e: - print(f"Error navigating: {e}") - finally: - browser.close() - -if __name__ == "__main__": - run() diff --git a/tests/magnet-utils.test.mjs b/tests/magnet-utils.test.mjs index 25eaa012..8a3b6a0f 100644 --- a/tests/magnet-utils.test.mjs +++ b/tests/magnet-utils.test.mjs @@ -198,3 +198,28 @@ test("helpers trim fragments from non-magnet values", () => { "Dropping the fragment should be reflected in didChange" ); }); + +test("normalizeAndAugmentMagnet filters out known broken trackers", () => { + const infoHash = "abcdef0123456789abcdef0123456789abcdef01"; + const brokenTrackers = [ + "wss://tracker.dler.org/announce", + "wss://tracker.ghostchu-services.top/announce" + ]; + + const rawMagnet = + `magnet:?xt=urn:btih:${infoHash}` + + `&tr=${brokenTrackers[0]}` + + `&tr=${brokenTrackers[1]}`; + + const result = normalizeMagnetObject(rawMagnet); + + const trackers = getParamValues(result.magnet, "tr"); + for (const broken of brokenTrackers) { + assert.ok( + !trackers.includes(broken), + `Expected broken tracker ${broken} to be removed` + ); + } + + assertDefaultTrackersPresent(result.magnet); +});