Add section-level dashboard server filtering
Replace per-group dashboard hiding with a global section filter, including live URLTest and Priority group selectors. Keep server selectors usable before choices exist and preserve shared rule-set values across conditional LuCI fields.
This commit is contained in:
@@ -185,76 +185,4 @@ if (cache.urltestGroups["proxy-urltest-cfg010002-out"].displayName != "Stable UR
|
||||
die("stable URLTest display name was not cached\n");
|
||||
' "$multi_output" "$multi_output.section-cache/proxy.json" || fail "multi URLTest settings regression"
|
||||
|
||||
cat >"$WORK_DIR/hide-added-fixture.json" <<'JSON'
|
||||
{
|
||||
"settings": {
|
||||
"interface": "lan",
|
||||
"routing_mode": "proxy"
|
||||
},
|
||||
"section": [
|
||||
{
|
||||
".name": "proxy",
|
||||
".type": "section",
|
||||
"enabled": "1",
|
||||
"action": "proxy",
|
||||
"selector_proxy_links": [
|
||||
"vless://00000000-0000-4000-8000-000000000001@example.com:443?encryption=none&security=tls&sni=example.com#first",
|
||||
"vless://00000000-0000-4000-8000-000000000002@example.org:443?encryption=none&security=tls&sni=example.org#second"
|
||||
]
|
||||
}
|
||||
],
|
||||
"urltest": [
|
||||
{
|
||||
".name": "cfg020001",
|
||||
".type": "urltest",
|
||||
"section": "proxy",
|
||||
"name": "Fast URLTest",
|
||||
"check_interval": "30s",
|
||||
"tolerance": "50",
|
||||
"testing_url": "https://fast.example/204",
|
||||
"filter_mode": "include",
|
||||
"include_regex": [ "first" ],
|
||||
"hide_added_outbounds": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
hide_added_output="$WORK_DIR/hide-added-config.json"
|
||||
mkdir -p "$hide_added_output.section-cache"
|
||||
ucode -L "$FORKOP_LIB" "$FORKOP_LIB/singbox/generator.uc" generate-config-fixture \
|
||||
"$WORK_DIR/hide-added-fixture.json" "$hide_added_output" "127.0.0.1"
|
||||
|
||||
ucode -e '
|
||||
let fs = require("fs");
|
||||
let cfg = json(fs.readfile(ARGV[0]));
|
||||
let urltest = null;
|
||||
let selector = null;
|
||||
|
||||
function contains(values, needle) {
|
||||
for (let value in values || [])
|
||||
if (value == needle)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let outbound in cfg.outbounds || []) {
|
||||
if (outbound && outbound.tag == "proxy-urltest-cfg020001-out")
|
||||
urltest = outbound;
|
||||
if (outbound && outbound.tag == "proxy-out")
|
||||
selector = outbound;
|
||||
}
|
||||
|
||||
if (!urltest || !contains(urltest.outbounds, "proxy-1-out") || contains(urltest.outbounds, "proxy-2-out"))
|
||||
die("URLTest should contain only the filtered first outbound\n");
|
||||
if (!selector)
|
||||
die("selector was not generated\n");
|
||||
if (contains(selector.outbounds, "proxy-1-out"))
|
||||
die("URLTest-added outbound should be hidden from selector\n");
|
||||
if (!contains(selector.outbounds, "proxy-2-out"))
|
||||
die("non-URLTest outbound should remain in selector\n");
|
||||
if (!contains(selector.outbounds, "proxy-urltest-cfg020001-out"))
|
||||
die("URLTest outbound should remain in selector\n");
|
||||
' "$hide_added_output" || fail "URLTest hide added selector regression"
|
||||
|
||||
printf 'URLTest interrupt checks passed\n'
|
||||
|
||||
Reference in New Issue
Block a user