fix: zapret2 & naming fixes
This commit is contained in:
32 files changed
+580
-261
No files matched your search
@@ -184,7 +184,7 @@ in
|
||||
assert builtins.elem "proxy-suite-awg-work.service" homeService.conflicts;
|
||||
assert builtins.elem "proxy-suite-tun.service" homeService.conflicts;
|
||||
assert builtins.elem "proxy-suite-tproxy.service" homeService.conflicts;
|
||||
assert builtins.elem "zapret-discord-youtube.service" homeService.conflicts;
|
||||
assert builtins.elem "proxy-suite-zapret.service" homeService.conflicts;
|
||||
assert builtins.elem "proxy-suite-per-app-zapret.service" homeService.conflicts;
|
||||
assert workService.wantedBy == [ ];
|
||||
assert homeService.serviceConfig.NoNewPrivileges;
|
||||
@@ -240,7 +240,7 @@ in
|
||||
assert builtins.elem "proxy-suite-awg-home.service"
|
||||
withGlobalTun.config.systemd.services.proxy-suite-tproxy.conflicts;
|
||||
assert builtins.elem "proxy-suite-awg-home.service"
|
||||
withGlobalTun.config.systemd.services.zapret-discord-youtube.conflicts;
|
||||
withGlobalTun.config.systemd.services.proxy-suite-zapret.conflicts;
|
||||
assert builtins.elem "proxy-suite-awg-home.service"
|
||||
withGlobalTun.config.systemd.services.proxy-suite-per-app-zapret.conflicts;
|
||||
assert builtins.elem "proxy-suite-socks.service" withGlobalAwgService.after;
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ let
|
||||
);
|
||||
in
|
||||
pkgs.lib.removePrefix "ZAPRET_BASE=" zapretBaseEnv;
|
||||
mkZapretBase = fixture: mkZapretBaseFor fixture "zapret-discord-youtube";
|
||||
mkZapretBase = fixture: mkZapretBaseFor fixture "proxy-suite-zapret";
|
||||
packagePathMatches =
|
||||
packages: pattern:
|
||||
builtins.any (
|
||||
|
||||
@@ -195,7 +195,7 @@ in
|
||||
perAppRoutingZapretWithoutGlobalFixture.config.systemd.user.services
|
||||
? "proxy-suite-per-app-zapret-anchor";
|
||||
assert
|
||||
!(perAppRoutingZapretWithoutGlobalFixture.config.systemd.services ? "zapret-discord-youtube");
|
||||
!(perAppRoutingZapretWithoutGlobalFixture.config.systemd.services ? "proxy-suite-zapret");
|
||||
assert builtins.length perAppRoutingZapretWithoutGlobalProfiles == 2;
|
||||
assert builtins.any (
|
||||
profile: profile.name == "zapret" && profile.route == "zapret"
|
||||
|
||||
+9
-9
@@ -196,11 +196,11 @@
|
||||
run proxy subs add rejected https://example.com/sub > rejected 2>&1 && exit 1
|
||||
grep -q 'did not come up' rejected
|
||||
|
||||
# Pinning goes through the unit, including "auto".
|
||||
run proxy select community-de | grep -q 'Pinned: community-de'
|
||||
run proxy select auto | grep -q 'Selecting automatically again'
|
||||
# Pinning and unpinning go through their units.
|
||||
run proxy pin community-de | grep -q 'Pinned: community-de'
|
||||
run proxy unpin | grep -q 'Unpinned'
|
||||
# Without a terminal and without a tag there is nothing to pick from.
|
||||
! run proxy select </dev/null 2>/dev/null
|
||||
! run proxy pin </dev/null 2>/dev/null
|
||||
|
||||
touch "$out"
|
||||
'';
|
||||
@@ -326,8 +326,8 @@
|
||||
has proxy-suite-awg-work logs
|
||||
has work awg on
|
||||
has torrent apps run
|
||||
has auto proxy select
|
||||
has community-de proxy select
|
||||
has unpin proxy
|
||||
has community-de proxy pin
|
||||
|
||||
# Flags, and completion past the first of several arguments.
|
||||
has --delay proxy outbounds test
|
||||
@@ -338,7 +338,7 @@
|
||||
has --qr inbounds sub
|
||||
|
||||
# Candidates carry a description after a tab.
|
||||
run proxy select > words
|
||||
run proxy pin > words
|
||||
grep -qx "$(printf 'own-vps\tproxy.outbounds')" words
|
||||
|
||||
# A shell completing must never die, however unreadable the state is.
|
||||
@@ -390,8 +390,8 @@
|
||||
# What proxy-ctl cannot see has to be said out loud.
|
||||
grep -q 'proxy.routing.rules are not visible' where
|
||||
|
||||
verdict discord.com '-> direct, with the zapret2 bypass'
|
||||
verdict nyt.com '-> direct, with the zapret2 bypass'
|
||||
verdict discord.com '-> direct, with the zapret bypass'
|
||||
verdict nyt.com '-> direct, with the zapret bypass'
|
||||
# Excluded is not bypassed: it must not read as a zapret2 verdict.
|
||||
verdict ok.ru '-> nothing runtime matches it'
|
||||
verdict example.org '-> nothing runtime matches it'
|
||||
|
||||
+13
-10
@@ -55,7 +55,7 @@ let
|
||||
proxyCfg = routeModeFixture.config.services.proxy-suite.proxy;
|
||||
clashApi = "http://127.0.0.1:9090";
|
||||
routeModeStateFile = "/run/proxy-suite/route-mode";
|
||||
priorityOutboundFile = "/var/lib/proxy-suite/priority-outbound";
|
||||
pinnedOutboundFile = "/var/lib/proxy-suite/pinned-outbound";
|
||||
outboundInventoryFile = "/run/proxy-suite-socks/outbounds.json";
|
||||
subscriptionCacheDir = "/var/lib/proxy-suite/subscriptions/sing-box";
|
||||
subscriptionCacheHelpersBlock = "";
|
||||
@@ -64,7 +64,7 @@ let
|
||||
jq = "${pkgs.jq}/bin/jq";
|
||||
};
|
||||
routeModeSetterScript = generated.readDerivation routeModeControlScripts.setRouteModeScript;
|
||||
prioritySetterScript = generated.readDerivation routeModeControlScripts.setPriorityOutboundScript;
|
||||
pinSetterScript = generated.readDerivation routeModeControlScripts.pinOutboundScript;
|
||||
routeModeRules = mkRouteModeRules routeModeFixture;
|
||||
in
|
||||
{
|
||||
@@ -125,16 +125,19 @@ in
|
||||
# across a reboot and prefers a live Clash switch over a restart.
|
||||
(
|
||||
let
|
||||
selectSvc = routeModeFixture.config.systemd.services."proxy-suite-outbound-select@";
|
||||
pinSvc = routeModeFixture.config.systemd.services."proxy-suite-outbound-pin@";
|
||||
reloadSvc = routeModeFixture.config.systemd.services."proxy-suite-outbound-reload";
|
||||
in
|
||||
assert selectSvc.serviceConfig.RemainAfterExit == false;
|
||||
assert selectSvc.serviceConfig.StateDirectory == "proxy-suite";
|
||||
assert pinSvc.serviceConfig.RemainAfterExit == false;
|
||||
assert
|
||||
routeModeFixture.config.systemd.services."proxy-suite-outbound-unpin".serviceConfig.ExecStart
|
||||
== "${routeModeControlScripts.pinOutboundScript}";
|
||||
assert pinSvc.serviceConfig.StateDirectory == "proxy-suite";
|
||||
assert reloadSvc.serviceConfig.RemainAfterExit == false;
|
||||
assert pkgs.lib.hasInfix "/var/lib/proxy-suite/priority-outbound" prioritySetterScript;
|
||||
assert pkgs.lib.hasInfix ''rm -f "/var/lib/proxy-suite/priority-outbound"'' prioritySetterScript;
|
||||
assert pkgs.lib.hasInfix "/proxies/proxy" prioritySetterScript;
|
||||
assert pkgs.lib.hasInfix "systemctl restart proxy-suite-socks" prioritySetterScript;
|
||||
assert pkgs.lib.hasInfix "/var/lib/proxy-suite/pinned-outbound" pinSetterScript;
|
||||
assert pkgs.lib.hasInfix ''rm -f "/var/lib/proxy-suite/pinned-outbound"'' pinSetterScript;
|
||||
assert pkgs.lib.hasInfix "/proxies/proxy" pinSetterScript;
|
||||
assert pkgs.lib.hasInfix "systemctl restart proxy-suite-socks" pinSetterScript;
|
||||
true
|
||||
)
|
||||
|
||||
@@ -149,7 +152,7 @@ in
|
||||
assert
|
||||
shellValueByPrefix minimalProxyCtlWrapper "export RUNTIME_SUBS_DIR="
|
||||
== "/var/lib/proxy-suite/subscriptions.d";
|
||||
assert pkgs.lib.hasInfix "proxy select [<tag>|auto]" minimalProxyCtlScript;
|
||||
assert pkgs.lib.hasInfix "proxy pin [tag]" minimalProxyCtlScript;
|
||||
assert pkgs.lib.hasInfix "proxy outbounds add <tag> <url>" minimalProxyCtlScript;
|
||||
true
|
||||
)
|
||||
|
||||
@@ -70,7 +70,7 @@ in
|
||||
# selection=first renames the pinned outbound - or the first one, absent a
|
||||
# pin - to "proxy" at start, rather than collapsing at eval time.
|
||||
(
|
||||
assert pkgs.lib.hasInfix ''PROXY_TAG="$PRIORITY_OUTBOUND"'' subscriptionFirstSelectionStartScript;
|
||||
assert pkgs.lib.hasInfix ''PROXY_TAG="$PINNED_OUTBOUND"'' subscriptionFirstSelectionStartScript;
|
||||
assert
|
||||
pkgs.lib.hasInfix ''map(if .tag == $t then .tag = "proxy" else . end)''
|
||||
subscriptionFirstSelectionStartScript;
|
||||
@@ -80,9 +80,9 @@ in
|
||||
# The pin is read from state, and one that names nothing is dropped.
|
||||
(
|
||||
assert
|
||||
pkgs.lib.hasInfix "/var/lib/proxy-suite/priority-outbound" subscriptionOnlyStartScript;
|
||||
pkgs.lib.hasInfix "/var/lib/proxy-suite/pinned-outbound" subscriptionOnlyStartScript;
|
||||
assert
|
||||
pkgs.lib.hasInfix "pinned outbound '$PRIORITY_OUTBOUND' is not available"
|
||||
pkgs.lib.hasInfix "pinned outbound '$PINNED_OUTBOUND' is not available"
|
||||
subscriptionOnlyStartScript;
|
||||
true
|
||||
)
|
||||
|
||||
@@ -79,8 +79,6 @@ in
|
||||
assert pkgs.lib.hasInfix "unit.indexOf(\"proxy-suite-\") === 0" userControlDefaultPolkitConfig;
|
||||
assert pkgs.lib.hasInfix "unit.indexOf(\"proxy-suite-per-app-\") !== 0"
|
||||
userControlDefaultPolkitConfig;
|
||||
assert pkgs.lib.hasInfix "unit === \"zapret-discord-youtube.service\""
|
||||
userControlDefaultPolkitConfig;
|
||||
true
|
||||
)
|
||||
|
||||
@@ -93,8 +91,6 @@ in
|
||||
assert
|
||||
builtins.match ".*unit\\.indexOf\\(\"proxy-suite-per-app-\"\\) === 0.*" userControlGlobalOnlyPolkitConfig
|
||||
== null;
|
||||
assert pkgs.lib.hasInfix "unit === \"zapret-discord-youtube.service\""
|
||||
userControlGlobalOnlyPolkitConfig;
|
||||
true
|
||||
)
|
||||
|
||||
@@ -107,7 +103,7 @@ in
|
||||
builtins.match ".*unit\\.indexOf\\(\"proxy-suite-per-app-\"\\) !== 0.*" userControlPerAppOnlyPolkitConfig
|
||||
== null;
|
||||
assert
|
||||
builtins.match ".*unit === \"zapret-discord-youtube\\.service\".*" userControlPerAppOnlyPolkitConfig
|
||||
builtins.match ".*unit\\.indexOf\\(\"proxy-suite-\"\\) === 0.*" userControlPerAppOnlyPolkitConfig
|
||||
== null;
|
||||
true
|
||||
)
|
||||
|
||||
@@ -22,7 +22,7 @@ let
|
||||
backend = null;
|
||||
backendArg = null;
|
||||
xraySidecarRoutingMark = null;
|
||||
priorityOutboundFile = null;
|
||||
pinnedOutboundFile = null;
|
||||
runtimeOutboundsDir = null;
|
||||
jq = null;
|
||||
python3 = null;
|
||||
|
||||
@@ -19,7 +19,7 @@ let
|
||||
];
|
||||
|
||||
zapretSyncFixture = evalZapret { };
|
||||
zapretSyncService = zapretSyncFixture.config.systemd.services."zapret-discord-youtube";
|
||||
zapretSyncService = zapretSyncFixture.config.systemd.services."proxy-suite-zapret";
|
||||
zapretSyncRules = mkRoutingRules zapretSyncFixture;
|
||||
zapretSyncBase = mkZapretBase zapretSyncFixture;
|
||||
|
||||
|
||||
+22
-3
@@ -31,7 +31,7 @@ let
|
||||
)
|
||||
);
|
||||
|
||||
globalService = "zapret-discord-youtube";
|
||||
globalService = "proxy-suite-zapret";
|
||||
perAppService = "proxy-suite-per-app-zapret";
|
||||
|
||||
zapretBase = fixture: envValue fixture globalService "ZAPRET_BASE=";
|
||||
@@ -101,7 +101,10 @@ in
|
||||
runtime =
|
||||
pkgs.runCommand "proxy-suite-zapret2-config-check"
|
||||
{
|
||||
nativeBuildInputs = [ pkgs.gnugrep ];
|
||||
nativeBuildInputs = [
|
||||
pkgs.gnugrep
|
||||
pkgs.lua
|
||||
];
|
||||
}
|
||||
''
|
||||
base=${zapretBase zapret2Global}
|
||||
@@ -139,6 +142,22 @@ in
|
||||
grep -qx 'NFQWS2_PORTS_TCP=80,443,1984,2053,2083,2087,2096,5222,8443' "${globalRuntime}/config"
|
||||
grep -qx 'NFQWS2_PORTS_UDP=443,590-600,1400,3478-3481,5349,19294-19344,49152-65535' "${globalRuntime}/config"
|
||||
grep -qF -- '/files/lua/z2k-state-persist.lua' "${globalRuntime}/config"
|
||||
# Counted failures are stamped before the state layer reads them, so a
|
||||
# success on a busy host cannot undo every rotation.
|
||||
grep -qE -- 'fail-stamp\.lua --lua-init=@[^ ]+/z2k-state-persist\.lua' "${globalRuntime}/config"
|
||||
STAMP=$(grep -oE '/nix/store/[^ ]+-proxy-suite-zapret2-fail-stamp\.lua' "${globalRuntime}/config") lua -e '
|
||||
function automate_failure_counter(hrec, crec) if crec then crec.failure = true end return "orig" end
|
||||
function clock_getfloattime() return 42.5 end
|
||||
dofile(os.getenv("STAMP"))
|
||||
local hrec, crec = {}, {}
|
||||
assert(automate_failure_counter(hrec, crec, 2, 60) == "orig" and hrec.z2k_last_fail_ts == 42.5)
|
||||
hrec.z2k_last_fail_ts = 1
|
||||
automate_failure_counter(hrec, crec, 2, 60)
|
||||
assert(hrec.z2k_last_fail_ts == 1, "a duplicate failure is not counted, so not stamped")
|
||||
'
|
||||
# Every UDP fake carries a blob; zapret2 errors on each packet otherwise.
|
||||
grep -qF -- '--lua-desync=fake:blob=0x0000' "${globalRuntime}/config"
|
||||
if grep -qF -- '--lua-desync=fake:repeats=' "${globalRuntime}/config"; then exit 1; fi
|
||||
# autoHostlist fills what circular leaves unset; the source keeps its fails and time.
|
||||
grep -qF -- '--lua-desync=circular:fails=2:time=300:retrans=3:nld=2:maxseq=32768:inseq=4096:udp_out=4:udp_in=1:reset ' "${globalRuntime}/config"
|
||||
|
||||
@@ -175,7 +194,7 @@ in
|
||||
"$detect/z2k-detect" tcp16 -h 2>/dev/null
|
||||
|
||||
# New maps restart only the zapret units this config installs.
|
||||
grep -qF 'try-restart zapret-discord-youtube.service' ${cutoffProbe}
|
||||
grep -qF 'try-restart proxy-suite-zapret.service' ${cutoffProbe}
|
||||
if grep -qF 'proxy-suite-per-app-zapret.service' ${cutoffProbe}; then exit 1; fi
|
||||
|
||||
# The proxy carries what no name fixes, unless the fallback is off.
|
||||
|
||||
Reference in new issue
Block a user