feat(rulesets): add Twitch preset and resilient CDN fallback

This commit is contained in:
Dushnilin
2026-09-14 14:46:28 +03:00
parent 4af55ebed3
commit 24c11bbca8
8 changed files with 47 additions and 9 deletions
+7
View File
@@ -46,6 +46,13 @@ assert(url.github_to_jsdelivr("https://raw.githubusercontent.com/owner/repo/main
let candidates = url.download_candidates("https://github.com/owner/repo/blob/main/hosts");
assert(candidates[0] == "https://raw.githubusercontent.com/owner/repo/main/hosts", "download_candidates first entry normalized");
let twitch_candidates = url.download_candidates("https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/twitch.srs");
assert(twitch_candidates[0] == "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/twitch.srs", "twitch candidate 0 is raw github");
assert(twitch_candidates[1] == "https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/twitch.srs", "twitch candidate 1 is jsdelivr cdn");
for (let c in twitch_candidates) {
assert(index(c, "forkop") < 0, "no forkop mirrors allowed");
}
// authority, host, port, userinfo with @ in query parameters
let complex = "vless://user-uuid@example.com:8443?authority=name@channel&mode=gun#my-fragment";
assert(url.authority(complex) == "example.com:8443", "authority strips userinfo and query with @");
+4
View File
@@ -47,6 +47,10 @@ assert_eq binary \
ucode -L "$TACHYON_LIB" -e 'let rulesets = require("singbox.rulesets"); if (rulesets.kind_from_reference_hint("geoip") != "subnets") exit(1);'
ucode -L "$TACHYON_LIB" -e 'let rulesets = require("singbox.rulesets"); if (type(rulesets.COMMUNITY_SERVICES) != "object" || !rulesets.COMMUNITY_SERVICES.discord) exit(1);'
ucode -L "$TACHYON_LIB" -e 'let rulesets = require("singbox.rulesets"); if (!rulesets.COMMUNITY_SERVICES.twitch) exit(1);'
assert_eq "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/twitch.srs" \
"$(ucode -L "$TACHYON_LIB" -e 'let rulesets = require("singbox.rulesets"); print(rulesets.community_url("twitch"));')" \
"twitch community ruleset url"
printf 'singbox rulesets checks passed\n'