3535 lines
117 KiB
Nix
3535 lines
117 KiB
Nix
{
|
||
system,
|
||
nixpkgs,
|
||
proxySuiteModule,
|
||
generatedOptionsDoc,
|
||
generatedReadmeDoc,
|
||
zapret,
|
||
}:
|
||
|
||
let
|
||
pkgs = import nixpkgs { inherit system; };
|
||
parserChecks = import ./checks/parsers.nix { inherit pkgs; };
|
||
suitePkgs = import ../pkgs/default.nix { inherit pkgs; };
|
||
readmeDocSource = builtins.readFile ../nix/readme-doc.nix;
|
||
trayModuleSource = builtins.readFile ../modules/proxy-suite/tray.nix;
|
||
tgWsProxyModuleSource = builtins.readFile ../modules/proxy-suite/tg-ws-proxy.nix;
|
||
controlModuleSource = builtins.readFile ../modules/proxy-suite/service/control.nix;
|
||
repoChecks = import ./checks/repo.nix {
|
||
inherit
|
||
pkgs
|
||
rg
|
||
generatedOptionsDoc
|
||
generatedReadmeDoc
|
||
readmeDocSource
|
||
trayModuleSource
|
||
tgWsProxyModuleSource
|
||
controlModuleSource
|
||
;
|
||
};
|
||
evalProxySuite =
|
||
modules:
|
||
import "${nixpkgs}/nixos/lib/eval-config.nix" {
|
||
inherit system;
|
||
modules = [ proxySuiteModule ] ++ modules;
|
||
};
|
||
forceEval = value: builtins.tryEval (builtins.deepSeq value true);
|
||
rg = "${pkgs.ripgrep}/bin/rg";
|
||
mkRouting =
|
||
fixture:
|
||
let
|
||
cfg = fixture.config.services.proxy-suite;
|
||
in
|
||
import ../modules/proxy-suite/rules.nix {
|
||
lib = pkgs.lib;
|
||
inherit pkgs cfg zapret;
|
||
};
|
||
mkRoutingRules = fixture: (mkRouting fixture).routingRules;
|
||
mkRouteModeRules = fixture: (mkRouting fixture).routeModeRules;
|
||
mkTProxyConfig =
|
||
fixture:
|
||
let
|
||
cfg = fixture.config.services.proxy-suite;
|
||
rules = mkRouting fixture;
|
||
configs = import ../modules/proxy-suite/config.nix {
|
||
lib = pkgs.lib;
|
||
inherit pkgs cfg rules;
|
||
};
|
||
in
|
||
builtins.fromJSON (builtins.unsafeDiscardStringContext (builtins.readFile configs.tproxyFile));
|
||
mkTunConfig =
|
||
fixture:
|
||
let
|
||
cfg = fixture.config.services.proxy-suite;
|
||
rules = mkRouting fixture;
|
||
configs = import ../modules/proxy-suite/config.nix {
|
||
lib = pkgs.lib;
|
||
inherit pkgs cfg rules;
|
||
};
|
||
in
|
||
builtins.fromJSON (builtins.unsafeDiscardStringContext (builtins.readFile configs.tunFile));
|
||
mkPerAppTunConfig =
|
||
fixture:
|
||
let
|
||
cfg = fixture.config.services.proxy-suite;
|
||
rules = mkRouting fixture;
|
||
configs = import ../modules/proxy-suite/config.nix {
|
||
lib = pkgs.lib;
|
||
inherit pkgs cfg rules;
|
||
};
|
||
in
|
||
builtins.fromJSON (builtins.unsafeDiscardStringContext (builtins.readFile configs.perAppTunFile));
|
||
mkTProxyNftRules =
|
||
fixture:
|
||
let
|
||
cfg = fixture.config.services.proxy-suite;
|
||
nftr = import ../modules/proxy-suite/nftables.nix {
|
||
lib = pkgs.lib;
|
||
inherit pkgs cfg;
|
||
};
|
||
in
|
||
builtins.readFile nftr.nftablesRulesFile;
|
||
hasDirectDomain =
|
||
rules: domain:
|
||
builtins.any (
|
||
rule: (rule ? domain_suffix) && rule.outbound == "direct" && builtins.elem domain rule.domain_suffix
|
||
) rules;
|
||
hasDirectIP =
|
||
rules: cidr:
|
||
builtins.any (
|
||
rule: (rule ? ip_cidr) && rule.outbound == "direct" && builtins.elem cidr rule.ip_cidr
|
||
) rules;
|
||
hasRuleSet =
|
||
rules: outbound: ruleSet:
|
||
builtins.any (
|
||
rule: (rule ? rule_set) && rule.outbound == outbound && builtins.elem ruleSet rule.rule_set
|
||
) rules;
|
||
dnsHasRuleSet =
|
||
dnsRules: ruleSet:
|
||
builtins.any (rule: (rule ? rule_set) && builtins.elem ruleSet rule.rule_set) dnsRules;
|
||
dnsServerByTag =
|
||
dnsConfig: tag: builtins.head (builtins.filter (server: server.tag == tag) dnsConfig.dns.servers);
|
||
mkZapretBaseFor =
|
||
fixture: serviceName:
|
||
let
|
||
env = fixture.config.systemd.services.${serviceName}.serviceConfig.Environment;
|
||
zapretBaseEnv = builtins.head (
|
||
builtins.filter (value: pkgs.lib.hasPrefix "ZAPRET_BASE=" value) env
|
||
);
|
||
in
|
||
pkgs.lib.removePrefix "ZAPRET_BASE=" zapretBaseEnv;
|
||
mkZapretBase = fixture: mkZapretBaseFor fixture "zapret-discord-youtube";
|
||
packagePathMatches =
|
||
packages: pattern:
|
||
builtins.any (
|
||
pkg: builtins.match pattern (builtins.unsafeDiscardStringContext (toString pkg)) != null
|
||
) packages;
|
||
packageByPattern =
|
||
packages: pattern:
|
||
builtins.head (
|
||
builtins.filter (
|
||
pkg: builtins.match pattern (builtins.unsafeDiscardStringContext (toString pkg)) != null
|
||
) packages
|
||
);
|
||
lineByPrefix =
|
||
text: prefix:
|
||
builtins.head (
|
||
builtins.filter (line: pkgs.lib.hasPrefix prefix line) (pkgs.lib.splitString "\n" text)
|
||
);
|
||
lineContaining =
|
||
text: infix:
|
||
builtins.head (
|
||
builtins.filter (line: pkgs.lib.hasInfix infix line) (pkgs.lib.splitString "\n" text)
|
||
);
|
||
staticOutboundJsonFromScript =
|
||
script:
|
||
let
|
||
line = lineContaining script "OB_JSON=$(cat \"";
|
||
parts = pkgs.lib.splitString "\"" line;
|
||
in
|
||
builtins.fromJSON (builtins.readFile (builtins.elemAt parts 1));
|
||
normalizeExec = value: if builtins.isList value then builtins.head value else value;
|
||
readExecScripts =
|
||
value:
|
||
let
|
||
execs = if builtins.isList value then value else [ value ];
|
||
in
|
||
pkgs.lib.concatStringsSep "\n" (map builtins.readFile execs);
|
||
quotedValueByPrefix =
|
||
text: prefix: pkgs.lib.removeSuffix "\"" (pkgs.lib.removePrefix prefix (lineByPrefix text prefix));
|
||
shellValueByPrefix =
|
||
text: prefix:
|
||
let
|
||
value = pkgs.lib.removePrefix prefix (lineByPrefix text prefix);
|
||
in
|
||
if pkgs.lib.hasPrefix "'" value && pkgs.lib.hasSuffix "'" value then
|
||
pkgs.lib.removeSuffix "'" (pkgs.lib.removePrefix "'" value)
|
||
else if pkgs.lib.hasPrefix "\"" value && pkgs.lib.hasSuffix "\"" value then
|
||
pkgs.lib.removeSuffix "\"" (pkgs.lib.removePrefix "\"" value)
|
||
else
|
||
value;
|
||
|
||
baseModule = {
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
outbounds = [
|
||
{
|
||
tag = "primary";
|
||
url = "http://proxy.example.com:8080";
|
||
}
|
||
];
|
||
};
|
||
};
|
||
};
|
||
mkFixture =
|
||
proxySuiteConfig:
|
||
evalProxySuite [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = proxySuiteConfig;
|
||
}
|
||
];
|
||
# Fixture that must fail validation; uses baseModule as the base.
|
||
mkBadFixture =
|
||
modules:
|
||
forceEval ((evalProxySuite ([ baseModule ] ++ modules)).config.system.build.toplevel.drvPath);
|
||
# Same but without baseModule (for fixtures that need custom base config).
|
||
mkBadFixtureRaw =
|
||
modules: forceEval ((evalProxySuite modules).config.system.build.toplevel.drvPath);
|
||
# Extract the proxy-ctl package and derived script/profile values from a fixture.
|
||
mkProxyCtlDerived =
|
||
fixture:
|
||
let
|
||
proxyCtl = packageByPattern fixture.config.environment.systemPackages ".*/[^/]*proxy-ctl(-[0-9.]+)?$";
|
||
wrapper = builtins.readFile "${proxyCtl}/bin/proxy-ctl";
|
||
in
|
||
{
|
||
inherit proxyCtl wrapper;
|
||
script = wrapper + "\n" + builtins.readFile "${proxyCtl}/bin/.proxy-ctl-wrapped";
|
||
profiles = builtins.fromJSON (
|
||
builtins.readFile (shellValueByPrefix wrapper "export PER_APP_ROUTING_PROFILES_FILE=")
|
||
);
|
||
};
|
||
|
||
minimal = evalProxySuite [ baseModule ];
|
||
_minimalProxyCtl = mkProxyCtlDerived minimal;
|
||
minimalProxyCtlWrapper = _minimalProxyCtl.wrapper;
|
||
minimalProxyCtlScript = _minimalProxyCtl.script;
|
||
minimalSocksService = minimal.config.systemd.services."proxy-suite-socks";
|
||
customSingBoxPackage = pkgs.writeShellScriptBin "sing-box" ''
|
||
exit 0
|
||
'';
|
||
customSingBoxPackageFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.proxy.singBox.package = customSingBoxPackage;
|
||
}
|
||
];
|
||
customSingBoxPackageBin = "${builtins.unsafeDiscardStringContext (toString customSingBoxPackage)}/bin/sing-box";
|
||
customSingBoxPackageStartScript = builtins.readFile (
|
||
customSingBoxPackageFixture.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart
|
||
);
|
||
|
||
xrayModule = {
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
xray.enable = true;
|
||
selection = "urltest";
|
||
outbounds = [
|
||
{
|
||
tag = "primary";
|
||
url = "vless://uuid@example.com:443?type=xhttp&security=tls&sni=cdn.example.com&host=cdn.example.com&path=%2Fx";
|
||
routing.domains = [ "specific.example" ];
|
||
}
|
||
];
|
||
routing = {
|
||
proxy.domains = [ "proxy.example" ];
|
||
direct = {
|
||
domains = [ "direct.example" ];
|
||
geosites = [ "category-ru" ];
|
||
};
|
||
block.domains = [ "block.example" ];
|
||
};
|
||
tproxy.enable = true;
|
||
tproxy.perApp.enable = true;
|
||
tun = {
|
||
enable = true;
|
||
perApp.enable = true;
|
||
};
|
||
};
|
||
perAppRouting = {
|
||
enable = true;
|
||
createDefaultProfiles = true;
|
||
};
|
||
};
|
||
};
|
||
xrayFixture = evalProxySuite [ xrayModule ];
|
||
xrayTproxyConfig = mkTProxyConfig xrayFixture;
|
||
xrayTunConfig = mkTunConfig xrayFixture;
|
||
xrayPerAppTunConfig = mkPerAppTunConfig xrayFixture;
|
||
xrayStartScript = builtins.readFile (
|
||
xrayFixture.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart
|
||
);
|
||
xrayTunStartScript = builtins.readFile (
|
||
xrayFixture.config.systemd.services."proxy-suite-tun".serviceConfig.ExecStart
|
||
);
|
||
xrayTunUpScript = builtins.readFile (
|
||
xrayFixture.config.systemd.services."proxy-suite-tun".serviceConfig.ExecStartPost
|
||
);
|
||
xrayPerAppTunStartScript = builtins.readFile (
|
||
xrayFixture.config.systemd.services."proxy-suite-per-app-tun".serviceConfig.ExecStart
|
||
);
|
||
xrayPerAppTunUpScript = builtins.readFile (
|
||
xrayFixture.config.systemd.services."proxy-suite-per-app-tun".serviceConfig.ExecStartPost
|
||
);
|
||
xrayPerAppTunCleanupScript = builtins.readFile (
|
||
xrayFixture.config.systemd.services."proxy-suite-per-app-tun".serviceConfig.ExecStopPost
|
||
);
|
||
xrayStartBackendJqFilterFile = shellValueByPrefix xrayStartScript "BACKEND_JQ_FILTER=";
|
||
xrayTunBackendJqFilterFile = shellValueByPrefix xrayTunStartScript "BACKEND_JQ_FILTER=";
|
||
xrayPerAppTunBackendJqFilterFile = shellValueByPrefix xrayPerAppTunStartScript "BACKEND_JQ_FILTER=";
|
||
xrayBackendJqFilter = builtins.readFile xrayTunBackendJqFilterFile;
|
||
xrayDnsLocalClient = xrayFixture.config.services.proxy-suite.proxy.dns.local.address;
|
||
xrayDnsRemoteClient = xrayFixture.config.services.proxy-suite.proxy.dns.remote.address;
|
||
xrayTunConfigJson = pkgs.writeText "proxy-suite-xray-tun-check.json" (
|
||
builtins.toJSON xrayTunConfig
|
||
);
|
||
xrayPerAppTunConfigJson = pkgs.writeText "proxy-suite-xray-per-app-tun-check.json" (
|
||
builtins.toJSON xrayPerAppTunConfig
|
||
);
|
||
xrayJqFilterRuntimeCheck =
|
||
pkgs.runCommand "proxy-suite-xray-jq-filter-runtime-check" { nativeBuildInputs = [ pkgs.jq ]; }
|
||
''
|
||
OBS='[{"protocol":"freedom","tag":"proxy-suite-ob-primary"}]'
|
||
|
||
check_runtime() {
|
||
local name="$1"
|
||
local input="$2"
|
||
local output="$TMPDIR/$name.json"
|
||
|
||
jq \
|
||
--argjson obs "$OBS" \
|
||
--argjson auth_enabled false \
|
||
--arg user "" \
|
||
--arg password "" \
|
||
--argjson route_enabled true \
|
||
--argjson route_rules '[]' \
|
||
--arg route_final "proxy" \
|
||
--arg dns_final "remote" \
|
||
--argjson clear_dns_rules false \
|
||
--arg xray_loglevel "" \
|
||
--arg xray_bind_interface "eth0" \
|
||
--arg xray_single_proxy_tag "proxy-suite-ob-primary" \
|
||
--argjson xray_tun_dns_runtime true \
|
||
--arg xray_dns_local_client ${pkgs.lib.escapeShellArg xrayDnsLocalClient} \
|
||
--arg xray_dns_remote_client ${pkgs.lib.escapeShellArg xrayDnsRemoteClient} \
|
||
-f ${pkgs.lib.escapeShellArg xrayTunBackendJqFilterFile} \
|
||
"$input" > "$output"
|
||
|
||
jq -e \
|
||
--arg remote ${pkgs.lib.escapeShellArg xrayDnsRemoteClient} \
|
||
--arg local ${pkgs.lib.escapeShellArg xrayDnsLocalClient} \
|
||
'
|
||
type == "object"
|
||
and (.dns.servers | length) >= 3
|
||
and .dns.servers[0].tag == "fakedns"
|
||
and ([.routing.rules[] | select((.ruleTag? // "") == "dns-hijack")] | length) == 1
|
||
and ([.routing.rules[] | select((.ruleTag? // "") == "dns-upstream-direct")] | length) == 1
|
||
and ([.outbounds[] | select(.tag == "proxy-suite-ob-primary" and (.streamSettings.sockopt.interface? // "") == "eth0")] | length) == 1
|
||
and ([.outbounds[] | select(.tag == "dns-out" and ((.streamSettings.sockopt.interface? // "") == ""))] | length) == 1
|
||
and ([.inbounds[] | select(.tag == "tun-in") | .settings.dns] | length) == 1
|
||
and ([.inbounds[] | select(.tag == "tun-in") | .settings.dns][0] == [$remote, $local])
|
||
and ((.routing | has("balancers")) | not)
|
||
and ((has("observatory")) | not)
|
||
' "$output" >/dev/null
|
||
}
|
||
|
||
check_runtime global ${pkgs.lib.escapeShellArg xrayTunConfigJson}
|
||
check_runtime per-app ${pkgs.lib.escapeShellArg xrayPerAppTunConfigJson}
|
||
touch "$out"
|
||
'';
|
||
xraySubscriptionFixture = evalProxySuite [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
xray.enable = true;
|
||
subscriptions = [
|
||
{
|
||
tag = "xray-sub";
|
||
url = "https://example.com/xray-sub";
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
xraySubscriptionStartScript = builtins.readFile (
|
||
xraySubscriptionFixture.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart
|
||
);
|
||
xrayRawStreamFixture = evalProxySuite [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
xray.enable = true;
|
||
outbounds = [
|
||
{
|
||
tag = "raw-stream";
|
||
xrayJson = {
|
||
protocol = "vless";
|
||
settings = {
|
||
address = "example.com";
|
||
port = 443;
|
||
id = "00000000-0000-0000-0000-000000000000";
|
||
encryption = "none";
|
||
};
|
||
streamSettings = {
|
||
network = "ws";
|
||
security = "tls";
|
||
tlsSettings.serverName = "cdn.example.com";
|
||
wsSettings.path = "/ws";
|
||
sockopt.tcpFastOpen = true;
|
||
};
|
||
};
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
xrayRawStreamStartScript = builtins.readFile (
|
||
xrayRawStreamFixture.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart
|
||
);
|
||
xrayRawStreamOutbound = staticOutboundJsonFromScript xrayRawStreamStartScript;
|
||
xrayDnsTcpFixture = evalProxySuite [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
xray.enable = true;
|
||
dns.local = {
|
||
type = "tcp";
|
||
address = "9.9.9.9";
|
||
port = 5353;
|
||
};
|
||
outbounds = [
|
||
{
|
||
tag = "primary";
|
||
url = "http://proxy.example.com:8080";
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
xrayDnsTcpConfig = mkTProxyConfig xrayDnsTcpFixture;
|
||
xrayDnsTlsUnavailable = mkBadFixtureRaw [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
xray.enable = true;
|
||
dns.remote = {
|
||
type = "tls";
|
||
address = "1.1.1.1";
|
||
port = 853;
|
||
};
|
||
outbounds = [
|
||
{
|
||
tag = "primary";
|
||
url = "http://proxy.example.com:8080";
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
hybridModule = {
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
xray.enable = true;
|
||
selection = "selector";
|
||
outbounds = [
|
||
{
|
||
tag = "primary";
|
||
url = "vless://uuid@example.com:443?type=tcp&security=reality&pbk=pubkey&fp=qq&sni=last.fm&sid=8a54&spx=%2F-%2Fen%2Fgp%2Fbestsellers&flow=xtls-rprx-vision&encryption=none";
|
||
}
|
||
{
|
||
tag = "xray-only";
|
||
url = "vless://uuid@example.com:443?type=xhttp&security=tls&sni=cdn.example.com&host=cdn.example.com&path=%2Fx";
|
||
}
|
||
];
|
||
tproxy.enable = true;
|
||
tun.enable = true;
|
||
tun.perApp.enable = true;
|
||
};
|
||
};
|
||
};
|
||
hybridFixture = evalProxySuite [ hybridModule ];
|
||
hybridTproxyConfig = mkTProxyConfig hybridFixture;
|
||
hybridTunConfig = mkTunConfig hybridFixture;
|
||
hybridStartScript = builtins.readFile (
|
||
hybridFixture.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart
|
||
);
|
||
hybridTunStartScript = builtins.readFile (
|
||
hybridFixture.config.systemd.services."proxy-suite-tun".serviceConfig.ExecStart
|
||
);
|
||
hybridPerAppTunStartScript = builtins.readFile (
|
||
hybridFixture.config.systemd.services."proxy-suite-per-app-tun".serviceConfig.ExecStart
|
||
);
|
||
hybridBackendJqFilterFile = shellValueByPrefix hybridStartScript "BACKEND_JQ_FILTER=";
|
||
hybridBackendJqFilter = builtins.readFile hybridBackendJqFilterFile;
|
||
hybridXrayRawFixture = evalProxySuite [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
xray.enable = true;
|
||
outbounds = [
|
||
{
|
||
tag = "raw-xray";
|
||
xrayJson = {
|
||
protocol = "freedom";
|
||
settings = { };
|
||
};
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
hybridXrayRawStartScript = builtins.readFile (
|
||
hybridXrayRawFixture.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart
|
||
);
|
||
hybridSubscriptionFixture = evalProxySuite [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
xray.enable = true;
|
||
subscriptions = [
|
||
{
|
||
tag = "community";
|
||
url = "https://example.com/hybrid-sub";
|
||
}
|
||
];
|
||
selection = "selector";
|
||
};
|
||
};
|
||
}
|
||
];
|
||
hybridSubscriptionStartScript = builtins.readFile (
|
||
hybridSubscriptionFixture.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart
|
||
);
|
||
hybridSubscriptionUpdateScript = builtins.readFile (
|
||
hybridSubscriptionFixture.config.systemd.services."proxy-suite-subscription-update".serviceConfig.ExecStart
|
||
);
|
||
proxyEnabledNoBackend = mkBadFixtureRaw [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
outbounds = [
|
||
{
|
||
tag = "primary";
|
||
url = "http://proxy.example.com:8080";
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
xraySelectorUnavailable = mkBadFixtureRaw [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
xray.enable = true;
|
||
selection = "selector";
|
||
outbounds = [
|
||
{
|
||
tag = "primary";
|
||
url = "http://proxy.example.com:8080";
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
xraySingBoxJsonUnavailable = mkBadFixtureRaw [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
xray.enable = true;
|
||
outbounds = [
|
||
{
|
||
tag = "raw";
|
||
singBoxJson = {
|
||
type = "direct";
|
||
};
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
singBoxXrayJsonUnavailable = mkBadFixtureRaw [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
outbounds = [
|
||
{
|
||
tag = "raw";
|
||
xrayJson = {
|
||
protocol = "freedom";
|
||
settings = { };
|
||
};
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
|
||
routeModeFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.proxy.routing = {
|
||
proxy = {
|
||
domains = [ "proxy.example" ];
|
||
geosites = [ "google" ];
|
||
};
|
||
direct.domains = [ "direct.example" ];
|
||
block.domains = [ "block.example" ];
|
||
rules = [
|
||
{
|
||
outbound = "direct";
|
||
domains = [ "custom-direct.example" ];
|
||
}
|
||
{
|
||
outbound = "primary";
|
||
domains = [ "custom-proxy.example" ];
|
||
}
|
||
{
|
||
outbound = "block";
|
||
domains = [ "custom-block.example" ];
|
||
}
|
||
];
|
||
};
|
||
}
|
||
];
|
||
routeModeStartScript = builtins.readFile (
|
||
routeModeFixture.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart
|
||
);
|
||
routeModeBackendJqFilterFile = shellValueByPrefix routeModeStartScript "BACKEND_JQ_FILTER=";
|
||
routeModeBackendJqFilter = builtins.readFile routeModeBackendJqFilterFile;
|
||
routeModeRules = mkRouteModeRules routeModeFixture;
|
||
|
||
tgSecretFile = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.tgWsProxy = {
|
||
enable = true;
|
||
host = "127.0.0.1";
|
||
secretFile = "/run/secrets/tg-ws-proxy";
|
||
};
|
||
}
|
||
];
|
||
tgSecretFileService = tgSecretFile.config.systemd.services."proxy-suite-tg-ws-proxy";
|
||
|
||
tgAllOptions = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.tgWsProxy = {
|
||
enable = true;
|
||
port = 2443;
|
||
host = "0.0.0.0";
|
||
secretFile = "/run/secrets/tg-ws-proxy";
|
||
verbose = true;
|
||
logFile = "/var/log/tg-ws-proxy.log";
|
||
logMaxMb = 2.5;
|
||
logBackups = 3;
|
||
bufKb = 512;
|
||
poolSize = 8;
|
||
cfProxyDomains = [
|
||
"cdn.example.com"
|
||
"edge.example.net"
|
||
];
|
||
cfProxyWorkerDomains = [ "worker.example.com" ];
|
||
cfProxyFallback = false;
|
||
fakeTlsDomain = "mask.example.com";
|
||
proxyProtocol = true;
|
||
wsKeepalive = 0;
|
||
};
|
||
}
|
||
];
|
||
tgAllOptionsStartScript = builtins.readFile (
|
||
tgAllOptions.config.systemd.services."proxy-suite-tg-ws-proxy".serviceConfig.ExecStart
|
||
);
|
||
|
||
tgWithGlobalTun = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite = {
|
||
proxy.tun.enable = true;
|
||
tgWsProxy = {
|
||
enable = true;
|
||
secretFile = "/run/secrets/tg-ws-proxy";
|
||
dcIps."2" = "149.154.167.220";
|
||
};
|
||
};
|
||
}
|
||
];
|
||
tgWithGlobalTunServiceConfig =
|
||
tgWithGlobalTun.config.systemd.services."proxy-suite-tg-ws-proxy".serviceConfig;
|
||
tgWithGlobalTunBypassUp = builtins.readFile tgWithGlobalTunServiceConfig.ExecStartPre;
|
||
tgWithGlobalTunBypassDown = builtins.readFile tgWithGlobalTunServiceConfig.ExecStopPost;
|
||
tgWithGlobalTunRules = mkRoutingRules tgWithGlobalTun;
|
||
|
||
tgWithGlobalTproxy = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite = {
|
||
proxy.tproxy.enable = true;
|
||
tgWsProxy = {
|
||
enable = true;
|
||
secretFile = "/run/secrets/tg-ws-proxy";
|
||
};
|
||
};
|
||
}
|
||
];
|
||
tgWithGlobalTproxyNft = mkTProxyNftRules tgWithGlobalTproxy;
|
||
|
||
tgRoutingMarkCollision = mkBadFixture [
|
||
{
|
||
services.proxy-suite = {
|
||
proxy.tproxy.enable = true;
|
||
tgWsProxy = {
|
||
enable = true;
|
||
secretFile = "/run/secrets/tg-ws-proxy";
|
||
routingMark = 1;
|
||
};
|
||
};
|
||
}
|
||
];
|
||
|
||
tgInvalidBufKb = mkBadFixture [
|
||
{
|
||
services.proxy-suite.tgWsProxy = {
|
||
enable = true;
|
||
secretFile = "/run/secrets/tg-ws-proxy";
|
||
bufKb = 3;
|
||
};
|
||
}
|
||
];
|
||
|
||
tgInvalidPoolSize = mkBadFixture [
|
||
{
|
||
services.proxy-suite.tgWsProxy = {
|
||
enable = true;
|
||
secretFile = "/run/secrets/tg-ws-proxy";
|
||
poolSize = -1;
|
||
};
|
||
}
|
||
];
|
||
|
||
tgInvalidLogBackups = mkBadFixture [
|
||
{
|
||
services.proxy-suite.tgWsProxy = {
|
||
enable = true;
|
||
secretFile = "/run/secrets/tg-ws-proxy";
|
||
logBackups = 0;
|
||
};
|
||
}
|
||
];
|
||
|
||
tgInvalidWsKeepalive = mkBadFixture [
|
||
{
|
||
services.proxy-suite.tgWsProxy = {
|
||
enable = true;
|
||
secretFile = "/run/secrets/tg-ws-proxy";
|
||
wsKeepalive = -1;
|
||
};
|
||
}
|
||
];
|
||
|
||
duplicateTags = forceEval (
|
||
(mkFixture {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
outbounds = [
|
||
{
|
||
tag = "dup";
|
||
url = "http://one.example.com:8080";
|
||
}
|
||
{
|
||
tag = "dup";
|
||
url = "http://two.example.com:8080";
|
||
}
|
||
];
|
||
};
|
||
}).config.system.build.toplevel.drvPath
|
||
);
|
||
|
||
reservedTag = forceEval (
|
||
(mkFixture {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
outbounds = [
|
||
{
|
||
tag = "proxy";
|
||
url = "http://proxy.example.com:8080";
|
||
}
|
||
];
|
||
};
|
||
}).config.system.build.toplevel.drvPath
|
||
);
|
||
|
||
unknownRoutingTarget = forceEval (
|
||
(mkFixture {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
outbounds = [
|
||
{
|
||
tag = "primary";
|
||
url = "http://proxy.example.com:8080";
|
||
}
|
||
];
|
||
routing.rules = [
|
||
{
|
||
outbound = "missing";
|
||
domains = [ "example.com" ];
|
||
}
|
||
];
|
||
};
|
||
}).config.system.build.toplevel.drvPath
|
||
);
|
||
|
||
tproxyWithFirewall = evalProxySuite [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
networking.firewall.enable = true;
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
tproxy.enable = true;
|
||
outbounds = [
|
||
{
|
||
tag = "primary";
|
||
url = "http://proxy.example.com:8080";
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
|
||
tproxyManualFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.proxy.tproxy.enable = true;
|
||
}
|
||
];
|
||
tproxyManualServiceConfig =
|
||
tproxyManualFixture.config.systemd.services."proxy-suite-tproxy".serviceConfig;
|
||
tproxyManualStartScript = builtins.readFile tproxyManualServiceConfig.ExecStart;
|
||
tproxyManualStopScript = builtins.readFile tproxyManualServiceConfig.ExecStop;
|
||
|
||
tproxyAutostartFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.proxy.tproxy = {
|
||
enable = true;
|
||
autostart = true;
|
||
};
|
||
}
|
||
];
|
||
|
||
tunManualFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.proxy.tun.enable = true;
|
||
}
|
||
];
|
||
|
||
tunAutostartFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.proxy.tun = {
|
||
enable = true;
|
||
autostart = true;
|
||
};
|
||
}
|
||
];
|
||
|
||
conflictingAutostartModes = mkBadFixture [
|
||
{
|
||
services.proxy-suite.proxy = {
|
||
tproxy = {
|
||
enable = true;
|
||
autostart = true;
|
||
};
|
||
tun = {
|
||
enable = true;
|
||
autostart = true;
|
||
};
|
||
};
|
||
}
|
||
];
|
||
|
||
globalTunWithoutProxy = mkBadFixture [
|
||
{
|
||
services.proxy-suite.proxy = {
|
||
enable = false;
|
||
tun.enable = true;
|
||
};
|
||
}
|
||
];
|
||
|
||
globalTproxyWithoutProxy = mkBadFixture [
|
||
{
|
||
services.proxy-suite.proxy = {
|
||
enable = false;
|
||
tproxy.enable = true;
|
||
};
|
||
}
|
||
];
|
||
|
||
routingOrFixture = evalProxySuite [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
outbounds = [
|
||
{
|
||
tag = "primary";
|
||
url = "http://proxy.example.com:8080";
|
||
}
|
||
];
|
||
routing.rules = [
|
||
{
|
||
outbound = "primary";
|
||
domains = [ "example.com" ];
|
||
geoips = [ "us" ];
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
|
||
ruDefaultRules = mkRoutingRules minimal;
|
||
ruDefaultConfig = mkTProxyConfig minimal;
|
||
|
||
ruDisabledFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.proxy.routing.enableRuDirect = false;
|
||
}
|
||
];
|
||
ruDisabledRules = mkRoutingRules ruDisabledFixture;
|
||
ruDisabledConfig = mkTProxyConfig ruDisabledFixture;
|
||
|
||
ruExplicitFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.proxy.routing = {
|
||
enableRuDirect = false;
|
||
direct.geosites = [ "category-ru" ];
|
||
};
|
||
}
|
||
];
|
||
ruExplicitConfig = mkTProxyConfig ruExplicitFixture;
|
||
|
||
dnsLocalOverrideFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.proxy.dns.local = {
|
||
type = "tcp";
|
||
address = "9.9.9.9";
|
||
port = 5353;
|
||
};
|
||
}
|
||
];
|
||
dnsLocalOverrideConfig = mkTProxyConfig dnsLocalOverrideFixture;
|
||
|
||
dnsRemoteOverrideFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.proxy.dns.remote = {
|
||
type = "tls";
|
||
address = "1.0.0.1";
|
||
port = 853;
|
||
};
|
||
}
|
||
];
|
||
dnsRemoteOverrideConfig = mkTProxyConfig dnsRemoteOverrideFixture;
|
||
tunDefaultConfig = mkTunConfig tunManualFixture;
|
||
tunServiceConfig = tunManualFixture.config.systemd.services."proxy-suite-tun".serviceConfig;
|
||
tunCleanupScript = builtins.readFile tunServiceConfig.ExecStopPost;
|
||
|
||
zapretSyncFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.zapret.enable = true;
|
||
}
|
||
];
|
||
zapretSyncService = zapretSyncFixture.config.systemd.services."zapret-discord-youtube";
|
||
zapretSyncRules = mkRoutingRules zapretSyncFixture;
|
||
zapretSyncBase = mkZapretBase zapretSyncFixture;
|
||
|
||
zapretSyncNoExtraListsFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.zapret = {
|
||
enable = true;
|
||
includeExtraUpstreamLists = false;
|
||
};
|
||
}
|
||
];
|
||
zapretSyncNoExtraListsBase = mkZapretBase zapretSyncNoExtraListsFixture;
|
||
zapretSyncNoExtraListsRules = mkRoutingRules zapretSyncNoExtraListsFixture;
|
||
|
||
zapretSyncExtraListsFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.zapret = {
|
||
enable = true;
|
||
includeExtraUpstreamLists = true;
|
||
};
|
||
}
|
||
];
|
||
zapretSyncExtraListsBase = mkZapretBase zapretSyncExtraListsFixture;
|
||
zapretSyncExtraListsRules = mkRoutingRules zapretSyncExtraListsFixture;
|
||
|
||
zapretSyncIpsFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.zapret = {
|
||
enable = true;
|
||
syncDirectRoutingUpstreamIps = true;
|
||
};
|
||
}
|
||
];
|
||
zapretSyncIpsRules = mkRoutingRules zapretSyncIpsFixture;
|
||
|
||
zapretSyncUserIpsDisabledFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.zapret = {
|
||
enable = true;
|
||
syncDirectRoutingUserIps = false;
|
||
ipsetAll = [ "203.0.113.0/24" ];
|
||
};
|
||
}
|
||
];
|
||
zapretSyncUserIpsDisabledRules = mkRoutingRules zapretSyncUserIpsDisabledFixture;
|
||
|
||
zapretSyncDisabledFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.zapret = {
|
||
enable = true;
|
||
syncDirectRouting = false;
|
||
};
|
||
}
|
||
];
|
||
zapretSyncDisabledRules = mkRoutingRules zapretSyncDisabledFixture;
|
||
|
||
zapretSyncDomainsOnlyFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.zapret = {
|
||
enable = true;
|
||
syncDirectRouting = true;
|
||
syncDirectRoutingUpstreamIps = false;
|
||
};
|
||
}
|
||
];
|
||
zapretSyncDomainsOnlyRules = mkRoutingRules zapretSyncDomainsOnlyFixture;
|
||
|
||
zapretExtrasFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.zapret = {
|
||
enable = true;
|
||
listGeneral = [ "pixiv.net" ];
|
||
};
|
||
}
|
||
];
|
||
zapretExtrasRules = mkRoutingRules zapretExtrasFixture;
|
||
|
||
zapretIpExtrasFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.zapret = {
|
||
enable = true;
|
||
ipsetAll = [ "203.0.113.0/24" ];
|
||
};
|
||
}
|
||
];
|
||
zapretIpExtrasRules = mkRoutingRules zapretIpExtrasFixture;
|
||
|
||
zapretExcludesFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.zapret = {
|
||
enable = true;
|
||
listExclude = [ "discord.com" ];
|
||
};
|
||
}
|
||
];
|
||
zapretExcludesRules = mkRoutingRules zapretExcludesFixture;
|
||
|
||
zapretIpExcludesFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.zapret = {
|
||
enable = true;
|
||
ipsetExclude = [ "1.1.1.0/24" ];
|
||
ipsetAll = [ "1.1.1.0/24" ];
|
||
};
|
||
}
|
||
];
|
||
zapretIpExcludesRules = mkRoutingRules zapretIpExcludesFixture;
|
||
|
||
zapretHostlistRulesFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.zapret = {
|
||
enable = true;
|
||
hostlistRules = [
|
||
{
|
||
name = "googlevideo";
|
||
domains = [
|
||
"googlevideo.com"
|
||
"ggpht.com"
|
||
];
|
||
preset = "google";
|
||
}
|
||
{
|
||
name = "example";
|
||
domains = [
|
||
"example.com"
|
||
"example.de"
|
||
];
|
||
nfqwsArgs = [ "--filter-tcp=443 --dpi-desync=fake,multisplit" ];
|
||
}
|
||
{
|
||
name = "twitter-no-direct";
|
||
domains = [ "x.example" ];
|
||
nfqwsArgs = [ "--filter-udp=443 --dpi-desync=fake --dpi-desync-repeats=6" ];
|
||
enableDirectSync = false;
|
||
}
|
||
];
|
||
};
|
||
}
|
||
];
|
||
zapretHostlistRules = mkRoutingRules zapretHostlistRulesFixture;
|
||
zapretHostlistBase = mkZapretBase zapretHostlistRulesFixture;
|
||
|
||
duplicateZapretHostlistNames = mkBadFixture [
|
||
{
|
||
services.proxy-suite.zapret = {
|
||
enable = true;
|
||
hostlistRules = [
|
||
{
|
||
name = "dup";
|
||
domains = [ "one.example" ];
|
||
nfqwsArgs = [ "--filter-tcp=443 --dpi-desync=fake" ];
|
||
}
|
||
{
|
||
name = "dup";
|
||
domains = [ "two.example" ];
|
||
nfqwsArgs = [ "--filter-tcp=443 --dpi-desync=fake" ];
|
||
}
|
||
];
|
||
};
|
||
}
|
||
];
|
||
|
||
emptyZapretHostlistDomains = mkBadFixture [
|
||
{
|
||
services.proxy-suite.zapret = {
|
||
enable = true;
|
||
hostlistRules = [
|
||
{
|
||
name = "empty";
|
||
domains = [ ];
|
||
nfqwsArgs = [ "--filter-tcp=443 --dpi-desync=fake" ];
|
||
}
|
||
];
|
||
};
|
||
}
|
||
];
|
||
|
||
missingZapretHostlistAction = mkBadFixture [
|
||
{
|
||
services.proxy-suite.zapret = {
|
||
enable = true;
|
||
hostlistRules = [
|
||
{
|
||
name = "missing";
|
||
domains = [ "missing.example" ];
|
||
}
|
||
];
|
||
};
|
||
}
|
||
];
|
||
|
||
proxyDirectFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.proxy.proxyByDefault = false;
|
||
}
|
||
];
|
||
proxyDirectConfig = mkTProxyConfig proxyDirectFixture;
|
||
|
||
trayAutostartFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.tray.enable = true;
|
||
}
|
||
];
|
||
|
||
trayManualFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.tray = {
|
||
enable = true;
|
||
autostart = false;
|
||
};
|
||
}
|
||
];
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# Subscription fixtures
|
||
# ---------------------------------------------------------------------------
|
||
|
||
subscriptionOnlyFixture = evalProxySuite [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
subscriptions = [
|
||
{
|
||
tag = "community";
|
||
url = "https://example.com/sub/token";
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
subscriptionOnlyProxyCtl = packageByPattern subscriptionOnlyFixture.config.environment.systemPackages ".*/[^/]*proxy-ctl(-[0-9.]+)?$";
|
||
subscriptionOnlyWrapper = builtins.readFile "${subscriptionOnlyProxyCtl}/bin/proxy-ctl";
|
||
subscriptionOnlyScript =
|
||
subscriptionOnlyWrapper
|
||
+ "\n"
|
||
+ builtins.readFile "${subscriptionOnlyProxyCtl}/bin/.proxy-ctl-wrapped";
|
||
subscriptionOnlyTags = builtins.fromJSON (
|
||
builtins.readFile (shellValueByPrefix subscriptionOnlyWrapper "export SUB_TAGS_FILE=")
|
||
);
|
||
subscriptionOnlyStartScript =
|
||
builtins.readFile
|
||
subscriptionOnlyFixture.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart;
|
||
subscriptionOnlyUpdateScript =
|
||
builtins.readFile
|
||
subscriptionOnlyFixture.config.systemd.services."proxy-suite-subscription-update".serviceConfig.ExecStart;
|
||
|
||
subscriptionWithStaticFixture = evalProxySuite [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
outbounds = [
|
||
{
|
||
tag = "own-vps";
|
||
url = "http://proxy.example.com:8080";
|
||
}
|
||
];
|
||
subscriptions = [
|
||
{
|
||
tag = "backup";
|
||
url = "https://example.com/sub/token";
|
||
}
|
||
];
|
||
selection = "urltest";
|
||
subscriptionUpdateInterval = "6h";
|
||
};
|
||
};
|
||
}
|
||
];
|
||
duplicateSubscriptionTags = mkBadFixtureRaw [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
subscriptions = [
|
||
{
|
||
tag = "dup";
|
||
url = "https://example.com/sub/one";
|
||
}
|
||
{
|
||
tag = "dup";
|
||
url = "https://example.com/sub/two";
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
|
||
unsafeSubscriptionTag = mkBadFixtureRaw [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
subscriptions = [
|
||
{
|
||
tag = "bad/tag";
|
||
url = "https://example.com/sub/token";
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
|
||
# selection=first with subscriptions only – start script must rename first
|
||
# subscription outbound to "proxy" so routing rules resolve at runtime.
|
||
subscriptionFirstSelectionFixture = evalProxySuite [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
subscriptions = [
|
||
{
|
||
tag = "community";
|
||
url = "https://example.com/sub/token";
|
||
}
|
||
];
|
||
selection = "first";
|
||
};
|
||
};
|
||
}
|
||
];
|
||
subscriptionPerAppTunFixture = evalProxySuite [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
subscriptions = [
|
||
{
|
||
tag = "community";
|
||
url = "https://example.com/sub/token";
|
||
}
|
||
];
|
||
tun.perApp.enable = true;
|
||
};
|
||
perAppRouting.enable = true;
|
||
};
|
||
}
|
||
];
|
||
subscriptionPerAppTunUpdateScript = builtins.readFile (
|
||
subscriptionPerAppTunFixture.config.systemd.services."proxy-suite-subscription-update".serviceConfig.ExecStart
|
||
);
|
||
|
||
subscriptionUrlFileFixture = evalProxySuite [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
subscriptions = [
|
||
{
|
||
tag = "private";
|
||
urlFile = "/run/secrets/sub-url";
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
|
||
urlTestCustomFixture = evalProxySuite [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
outbounds = [
|
||
{
|
||
tag = "test-proxy";
|
||
url = "http://proxy.example.com:8080";
|
||
}
|
||
];
|
||
selection = "urltest";
|
||
urlTest = {
|
||
url = "https://telegram.org";
|
||
interval = "1m";
|
||
};
|
||
singBox.urlTest.tolerance = 100;
|
||
};
|
||
};
|
||
}
|
||
];
|
||
|
||
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;
|
||
perAppRoutingProxychainsProxyCtl = _perAppRoutingProxychains.proxyCtl;
|
||
perAppRoutingProxychainsWrapper = _perAppRoutingProxychains.wrapper;
|
||
perAppRoutingProxychainsScript = _perAppRoutingProxychains.script;
|
||
perAppRoutingProxychainsProfiles = _perAppRoutingProxychains.profiles;
|
||
perAppRoutingProxychainsConfig = builtins.readFile (
|
||
shellValueByPrefix perAppRoutingProxychainsWrapper "export PROXYCHAINS_CONFIG="
|
||
);
|
||
|
||
localProxyAuthFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.proxy.auth = {
|
||
username = "local-user";
|
||
password = "local-pass";
|
||
};
|
||
}
|
||
];
|
||
localProxyAuthStartScript = builtins.readFile (
|
||
localProxyAuthFixture.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart
|
||
);
|
||
localProxyAuthBackendJqFilterFile = shellValueByPrefix localProxyAuthStartScript "BACKEND_JQ_FILTER=";
|
||
localProxyAuthBackendJqFilter = builtins.readFile localProxyAuthBackendJqFilterFile;
|
||
|
||
localProxyAuthPasswordFileFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite = {
|
||
proxy.auth = {
|
||
username = "local-user";
|
||
passwordFile = "/run/secrets/local-proxy-password";
|
||
};
|
||
perAppRouting = {
|
||
enable = true;
|
||
proxychains.enable = true;
|
||
profiles = [
|
||
{
|
||
name = "steam-browser";
|
||
route = "proxychains";
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
_localProxyAuthPasswordFile = mkProxyCtlDerived localProxyAuthPasswordFileFixture;
|
||
localProxyAuthPasswordFileWrapper = _localProxyAuthPasswordFile.wrapper;
|
||
localProxyAuthPasswordFileScript = _localProxyAuthPasswordFile.script;
|
||
localProxyAuthPasswordFileStartScript = builtins.readFile (
|
||
localProxyAuthPasswordFileFixture.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart
|
||
);
|
||
|
||
perAppRoutingDefaultProfilesFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.perAppRouting = {
|
||
enable = true;
|
||
createDefaultProfiles = true;
|
||
proxychains.enable = true;
|
||
};
|
||
}
|
||
];
|
||
_perAppRoutingDefaultProfiles = mkProxyCtlDerived perAppRoutingDefaultProfilesFixture;
|
||
perAppRoutingDefaultProfilesProxyCtl = _perAppRoutingDefaultProfiles.proxyCtl;
|
||
perAppRoutingDefaultProfilesWrapper = _perAppRoutingDefaultProfiles.wrapper;
|
||
perAppRoutingDefaultProfilesScript = _perAppRoutingDefaultProfiles.script;
|
||
perAppRoutingDefaultProfiles = _perAppRoutingDefaultProfiles.profiles;
|
||
|
||
perAppRoutingNoDefaultProfilesFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite = {
|
||
proxy = {
|
||
tun.perApp.enable = true;
|
||
tproxy.perApp.enable = true;
|
||
};
|
||
zapret = {
|
||
enable = true;
|
||
perApp.enable = true;
|
||
};
|
||
perAppRouting = {
|
||
enable = true;
|
||
createDefaultProfiles = false;
|
||
proxychains.enable = true;
|
||
};
|
||
};
|
||
}
|
||
];
|
||
_perAppRoutingNoDefaultProfiles = mkProxyCtlDerived perAppRoutingNoDefaultProfilesFixture;
|
||
perAppRoutingNoDefaultProfilesProxyCtl = _perAppRoutingNoDefaultProfiles.proxyCtl;
|
||
perAppRoutingNoDefaultProfilesWrapper = _perAppRoutingNoDefaultProfiles.wrapper;
|
||
perAppRoutingNoDefaultProfilesScript = _perAppRoutingNoDefaultProfiles.script;
|
||
perAppRoutingNoDefaultProfiles = _perAppRoutingNoDefaultProfiles.profiles;
|
||
|
||
perAppRoutingDefaultProfilesWithoutProxychainsEnable = mkBadFixture [
|
||
{
|
||
services.proxy-suite.perAppRouting = {
|
||
enable = true;
|
||
createDefaultProfiles = true;
|
||
};
|
||
}
|
||
];
|
||
|
||
perAppRoutingTunFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite = {
|
||
proxy.tun.perApp.enable = true;
|
||
perAppRouting = {
|
||
enable = true;
|
||
createDefaultProfiles = true;
|
||
};
|
||
};
|
||
}
|
||
];
|
||
_perAppRoutingTun = mkProxyCtlDerived perAppRoutingTunFixture;
|
||
perAppRoutingTunProxyCtl = _perAppRoutingTun.proxyCtl;
|
||
perAppRoutingTunWrapper = _perAppRoutingTun.wrapper;
|
||
perAppRoutingTunScript = _perAppRoutingTun.script;
|
||
perAppRoutingTunProfiles = _perAppRoutingTun.profiles;
|
||
perAppRoutingTunServiceConfig =
|
||
perAppRoutingTunFixture.config.systemd.services."proxy-suite-per-app-tun".serviceConfig;
|
||
perAppRoutingTunStartScript = builtins.readFile perAppRoutingTunServiceConfig.ExecStart;
|
||
perAppRoutingTunUpScript = builtins.readFile perAppRoutingTunServiceConfig.ExecStartPost;
|
||
perAppRoutingTunCleanupScript = builtins.readFile perAppRoutingTunServiceConfig.ExecStopPost;
|
||
perAppRoutingTunConfig = mkPerAppTunConfig perAppRoutingTunFixture;
|
||
perAppRoutingTunDirectOutbound = builtins.head (
|
||
builtins.filter (item: item.tag == "direct") perAppRoutingTunConfig.outbounds
|
||
);
|
||
perAppRoutingTunUserStartExec =
|
||
perAppRoutingTunFixture.config.systemd.services."proxy-suite-per-app-tun-user@".serviceConfig.ExecStart;
|
||
perAppRoutingTunUserStartScript = builtins.readFile (
|
||
builtins.head (pkgs.lib.splitString " " perAppRoutingTunUserStartExec)
|
||
);
|
||
|
||
perAppRoutingTunWithTproxyFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite = {
|
||
proxy = {
|
||
tproxy.enable = true;
|
||
tun.perApp.enable = true;
|
||
};
|
||
perAppRouting = {
|
||
enable = true;
|
||
createDefaultProfiles = true;
|
||
};
|
||
};
|
||
}
|
||
];
|
||
perAppRoutingTunWithTproxyStartScript =
|
||
builtins.readFile
|
||
perAppRoutingTunWithTproxyFixture.config.systemd.services."proxy-suite-per-app-tun".serviceConfig.ExecStart;
|
||
perAppRoutingTunWithTproxyConfig = mkPerAppTunConfig perAppRoutingTunWithTproxyFixture;
|
||
perAppRoutingTunWithTproxyDirectOutbound = builtins.head (
|
||
builtins.filter (item: item.tag == "direct") perAppRoutingTunWithTproxyConfig.outbounds
|
||
);
|
||
|
||
perAppRoutingTunWithoutEnable = mkBadFixture [
|
||
{
|
||
services.proxy-suite.perAppRouting = {
|
||
enable = true;
|
||
profiles = [
|
||
{
|
||
name = "game";
|
||
route = "tun";
|
||
}
|
||
];
|
||
};
|
||
}
|
||
];
|
||
|
||
perAppRoutingTproxyFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite = {
|
||
proxy.tproxy.perApp.enable = true;
|
||
perAppRouting = {
|
||
enable = true;
|
||
createDefaultProfiles = true;
|
||
};
|
||
};
|
||
}
|
||
];
|
||
_perAppRoutingTproxy = mkProxyCtlDerived perAppRoutingTproxyFixture;
|
||
perAppRoutingTproxyProxyCtl = _perAppRoutingTproxy.proxyCtl;
|
||
perAppRoutingTproxyWrapper = _perAppRoutingTproxy.wrapper;
|
||
perAppRoutingTproxyScript = _perAppRoutingTproxy.script;
|
||
perAppRoutingTproxyProfiles = _perAppRoutingTproxy.profiles;
|
||
perAppRoutingTproxyServiceConfig =
|
||
perAppRoutingTproxyFixture.config.systemd.services."proxy-suite-per-app-tproxy".serviceConfig;
|
||
perAppRoutingTproxyStartScript = builtins.readFile perAppRoutingTproxyServiceConfig.ExecStart;
|
||
perAppRoutingTproxyStopScript = builtins.readFile perAppRoutingTproxyServiceConfig.ExecStop;
|
||
perAppRoutingTproxyUserStartExec =
|
||
perAppRoutingTproxyFixture.config.systemd.services."proxy-suite-per-app-tproxy-user@".serviceConfig.ExecStart;
|
||
perAppRoutingTproxyUserStartScript = builtins.readFile (
|
||
builtins.head (pkgs.lib.splitString " " perAppRoutingTproxyUserStartExec)
|
||
);
|
||
|
||
perAppRoutingTproxyWithoutEnable = mkBadFixture [
|
||
{
|
||
services.proxy-suite.perAppRouting = {
|
||
enable = true;
|
||
profiles = [
|
||
{
|
||
name = "browser";
|
||
route = "tproxy";
|
||
}
|
||
];
|
||
};
|
||
}
|
||
];
|
||
|
||
perAppRoutingProxychainsWithoutProxy = mkBadFixture [
|
||
{
|
||
services.proxy-suite = {
|
||
proxy.enable = false;
|
||
perAppRouting = {
|
||
enable = true;
|
||
proxychains.enable = true;
|
||
};
|
||
};
|
||
}
|
||
];
|
||
|
||
perAppRoutingTunBackendWithoutProxy = mkBadFixture [
|
||
{
|
||
services.proxy-suite = {
|
||
proxy = {
|
||
enable = false;
|
||
tun.perApp.enable = true;
|
||
};
|
||
perAppRouting.enable = true;
|
||
};
|
||
}
|
||
];
|
||
|
||
perAppRoutingTproxyBackendWithoutProxy = mkBadFixture [
|
||
{
|
||
services.proxy-suite = {
|
||
proxy = {
|
||
enable = false;
|
||
tproxy.perApp.enable = true;
|
||
};
|
||
perAppRouting.enable = true;
|
||
};
|
||
}
|
||
];
|
||
|
||
perAppRoutingTunProfileWithoutProxy = mkBadFixture [
|
||
{
|
||
services.proxy-suite = {
|
||
proxy.enable = false;
|
||
perAppRouting = {
|
||
enable = true;
|
||
profiles = [
|
||
{
|
||
name = "game";
|
||
route = "tun";
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
|
||
perAppRoutingTproxyProfileWithoutProxy = mkBadFixture [
|
||
{
|
||
services.proxy-suite = {
|
||
proxy.enable = false;
|
||
perAppRouting = {
|
||
enable = true;
|
||
profiles = [
|
||
{
|
||
name = "browser";
|
||
route = "tproxy";
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
|
||
perAppRoutingZapretFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite = {
|
||
zapret = {
|
||
enable = true;
|
||
perApp.enable = true;
|
||
};
|
||
perAppRouting = {
|
||
enable = true;
|
||
createDefaultProfiles = true;
|
||
proxychains.enable = true;
|
||
};
|
||
};
|
||
}
|
||
];
|
||
_perAppRoutingZapret = mkProxyCtlDerived perAppRoutingZapretFixture;
|
||
perAppRoutingZapretProxyCtl = _perAppRoutingZapret.proxyCtl;
|
||
perAppRoutingZapretWrapper = _perAppRoutingZapret.wrapper;
|
||
perAppRoutingZapretScript = _perAppRoutingZapret.script;
|
||
perAppRoutingZapretProfiles = _perAppRoutingZapret.profiles;
|
||
perAppRoutingZapretStartScript =
|
||
readExecScripts
|
||
perAppRoutingZapretFixture.config.systemd.services."proxy-suite-per-app-zapret".serviceConfig.ExecStartPre;
|
||
perAppRoutingZapretUserStartExec =
|
||
perAppRoutingZapretFixture.config.systemd.services."proxy-suite-per-app-zapret-user@".serviceConfig.ExecStart;
|
||
perAppRoutingZapretUserStartScript = builtins.readFile (
|
||
builtins.head (pkgs.lib.splitString " " perAppRoutingZapretUserStartExec)
|
||
);
|
||
perAppRoutingZapretService =
|
||
perAppRoutingZapretFixture.config.systemd.services."proxy-suite-per-app-zapret";
|
||
perAppRoutingZapretBase = mkZapretBase perAppRoutingZapretFixture;
|
||
perAppRoutingZapretConfig = builtins.readFile "${perAppRoutingZapretBase}/config";
|
||
perAppRoutingPerAppZapretBase = mkZapretBaseFor perAppRoutingZapretFixture "proxy-suite-per-app-zapret";
|
||
perAppRoutingPerAppZapretConfig = builtins.readFile "${perAppRoutingPerAppZapretBase}/config";
|
||
perAppRoutingZapretGlobalCustomScript = builtins.readFile "${perAppRoutingZapretBase}/init.d/sysv/custom.d/50-proxy-suite-custom.sh";
|
||
|
||
perAppRoutingZapretWithoutGlobalFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite = {
|
||
zapret = {
|
||
enable = false;
|
||
perApp.enable = true;
|
||
};
|
||
perAppRouting = {
|
||
enable = true;
|
||
createDefaultProfiles = true;
|
||
proxychains.enable = true;
|
||
};
|
||
};
|
||
}
|
||
];
|
||
_perAppRoutingZapretWithoutGlobal = mkProxyCtlDerived perAppRoutingZapretWithoutGlobalFixture;
|
||
perAppRoutingZapretWithoutGlobalProfiles = _perAppRoutingZapretWithoutGlobal.profiles;
|
||
perAppRoutingZapretWithoutGlobalPerAppBase = mkZapretBaseFor perAppRoutingZapretWithoutGlobalFixture "proxy-suite-per-app-zapret";
|
||
perAppRoutingZapretWithoutGlobalPerAppConfig = builtins.readFile "${perAppRoutingZapretWithoutGlobalPerAppBase}/config";
|
||
|
||
perAppRoutingTunPolkitConfig = perAppRoutingTunFixture.config.security.polkit.extraConfig;
|
||
|
||
userControlGlobalOnlyFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.userControl = {
|
||
global.enable = true;
|
||
perApp.enable = false;
|
||
};
|
||
}
|
||
];
|
||
userControlGlobalOnlyPolkitConfig = userControlGlobalOnlyFixture.config.security.polkit.extraConfig;
|
||
|
||
userControlPerAppOnlyFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite = {
|
||
proxy.tun.perApp.enable = true;
|
||
perAppRouting = {
|
||
enable = true;
|
||
createDefaultProfiles = true;
|
||
};
|
||
userControl = {
|
||
global.enable = false;
|
||
perApp.enable = true;
|
||
};
|
||
};
|
||
}
|
||
];
|
||
userControlPerAppOnlyPolkitConfig = userControlPerAppOnlyFixture.config.security.polkit.extraConfig;
|
||
|
||
userControlDisabledFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.userControl = {
|
||
global.enable = false;
|
||
perApp.enable = false;
|
||
};
|
||
}
|
||
];
|
||
|
||
perAppRoutingZapretWithoutEnable = mkBadFixture [
|
||
{
|
||
services.proxy-suite = {
|
||
zapret.enable = true;
|
||
perAppRouting = {
|
||
enable = true;
|
||
profiles = [
|
||
{
|
||
name = "yt";
|
||
route = "zapret";
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
|
||
duplicatePerAppRoutingProfiles = mkBadFixture [
|
||
{
|
||
services.proxy-suite.perAppRouting = {
|
||
enable = true;
|
||
profiles = [
|
||
{ name = "dup"; }
|
||
{ name = "dup"; }
|
||
];
|
||
};
|
||
}
|
||
];
|
||
|
||
perAppRoutingProfilesWithoutEnable = mkBadFixture [
|
||
{ services.proxy-suite.perAppRouting.profiles = [ { name = "oops"; } ]; }
|
||
];
|
||
|
||
perAppRoutingProxychainsWithoutEnable = mkBadFixture [
|
||
{
|
||
services.proxy-suite.perAppRouting = {
|
||
enable = true;
|
||
profiles = [
|
||
{
|
||
name = "steam-browser";
|
||
route = "proxychains";
|
||
}
|
||
];
|
||
};
|
||
}
|
||
];
|
||
|
||
perAppRoutingTunFwmarkCollision = mkBadFixture [
|
||
{
|
||
services.proxy-suite = {
|
||
proxy = {
|
||
tproxy = {
|
||
enable = true;
|
||
proxyMark = 16;
|
||
};
|
||
tun.perApp = {
|
||
enable = true;
|
||
fwmark = 16;
|
||
};
|
||
};
|
||
perAppRouting.enable = true;
|
||
};
|
||
}
|
||
];
|
||
|
||
perAppRoutingTproxyFwmarkCollision = mkBadFixture [
|
||
{
|
||
services.proxy-suite = {
|
||
proxy.tproxy = {
|
||
proxyMark = 17;
|
||
perApp = {
|
||
enable = true;
|
||
fwmark = 17;
|
||
};
|
||
};
|
||
perAppRouting.enable = true;
|
||
};
|
||
}
|
||
];
|
||
|
||
perAppRoutingTunTproxyFwmarkCollision = mkBadFixture [
|
||
{
|
||
services.proxy-suite = {
|
||
proxy = {
|
||
tun.perApp = {
|
||
enable = true;
|
||
fwmark = 23;
|
||
};
|
||
tproxy.perApp = {
|
||
enable = true;
|
||
fwmark = 23;
|
||
};
|
||
};
|
||
perAppRouting.enable = true;
|
||
};
|
||
}
|
||
];
|
||
|
||
perAppRoutingTunTproxyRouteTableCollision = mkBadFixture [
|
||
{
|
||
services.proxy-suite = {
|
||
proxy = {
|
||
tun.perApp = {
|
||
enable = true;
|
||
routeTable = 123;
|
||
};
|
||
tproxy.perApp = {
|
||
enable = true;
|
||
routeTable = 123;
|
||
};
|
||
};
|
||
perAppRouting.enable = true;
|
||
};
|
||
}
|
||
];
|
||
|
||
perAppRoutingZapretFilterMarkCollision = mkBadFixture [
|
||
{
|
||
services.proxy-suite = {
|
||
zapret = {
|
||
enable = true;
|
||
perApp = {
|
||
enable = true;
|
||
filterMark = 268435456;
|
||
};
|
||
};
|
||
proxy.tproxy.proxyMark = 268435456;
|
||
perAppRouting.enable = true;
|
||
};
|
||
}
|
||
];
|
||
|
||
perAppRoutingTproxyZapretMarkCollision = mkBadFixture [
|
||
{
|
||
services.proxy-suite = {
|
||
zapret = {
|
||
enable = true;
|
||
perApp = {
|
||
enable = true;
|
||
filterMark = 23;
|
||
};
|
||
};
|
||
proxy.tproxy.perApp = {
|
||
enable = true;
|
||
fwmark = 23;
|
||
};
|
||
perAppRouting.enable = true;
|
||
};
|
||
}
|
||
];
|
||
|
||
# Validation failures
|
||
subscriptionBothSources = mkBadFixtureRaw [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
subscriptions = [
|
||
{
|
||
tag = "bad";
|
||
url = "https://example.com/sub/token";
|
||
urlFile = "/run/secrets/sub-url";
|
||
}
|
||
];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
|
||
subscriptionNoSources = mkBadFixtureRaw [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
subscriptions = [ { tag = "bad"; } ];
|
||
};
|
||
};
|
||
}
|
||
];
|
||
|
||
localProxyAuthNoPassword = mkBadFixture [
|
||
{ services.proxy-suite.proxy.auth.username = "local-user"; }
|
||
];
|
||
|
||
localProxyAuthNoUsername = mkBadFixture [
|
||
{ services.proxy-suite.proxy.auth.password = "local-pass"; }
|
||
];
|
||
|
||
localProxyAuthBothPasswordSources = mkBadFixture [
|
||
{
|
||
services.proxy-suite.proxy.auth = {
|
||
username = "local-user";
|
||
password = "local-pass";
|
||
passwordFile = "/run/secrets/local-proxy-password";
|
||
};
|
||
}
|
||
];
|
||
|
||
noProxyBackendDefaultFixture = evalProxySuite [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite.enable = true;
|
||
}
|
||
];
|
||
|
||
noOutboundsNoSubscriptions = mkBadFixtureRaw [
|
||
{
|
||
system.stateVersion = "26.05";
|
||
services.proxy-suite = {
|
||
enable = true;
|
||
proxy = {
|
||
enable = true;
|
||
singBox.enable = true;
|
||
};
|
||
};
|
||
}
|
||
];
|
||
|
||
blockGeoFixture = evalProxySuite [
|
||
baseModule
|
||
{
|
||
services.proxy-suite.proxy.routing.block = {
|
||
geosites = [ "category-ads-all" ];
|
||
geoips = [ "cn" ];
|
||
};
|
||
}
|
||
];
|
||
blockGeoRules = mkRoutingRules blockGeoFixture;
|
||
|
||
routingOrRules = mkRoutingRules routingOrFixture;
|
||
|
||
routingOrDomainRules = builtins.filter (
|
||
rule: (rule ? domain_suffix) && rule.domain_suffix == [ "example.com" ]
|
||
) routingOrRules;
|
||
|
||
routingOrGeoIPRules = builtins.filter (
|
||
rule: (rule ? rule_set) && rule.rule_set == [ "geoip-us" ]
|
||
) routingOrRules;
|
||
|
||
validated = builtins.all (x: x) [
|
||
(
|
||
assert minimal.config.services.proxy-suite.proxy.listenAddress == "127.0.0.1";
|
||
true
|
||
)
|
||
# -- proxy.auth: default mixed inbound stays unauthenticated --
|
||
(
|
||
let
|
||
mixedInbound = builtins.head (
|
||
builtins.filter (inbound: inbound.tag == "mixed-in") ruDefaultConfig.inbounds
|
||
);
|
||
in
|
||
assert !(mixedInbound ? users);
|
||
true
|
||
)
|
||
# -- proxy.auth: authenticated mixed inbound is injected at runtime --
|
||
(
|
||
assert pkgs.lib.hasInfix ''LOCAL_PROXY_PASSWORD="$(cat "'' localProxyAuthStartScript;
|
||
assert pkgs.lib.hasInfix "BACKEND_JQ_FILTER=" localProxyAuthStartScript;
|
||
assert pkgs.lib.hasInfix ''-f "$BACKEND_JQ_FILTER"'' localProxyAuthStartScript;
|
||
assert pkgs.lib.hasInfix "--arg user local-user" localProxyAuthStartScript;
|
||
assert pkgs.lib.hasInfix ''--arg password "$LOCAL_PROXY_PASSWORD"'' localProxyAuthStartScript;
|
||
assert pkgs.lib.hasInfix ''select(.type == "mixed" and .tag == "mixed-in") | .users''
|
||
localProxyAuthBackendJqFilter;
|
||
assert pkgs.lib.hasInfix ''chmod 600 "$RUNTIME_DIR/config.json"'' localProxyAuthStartScript;
|
||
true
|
||
)
|
||
# -- proxy.auth: passwordFile is read from runtime path and proxychains uses runtime config --
|
||
(
|
||
assert pkgs.lib.hasInfix "/run/secrets/local-proxy-password" localProxyAuthPasswordFileStartScript;
|
||
assert pkgs.lib.hasInfix "/run/proxy-suite-socks/proxychains.conf"
|
||
localProxyAuthPasswordFileStartScript;
|
||
assert pkgs.lib.hasInfix "printf 'socks5 %s %s %s %s\\n'" localProxyAuthPasswordFileStartScript;
|
||
assert pkgs.lib.hasInfix ''chgrp proxy-suite "/run/proxy-suite-socks/proxychains.conf"''
|
||
localProxyAuthPasswordFileStartScript;
|
||
assert pkgs.lib.hasInfix ''chmod 640 "/run/proxy-suite-socks/proxychains.conf"''
|
||
localProxyAuthPasswordFileStartScript;
|
||
assert builtins.hasAttr "proxy-suite" localProxyAuthPasswordFileFixture.config.users.groups;
|
||
assert
|
||
shellValueByPrefix localProxyAuthPasswordFileWrapper "export PROXYCHAINS_CONFIG="
|
||
== "/run/proxy-suite-socks/proxychains.conf";
|
||
assert pkgs.lib.hasInfix "Proxychains config is not readable" localProxyAuthPasswordFileScript;
|
||
true
|
||
)
|
||
# -- proxy.auth: incomplete or conflicting auth config fails --
|
||
(
|
||
assert localProxyAuthNoPassword.success == false;
|
||
assert localProxyAuthNoUsername.success == false;
|
||
assert localProxyAuthBothPasswordSources.success == false;
|
||
true
|
||
)
|
||
(
|
||
assert tgSecretFile.config.services.proxy-suite.tgWsProxy.host == "127.0.0.1";
|
||
true
|
||
)
|
||
(
|
||
assert minimal.config.services.proxy-suite.tgWsProxy.host == "127.0.0.1";
|
||
true
|
||
)
|
||
(
|
||
assert minimal.config.services.proxy-suite.tgWsProxy.dcIps == { };
|
||
true
|
||
)
|
||
# -- tg-ws-proxy: upstream runtime flags are exposed as typed module options --
|
||
(
|
||
assert pkgs.lib.hasInfix "--port=2443" tgAllOptionsStartScript;
|
||
assert pkgs.lib.hasInfix "--host=0.0.0.0" tgAllOptionsStartScript;
|
||
assert pkgs.lib.hasInfix "--secret-file=\"$CREDENTIALS_DIRECTORY/tg_ws_proxy_secret\""
|
||
tgAllOptionsStartScript;
|
||
assert pkgs.lib.hasInfix "--verbose" tgAllOptionsStartScript;
|
||
assert pkgs.lib.hasInfix "--log-file=/var/log/tg-ws-proxy.log" tgAllOptionsStartScript;
|
||
assert pkgs.lib.hasInfix "--log-max-mb=2.500000" tgAllOptionsStartScript;
|
||
assert pkgs.lib.hasInfix "--log-backups=3" tgAllOptionsStartScript;
|
||
assert pkgs.lib.hasInfix "--buf-kb=512" tgAllOptionsStartScript;
|
||
assert pkgs.lib.hasInfix "--pool-size=8" tgAllOptionsStartScript;
|
||
assert pkgs.lib.hasInfix "--cfproxy-domain=cdn.example.com" tgAllOptionsStartScript;
|
||
assert pkgs.lib.hasInfix "--cfproxy-domain=edge.example.net" tgAllOptionsStartScript;
|
||
assert pkgs.lib.hasInfix "--cfproxy-worker-domain=worker.example.com" tgAllOptionsStartScript;
|
||
assert pkgs.lib.hasInfix "--no-cfproxy" tgAllOptionsStartScript;
|
||
assert pkgs.lib.hasInfix "--fake-tls-domain=mask.example.com" tgAllOptionsStartScript;
|
||
assert pkgs.lib.hasInfix "--proxy-protocol" tgAllOptionsStartScript;
|
||
assert pkgs.lib.hasInfix "--ws-keepalive=0" tgAllOptionsStartScript;
|
||
assert tgInvalidBufKb.success == false;
|
||
assert tgInvalidPoolSize.success == false;
|
||
assert tgInvalidLogBackups.success == false;
|
||
assert tgInvalidWsKeepalive.success == false;
|
||
true
|
||
)
|
||
(
|
||
assert
|
||
tgSecretFile.config.systemd.services."proxy-suite-tg-ws-proxy".serviceConfig.LoadCredential
|
||
== [ "tg_ws_proxy_secret:/run/secrets/tg-ws-proxy" ];
|
||
true
|
||
)
|
||
# -- tg-ws-proxy: global TUN/TProxy bypass mark keeps relay traffic out of transparent capture --
|
||
(
|
||
assert tgWithGlobalTunServiceConfig.SocketMark == "4";
|
||
assert pkgs.lib.hasInfix "rule add pref 8999 fwmark 4 lookup main" tgWithGlobalTunBypassUp;
|
||
assert pkgs.lib.hasInfix "rule del pref 8999 fwmark 4 lookup main" tgWithGlobalTunBypassDown;
|
||
assert hasDirectIP tgWithGlobalTunRules "149.154.167.220";
|
||
assert pkgs.lib.hasInfix "meta mark 4 return" tgWithGlobalTproxyNft;
|
||
assert tgRoutingMarkCollision.success == false;
|
||
true
|
||
)
|
||
# -- boot ordering: network-sensitive global services wait for network-online --
|
||
(
|
||
assert builtins.elem "network-online.target" minimalSocksService.after;
|
||
assert builtins.elem "network-online.target" minimalSocksService.wants;
|
||
assert builtins.elem "network-online.target" tgSecretFileService.after;
|
||
assert builtins.elem "network-online.target" tgSecretFileService.wants;
|
||
assert builtins.elem "network-online.target" zapretSyncService.after;
|
||
assert builtins.elem "network-online.target" zapretSyncService.wants;
|
||
true
|
||
)
|
||
# -- sing-box package override propagates into generated service scripts --
|
||
(
|
||
assert pkgs.lib.hasInfix customSingBoxPackageBin customSingBoxPackageStartScript;
|
||
true
|
||
)
|
||
# -- hybrid backend: sing-box frontend with XRay loopback sidecar --
|
||
(
|
||
let
|
||
dnsBridgeInbound = builtins.head (
|
||
builtins.filter (inbound: inbound.tag == "xray-dns-in") hybridTproxyConfig.inbounds
|
||
);
|
||
mixedInbound = builtins.head (
|
||
builtins.filter (inbound: inbound.tag == "mixed-in") hybridTproxyConfig.inbounds
|
||
);
|
||
tproxyInbound = builtins.head (
|
||
builtins.filter (inbound: inbound.tag == "tproxy-in") hybridTproxyConfig.inbounds
|
||
);
|
||
tunDnsBridgeInbound = builtins.head (
|
||
builtins.filter (inbound: inbound.tag == "xray-dns-in") hybridTunConfig.inbounds
|
||
);
|
||
dnsBridgeRouteRule = builtins.head (
|
||
builtins.filter (
|
||
rule:
|
||
(rule.action or "") == "hijack-dns" && (rule ? inbound) && builtins.elem "xray-dns-in" rule.inbound
|
||
) hybridTproxyConfig.route.rules
|
||
);
|
||
in
|
||
assert hybridFixture.config.services.proxy-suite.proxy.singBox.enable;
|
||
assert hybridFixture.config.services.proxy-suite.proxy.xray.enable;
|
||
assert hybridTproxyConfig ? route;
|
||
assert !(hybridTproxyConfig ? routing);
|
||
assert dnsBridgeInbound.type == "direct";
|
||
assert dnsBridgeInbound.listen == "127.0.0.1";
|
||
assert dnsBridgeInbound.listen_port == 18533;
|
||
assert mixedInbound.type == "mixed";
|
||
assert tproxyInbound.type == "tproxy";
|
||
assert tunDnsBridgeInbound.listen_port == 18534;
|
||
assert
|
||
dnsBridgeRouteRule.network == [
|
||
"tcp"
|
||
"udp"
|
||
];
|
||
assert pkgs.lib.hasInfix "/bin/sing-box run -c" hybridStartScript;
|
||
assert pkgs.lib.hasInfix "/bin/xray run -c" hybridStartScript;
|
||
assert pkgs.lib.hasInfix "xray-sidecar.json" hybridStartScript;
|
||
assert pkgs.lib.hasInfix "XRAY_SIDECAR_NEXT_PORT=33080" hybridStartScript;
|
||
assert pkgs.lib.hasInfix "XRAY_SIDECAR_DNS_PORT=18533" hybridStartScript;
|
||
assert pkgs.lib.hasInfix "XRAY_SIDECAR_NEXT_PORT=33180" hybridTunStartScript;
|
||
assert pkgs.lib.hasInfix "XRAY_SIDECAR_DNS_PORT=18534" hybridTunStartScript;
|
||
assert pkgs.lib.hasInfix "XRAY_SIDECAR_NEXT_PORT=33280" hybridPerAppTunStartScript;
|
||
assert pkgs.lib.hasInfix "XRAY_SIDECAR_DNS_PORT=18535" hybridPerAppTunStartScript;
|
||
assert pkgs.lib.hasInfix "--backend sing-box" hybridStartScript;
|
||
assert pkgs.lib.hasInfix "--backend xray" hybridStartScript;
|
||
assert pkgs.lib.hasInfix "_proxy_suite_add_xray_sidecar_ob" hybridStartScript;
|
||
assert pkgs.lib.hasInfix "hybrid XRay json sidecar" hybridXrayRawStartScript;
|
||
assert pkgs.lib.hasInfix ''{type:"socks",tag:$tag,server:"127.0.0.1"'' hybridXrayRawStartScript;
|
||
assert pkgs.lib.hasInfix "udp:true" hybridXrayRawStartScript;
|
||
assert pkgs.lib.hasInfix "routing_mark:2" hybridXrayRawStartScript;
|
||
assert pkgs.lib.hasInfix "sing_box_preserved_rules" hybridBackendJqFilter;
|
||
assert pkgs.lib.hasInfix "xray-dns-in" hybridBackendJqFilter;
|
||
assert pkgs.lib.hasInfix "--backend hybrid" hybridSubscriptionStartScript;
|
||
assert pkgs.lib.hasInfix "--backend hybrid" hybridSubscriptionUpdateScript;
|
||
assert pkgs.lib.hasInfix
|
||
''type == "object" and (.singBox | type == "array") and (.xray | type == "array")''
|
||
hybridSubscriptionStartScript;
|
||
assert pkgs.lib.hasInfix ".singBox" hybridSubscriptionStartScript;
|
||
assert pkgs.lib.hasInfix ".xray[]" hybridSubscriptionStartScript;
|
||
assert pkgs.lib.hasInfix "_proxy_suite_add_xray_sidecar_ob" hybridSubscriptionStartScript;
|
||
true
|
||
)
|
||
# -- xray backend: same service surface, XRay config shape, and urltest balancer --
|
||
(
|
||
let
|
||
socksInbound = builtins.head (
|
||
builtins.filter (inbound: inbound.tag == "mixed-in") xrayTproxyConfig.inbounds
|
||
);
|
||
tproxyInbound = builtins.head (
|
||
builtins.filter (inbound: inbound.tag == "tproxy-in") xrayTproxyConfig.inbounds
|
||
);
|
||
specificRule = builtins.head (
|
||
builtins.filter (
|
||
rule: (rule ? domain) && builtins.elem "domain:specific.example" rule.domain
|
||
) xrayTproxyConfig.routing.rules
|
||
);
|
||
balancer = builtins.head xrayTproxyConfig.routing.balancers;
|
||
in
|
||
assert xrayFixture.config.services.proxy-suite.proxy.xray.enable;
|
||
assert xrayFixture.config.systemd.services ? "proxy-suite-socks";
|
||
assert xrayFixture.config.systemd.services ? "proxy-suite-tproxy";
|
||
assert xrayFixture.config.systemd.services ? "proxy-suite-tun";
|
||
assert xrayFixture.config.systemd.services ? "proxy-suite-per-app-tun";
|
||
assert pkgs.lib.hasInfix "/bin/xray run -c" xrayStartScript;
|
||
assert pkgs.lib.hasInfix "--backend xray" xrayStartScript;
|
||
assert socksInbound.protocol == "socks";
|
||
assert socksInbound.settings.auth == "noauth";
|
||
assert socksInbound.settings.udp == true;
|
||
assert tproxyInbound.protocol == "tunnel";
|
||
assert tproxyInbound.settings.followRedirect == true;
|
||
assert tproxyInbound.streamSettings.sockopt.tproxy == "tproxy";
|
||
assert specificRule.outboundTag == "proxy-suite-ob-primary";
|
||
assert specificRule.ruleTag == "custom-proxy-domain";
|
||
assert balancer.tag == "proxy";
|
||
assert balancer.selector == [ "proxy-suite-ob-" ];
|
||
assert balancer.strategy.type == "leastPing";
|
||
assert xrayTproxyConfig.observatory.subjectSelector == [ "proxy-suite-ob-" ];
|
||
assert xrayTproxyConfig.observatory.probeUrl == "https://www.gstatic.com/generate_204";
|
||
true
|
||
)
|
||
(
|
||
let
|
||
tunInbound = builtins.head (
|
||
builtins.filter (inbound: inbound.tag == "tun-in") xrayTunConfig.inbounds
|
||
);
|
||
perAppTunInbound = builtins.head (
|
||
builtins.filter (inbound: inbound.tag == "tun-in") xrayPerAppTunConfig.inbounds
|
||
);
|
||
tunDirectOutbound = builtins.head (
|
||
builtins.filter (outbound: outbound.tag == "direct") xrayTunConfig.outbounds
|
||
);
|
||
perAppTunDirectOutbound = builtins.head (
|
||
builtins.filter (outbound: outbound.tag == "direct") xrayPerAppTunConfig.outbounds
|
||
);
|
||
tunDnsOutbound = builtins.head (
|
||
builtins.filter (outbound: outbound.tag == "dns-out") xrayTunConfig.outbounds
|
||
);
|
||
tunHasFinalRuleTag = builtins.any (
|
||
rule: (rule ? ruleTag) && rule.ruleTag == "final-default"
|
||
) xrayTunConfig.routing.rules;
|
||
tunHasDirectGeositeRule = builtins.any (
|
||
rule: (rule ? ruleTag) && rule.ruleTag == "direct-geosite"
|
||
) xrayTunConfig.routing.rules;
|
||
tunHasDnsHijackRule = builtins.any (
|
||
rule: (rule ? ruleTag) && rule.ruleTag == "dns-hijack"
|
||
) xrayTunConfig.routing.rules;
|
||
tunHasDnsUpstreamRule = builtins.any (
|
||
rule: (rule ? ruleTag) && rule.ruleTag == "dns-upstream-direct"
|
||
) xrayTunConfig.routing.rules;
|
||
in
|
||
assert tunInbound.protocol == "tun";
|
||
assert tunInbound.settings.name == "singtun0";
|
||
assert
|
||
tunInbound.settings.gateway == [
|
||
"172.19.0.1/30"
|
||
"fd66:19::1/64"
|
||
];
|
||
assert builtins.length tunInbound.settings.dns == 2;
|
||
assert tunInbound.settings.autoOutboundsInterface == "auto";
|
||
assert tunInbound.sniffing.destOverride == [ "fakedns" ];
|
||
assert tunInbound.sniffing.metadataOnly == true;
|
||
assert xrayTunConfig.routing.domainStrategy == "IPIfNonMatch";
|
||
assert tunHasFinalRuleTag;
|
||
assert tunHasDirectGeositeRule;
|
||
assert tunHasDnsHijackRule;
|
||
assert tunHasDnsUpstreamRule;
|
||
assert xrayTunConfig.dns.queryStrategy == "UseIP";
|
||
assert xrayTunConfig.dns.tag == "dns-in";
|
||
assert (builtins.head xrayTunConfig.dns.servers).address == "fakedns";
|
||
assert (builtins.head xrayTunConfig.dns.servers).tag == "fakedns";
|
||
assert (builtins.elemAt xrayTunConfig.dns.servers 1).tag == "remote";
|
||
assert (builtins.elemAt xrayTunConfig.dns.servers 2).tag == "local";
|
||
assert builtins.length xrayTunConfig.fakedns == 2;
|
||
assert tunDnsOutbound.protocol == "dns";
|
||
assert
|
||
tunDnsOutbound.settings.rules == [
|
||
{
|
||
action = "direct";
|
||
qType = "2-27,29-65535";
|
||
}
|
||
];
|
||
assert tunDirectOutbound.streamSettings.sockopt.mark == 2;
|
||
assert xrayStartBackendJqFilterFile == xrayTunBackendJqFilterFile;
|
||
assert xrayTunBackendJqFilterFile == xrayPerAppTunBackendJqFilterFile;
|
||
assert pkgs.lib.hasInfix "BACKEND_JQ_FILTER=" xrayStartScript;
|
||
assert pkgs.lib.hasInfix ''-f "$BACKEND_JQ_FILTER"'' xrayStartScript;
|
||
assert pkgs.lib.hasInfix
|
||
''select(.protocol == "socks" and .tag == "mixed-in") | .settings.accounts''
|
||
xrayBackendJqFilter;
|
||
assert
|
||
!(pkgs.lib.hasInfix ''select(.protocol == "socks" and .tag == "mixed-in") | .settings.users'' xrayBackendJqFilter);
|
||
assert pkgs.lib.hasInfix "xray-loglevel" xrayTunStartScript;
|
||
assert pkgs.lib.hasInfix "XRAY_SINGLE_PROXY_TAG=" xrayTunStartScript;
|
||
assert pkgs.lib.hasInfix "ip -4 route get 1.1.1.1" xrayTunStartScript;
|
||
assert pkgs.lib.hasInfix "ip -4 route get 1.1.1.1 mark 2" xrayTunStartScript;
|
||
assert pkgs.lib.hasInfix "BACKEND_JQ_FILTER=" xrayTunStartScript;
|
||
assert pkgs.lib.hasInfix ''-f "$BACKEND_JQ_FILTER"'' xrayTunStartScript;
|
||
assert pkgs.lib.hasInfix "xray_tun_dns_runtime" xrayTunStartScript;
|
||
assert pkgs.lib.hasInfix "xray_preserved_rules" xrayBackendJqFilter;
|
||
assert pkgs.lib.hasInfix "dns-upstream-direct" xrayBackendJqFilter;
|
||
assert pkgs.lib.hasInfix "xray_tun_dns_addresses" xrayBackendJqFilter;
|
||
assert pkgs.lib.hasInfix "dns-hijack" xrayBackendJqFilter;
|
||
assert pkgs.lib.hasInfix ".streamSettings.sockopt.interface = $interface" xrayBackendJqFilter;
|
||
assert pkgs.lib.hasInfix "del(.routing.balancers)" xrayBackendJqFilter;
|
||
assert pkgs.lib.hasInfix "del(.observatory)" xrayBackendJqFilter;
|
||
assert pkgs.lib.hasInfix "xray_rewrite_proxy_rule" xrayBackendJqFilter;
|
||
assert pkgs.lib.hasInfix ".protocol == \"dns\"" xrayBackendJqFilter;
|
||
assert pkgs.lib.hasInfix ''tun_route_prefix="$(cidr_network "$tun_cidr")"'' xrayTunUpScript;
|
||
assert pkgs.lib.hasInfix "fd66:19::1/64" xrayTunUpScript;
|
||
assert pkgs.lib.hasInfix ''uplink_addr="$('' xrayTunUpScript;
|
||
assert pkgs.lib.hasInfix ''addr replace "$tun_cidr" dev singtun0'' xrayTunUpScript;
|
||
assert pkgs.lib.hasInfix ''-6 addr replace "$tun6_cidr" dev singtun0'' xrayTunUpScript;
|
||
assert pkgs.lib.hasInfix
|
||
''route replace "$tun_route_prefix" dev singtun0 src "$tun_addr" table 2022''
|
||
xrayTunUpScript;
|
||
assert pkgs.lib.hasInfix ''route replace default dev singtun0 src "$uplink_addr" table 2022''
|
||
xrayTunUpScript;
|
||
assert pkgs.lib.hasInfix ''-6 route replace "$tun6_route_prefix" dev singtun0 table 2022''
|
||
xrayTunUpScript;
|
||
assert pkgs.lib.hasInfix "-6 route replace default dev singtun0 table 2022" xrayTunUpScript;
|
||
assert pkgs.lib.hasInfix "rule add pref 8996 fwmark 17 table 102" xrayTunUpScript;
|
||
assert pkgs.lib.hasInfix "rule add pref 8997 fwmark 16 table 101" xrayTunUpScript;
|
||
assert pkgs.lib.hasInfix "rule add pref 9000 not fwmark 2 table 2022" xrayTunUpScript;
|
||
assert pkgs.lib.hasInfix "-6 rule add pref 8997 fwmark 16 table 101" xrayTunUpScript;
|
||
assert pkgs.lib.hasInfix "-6 rule add pref 9000 not fwmark 2 table 2022" xrayTunUpScript;
|
||
assert perAppTunInbound.settings.name == "psperapptun0";
|
||
assert
|
||
perAppTunInbound.settings.gateway == [
|
||
"172.20.0.1/30"
|
||
"fd66:20::1/64"
|
||
];
|
||
assert builtins.length perAppTunInbound.settings.dns == 2;
|
||
assert perAppTunInbound.sniffing.destOverride == [ "fakedns" ];
|
||
assert perAppTunInbound.sniffing.metadataOnly == true;
|
||
assert xrayPerAppTunConfig.routing.domainStrategy == "IPIfNonMatch";
|
||
assert (builtins.head xrayPerAppTunConfig.dns.servers).address == "fakedns";
|
||
assert xrayPerAppTunConfig.dns.tag == "dns-in";
|
||
assert builtins.length xrayPerAppTunConfig.fakedns == 2;
|
||
assert perAppTunDirectOutbound.streamSettings.sockopt.mark == 2;
|
||
assert pkgs.lib.hasInfix "XRAY_SINGLE_PROXY_TAG=" xrayPerAppTunStartScript;
|
||
assert pkgs.lib.hasInfix "ip -4 route get 1.1.1.1" xrayPerAppTunStartScript;
|
||
assert pkgs.lib.hasInfix "ip -4 route get 1.1.1.1 mark 2" xrayPerAppTunStartScript;
|
||
assert pkgs.lib.hasInfix "BACKEND_JQ_FILTER=" xrayPerAppTunStartScript;
|
||
assert pkgs.lib.hasInfix ''-f "$BACKEND_JQ_FILTER"'' xrayPerAppTunStartScript;
|
||
assert pkgs.lib.hasInfix "--routing-mark 2" xrayPerAppTunStartScript;
|
||
assert pkgs.lib.hasInfix "xray_tun_dns_runtime" xrayPerAppTunStartScript;
|
||
assert pkgs.lib.hasInfix ".streamSettings.sockopt.interface = $interface" xrayBackendJqFilter;
|
||
assert pkgs.lib.hasInfix "del(.routing.balancers)" xrayBackendJqFilter;
|
||
assert pkgs.lib.hasInfix "del(.observatory)" xrayBackendJqFilter;
|
||
assert pkgs.lib.hasInfix ''tun_route_prefix="$(cidr_network "$tun_cidr")"'' xrayPerAppTunUpScript;
|
||
assert pkgs.lib.hasInfix "fd66:20::1/64" xrayPerAppTunUpScript;
|
||
assert pkgs.lib.hasInfix ''uplink_addr="$('' xrayPerAppTunUpScript;
|
||
assert pkgs.lib.hasInfix ''addr replace "$tun_cidr" dev psperapptun0'' xrayPerAppTunUpScript;
|
||
assert pkgs.lib.hasInfix ''-6 addr replace "$tun6_cidr" dev psperapptun0'' xrayPerAppTunUpScript;
|
||
assert pkgs.lib.hasInfix
|
||
''route replace "$tun_route_prefix" dev psperapptun0 src "$tun_addr" table 101''
|
||
xrayPerAppTunUpScript;
|
||
assert pkgs.lib.hasInfix ''route replace default dev psperapptun0 src "$uplink_addr" table 101''
|
||
xrayPerAppTunUpScript;
|
||
assert pkgs.lib.hasInfix ''-6 route replace "$tun6_route_prefix" dev psperapptun0 table 101''
|
||
xrayPerAppTunUpScript;
|
||
assert pkgs.lib.hasInfix "-6 route replace default dev psperapptun0 table 101"
|
||
xrayPerAppTunUpScript;
|
||
assert pkgs.lib.hasInfix "-6 rule add fwmark 16 table 101" xrayPerAppTunUpScript;
|
||
assert pkgs.lib.hasInfix "-4 route flush table 101" xrayPerAppTunCleanupScript;
|
||
assert pkgs.lib.hasInfix "-6 route flush table 101" xrayPerAppTunCleanupScript;
|
||
assert pkgs.lib.hasInfix "resolvectl flush-caches" xrayPerAppTunCleanupScript;
|
||
true
|
||
)
|
||
(
|
||
assert pkgs.lib.hasInfix ''CACHE_FILE="/var/lib/proxy-suite/subscriptions/xray/xray-sub.json"''
|
||
xraySubscriptionStartScript;
|
||
assert pkgs.lib.hasInfix "--backend xray" xraySubscriptionStartScript;
|
||
true
|
||
)
|
||
# -- xray backend: raw stream settings and DNS encoding are preserved --
|
||
(
|
||
let
|
||
localDns = dnsServerByTag xrayDnsTcpConfig "local";
|
||
in
|
||
assert xrayRawStreamOutbound.tag == "proxy";
|
||
assert xrayRawStreamOutbound.streamSettings.network == "ws";
|
||
assert xrayRawStreamOutbound.streamSettings.security == "tls";
|
||
assert xrayRawStreamOutbound.streamSettings.tlsSettings.serverName == "cdn.example.com";
|
||
assert xrayRawStreamOutbound.streamSettings.wsSettings.path == "/ws";
|
||
assert xrayRawStreamOutbound.streamSettings.sockopt.tcpFastOpen == true;
|
||
assert xrayRawStreamOutbound.streamSettings.sockopt.mark == 2;
|
||
assert localDns.address == "tcp://9.9.9.9";
|
||
assert localDns.port == 5353;
|
||
assert localDns.queryStrategy == "UseIP";
|
||
assert xrayDnsTlsUnavailable.success == false;
|
||
true
|
||
)
|
||
# -- backend selection and backend-specific raw JSON options are enforced --
|
||
(
|
||
assert proxyEnabledNoBackend.success == false;
|
||
assert xraySelectorUnavailable.success == false;
|
||
assert xraySingBoxJsonUnavailable.success == false;
|
||
assert singBoxXrayJsonUnavailable.success == false;
|
||
true
|
||
)
|
||
(
|
||
assert duplicateTags.success == false;
|
||
true
|
||
)
|
||
(
|
||
assert reservedTag.success == false;
|
||
true
|
||
)
|
||
(
|
||
assert unknownRoutingTarget.success == false;
|
||
true
|
||
)
|
||
(
|
||
assert duplicateZapretHostlistNames.success == false;
|
||
true
|
||
)
|
||
(
|
||
assert emptyZapretHostlistDomains.success == false;
|
||
true
|
||
)
|
||
(
|
||
assert missingZapretHostlistAction.success == false;
|
||
true
|
||
)
|
||
(
|
||
assert tproxyWithFirewall.config.networking.firewall.enable;
|
||
true
|
||
)
|
||
(
|
||
assert tproxyManualFixture.config.services.proxy-suite.proxy.tproxy.autostart == false;
|
||
assert tproxyManualFixture.config.systemd.services."proxy-suite-tproxy".wantedBy == [ ];
|
||
true
|
||
)
|
||
(
|
||
assert
|
||
tproxyAutostartFixture.config.systemd.services."proxy-suite-tproxy".wantedBy
|
||
== [ "multi-user.target" ];
|
||
true
|
||
)
|
||
(
|
||
assert pkgs.lib.hasInfix "set -euo pipefail" tproxyManualStartScript;
|
||
assert pkgs.lib.hasInfix "rule del fwmark 1 table 100" tproxyManualStartScript;
|
||
assert pkgs.lib.hasInfix "route replace local default dev lo table 100" tproxyManualStartScript;
|
||
assert pkgs.lib.hasInfix "set +e" tproxyManualStopScript;
|
||
assert pkgs.lib.hasInfix "rule del fwmark 1 table 100" tproxyManualStopScript;
|
||
true
|
||
)
|
||
(
|
||
assert tunManualFixture.config.services.proxy-suite.proxy.tun.autostart == false;
|
||
assert tunManualFixture.config.systemd.services."proxy-suite-tun".wantedBy == [ ];
|
||
true
|
||
)
|
||
(
|
||
let
|
||
inbound = builtins.head (builtins.filter (item: item.tag == "tun-in") tunDefaultConfig.inbounds);
|
||
in
|
||
assert inbound.iproute2_table_index == 2022;
|
||
assert inbound.iproute2_rule_index == 9000;
|
||
assert tunDefaultConfig.route.auto_detect_interface == true;
|
||
true
|
||
)
|
||
(
|
||
assert tunManualFixture.config.networking.nftables.enable;
|
||
true
|
||
)
|
||
(
|
||
assert tunServiceConfig.ExecStartPre == tunServiceConfig.ExecStopPost;
|
||
assert pkgs.lib.hasInfix "delete table inet sing-box" tunCleanupScript;
|
||
assert pkgs.lib.hasInfix "rule del table 2022" tunCleanupScript;
|
||
assert pkgs.lib.hasInfix "rule del pref 8996" tunCleanupScript;
|
||
assert pkgs.lib.hasInfix "rule del pref 8997" tunCleanupScript;
|
||
assert pkgs.lib.hasInfix "route flush table 2022" tunCleanupScript;
|
||
assert pkgs.lib.hasInfix "link del dev" tunCleanupScript;
|
||
assert pkgs.lib.hasInfix "singtun0" tunCleanupScript;
|
||
true
|
||
)
|
||
(
|
||
assert
|
||
tunAutostartFixture.config.systemd.services."proxy-suite-tun".wantedBy == [ "multi-user.target" ];
|
||
true
|
||
)
|
||
(
|
||
assert conflictingAutostartModes.success == false;
|
||
true
|
||
)
|
||
(
|
||
assert globalTunWithoutProxy.success == false;
|
||
assert globalTproxyWithoutProxy.success == false;
|
||
true
|
||
)
|
||
(
|
||
assert builtins.length routingOrDomainRules == 1;
|
||
true
|
||
)
|
||
(
|
||
assert builtins.length routingOrGeoIPRules == 1;
|
||
true
|
||
)
|
||
(
|
||
assert (builtins.head routingOrDomainRules).outbound == "proxy";
|
||
true
|
||
)
|
||
(
|
||
assert (builtins.head routingOrGeoIPRules).outbound == "proxy";
|
||
true
|
||
)
|
||
(
|
||
let
|
||
localDns = dnsServerByTag ruDefaultConfig "local";
|
||
remoteDns = dnsServerByTag ruDefaultConfig "remote";
|
||
in
|
||
assert localDns.type == "udp";
|
||
assert localDns.server == "1.1.1.1";
|
||
assert localDns.server_port == 53;
|
||
assert !(localDns ? detour);
|
||
assert remoteDns.type == "udp";
|
||
assert remoteDns.server == "1.1.1.1";
|
||
assert remoteDns.server_port == 53;
|
||
assert remoteDns.detour == "proxy";
|
||
true
|
||
)
|
||
(
|
||
assert hasRuleSet ruDefaultRules "direct" "geosite-category-ru";
|
||
true
|
||
)
|
||
(
|
||
assert hasRuleSet ruDefaultRules "direct" "geoip-ru";
|
||
true
|
||
)
|
||
(
|
||
assert dnsHasRuleSet ruDefaultConfig.dns.rules "geosite-category-ru";
|
||
true
|
||
)
|
||
(
|
||
assert !(hasRuleSet ruDisabledRules "direct" "geosite-category-ru");
|
||
true
|
||
)
|
||
(
|
||
assert !(hasRuleSet ruDisabledRules "direct" "geoip-ru");
|
||
true
|
||
)
|
||
(
|
||
assert !(dnsHasRuleSet ruDisabledConfig.dns.rules "geosite-category-ru");
|
||
true
|
||
)
|
||
(
|
||
assert dnsHasRuleSet ruExplicitConfig.dns.rules "geosite-category-ru";
|
||
true
|
||
)
|
||
(
|
||
let
|
||
localDns = dnsServerByTag dnsLocalOverrideConfig "local";
|
||
in
|
||
assert localDns.type == "tcp";
|
||
assert localDns.server == "9.9.9.9";
|
||
assert localDns.server_port == 5353;
|
||
assert !(localDns ? detour);
|
||
true
|
||
)
|
||
(
|
||
let
|
||
remoteDns = dnsServerByTag dnsRemoteOverrideConfig "remote";
|
||
in
|
||
assert remoteDns.type == "tls";
|
||
assert remoteDns.server == "1.0.0.1";
|
||
assert remoteDns.server_port == 853;
|
||
assert remoteDns.detour == "proxy";
|
||
true
|
||
)
|
||
(
|
||
let
|
||
localDns = dnsServerByTag tunDefaultConfig "local";
|
||
in
|
||
assert !(localDns ? detour);
|
||
true
|
||
)
|
||
(
|
||
assert hasDirectDomain zapretSyncRules "discord.com";
|
||
true
|
||
)
|
||
(
|
||
assert hasDirectDomain zapretSyncRules "youtube.com";
|
||
true
|
||
)
|
||
(
|
||
assert hasDirectDomain zapretSyncRules "cloudflare-ech.com";
|
||
true
|
||
)
|
||
(
|
||
assert !(hasDirectDomain zapretSyncRules "twitter.com");
|
||
true
|
||
)
|
||
(
|
||
assert !(hasDirectIP zapretSyncRules "1.1.1.0/24");
|
||
true
|
||
)
|
||
(
|
||
assert hasDirectDomain zapretSyncDomainsOnlyRules "cloudflare-ech.com";
|
||
true
|
||
)
|
||
(
|
||
assert !(hasDirectIP zapretSyncDomainsOnlyRules "1.1.1.0/24");
|
||
true
|
||
)
|
||
(
|
||
assert hasDirectIP zapretSyncIpsRules "1.1.1.0/24";
|
||
true
|
||
)
|
||
(
|
||
assert !(hasDirectDomain zapretSyncNoExtraListsRules "twitter.com");
|
||
true
|
||
)
|
||
(
|
||
assert hasDirectDomain zapretSyncExtraListsRules "twitter.com";
|
||
true
|
||
)
|
||
(
|
||
assert !(hasDirectIP zapretSyncUserIpsDisabledRules "203.0.113.0/24");
|
||
true
|
||
)
|
||
(
|
||
assert !(hasDirectDomain zapretSyncDisabledRules "discord.com");
|
||
true
|
||
)
|
||
(
|
||
assert !(hasDirectIP zapretSyncDisabledRules "1.1.1.0/24");
|
||
true
|
||
)
|
||
(
|
||
assert hasDirectDomain zapretExtrasRules "pixiv.net";
|
||
true
|
||
)
|
||
(
|
||
assert hasDirectIP zapretIpExtrasRules "203.0.113.0/24";
|
||
true
|
||
)
|
||
(
|
||
assert !(hasDirectDomain zapretExcludesRules "discord.com");
|
||
true
|
||
)
|
||
(
|
||
assert !(hasDirectIP zapretIpExcludesRules "1.1.1.0/24");
|
||
true
|
||
)
|
||
(
|
||
assert hasDirectDomain zapretHostlistRules "googlevideo.com";
|
||
true
|
||
)
|
||
(
|
||
assert hasDirectDomain zapretHostlistRules "example.com";
|
||
true
|
||
)
|
||
(
|
||
assert !(hasDirectDomain zapretHostlistRules "x.example");
|
||
true
|
||
)
|
||
(
|
||
assert hasRuleSet blockGeoRules "block" "geosite-category-ads-all";
|
||
true
|
||
)
|
||
(
|
||
assert hasRuleSet blockGeoRules "block" "geoip-cn";
|
||
true
|
||
)
|
||
(
|
||
assert proxyDirectConfig.dns.final == "local";
|
||
true
|
||
)
|
||
(
|
||
assert ruDefaultConfig.dns.final == "remote";
|
||
true
|
||
)
|
||
(
|
||
assert ruDefaultConfig.route.default_domain_resolver == "local";
|
||
assert tunDefaultConfig.route.default_domain_resolver == "local";
|
||
assert perAppRoutingTunConfig.route.default_domain_resolver == "local";
|
||
true
|
||
)
|
||
(
|
||
assert packagePathMatches trayAutostartFixture.config.environment.systemPackages
|
||
".*/[^/]*proxy-suite-tray(-[0-9.]+)?$";
|
||
true
|
||
)
|
||
(
|
||
assert packagePathMatches trayAutostartFixture.config.environment.systemPackages
|
||
".*/[^/]*proxy-suite-tray\\.desktop$";
|
||
true
|
||
)
|
||
(
|
||
assert
|
||
builtins.match ".*/share/xdg/autostart/proxy-suite-tray\\.desktop$" (
|
||
builtins.unsafeDiscardStringContext
|
||
trayAutostartFixture.config.environment.etc."xdg/autostart/proxy-suite-tray.desktop".source
|
||
) != null;
|
||
true
|
||
)
|
||
(
|
||
assert !(trayManualFixture.config.environment.etc ? "xdg/autostart/proxy-suite-tray.desktop");
|
||
true
|
||
)
|
||
(
|
||
assert packagePathMatches trayManualFixture.config.environment.systemPackages
|
||
".*/[^/]*proxy-suite-tray\\.desktop$";
|
||
true
|
||
)
|
||
|
||
# -- subscription: basic config is accepted --
|
||
(
|
||
assert subscriptionOnlyFixture.config.services.proxy-suite.proxy.subscriptions != [ ];
|
||
true
|
||
)
|
||
|
||
# -- subscription: wrapper exposes tags through a JSON file, not shell word splitting --
|
||
(
|
||
assert subscriptionOnlyTags == [ "community" ];
|
||
assert pkgs.lib.hasInfix "export SUB_TAGS_FILE=" subscriptionOnlyScript;
|
||
assert !(pkgs.lib.hasInfix "SUB_TAGS_RAW" subscriptionOnlyScript);
|
||
true
|
||
)
|
||
|
||
# -- subscription: update service is created when subscriptions are configured --
|
||
(
|
||
assert subscriptionOnlyFixture.config.systemd.services ? "proxy-suite-subscription-update";
|
||
true
|
||
)
|
||
|
||
# -- subscription: update timer is created when subscriptions are configured --
|
||
(
|
||
assert subscriptionOnlyFixture.config.systemd.timers ? "proxy-suite-subscription-update";
|
||
true
|
||
)
|
||
|
||
# -- subscription: StateDirectory set on socks service --
|
||
(
|
||
assert
|
||
subscriptionOnlyFixture.config.systemd.services."proxy-suite-socks".serviceConfig.StateDirectory
|
||
== "proxy-suite";
|
||
true
|
||
)
|
||
|
||
# -- subscription: custom update interval flows through to timer --
|
||
(
|
||
assert
|
||
subscriptionWithStaticFixture.config.systemd.timers."proxy-suite-subscription-update".timerConfig.OnUnitActiveSec
|
||
== "6h";
|
||
true
|
||
)
|
||
|
||
# -- subscription: duplicate tags fail because they are cache keys and tag prefixes --
|
||
(
|
||
assert duplicateSubscriptionTags.success == false;
|
||
true
|
||
)
|
||
|
||
# -- subscription: tag must be a filesystem-safe identifier --
|
||
(
|
||
assert unsafeSubscriptionTag.success == false;
|
||
true
|
||
)
|
||
|
||
# -- subscription: selection=first renames first subscription outbound to "proxy" --
|
||
(
|
||
let
|
||
startScript =
|
||
subscriptionFirstSelectionFixture.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart;
|
||
scriptText = builtins.readFile startScript;
|
||
in
|
||
assert builtins.match ".*proxy.*" scriptText != null;
|
||
true
|
||
)
|
||
|
||
# -- runtime parser: socks start script sets PYTHONPATH for static URL parser imports --
|
||
(
|
||
let
|
||
startScript =
|
||
subscriptionWithStaticFixture.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart;
|
||
scriptText = builtins.readFile startScript;
|
||
in
|
||
assert builtins.match ".*PYTHONPATH=.*build-outbound\\.py.*" scriptText != null;
|
||
true
|
||
)
|
||
|
||
# -- subscription/runtime parser: update script sets PYTHONPATH for parser module imports --
|
||
(
|
||
let
|
||
updateScript =
|
||
subscriptionOnlyFixture.config.systemd.services."proxy-suite-subscription-update".serviceConfig.ExecStart;
|
||
scriptText = builtins.readFile updateScript;
|
||
in
|
||
assert builtins.match ".*PYTHONPATH=.*fetch-subscription\\.py.*" scriptText != null;
|
||
true
|
||
)
|
||
|
||
# -- subscription/runtime: generated cache paths use the raw validated tag, not shell-escaped quotes --
|
||
(
|
||
assert pkgs.lib.hasInfix ''CACHE_FILE="/var/lib/proxy-suite/subscriptions/sing-box/community.json"''
|
||
subscriptionOnlyStartScript;
|
||
assert pkgs.lib.hasInfix "/var/lib/proxy-suite/subscriptions/sing-box/community.json.tmp"
|
||
subscriptionOnlyUpdateScript;
|
||
assert !(pkgs.lib.hasInfix "subscriptions/'community'.json" subscriptionOnlyStartScript);
|
||
assert !(pkgs.lib.hasInfix "subscriptions/'community'.json" subscriptionOnlyUpdateScript);
|
||
true
|
||
)
|
||
|
||
# -- subscription/runtime: invalid cache files are ignored and refreshed --
|
||
(
|
||
assert pkgs.lib.hasInfix "_proxy_suite_valid_subscription_cache()" subscriptionOnlyStartScript;
|
||
assert pkgs.lib.hasInfix "_proxy_suite_drop_invalid_subscription_cache" subscriptionOnlyStartScript;
|
||
assert pkgs.lib.hasInfix "removed invalid subscription cache" subscriptionOnlyStartScript;
|
||
assert pkgs.lib.hasInfix "produced an invalid cache" subscriptionOnlyUpdateScript;
|
||
true
|
||
)
|
||
|
||
# -- subscription/runtime: refresh only restarts sing-box units that are active --
|
||
(
|
||
assert pkgs.lib.hasInfix "is-active --quiet proxy-suite-socks" subscriptionOnlyUpdateScript;
|
||
assert pkgs.lib.hasInfix "restart proxy-suite-socks" subscriptionOnlyUpdateScript;
|
||
assert pkgs.lib.hasInfix "is-active --quiet proxy-suite-tun" subscriptionOnlyUpdateScript;
|
||
assert !(pkgs.lib.hasInfix "SOCKS_WAS_ACTIVE" subscriptionOnlyUpdateScript);
|
||
true
|
||
)
|
||
|
||
# -- subscription/runtime: refresh also handles the per-app TUN sing-box service when present --
|
||
(
|
||
assert pkgs.lib.hasInfix "is-active --quiet proxy-suite-per-app-tun"
|
||
subscriptionPerAppTunUpdateScript;
|
||
assert pkgs.lib.hasInfix "restart proxy-suite-per-app-tun" subscriptionPerAppTunUpdateScript;
|
||
assert !(pkgs.lib.hasInfix "PER_APP_TUN_WAS_ACTIVE" subscriptionPerAppTunUpdateScript);
|
||
true
|
||
)
|
||
|
||
# -- subscription: no update service/timer without subscriptions --
|
||
(
|
||
assert !(minimal.config.systemd.services ? "proxy-suite-subscription-update");
|
||
true
|
||
)
|
||
(
|
||
assert !(minimal.config.systemd.timers ? "proxy-suite-subscription-update");
|
||
true
|
||
)
|
||
|
||
# -- subscription: urlFile form accepted --
|
||
(
|
||
assert subscriptionUrlFileFixture.config.services.proxy-suite.proxy.subscriptions != [ ];
|
||
true
|
||
)
|
||
|
||
# -- runtime route mode: proxy-ctl wrapper exports the volatile state file and baseline default --
|
||
(
|
||
assert
|
||
shellValueByPrefix minimalProxyCtlWrapper "export ROUTE_MODE_STATE_FILE="
|
||
== "/run/proxy-suite/route-mode";
|
||
assert shellValueByPrefix minimalProxyCtlWrapper "export DEFAULT_ROUTE_MODE=" == "blacklist";
|
||
true
|
||
)
|
||
|
||
# -- runtime route mode: proxy-ctl help/status script exposes default + four explicit modes --
|
||
(
|
||
assert pkgs.lib.hasInfix "route-mode default|whitelist|blacklist|all-proxy|all-bypass|status"
|
||
minimalProxyCtlScript;
|
||
assert pkgs.lib.hasInfix ''printf 'route_mode=%s\n' "$(_route_mode_current)"''
|
||
minimalProxyCtlScript;
|
||
assert pkgs.lib.hasInfix ''printf 'default_route_mode=%s\n' "$(_route_mode_default)"''
|
||
minimalProxyCtlScript;
|
||
assert pkgs.lib.hasInfix ''systemctl start "proxy-suite-route-mode@''${action}.service"''
|
||
minimalProxyCtlScript;
|
||
true
|
||
)
|
||
|
||
# -- runtime route mode: socks start script includes all override branches and uses volatile state --
|
||
(
|
||
assert pkgs.lib.hasInfix ''ROUTE_MODE_STATE_FILE="/run/proxy-suite/route-mode"''
|
||
routeModeStartScript;
|
||
assert pkgs.lib.hasInfix "BACKEND_JQ_FILTER=" routeModeStartScript;
|
||
assert pkgs.lib.hasInfix ''-f "$BACKEND_JQ_FILTER"'' routeModeStartScript;
|
||
assert pkgs.lib.hasInfix "all-proxy)" routeModeStartScript;
|
||
assert pkgs.lib.hasInfix "all-bypass)" routeModeStartScript;
|
||
assert pkgs.lib.hasInfix ".route.rules = (sing_box_preserved_rules + $route_rules)"
|
||
routeModeBackendJqFilter;
|
||
assert pkgs.lib.hasInfix ".dns.rules = []" routeModeBackendJqFilter;
|
||
true
|
||
)
|
||
|
||
# -- runtime route mode: grouped routing metadata preserves custom rule categories and order --
|
||
(
|
||
assert builtins.length routeModeRules.custom == 3;
|
||
assert (builtins.elemAt routeModeRules.custom 0).category == "direct";
|
||
assert (builtins.elemAt routeModeRules.custom 1).category == "proxy";
|
||
assert (builtins.elemAt routeModeRules.custom 2).category == "block";
|
||
true
|
||
)
|
||
|
||
# -- runtime route mode: setter unit is present and writes into /run --
|
||
(
|
||
let
|
||
setterSvc = routeModeFixture.config.systemd.services."proxy-suite-route-mode@";
|
||
setterScript = builtins.readFile (
|
||
builtins.head (pkgs.lib.splitString " " setterSvc.serviceConfig.ExecStart)
|
||
);
|
||
in
|
||
assert !(setterSvc.serviceConfig ? RuntimeDirectory);
|
||
assert pkgs.lib.hasInfix "/run/proxy-suite/route-mode" setterScript;
|
||
assert pkgs.lib.hasInfix "default)" setterScript;
|
||
assert pkgs.lib.hasInfix "all-proxy)" setterScript;
|
||
assert pkgs.lib.hasInfix "all-bypass)" setterScript;
|
||
true
|
||
)
|
||
|
||
# -- subscription: both url + urlFile fails --
|
||
(
|
||
assert subscriptionBothSources.success == false;
|
||
true
|
||
)
|
||
|
||
# -- subscription: neither url nor urlFile fails --
|
||
(
|
||
assert subscriptionNoSources.success == false;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: proxychains/direct profile config is accepted --
|
||
(
|
||
assert perAppRoutingProxychainsFixture.config.services.proxy-suite.perAppRouting.enable;
|
||
true
|
||
)
|
||
(
|
||
assert
|
||
builtins.length perAppRoutingProxychainsFixture.config.services.proxy-suite.perAppRouting.profiles
|
||
== 2;
|
||
true
|
||
)
|
||
(
|
||
assert builtins.length perAppRoutingProxychainsProfiles == 2;
|
||
true
|
||
)
|
||
|
||
# -- 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 --
|
||
(
|
||
assert builtins.length perAppRoutingNoDefaultProfiles == 0;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: createDefaultProfiles injects curated tun profile when backend is enabled --
|
||
(
|
||
assert builtins.length perAppRoutingTunProfiles == 2;
|
||
assert builtins.any (
|
||
profile: profile.name == "tun" && profile.route == "tun"
|
||
) perAppRoutingTunProfiles;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: createDefaultProfiles injects curated tproxy profile when backend is enabled --
|
||
(
|
||
assert builtins.length perAppRoutingTproxyProfiles == 2;
|
||
assert builtins.any (
|
||
profile: profile.name == "tproxy" && profile.route == "tproxy"
|
||
) perAppRoutingTproxyProfiles;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: createDefaultProfiles injects curated zapret profile when backend is enabled --
|
||
(
|
||
assert builtins.length perAppRoutingZapretProfiles == 2;
|
||
assert builtins.any (
|
||
profile: profile.name == "zapret" && profile.route == "zapret"
|
||
) perAppRoutingZapretProfiles;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: proxy-ctl script embeds wrap/apps commands --
|
||
(
|
||
assert pkgs.lib.hasInfix "help)" perAppRoutingProxychainsScript;
|
||
assert pkgs.lib.hasInfix "show this help message" perAppRoutingProxychainsScript;
|
||
assert pkgs.lib.hasInfix "enable/disable the proxy backend stack" perAppRoutingProxychainsScript;
|
||
assert pkgs.lib.hasInfix "restart active global proxy-suite services"
|
||
perAppRoutingProxychainsScript;
|
||
assert pkgs.lib.hasInfix "wrap <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 --
|
||
(
|
||
assert pkgs.lib.hasInfix "if _svc_exists proxy-suite-socks; then" minimalProxyCtlScript;
|
||
assert pkgs.lib.hasInfix "_svc_exists \"$svc\" && _svc_active \"$svc\"" minimalProxyCtlScript;
|
||
assert pkgs.lib.hasInfix "proxy-suite-tg-ws-proxy" minimalProxyCtlScript;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: generated proxy-ctl script dispatches through proxychains4 --
|
||
(
|
||
assert pkgs.lib.hasInfix "export PROXYCHAINS_QUIET_ARG='-q'" perAppRoutingProxychainsScript;
|
||
assert pkgs.lib.hasInfix
|
||
"exec proxychains4 $PROXYCHAINS_QUIET_ARG -f \"$PROXYCHAINS_CONFIG\" \"$@\""
|
||
perAppRoutingProxychainsScript;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: generated proxy-ctl script dispatches tun profiles through systemd slices --
|
||
(
|
||
assert pkgs.lib.hasInfix "PER_APP_ROUTING_TUN_ENABLED" perAppRoutingTunScript;
|
||
assert pkgs.lib.hasInfix "systemd-run --user --scope --quiet --collect --same-dir"
|
||
perAppRoutingTunScript;
|
||
assert pkgs.lib.hasInfix "_check_no_global_proxy tun" perAppRoutingTunScript;
|
||
assert pkgs.lib.hasInfix ''_wrap_slice "proxy-suite-per-app-tun" "$PER_APP_ROUTING_TUN_ENABLED"''
|
||
perAppRoutingTunScript;
|
||
assert pkgs.lib.hasInfix "$slice_base-user@$uid.service" perAppRoutingTunScript;
|
||
assert pkgs.lib.hasInfix "cleanup_slice()" perAppRoutingTunScript;
|
||
assert pkgs.lib.hasInfix "trap cleanup_slice EXIT" perAppRoutingTunScript;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: generated proxy-ctl script dispatches tproxy profiles through systemd slices --
|
||
(
|
||
assert pkgs.lib.hasInfix "PER_APP_ROUTING_TPROXY_ENABLED" perAppRoutingTproxyScript;
|
||
assert pkgs.lib.hasInfix
|
||
''_wrap_slice "proxy-suite-per-app-tproxy" "$PER_APP_ROUTING_TPROXY_ENABLED"''
|
||
perAppRoutingTproxyScript;
|
||
assert pkgs.lib.hasInfix "$slice_base-\${profile}-$$" perAppRoutingTproxyScript;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: generated proxy-ctl script dispatches zapret profiles through systemd slices --
|
||
(
|
||
assert pkgs.lib.hasInfix "PER_APP_ROUTING_ZAPRET_ENABLED" perAppRoutingZapretScript;
|
||
assert pkgs.lib.hasInfix
|
||
''_wrap_slice "proxy-suite-per-app-zapret" "$PER_APP_ROUTING_ZAPRET_ENABLED"''
|
||
perAppRoutingZapretScript;
|
||
assert pkgs.lib.hasInfix "$slice_base-\${profile}-$$" perAppRoutingZapretScript;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: user mark script installs fwmark + conntrack mark rules --
|
||
(
|
||
assert pkgs.lib.hasInfix "meta mark set" perAppRoutingTunUserStartScript;
|
||
assert pkgs.lib.hasInfix "ct mark set" perAppRoutingTunUserStartScript;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app TUN config is separate and does not auto-route globally --
|
||
(
|
||
let
|
||
inbound = builtins.head (
|
||
builtins.filter (item: item.tag == "tun-in") perAppRoutingTunConfig.inbounds
|
||
);
|
||
in
|
||
assert inbound.interface_name == "psperapptun0";
|
||
assert inbound.address == [ "172.20.0.1/30" ];
|
||
assert inbound.auto_route == false;
|
||
assert inbound.auto_redirect == false;
|
||
assert inbound.strict_route == false;
|
||
assert !(inbound ? iproute2_table_index);
|
||
assert !(inbound ? iproute2_rule_index);
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app TUN local DNS keeps direct path without explicit detour --
|
||
(
|
||
let
|
||
localDns = dnsServerByTag perAppRoutingTunConfig "local";
|
||
in
|
||
assert !(localDns ? detour);
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app TUN does not set outbound routing marks when TProxy is disabled --
|
||
(
|
||
assert builtins.match ".*--routing-mark.*" perAppRoutingTunStartScript == null;
|
||
assert !(perAppRoutingTunDirectOutbound ? routing_mark);
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app TUN applies outbound routing marks when TProxy is enabled --
|
||
(
|
||
let
|
||
expectedMark = perAppRoutingTunWithTproxyFixture.config.services.proxy-suite.proxy.tproxy.proxyMark;
|
||
in
|
||
assert builtins.match ".*--routing-mark.*" perAppRoutingTunWithTproxyStartScript != null;
|
||
assert perAppRoutingTunWithTproxyDirectOutbound.routing_mark == expectedMark;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app TUN service and helper units are created --
|
||
(
|
||
assert perAppRoutingTunFixture.config.systemd.services ? "proxy-suite-per-app-tun";
|
||
assert perAppRoutingTunFixture.config.systemd.services ? "proxy-suite-per-app-tun-user@";
|
||
assert perAppRoutingTunFixture.config.systemd.user.services ? "proxy-suite-per-app-tun-anchor";
|
||
assert perAppRoutingTunServiceConfig.ExecStartPre == perAppRoutingTunServiceConfig.ExecStopPost;
|
||
assert !(pkgs.lib.hasInfix "-6 addr replace" perAppRoutingTunUpScript);
|
||
assert !(pkgs.lib.hasInfix "-6 route replace" perAppRoutingTunUpScript);
|
||
assert !(pkgs.lib.hasInfix "-6 rule add" perAppRoutingTunUpScript);
|
||
assert pkgs.lib.hasInfix "link del dev" perAppRoutingTunCleanupScript;
|
||
assert pkgs.lib.hasInfix "psperapptun0" perAppRoutingTunCleanupScript;
|
||
assert pkgs.lib.hasInfix "rule del fwmark 16 table 101" perAppRoutingTunCleanupScript;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app TProxy service and helper units are created --
|
||
(
|
||
assert perAppRoutingTproxyFixture.config.systemd.services ? "proxy-suite-per-app-tproxy";
|
||
assert perAppRoutingTproxyFixture.config.systemd.services ? "proxy-suite-per-app-tproxy-user@";
|
||
assert
|
||
perAppRoutingTproxyFixture.config.systemd.user.services ? "proxy-suite-per-app-tproxy-anchor";
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app zapret service and helper units are created --
|
||
(
|
||
assert perAppRoutingZapretFixture.config.systemd.services ? "proxy-suite-per-app-zapret";
|
||
assert perAppRoutingZapretFixture.config.systemd.services ? "proxy-suite-per-app-zapret-user@";
|
||
assert
|
||
perAppRoutingZapretFixture.config.systemd.user.services ? "proxy-suite-per-app-zapret-anchor";
|
||
assert builtins.elem "network-online.target" perAppRoutingZapretService.after;
|
||
assert builtins.elem "network-online.target" perAppRoutingZapretService.wants;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app zapret can run without the global zapret service --
|
||
(
|
||
assert
|
||
perAppRoutingZapretWithoutGlobalFixture.config.systemd.services ? "proxy-suite-per-app-zapret";
|
||
assert
|
||
perAppRoutingZapretWithoutGlobalFixture.config.systemd.services
|
||
? "proxy-suite-per-app-zapret-user@";
|
||
assert
|
||
perAppRoutingZapretWithoutGlobalFixture.config.systemd.user.services
|
||
? "proxy-suite-per-app-zapret-anchor";
|
||
assert
|
||
!(perAppRoutingZapretWithoutGlobalFixture.config.systemd.services ? "zapret-discord-youtube");
|
||
assert builtins.length perAppRoutingZapretWithoutGlobalProfiles == 2;
|
||
assert builtins.any (
|
||
profile: profile.name == "zapret" && profile.route == "zapret"
|
||
) perAppRoutingZapretWithoutGlobalProfiles;
|
||
assert pkgs.lib.hasInfix "proxy-suite-per-app-zapret" perAppRoutingZapretWithoutGlobalPerAppBase;
|
||
assert !(pkgs.lib.hasInfix "proxy-suite-zapret" perAppRoutingZapretWithoutGlobalPerAppBase);
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app TUN enables nftables and user control group --
|
||
(
|
||
assert perAppRoutingTunFixture.config.networking.nftables.enable;
|
||
assert perAppRoutingTunFixture.config.users.groups ? "proxy-suite";
|
||
assert builtins.elem "network-online.target"
|
||
tunManualFixture.config.systemd.services."proxy-suite-tun".after;
|
||
assert builtins.elem "network-online.target"
|
||
tunManualFixture.config.systemd.services."proxy-suite-tun".wants;
|
||
true
|
||
)
|
||
|
||
# -- userControl: default polkit rule covers both per-app and global proxy-ctl managed units --
|
||
(
|
||
assert pkgs.lib.hasInfix "unit.indexOf(\"proxy-suite-per-app-\") === 0"
|
||
perAppRoutingTunPolkitConfig;
|
||
assert pkgs.lib.hasInfix "unit.indexOf(\"proxy-suite-\") === 0" perAppRoutingTunPolkitConfig;
|
||
assert pkgs.lib.hasInfix "unit.indexOf(\"proxy-suite-per-app-\") !== 0"
|
||
perAppRoutingTunPolkitConfig;
|
||
assert pkgs.lib.hasInfix "unit === \"zapret-discord-youtube.service\"" perAppRoutingTunPolkitConfig;
|
||
true
|
||
)
|
||
|
||
# -- userControl: global-only rule excludes per-app units --
|
||
(
|
||
assert userControlGlobalOnlyFixture.config.users.groups ? "proxy-suite";
|
||
assert pkgs.lib.hasInfix "unit.indexOf(\"proxy-suite-\") === 0" userControlGlobalOnlyPolkitConfig;
|
||
assert pkgs.lib.hasInfix "unit.indexOf(\"proxy-suite-per-app-\") !== 0"
|
||
userControlGlobalOnlyPolkitConfig;
|
||
assert
|
||
builtins.match ".*unit\\.indexOf\\(\"proxy-suite-per-app-\"\\) === 0.*" userControlGlobalOnlyPolkitConfig
|
||
== null;
|
||
assert pkgs.lib.hasInfix "unit === \"zapret-discord-youtube.service\""
|
||
userControlGlobalOnlyPolkitConfig;
|
||
true
|
||
)
|
||
|
||
# -- userControl: per-app-only rule covers per-app-scoped helpers only --
|
||
(
|
||
assert userControlPerAppOnlyFixture.config.users.groups ? "proxy-suite";
|
||
assert pkgs.lib.hasInfix "unit.indexOf(\"proxy-suite-per-app-\") === 0"
|
||
userControlPerAppOnlyPolkitConfig;
|
||
assert
|
||
builtins.match ".*unit\\.indexOf\\(\"proxy-suite-per-app-\"\\) !== 0.*" userControlPerAppOnlyPolkitConfig
|
||
== null;
|
||
assert
|
||
builtins.match ".*unit === \"zapret-discord-youtube\\.service\".*" userControlPerAppOnlyPolkitConfig
|
||
== null;
|
||
true
|
||
)
|
||
|
||
# -- userControl: disabling both scopes removes group and polkit wiring --
|
||
(
|
||
assert !(userControlDisabledFixture.config.users.groups ? "proxy-suite");
|
||
assert !userControlDisabledFixture.config.security.polkit.enable;
|
||
assert
|
||
builtins.match ".*subject\\.isInGroup\\(\"proxy-suite\"\\).*" userControlDisabledFixture.config.security.polkit.extraConfig
|
||
== null;
|
||
assert
|
||
builtins.match ".*org\\.freedesktop\\.systemd1\\.manage-units.*" userControlDisabledFixture.config.security.polkit.extraConfig
|
||
== null;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app TProxy helper installs socket cgroup mark rules --
|
||
(
|
||
assert pkgs.lib.hasInfix "socket cgroupv2" perAppRoutingTproxyUserStartScript;
|
||
assert pkgs.lib.hasInfix "meta mark set" perAppRoutingTproxyUserStartScript;
|
||
assert pkgs.lib.hasInfix "ct mark set" perAppRoutingTproxyUserStartScript;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app TProxy startup installs nftables and loopback policy route --
|
||
(
|
||
assert pkgs.lib.hasInfix "proxy_suite_per_app_tproxy" perAppRoutingTproxyStartScript;
|
||
assert pkgs.lib.hasInfix "rule del fwmark 17 table 102" perAppRoutingTproxyStartScript;
|
||
assert pkgs.lib.hasInfix "route replace local default dev lo table 102"
|
||
perAppRoutingTproxyStartScript;
|
||
assert pkgs.lib.hasInfix "rule add fwmark 17 table 102" perAppRoutingTproxyStartScript;
|
||
assert pkgs.lib.hasInfix "set +e" perAppRoutingTproxyStopScript;
|
||
assert pkgs.lib.hasInfix "rule del fwmark 17 table 102" perAppRoutingTproxyStopScript;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app zapret helper installs socket cgroup bitwise mark rules --
|
||
(
|
||
assert pkgs.lib.hasInfix "socket cgroupv2" perAppRoutingZapretUserStartScript;
|
||
assert pkgs.lib.hasInfix "meta mark set meta mark or 268435456" perAppRoutingZapretUserStartScript;
|
||
assert pkgs.lib.hasInfix "ct mark set ct mark or 268435456" perAppRoutingZapretUserStartScript;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app zapret startup installs nftables backend --
|
||
(
|
||
assert pkgs.lib.hasInfix "proxy_suite_per_app_zapret_mark" perAppRoutingZapretStartScript;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: global zapret config keeps FILTER_MARK disabled --
|
||
(
|
||
assert pkgs.lib.hasInfix "FILTER_MARK=" perAppRoutingZapretConfig;
|
||
assert builtins.match ".*FILTER_MARK=0x10000000.*" perAppRoutingZapretConfig == null;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app zapret config is a separate instance with its own filter/qnum/marks --
|
||
(
|
||
assert pkgs.lib.hasInfix "FILTER_MARK=0x10000000" perAppRoutingPerAppZapretConfig;
|
||
assert pkgs.lib.hasInfix "MODE_FILTER=none" perAppRoutingPerAppZapretConfig;
|
||
assert pkgs.lib.hasInfix "QNUM=201" perAppRoutingPerAppZapretConfig;
|
||
assert pkgs.lib.hasInfix "DESYNC_MARK=0x8000000" perAppRoutingPerAppZapretConfig;
|
||
assert pkgs.lib.hasInfix "DESYNC_MARK_POSTNAT=0x4000000" perAppRoutingPerAppZapretConfig;
|
||
assert pkgs.lib.hasInfix "ZAPRET_NFT_TABLE=proxy_suite_per_app_zapret"
|
||
perAppRoutingPerAppZapretConfig;
|
||
true
|
||
)
|
||
(
|
||
assert pkgs.lib.hasInfix "FILTER_MARK=0x10000000" perAppRoutingZapretWithoutGlobalPerAppConfig;
|
||
assert pkgs.lib.hasInfix "QNUM=201" perAppRoutingZapretWithoutGlobalPerAppConfig;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: global zapret installs a bypass hook for app-marked traffic --
|
||
(
|
||
assert pkgs.lib.hasInfix "proxy-suite per-app-zapret bypass" perAppRoutingZapretGlobalCustomScript;
|
||
assert pkgs.lib.hasInfix "mark and 268435456 != 0 return" perAppRoutingZapretGlobalCustomScript;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: route=proxychains requires proxychains.enable --
|
||
(
|
||
assert perAppRoutingProxychainsWithoutEnable.success == false;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: proxychains requires proxy.enable --
|
||
(
|
||
assert perAppRoutingProxychainsWithoutProxy.success == false;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: profiles require perAppRouting.enable --
|
||
(
|
||
assert perAppRoutingProfilesWithoutEnable.success == false;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: default proxychains profile still requires proxychains.enable --
|
||
(
|
||
assert perAppRoutingDefaultProfilesWithoutProxychainsEnable.success == false;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: route=tun requires proxy.tun.perApp.enable --
|
||
(
|
||
assert perAppRoutingTunWithoutEnable.success == false;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app TUN backend requires proxy.enable --
|
||
(
|
||
assert perAppRoutingTunBackendWithoutProxy.success == false;
|
||
assert perAppRoutingTunProfileWithoutProxy.success == false;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: route=tproxy requires proxy.tproxy.perApp.enable --
|
||
(
|
||
assert perAppRoutingTproxyWithoutEnable.success == false;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app TProxy backend requires proxy.enable --
|
||
(
|
||
assert perAppRoutingTproxyBackendWithoutProxy.success == false;
|
||
assert perAppRoutingTproxyProfileWithoutProxy.success == false;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: route=zapret requires zapret.perApp.enable --
|
||
(
|
||
assert perAppRoutingZapretWithoutEnable.success == false;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: profile names must be unique --
|
||
(
|
||
assert duplicatePerAppRoutingProfiles.success == false;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: with TProxy enabled, app TUN fwmark must differ from proxyMark --
|
||
(
|
||
assert perAppRoutingTunFwmarkCollision.success == false;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app TProxy fwmark must differ from proxy.tproxy.proxyMark --
|
||
(
|
||
assert perAppRoutingTproxyFwmarkCollision.success == false;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app TUN and app TProxy fwmarks must differ --
|
||
(
|
||
assert perAppRoutingTunTproxyFwmarkCollision.success == false;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app TUN and app TProxy route tables must differ --
|
||
(
|
||
assert perAppRoutingTunTproxyRouteTableCollision.success == false;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app zapret filter mark must differ from proxy.tproxy.proxyMark --
|
||
(
|
||
assert perAppRoutingZapretFilterMarkCollision.success == false;
|
||
true
|
||
)
|
||
|
||
# -- perAppRouting: app TProxy and app zapret marks must differ --
|
||
(
|
||
assert perAppRoutingTproxyZapretMarkCollision.success == false;
|
||
true
|
||
)
|
||
|
||
# -- subscription: no outbounds + no subscriptions fails --
|
||
(
|
||
assert noProxyBackendDefaultFixture.config.services.proxy-suite.proxy.enable == false;
|
||
assert !(noProxyBackendDefaultFixture.config.systemd.services ? "proxy-suite-socks");
|
||
assert noOutboundsNoSubscriptions.success == false;
|
||
true
|
||
)
|
||
|
||
# -- urlTest: custom url/interval/tolerance propagate to start script --
|
||
(
|
||
let
|
||
startScript =
|
||
urlTestCustomFixture.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart;
|
||
scriptText = builtins.readFile startScript;
|
||
in
|
||
assert builtins.match ".*telegram\\.org.*" scriptText != null;
|
||
assert builtins.match ".*1m.*" scriptText != null;
|
||
assert builtins.match ".*100.*" scriptText != null;
|
||
true
|
||
)
|
||
|
||
# -- urlTest: defaults are sane --
|
||
(
|
||
let
|
||
cfg = minimal.config.services.proxy-suite.proxy.urlTest;
|
||
in
|
||
assert cfg.url == "https://www.gstatic.com/generate_204";
|
||
assert cfg.interval == "3m";
|
||
assert minimal.config.services.proxy-suite.proxy.singBox.urlTest.tolerance == 50;
|
||
true
|
||
)
|
||
];
|
||
in
|
||
{
|
||
proxy-suite-module = builtins.seq validated (pkgs.writeText "proxy-suite-module-check" "ok");
|
||
proxy-suite-tray-build = suitePkgs.proxy-suite-tray;
|
||
xray-jq-filter-runtime = xrayJqFilterRuntimeCheck;
|
||
|
||
zapret-hostlist-rules = pkgs.runCommand "proxy-suite-zapret-hostlist-rules-check" { } ''
|
||
grep -F -- '--hostlist="${zapretSyncExtraListsBase}/hostlists/list-twitter.txt"' "${zapretSyncExtraListsBase}/config"
|
||
grep -F -- '--hostlist="${zapretSyncExtraListsBase}/hostlists/list-instagram.txt"' "${zapretSyncExtraListsBase}/config"
|
||
grep -F -- '--hostlist="${zapretSyncExtraListsBase}/hostlists/list-soundcloud.txt"' "${zapretSyncExtraListsBase}/config"
|
||
! grep -F -- '--hostlist="${zapretSyncBase}/hostlists/list-twitter.txt"' "${zapretSyncBase}/config"
|
||
! grep -F -- '--hostlist="${zapretSyncBase}/hostlists/list-instagram.txt"' "${zapretSyncBase}/config"
|
||
! grep -F -- '--hostlist="${zapretSyncBase}/hostlists/list-soundcloud.txt"' "${zapretSyncBase}/config"
|
||
! grep -F -- '--hostlist="${zapretSyncNoExtraListsBase}/hostlists/list-twitter.txt"' "${zapretSyncNoExtraListsBase}/config"
|
||
! grep -F -- '--hostlist="${zapretSyncNoExtraListsBase}/hostlists/list-instagram.txt"' "${zapretSyncNoExtraListsBase}/config"
|
||
! grep -F -- '--hostlist="${zapretSyncNoExtraListsBase}/hostlists/list-soundcloud.txt"' "${zapretSyncNoExtraListsBase}/config"
|
||
grep -F 'googlevideo.com' "${zapretHostlistBase}/hostlists/list-googlevideo.txt"
|
||
grep -F 'example.de' "${zapretHostlistBase}/hostlists/list-example.txt"
|
||
grep -F -- '--hostlist="${zapretHostlistBase}/hostlists/list-googlevideo.txt"' "${zapretHostlistBase}/config"
|
||
grep -F -- '--hostlist="${zapretHostlistBase}/hostlists/list-example.txt"' "${zapretHostlistBase}/config"
|
||
grep -F -- '--filter-tcp=443 --dpi-desync=fake,multisplit --hostlist="${zapretHostlistBase}/hostlists/list-example.txt" --hostlist-exclude="${zapretHostlistBase}/hostlists/list-exclude.txt" --hostlist-exclude="${zapretHostlistBase}/hostlists/list-exclude-user.txt" --ipset-exclude="${zapretHostlistBase}/hostlists/ipset-exclude.txt" --ipset-exclude="${zapretHostlistBase}/hostlists/ipset-exclude-user.txt" --new' "${zapretHostlistBase}/config"
|
||
touch "$out"
|
||
'';
|
||
}
|
||
// parserChecks
|
||
// repoChecks
|