Files
proxy-suite-flake/nix/checks/per-app-routing-proxychains.nix
2026-09-18 21:39:18 +05:00

117 lines
3.9 KiB
Nix

{
checkLib,
pkgs,
evalProxySuite,
baseModule,
mkProxyCtlDerived,
minimalProxyCtlScript,
}:
let
inherit (checkLib) ok;
generated = import ./read-generated.nix;
perAppRoutingProxychainsFixture = evalProxySuite [
baseModule
{
services.proxy-suite.perAppRouting = {
enable = true;
proxychains.enable = true;
profiles = [
{
name = "steam-browser";
route = "proxychains";
}
{
name = "native-direct";
route = "direct";
}
];
};
}
];
perAppRoutingProxychains = mkProxyCtlDerived perAppRoutingProxychainsFixture;
perAppRoutingProxychainsWrapper = perAppRoutingProxychains.wrapper;
perAppRoutingProxychainsScript = perAppRoutingProxychains.script;
perAppRoutingProxychainsProfiles = perAppRoutingProxychains.profiles;
perAppRoutingProxychainsConfig = generated.readDerivation perAppRoutingProxychains.proxychainsConfigFile;
perAppRoutingDefaultProfilesFixture = evalProxySuite [
baseModule
{
services.proxy-suite.perAppRouting = {
enable = true;
createDefaultProfiles = true;
proxychains.enable = true;
};
}
];
perAppRoutingDefaultProfiles = (mkProxyCtlDerived perAppRoutingDefaultProfilesFixture).profiles;
perAppRoutingNoDefaultProfilesFixture = evalProxySuite [
baseModule
{
services.proxy-suite = {
zapret.enable = true;
perAppRouting = {
enable = true;
createDefaultProfiles = false;
proxychains.enable = true;
tun.enable = true;
tproxy.enable = true;
zapret.enable = true;
};
};
}
];
perAppRoutingNoDefaultProfiles = (mkProxyCtlDerived perAppRoutingNoDefaultProfilesFixture).profiles;
in
{
assertions = [
# -- perAppRouting: proxychains/direct profile config is accepted --
(ok (perAppRoutingProxychainsFixture.config.services.proxy-suite.perAppRouting.enable))
(
assert
builtins.length perAppRoutingProxychainsFixture.config.services.proxy-suite.perAppRouting.profiles
== 2;
true
)
(ok (builtins.length perAppRoutingProxychainsProfiles == 2))
# -- perAppRouting: createDefaultProfiles injects curated proxychains profile --
(
assert builtins.length perAppRoutingDefaultProfiles == 1;
assert (builtins.head perAppRoutingDefaultProfiles).name == "proxychains";
assert (builtins.head perAppRoutingDefaultProfiles).route == "proxychains";
true
)
# -- perAppRouting: createDefaultProfiles = false injects no curated profiles --
(ok (builtins.length perAppRoutingNoDefaultProfiles == 0))
# -- perAppRouting: proxy-ctl script embeds wrap/apps commands --
(
assert pkgs.lib.hasInfix "Usage: proxy-ctl <group>" perAppRoutingProxychainsScript;
assert pkgs.lib.hasInfix "local proxy backend" perAppRoutingProxychainsScript;
assert pkgs.lib.hasInfix "restart active services" perAppRoutingProxychainsScript;
assert pkgs.lib.hasInfix "apps run <profile> -- <cmd>" perAppRoutingProxychainsScript;
assert pkgs.lib.hasInfix "apps" perAppRoutingProxychainsScript;
true
)
# -- perAppRouting: proxychains config is quiet and points at local SOCKS listener --
(
assert pkgs.lib.hasInfix "quiet_mode" perAppRoutingProxychainsConfig;
assert pkgs.lib.hasInfix "proxy_dns" perAppRoutingProxychainsConfig;
assert pkgs.lib.hasInfix "socks5 127.0.0.1 1080" perAppRoutingProxychainsConfig;
true
)
# -- proxy-ctl: restart skips services that are not present in zapret-only or tg-only builds --
(ok (pkgs.lib.hasInfix "proxy-suite-tg-ws-proxy" minimalProxyCtlScript))
# -- perAppRouting: generated proxy-ctl script dispatches through proxychains4 --
(ok (pkgs.lib.hasInfix "export PROXYCHAINS_QUIET_ARG=-q" perAppRoutingProxychainsScript))
];
}