chore: collapse packages
This commit is contained in:
29 files changed
+151
-111
No files matched your search
@@ -25,7 +25,7 @@ let
|
|||||||
profile.settings
|
profile.settings
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
inlineVpnFile = name: profile: pkgs.writeText "proxy-suite-awg-${name}.vpn" profile.vpn;
|
inlineVpnFile = name: profile: pkgs.writeText "proxy-suite-awg" profile.vpn;
|
||||||
sourceKind =
|
sourceKind =
|
||||||
profile:
|
profile:
|
||||||
if profile.configFile != null then
|
if profile.configFile != null then
|
||||||
@@ -48,7 +48,7 @@ let
|
|||||||
null;
|
null;
|
||||||
manifestFor =
|
manifestFor =
|
||||||
name: profile:
|
name: profile:
|
||||||
pkgs.writeText "proxy-suite-awg-${name}-manifest.json" (
|
pkgs.writeText "proxy-suite-awg" (
|
||||||
builtins.toJSON (
|
builtins.toJSON (
|
||||||
{
|
{
|
||||||
kind = sourceKind profile;
|
kind = sourceKind profile;
|
||||||
@@ -59,7 +59,12 @@ let
|
|||||||
// lib.optionalAttrs (profile.settings != null) { settings = profile.settings; }
|
// lib.optionalAttrs (profile.settings != null) { settings = profile.settings; }
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
configTool = ../../scripts/amneziawg_config.py;
|
configTool = "${
|
||||||
|
builtins.path {
|
||||||
|
name = "proxy-suite-scripts";
|
||||||
|
path = ../../scripts;
|
||||||
|
}
|
||||||
|
}/amneziawg_config.py";
|
||||||
runtimeDir = name: "/run/${serviceName name}";
|
runtimeDir = name: "/run/${serviceName name}";
|
||||||
runtimeConfig = name: profile: "${runtimeDir name}/${profile.interfaceName}.conf";
|
runtimeConfig = name: profile: "${runtimeDir name}/${profile.interfaceName}.conf";
|
||||||
# Keep proxy backend sockets (proxyMark) out of AWG's default-route table.
|
# Keep proxy backend sockets (proxyMark) out of AWG's default-route table.
|
||||||
@@ -70,13 +75,13 @@ let
|
|||||||
let
|
let
|
||||||
manifest = manifestFor name profile;
|
manifest = manifestFor name profile;
|
||||||
configPath = runtimeConfig name profile;
|
configPath = runtimeConfig name profile;
|
||||||
prepare = pkgs.writeShellScript "proxy-suite-awg-${name}-prepare" ''
|
prepare = pkgs.writeShellScript "proxy-suite-awg" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
${pkgs.python3}/bin/python3 ${configTool} \
|
${pkgs.python3}/bin/python3 ${configTool} \
|
||||||
--manifest ${lib.escapeShellArg (toString manifest)} \
|
--manifest ${lib.escapeShellArg (toString manifest)} \
|
||||||
--output ${lib.escapeShellArg configPath}
|
--output ${lib.escapeShellArg configPath}
|
||||||
'';
|
'';
|
||||||
proxyBypassUp = pkgs.writeShellScript "proxy-suite-awg-${name}-proxy-bypass-up" ''
|
proxyBypassUp = pkgs.writeShellScript "proxy-suite-awg" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
add_bypass_rule() {
|
add_bypass_rule() {
|
||||||
@@ -99,7 +104,7 @@ let
|
|||||||
add_bypass_rule -4
|
add_bypass_rule -4
|
||||||
add_bypass_rule -6
|
add_bypass_rule -6
|
||||||
'';
|
'';
|
||||||
proxyBypassDown = pkgs.writeShellScript "proxy-suite-awg-${name}-proxy-bypass-down" ''
|
proxyBypassDown = pkgs.writeShellScript "proxy-suite-awg" ''
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
while ${pkgs.iproute2}/bin/ip -4 rule del \
|
while ${pkgs.iproute2}/bin/ip -4 rule del \
|
||||||
@@ -109,7 +114,7 @@ let
|
|||||||
pref ${toString proxyBypassRulePriority} \
|
pref ${toString proxyBypassRulePriority} \
|
||||||
fwmark ${toString cfg.proxy.tproxy.proxyMark} lookup main 2>/dev/null; do :; done
|
fwmark ${toString cfg.proxy.tproxy.proxyMark} lookup main 2>/dev/null; do :; done
|
||||||
'';
|
'';
|
||||||
start = pkgs.writeShellScript "proxy-suite-awg-${name}-start" ''
|
start = pkgs.writeShellScript "proxy-suite-awg" ''
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
@@ -170,7 +175,7 @@ let
|
|||||||
echo "proxy-suite: AmneziaWG profile '${name}' did not complete a handshake; rolling back routes" >&2
|
echo "proxy-suite: AmneziaWG profile '${name}' did not complete a handshake; rolling back routes" >&2
|
||||||
false
|
false
|
||||||
'';
|
'';
|
||||||
stop = pkgs.writeShellScript "proxy-suite-awg-${name}-stop" ''
|
stop = pkgs.writeShellScript "proxy-suite-awg" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
exec ${awgCfg.toolsPackage}/bin/awg-quick down ${lib.escapeShellArg configPath}
|
exec ${awgCfg.toolsPackage}/bin/awg-quick down ${lib.escapeShellArg configPath}
|
||||||
'';
|
'';
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
# publish what it learns, which sing-box then picks up without a restart.
|
# publish what it learns, which sing-box then picks up without a restart.
|
||||||
{ pkgs }:
|
{ pkgs }:
|
||||||
|
|
||||||
pkgs.writeShellScript "proxy-suite-autoproxy-render" ''
|
pkgs.writeShellScript "proxy-suite-autoproxy" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
# $1 - probe-exits.json (index -> tag -> path), $2 - state.json
|
# $1 - probe-exits.json (index -> tag -> path), $2 - state.json
|
||||||
export PATH=${pkgs.lib.makeBinPath [
|
export PATH=${pkgs.lib.makeBinPath [
|
||||||
|
|||||||
@@ -12,6 +12,12 @@
|
|||||||
let
|
let
|
||||||
apCfg = cfg.proxy.autoProxy;
|
apCfg = cfg.proxy.autoProxy;
|
||||||
render = import ./autoproxy-render.nix { inherit pkgs; };
|
render = import ./autoproxy-render.nix { inherit pkgs; };
|
||||||
|
jqFile =
|
||||||
|
path:
|
||||||
|
builtins.path {
|
||||||
|
name = "proxy-suite-autoproxy";
|
||||||
|
inherit path;
|
||||||
|
};
|
||||||
|
|
||||||
bin = lib.makeBinPath [
|
bin = lib.makeBinPath [
|
||||||
pkgs.coreutils
|
pkgs.coreutils
|
||||||
@@ -36,7 +42,7 @@ let
|
|||||||
[ -z "$clash_secret" ] || clash_auth=(-H "Authorization: Bearer $clash_secret")
|
[ -z "$clash_secret" ] || clash_auth=(-H "Authorization: Bearer $clash_secret")
|
||||||
'';
|
'';
|
||||||
|
|
||||||
sampler = pkgs.writeShellScript "proxy-suite-autoproxy-sample" ''
|
sampler = pkgs.writeShellScript "proxy-suite-autoproxy" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
export PATH=${bin}
|
export PATH=${bin}
|
||||||
state_dir=''${AUTOPROXY_STATE_DIR:-${lib.escapeShellArg autoProxyStateDir}}
|
state_dir=''${AUTOPROXY_STATE_DIR:-${lib.escapeShellArg autoProxyStateDir}}
|
||||||
@@ -55,12 +61,12 @@ let
|
|||||||
curl -sS --noproxy '*' --max-time 1 "''${clash_auth[@]}" "http://$clash_api/connections" 2>/dev/null ||
|
curl -sS --noproxy '*' --max-time 1 "''${clash_auth[@]}" "http://$clash_api/connections" 2>/dev/null ||
|
||||||
echo '{}'
|
echo '{}'
|
||||||
done | jq -s -r --argjson min ${toString (300 * 1024)} \
|
done | jq -s -r --argjson min ${toString (300 * 1024)} \
|
||||||
--argjson below ${toString (apCfg.slowBelowKiBps * 1024)} -f ${./autoproxy-slow-sample.jq} || true
|
--argjson below ${toString (apCfg.slowBelowKiBps * 1024)} -f ${jqFile ./autoproxy-slow-sample.jq} || true
|
||||||
)
|
)
|
||||||
[ -z "$lines" ] || printf '%s\n' "$lines" >> "$state_dir/samples"
|
[ -z "$lines" ] || printf '%s\n' "$lines" >> "$state_dir/samples"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
runner = pkgs.writeShellScript "proxy-suite-autoproxy-run" ''
|
runner = pkgs.writeShellScript "proxy-suite-autoproxy" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
export PATH=${bin}
|
export PATH=${bin}
|
||||||
|
|
||||||
@@ -116,7 +122,7 @@ let
|
|||||||
# $1 JSON array of exit tags, $2 registrable domain, $3 wall:<page>|refused|slow.
|
# $1 JSON array of exit tags, $2 registrable domain, $3 wall:<page>|refused|slow.
|
||||||
strike() {
|
strike() {
|
||||||
update --argjson tags "$1" --arg d "$2" --arg why "$3" --argjson now "$now" --argjson ttl "$ttl" \
|
update --argjson tags "$1" --arg d "$2" --arg why "$3" --argjson now "$now" --argjson ttl "$ttl" \
|
||||||
-f ${./autoproxy-strike.jq}
|
-f ${jqFile ./autoproxy-strike.jq}
|
||||||
}
|
}
|
||||||
|
|
||||||
# $1 registrable domain, $2 host probed, $3 probe JSON. Routes apply to the
|
# $1 registrable domain, $2 host probed, $3 probe JSON. Routes apply to the
|
||||||
@@ -198,7 +204,7 @@ let
|
|||||||
strike '[]' "" ""
|
strike '[]' "" ""
|
||||||
|
|
||||||
# See autoproxy-rounds.jq: one exit per AS, then the rest, bad exits last.
|
# See autoproxy-rounds.jq: one exit per AS, then the rest, bad exits last.
|
||||||
rounds=$(jq -c --slurpfile s "$state" -f ${./autoproxy-rounds.jq} "$index")
|
rounds=$(jq -c --slurpfile s "$state" -f ${jqFile ./autoproxy-rounds.jq} "$index")
|
||||||
round1=$(jq -r .r1 <<<"$rounds")
|
round1=$(jq -r .r1 <<<"$rounds")
|
||||||
round2=$(jq -r .r2 <<<"$rounds")
|
round2=$(jq -r .r2 <<<"$rounds")
|
||||||
|
|
||||||
@@ -293,7 +299,7 @@ let
|
|||||||
rm -f "$state_dir/samples.taking"
|
rm -f "$state_dir/samples.taking"
|
||||||
before=$(jq -c '.domains' "$state")
|
before=$(jq -c '.domains' "$state")
|
||||||
update --argjson o "$obs" --argjson now "$now" --argjson ttl "$ttl" --argjson hits 3 \
|
update --argjson o "$obs" --argjson now "$now" --argjson ttl "$ttl" --argjson hits 3 \
|
||||||
-f ${./autoproxy-slow-judge.jq}
|
-f ${jqFile ./autoproxy-slow-judge.jq}
|
||||||
|
|
||||||
# Each crawling destination gets the next exit, in probe order, that
|
# Each crawling destination gets the next exit, in probe order, that
|
||||||
# answers it as well as direct does (`probe --via`). None left: it
|
# answers it as well as direct does (`probe --via`). None left: it
|
||||||
|
|||||||
@@ -63,22 +63,22 @@ let
|
|||||||
routeModeRules =
|
routeModeRules =
|
||||||
if derived.pureXrayEnabled then rules.xrayRouteModeRules else rules.singBoxRouteModeRules;
|
if derived.pureXrayEnabled then rules.xrayRouteModeRules else rules.singBoxRouteModeRules;
|
||||||
|
|
||||||
tproxyFile = pkgs.writeText "proxy-suite-tproxy-template.json" (
|
tproxyFile = pkgs.writeText "proxy-suite-core" (
|
||||||
builtins.toJSON selectedTemplates.tproxy
|
builtins.toJSON selectedTemplates.tproxy
|
||||||
);
|
);
|
||||||
tunFile = pkgs.writeText "proxy-suite-tun-template.json" (
|
tunFile = pkgs.writeText "proxy-suite-core" (
|
||||||
builtins.toJSON selectedTemplates.tun
|
builtins.toJSON selectedTemplates.tun
|
||||||
);
|
);
|
||||||
perAppTunFile = pkgs.writeText "proxy-suite-per-app-tun-template.json" (
|
perAppTunFile = pkgs.writeText "proxy-suite-core" (
|
||||||
builtins.toJSON selectedTemplates.perAppTun
|
builtins.toJSON selectedTemplates.perAppTun
|
||||||
);
|
);
|
||||||
routeModeRulesFile = pkgs.writeText "proxy-suite-route-mode-rules.json" (
|
routeModeRulesFile = pkgs.writeText "proxy-suite-core" (
|
||||||
builtins.toJSON routeModeRules
|
builtins.toJSON routeModeRules
|
||||||
);
|
);
|
||||||
proxyInboundsFile = pkgs.writeText "proxy-suite-inbounds-template.json" (
|
proxyInboundsFile = pkgs.writeText "proxy-suite-inbounds" (
|
||||||
builtins.toJSON proxyInboundsTemplate
|
builtins.toJSON proxyInboundsTemplate
|
||||||
);
|
);
|
||||||
proxyInboundsSpecFile = pkgs.writeText "proxy-suite-inbounds-spec.json" (
|
proxyInboundsSpecFile = pkgs.writeText "proxy-suite-inbounds" (
|
||||||
builtins.toJSON proxyInboundsSpec
|
builtins.toJSON proxyInboundsSpec
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
|
|||||||
@@ -20,12 +20,30 @@ let
|
|||||||
packages = import ../../pkgs/default.nix { inherit pkgs; };
|
packages = import ../../pkgs/default.nix { inherit pkgs; };
|
||||||
nftr = import ./nftables.nix { inherit lib pkgs cfg; };
|
nftr = import ./nftables.nix { inherit lib pkgs cfg; };
|
||||||
derived = import ./derived.nix { inherit lib cfg; };
|
derived = import ./derived.nix { inherit lib cfg; };
|
||||||
|
|
||||||
|
# Scripts share one store name per block, and journald names a unit's output
|
||||||
|
# after its ExecStart basename; tag each unit with its own name instead.
|
||||||
|
unitsWithOwnSyslogIdentifier = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf (
|
||||||
|
lib.types.submodule (
|
||||||
|
{ name, ... }:
|
||||||
|
{
|
||||||
|
config.serviceConfig.SyslogIdentifier = lib.mkIf (
|
||||||
|
lib.hasPrefix "proxy-suite-" name || name == "zapret-discord-youtube"
|
||||||
|
) (lib.mkDefault (lib.removeSuffix "@" name));
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./options
|
./options
|
||||||
];
|
];
|
||||||
|
|
||||||
|
options.systemd.services = unitsWithOwnSyslogIdentifier;
|
||||||
|
options.systemd.user.services = unitsWithOwnSyslogIdentifier;
|
||||||
|
|
||||||
config = lib.mkMerge [
|
config = lib.mkMerge [
|
||||||
{
|
{
|
||||||
# xray and sing-box default to this flake's own nixpkgs (redirect it
|
# xray and sing-box default to this flake's own nixpkgs (redirect it
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ let
|
|||||||
tproxyLocalSubnetLines = mkLocalSubnetLines globalTproxy.localSubnets;
|
tproxyLocalSubnetLines = mkLocalSubnetLines globalTproxy.localSubnets;
|
||||||
perAppTproxyLocalSubnetLines = mkLocalSubnetLines perAppTproxy.localSubnets;
|
perAppTproxyLocalSubnetLines = mkLocalSubnetLines perAppTproxy.localSubnets;
|
||||||
|
|
||||||
nftablesRulesFile = pkgs.writeText "proxy-suite-tproxy.nft" ''
|
nftablesRulesFile = pkgs.writeText "proxy-suite-routing" ''
|
||||||
${reservedIpBlock}
|
${reservedIpBlock}
|
||||||
table ip singbox {
|
table ip singbox {
|
||||||
chain prerouting {
|
chain prerouting {
|
||||||
@@ -66,7 +66,7 @@ let
|
|||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
perAppTproxyRulesFile = pkgs.writeText "proxy-suite-per-app-tproxy.nft" ''
|
perAppTproxyRulesFile = pkgs.writeText "proxy-suite-routing" ''
|
||||||
${reservedIpBlock}
|
${reservedIpBlock}
|
||||||
table ip proxy_suite_per_app_tproxy {
|
table ip proxy_suite_per_app_tproxy {
|
||||||
chain prerouting {
|
chain prerouting {
|
||||||
@@ -90,7 +90,7 @@ let
|
|||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
perAppZapretRulesFile = pkgs.writeText "proxy-suite-per-app-zapret.nft" ''
|
perAppZapretRulesFile = pkgs.writeText "proxy-suite-routing" ''
|
||||||
table inet proxy_suite_per_app_zapret_mark {
|
table inet proxy_suite_per_app_zapret_mark {
|
||||||
chain prerouting {
|
chain prerouting {
|
||||||
type filter hook prerouting priority -103; policy accept;
|
type filter hook prerouting priority -103; policy accept;
|
||||||
@@ -105,7 +105,7 @@ let
|
|||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
perAppTunChainFile = pkgs.writeText "proxy-suite-per-app-tun-chain.nft" ''
|
perAppTunChainFile = pkgs.writeText "proxy-suite-routing" ''
|
||||||
${reservedIpBlock}
|
${reservedIpBlock}
|
||||||
table inet proxy_suite_per_app_tun {
|
table inet proxy_suite_per_app_tun {
|
||||||
chain output {
|
chain output {
|
||||||
|
|||||||
@@ -69,11 +69,14 @@ let
|
|||||||
headBin = "${pkgs.coreutils}/bin/head";
|
headBin = "${pkgs.coreutils}/bin/head";
|
||||||
seqBin = "${pkgs.coreutils}/bin/seq";
|
seqBin = "${pkgs.coreutils}/bin/seq";
|
||||||
findBin = "${pkgs.findutils}/bin/find";
|
findBin = "${pkgs.findutils}/bin/find";
|
||||||
amneziaWgProfileNamesFile = pkgs.writeText "proxy-suite-awg-profiles.json" (
|
amneziaWgProfileNamesFile = pkgs.writeText "proxy-suite-core" (
|
||||||
builtins.toJSON (builtins.attrNames cfg.amneziaWg.profiles)
|
builtins.toJSON (builtins.attrNames cfg.amneziaWg.profiles)
|
||||||
);
|
);
|
||||||
|
|
||||||
proxySuiteScriptsDir = ../../../scripts;
|
proxySuiteScriptsDir = builtins.path {
|
||||||
|
name = "proxy-suite-scripts";
|
||||||
|
path = ../../../scripts;
|
||||||
|
};
|
||||||
parserScriptsPythonPath = proxySuiteScriptsDir;
|
parserScriptsPythonPath = proxySuiteScriptsDir;
|
||||||
buildOutboundPy = "${proxySuiteScriptsDir}/build-outbound.py";
|
buildOutboundPy = "${proxySuiteScriptsDir}/build-outbound.py";
|
||||||
buildInboundPy = "${proxySuiteScriptsDir}/build-inbound.py";
|
buildInboundPy = "${proxySuiteScriptsDir}/build-inbound.py";
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ let
|
|||||||
"proxy-suite-per-app-tun"
|
"proxy-suite-per-app-tun"
|
||||||
];
|
];
|
||||||
|
|
||||||
subscriptionUpdateScript = pkgs.writeShellScript "proxy-suite-subscription-update" ''
|
subscriptionUpdateScript = pkgs.writeShellScript "proxy-suite-core" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
CACHE_DIR="${subscriptionCacheDir}"
|
CACHE_DIR="${subscriptionCacheDir}"
|
||||||
mkdir -p "$CACHE_DIR"
|
mkdir -p "$CACHE_DIR"
|
||||||
@@ -46,7 +46,7 @@ let
|
|||||||
exit "$FAILED"
|
exit "$FAILED"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
setRouteModeScript = pkgs.writeShellScript "proxy-suite-set-route-mode" ''
|
setRouteModeScript = pkgs.writeShellScript "proxy-suite-core" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
mode="''${1:-}"
|
mode="''${1:-}"
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ let
|
|||||||
# Pins the outbound the proxy prefers, or "auto" to hand the choice back to the
|
# Pins the outbound the proxy prefers, or "auto" to hand the choice back to the
|
||||||
# configured selection. The pin is persisted either way; a live Clash API switch
|
# configured selection. The pin is persisted either way; a live Clash API switch
|
||||||
# only saves the restart.
|
# only saves the restart.
|
||||||
setPriorityOutboundScript = pkgs.writeShellScript "proxy-suite-set-priority-outbound" ''
|
setPriorityOutboundScript = pkgs.writeShellScript "proxy-suite-core" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
tag="''${1:-}"
|
tag="''${1:-}"
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ let
|
|||||||
# Applies whatever is now in the runtime spool directories. A removed runtime
|
# Applies whatever is now in the runtime spool directories. A removed runtime
|
||||||
# subscription leaves a root-owned cache behind that the group cannot unlink,
|
# subscription leaves a root-owned cache behind that the group cannot unlink,
|
||||||
# so the cache dir is reconciled against the sources here.
|
# so the cache dir is reconciled against the sources here.
|
||||||
reloadOutboundsScript = pkgs.writeShellScript "proxy-suite-reload-outbounds" ''
|
reloadOutboundsScript = pkgs.writeShellScript "proxy-suite-core" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
${subscriptionCacheHelpersBlock}
|
${subscriptionCacheHelpersBlock}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ let
|
|||||||
xrayPerAppTunIPv6RoutePrefix
|
xrayPerAppTunIPv6RoutePrefix
|
||||||
;
|
;
|
||||||
|
|
||||||
perAppTunWaitForInterface = pkgs.writeShellScript "proxy-suite-per-app-tun-wait-for-interface" ''
|
perAppTunWaitForInterface = pkgs.writeShellScript "proxy-suite-per-app" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
for _ in $(${seqBin} 1 50); do
|
for _ in $(${seqBin} 1 50); do
|
||||||
if ${ip} link show dev ${lib.escapeShellArg perAppRoutingTun.interface} >/dev/null 2>&1; then
|
if ${ip} link show dev ${lib.escapeShellArg perAppRoutingTun.interface} >/dev/null 2>&1; then
|
||||||
@@ -39,7 +39,7 @@ let
|
|||||||
exit 1
|
exit 1
|
||||||
'';
|
'';
|
||||||
|
|
||||||
perAppTunUpScript = pkgs.writeShellScript "proxy-suite-per-app-tun-up" ''
|
perAppTunUpScript = pkgs.writeShellScript "proxy-suite-per-app" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
tun_cidr=${lib.escapeShellArg perAppRoutingTun.address}
|
tun_cidr=${lib.escapeShellArg perAppRoutingTun.address}
|
||||||
@@ -83,7 +83,7 @@ let
|
|||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
perAppTunDownScript = pkgs.writeShellScript "proxy-suite-per-app-tun-down" ''
|
perAppTunDownScript = pkgs.writeShellScript "proxy-suite-per-app" ''
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
# Best-effort cleanup for graceful stops and for unclean previous exits.
|
# Best-effort cleanup for graceful stops and for unclean previous exits.
|
||||||
@@ -106,7 +106,7 @@ let
|
|||||||
${builders.flushResolvedCaches}
|
${builders.flushResolvedCaches}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
perAppTproxyUpScript = pkgs.writeShellScript "proxy-suite-per-app-tproxy-up" ''
|
perAppTproxyUpScript = pkgs.writeShellScript "proxy-suite-per-app" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
${builders.mkNftDeleteTable { inherit nft; family = "ip"; table = "proxy_suite_per_app_tproxy"; }}
|
${builders.mkNftDeleteTable { inherit nft; family = "ip"; table = "proxy_suite_per_app_tproxy"; }}
|
||||||
@@ -122,7 +122,7 @@ let
|
|||||||
${ip} rule add fwmark ${toString perAppRoutingTproxy.fwmark} table ${toString perAppRoutingTproxy.routeTable}
|
${ip} rule add fwmark ${toString perAppRoutingTproxy.fwmark} table ${toString perAppRoutingTproxy.routeTable}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
perAppTproxyDownScript = pkgs.writeShellScript "proxy-suite-per-app-tproxy-down" ''
|
perAppTproxyDownScript = pkgs.writeShellScript "proxy-suite-per-app" ''
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
${builders.mkNftDeleteTable { inherit nft; family = "ip"; table = "proxy_suite_per_app_tproxy"; }}
|
${builders.mkNftDeleteTable { inherit nft; family = "ip"; table = "proxy_suite_per_app_tproxy"; }}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ let
|
|||||||
localProxyAuth.username != null
|
localProxyAuth.username != null
|
||||||
&& (localProxyAuth.password != null || localProxyAuth.passwordFile != null);
|
&& (localProxyAuth.password != null || localProxyAuth.passwordFile != null);
|
||||||
|
|
||||||
perAppRoutingProfilesFile = pkgs.writeText "proxy-suite-per-app-routing-profiles.json" (
|
perAppRoutingProfilesFile = pkgs.writeText "proxy-suite-per-app" (
|
||||||
builtins.toJSON effectivePerAppRoutingProfiles
|
builtins.toJSON effectivePerAppRoutingProfiles
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ let
|
|||||||
if localProxyAuthEnabled then
|
if localProxyAuthEnabled then
|
||||||
"/run/proxy-suite-socks/proxychains.conf"
|
"/run/proxy-suite-socks/proxychains.conf"
|
||||||
else
|
else
|
||||||
pkgs.writeText "proxy-suite-proxychains.conf" ''
|
pkgs.writeText "proxy-suite-per-app" ''
|
||||||
strict_chain
|
strict_chain
|
||||||
${lib.optionalString perAppRoutingCfg.proxychains.quiet "quiet_mode"}
|
${lib.optionalString perAppRoutingCfg.proxychains.quiet "quiet_mode"}
|
||||||
${lib.optionalString perAppRoutingCfg.proxychains.proxyDns "proxy_dns"}
|
${lib.optionalString perAppRoutingCfg.proxychains.proxyDns "proxy_dns"}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ let
|
|||||||
sliceLabel,
|
sliceLabel,
|
||||||
markRule,
|
markRule,
|
||||||
}:
|
}:
|
||||||
pkgs.writeShellScript "proxy-suite-${name}-user-start" ''
|
pkgs.writeShellScript "proxy-suite-per-app" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
uid="$1"
|
uid="$1"
|
||||||
rule_comment_prefix="proxy-suite-${name}-user-$uid"
|
rule_comment_prefix="proxy-suite-${name}-user-$uid"
|
||||||
@@ -67,7 +67,7 @@ let
|
|||||||
nftTable,
|
nftTable,
|
||||||
nftChain,
|
nftChain,
|
||||||
}:
|
}:
|
||||||
pkgs.writeShellScript "proxy-suite-${name}-user-stop" ''
|
pkgs.writeShellScript "proxy-suite-per-app" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
uid="$1"
|
uid="$1"
|
||||||
rule_comment_prefix="proxy-suite-${name}-user-$uid"
|
rule_comment_prefix="proxy-suite-${name}-user-$uid"
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ let
|
|||||||
if ob.urlFile != null then
|
if ob.urlFile != null then
|
||||||
ob.urlFile
|
ob.urlFile
|
||||||
else if ob.url != null then
|
else if ob.url != null then
|
||||||
pkgs.writeText "proxy-suite-inbound-via-url-${ob.tag}" ob.url
|
pkgs.writeText "proxy-suite-inbounds" ob.url
|
||||||
else
|
else
|
||||||
null;
|
null;
|
||||||
in
|
in
|
||||||
@@ -64,7 +64,7 @@ let
|
|||||||
''
|
''
|
||||||
# via outbound: ${ob.tag} (static xray json)
|
# via outbound: ${ob.tag} (static xray json)
|
||||||
OB_JSON=$(cat ${
|
OB_JSON=$(cat ${
|
||||||
pkgs.writeText "proxy-suite-inbound-via-${ob.tag}.json" (
|
pkgs.writeText "proxy-suite-inbounds" (
|
||||||
builtins.toJSON (ob.xrayJson // { inherit (ob) tag; })
|
builtins.toJSON (ob.xrayJson // { inherit (ob) tag; })
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -111,7 +111,7 @@ let
|
|||||||
chmod ${if userControlEnabled then "640" else "600"} "${subscriptionsFile}"
|
chmod ${if userControlEnabled then "640" else "600"} "${subscriptionsFile}"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
startInbounds = pkgs.writeShellScript "proxy-suite-start-inbounds" ''
|
startInbounds = pkgs.writeShellScript "proxy-suite-inbounds" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
umask 077
|
umask 077
|
||||||
RUNTIME_DIR="${runtimeDir}"
|
RUNTIME_DIR="${runtimeDir}"
|
||||||
@@ -156,7 +156,7 @@ let
|
|||||||
# Adds XRay's per-user counters to the daily totals, read and reset in one call.
|
# Adds XRay's per-user counters to the daily totals, read and reset in one call.
|
||||||
# ponytail: a restart of the inbounds loses what was counted since the last run, at
|
# ponytail: a restart of the inbounds loses what was counted since the last run, at
|
||||||
# most one timer interval; collect from ExecStop if that matters.
|
# most one timer interval; collect from ExecStop if that matters.
|
||||||
collectInboundStats = pkgs.writeShellScript "proxy-suite-inbound-stats" ''
|
collectInboundStats = pkgs.writeShellScript "proxy-suite-inbounds" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
file=${lib.escapeShellArg constants.inboundStatsFile}
|
file=${lib.escapeShellArg constants.inboundStatsFile}
|
||||||
if ! reading=$(${xray} api statsquery --server=127.0.0.1:${toString constants.inboundStatsApiPort} \
|
if ! reading=$(${xray} api statsquery --server=127.0.0.1:${toString constants.inboundStatsApiPort} \
|
||||||
@@ -170,7 +170,12 @@ let
|
|||||||
${jq} --argjson q "$reading" \
|
${jq} --argjson q "$reading" \
|
||||||
--arg day "$(${pkgs.coreutils}/bin/date +%F)" \
|
--arg day "$(${pkgs.coreutils}/bin/date +%F)" \
|
||||||
--argjson now "$(${pkgs.coreutils}/bin/date +%s)" \
|
--argjson now "$(${pkgs.coreutils}/bin/date +%s)" \
|
||||||
-f ${../inbound-stats-add.jq} "$file" > "$tmp"
|
-f ${
|
||||||
|
builtins.path {
|
||||||
|
name = "proxy-suite-inbounds";
|
||||||
|
path = ../inbound-stats-add.jq;
|
||||||
|
}
|
||||||
|
} "$file" > "$tmp"
|
||||||
${lib.optionalString userControlEnabled ''
|
${lib.optionalString userControlEnabled ''
|
||||||
${pkgs.coreutils}/bin/chgrp ${lib.escapeShellArg userControlCfg.group} "$tmp" ||
|
${pkgs.coreutils}/bin/chgrp ${lib.escapeShellArg userControlCfg.group} "$tmp" ||
|
||||||
echo "proxy-suite: group ${userControlCfg.group} cannot read the stats; they stay root-only" >&2
|
echo "proxy-suite: group ${userControlCfg.group} cannot read the stats; they stay root-only" >&2
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ let
|
|||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
xrayTunUpScript = pkgs.writeShellScript "proxy-suite-xray-tun-up" ''
|
xrayTunUpScript = pkgs.writeShellScript "proxy-suite-routing" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
tun_cidr=${lib.escapeShellArg globalTun.address}
|
tun_cidr=${lib.escapeShellArg globalTun.address}
|
||||||
@@ -81,7 +81,7 @@ in
|
|||||||
${ip} -6 rule add pref ${toString tunAutoRouteRulePriority} not fwmark ${toString globalTproxy.proxyMark} table ${toString tunAutoRouteTableIndex}
|
${ip} -6 rule add pref ${toString tunAutoRouteRulePriority} not fwmark ${toString globalTproxy.proxyMark} table ${toString tunAutoRouteTableIndex}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
tproxyUpScript = pkgs.writeShellScript "proxy-suite-tproxy-up" ''
|
tproxyUpScript = pkgs.writeShellScript "proxy-suite-routing" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Start from a clean policy-routing state. `ip rule add` permits duplicate
|
# Start from a clean policy-routing state. `ip rule add` permits duplicate
|
||||||
@@ -100,7 +100,7 @@ in
|
|||||||
${ip} rule add fwmark ${toString globalTproxy.fwmark} table ${toString globalTproxy.routeTable}
|
${ip} rule add fwmark ${toString globalTproxy.fwmark} table ${toString globalTproxy.routeTable}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
tproxyDownScript = pkgs.writeShellScript "proxy-suite-tproxy-down" ''
|
tproxyDownScript = pkgs.writeShellScript "proxy-suite-routing" ''
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
${builders.mkNftDeleteTable { inherit nft; family = "ip"; table = "singbox"; }}
|
${builders.mkNftDeleteTable { inherit nft; family = "ip"; table = "singbox"; }}
|
||||||
@@ -112,7 +112,7 @@ in
|
|||||||
${builders.mkIpLocalDefaultRouteDelete { inherit ip; table = globalTproxy.routeTable; }}
|
${builders.mkIpLocalDefaultRouteDelete { inherit ip; table = globalTproxy.routeTable; }}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
tunCleanupScript = pkgs.writeShellScript "proxy-suite-tun-cleanup" ''
|
tunCleanupScript = pkgs.writeShellScript "proxy-suite-routing" ''
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
# SingBox normally removes these on graceful shutdown, but stale
|
# SingBox normally removes these on graceful shutdown, but stale
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ let
|
|||||||
if backendRaw != null then
|
if backendRaw != null then
|
||||||
let
|
let
|
||||||
outboundJson = builtins.toJSON (rawOutboundJson ob tag routingMark);
|
outboundJson = builtins.toJSON (rawOutboundJson ob tag routingMark);
|
||||||
jsonFile = pkgs.writeText "proxy-suite-ob-${tag}.json" outboundJson;
|
jsonFile = pkgs.writeText "proxy-suite-core" outboundJson;
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
# outbound: ${tag} (static ${backend} json)
|
# outbound: ${tag} (static ${backend} json)
|
||||||
@@ -189,8 +189,7 @@ let
|
|||||||
''
|
''
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
urlSource =
|
urlSource = if ob.urlFile != null then ob.urlFile else pkgs.writeText "proxy-suite-core" ob.url;
|
||||||
if ob.urlFile != null then ob.urlFile else pkgs.writeText "proxy-suite-url-${ob.tag}" ob.url;
|
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
# outbound: ${tag}
|
# outbound: ${tag}
|
||||||
@@ -219,7 +218,7 @@ let
|
|||||||
if ob.xrayJson != null then
|
if ob.xrayJson != null then
|
||||||
let
|
let
|
||||||
outboundJson = builtins.toJSON (xrayRawOutboundJson ob tag);
|
outboundJson = builtins.toJSON (xrayRawOutboundJson ob tag);
|
||||||
jsonFile = pkgs.writeText "proxy-suite-xray-sidecar-ob-${tag}.json" outboundJson;
|
jsonFile = pkgs.writeText "proxy-suite-core" outboundJson;
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
# outbound: ${tag} (hybrid XRay json sidecar)
|
# outbound: ${tag} (hybrid XRay json sidecar)
|
||||||
@@ -230,7 +229,7 @@ let
|
|||||||
else if ob.singBoxJson != null || ob.json != null then
|
else if ob.singBoxJson != null || ob.json != null then
|
||||||
let
|
let
|
||||||
outboundJson = builtins.toJSON (singBoxRawOutboundJson ob tag routingMark);
|
outboundJson = builtins.toJSON (singBoxRawOutboundJson ob tag routingMark);
|
||||||
jsonFile = pkgs.writeText "proxy-suite-sing-box-ob-${tag}.json" outboundJson;
|
jsonFile = pkgs.writeText "proxy-suite-core" outboundJson;
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
# outbound: ${tag} (hybrid SingBox json)
|
# outbound: ${tag} (hybrid SingBox json)
|
||||||
@@ -240,8 +239,7 @@ let
|
|||||||
''
|
''
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
urlSource =
|
urlSource = if ob.urlFile != null then ob.urlFile else pkgs.writeText "proxy-suite-core" ob.url;
|
||||||
if ob.urlFile != null then ob.urlFile else pkgs.writeText "proxy-suite-url-${ob.tag}" ob.url;
|
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
# outbound: ${tag} (hybrid ${ob.backend})
|
# outbound: ${tag} (hybrid ${ob.backend})
|
||||||
@@ -286,7 +284,7 @@ let
|
|||||||
};
|
};
|
||||||
outbound = if pureXrayEnabled then xrayOutbound else singBoxOutbound;
|
outbound = if pureXrayEnabled then xrayOutbound else singBoxOutbound;
|
||||||
outboundJson = builtins.toJSON outbound;
|
outboundJson = builtins.toJSON outbound;
|
||||||
jsonFile = pkgs.writeText "proxy-suite-ob-ssh-proxy-${backend}.json" outboundJson;
|
jsonFile = pkgs.writeText "proxy-suite-core" outboundJson;
|
||||||
|
|
||||||
# Read at start so the known-hosts file stays out of the store.
|
# Read at start so the known-hosts file stays out of the store.
|
||||||
knownHostsTarget =
|
knownHostsTarget =
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ let
|
|||||||
if sub.urlFile != null then
|
if sub.urlFile != null then
|
||||||
sub.urlFile
|
sub.urlFile
|
||||||
else
|
else
|
||||||
pkgs.writeText "proxy-suite-sub-url-${sub.tag}" sub.url;
|
pkgs.writeText "proxy-suite-core" sub.url;
|
||||||
|
|
||||||
# Defined in every script that touches a cache: the start scripts and the
|
# Defined in every script that touches a cache: the start scripts and the
|
||||||
# update unit.
|
# update unit.
|
||||||
@@ -181,7 +181,7 @@ let
|
|||||||
done < <(_proxy_suite_runtime_subscriptions)
|
done < <(_proxy_suite_runtime_subscriptions)
|
||||||
'';
|
'';
|
||||||
|
|
||||||
subscriptionTagsFile = pkgs.writeText "proxy-suite-subscription-tags.json" (
|
subscriptionTagsFile = pkgs.writeText "proxy-suite-core" (
|
||||||
builtins.toJSON (map (sub: sub.tag) proxyCfg.subscriptions)
|
builtins.toJSON (map (sub: sub.tag) proxyCfg.subscriptions)
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ let
|
|||||||
if localProxyAuth.passwordFile != null then
|
if localProxyAuth.passwordFile != null then
|
||||||
localProxyAuth.passwordFile
|
localProxyAuth.passwordFile
|
||||||
else if localProxyAuth.password != null then
|
else if localProxyAuth.password != null then
|
||||||
pkgs.writeText "proxy-suite-local-proxy-password" localProxyAuth.password
|
pkgs.writeText "proxy-suite-core" localProxyAuth.password
|
||||||
else
|
else
|
||||||
null;
|
null;
|
||||||
routeModeStateFile = "/run/proxy-suite/route-mode";
|
routeModeStateFile = "/run/proxy-suite/route-mode";
|
||||||
@@ -148,7 +148,7 @@ let
|
|||||||
proxyInboundsGuardPrivate
|
proxyInboundsGuardPrivate
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
backendJqFilterFile = pkgs.writeText "proxy-suite-${backend}-backend-filter.jq" backendJqFilter;
|
backendJqFilterFile = pkgs.writeText "proxy-suite-core" backendJqFilter;
|
||||||
|
|
||||||
startScripts = import ./start-scripts.nix {
|
startScripts = import ./start-scripts.nix {
|
||||||
inherit
|
inherit
|
||||||
|
|||||||
@@ -135,7 +135,6 @@ let
|
|||||||
|
|
||||||
mkStartScript =
|
mkStartScript =
|
||||||
{
|
{
|
||||||
name,
|
|
||||||
runtimeDir,
|
runtimeDir,
|
||||||
configFile,
|
configFile,
|
||||||
routingMark ? null,
|
routingMark ? null,
|
||||||
@@ -148,7 +147,7 @@ let
|
|||||||
enableOutboundTest ? false,
|
enableOutboundTest ? false,
|
||||||
enableZapretCutoff ? false,
|
enableZapretCutoff ? false,
|
||||||
}:
|
}:
|
||||||
pkgs.writeShellScript name ''
|
pkgs.writeShellScript "proxy-suite-core" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
RUNTIME_DIR="${runtimeDir}"
|
RUNTIME_DIR="${runtimeDir}"
|
||||||
ROUTE_MODE_STATE_FILE="${routeModeStateFile}"
|
ROUTE_MODE_STATE_FILE="${routeModeStateFile}"
|
||||||
@@ -370,7 +369,6 @@ let
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
startSocks = mkStartScript {
|
startSocks = mkStartScript {
|
||||||
name = "proxy-suite-start-socks";
|
|
||||||
runtimeDir = "/run/proxy-suite-socks";
|
runtimeDir = "/run/proxy-suite-socks";
|
||||||
configFile = tproxyFile;
|
configFile = tproxyFile;
|
||||||
routingMark = globalTproxy.proxyMark;
|
routingMark = globalTproxy.proxyMark;
|
||||||
@@ -384,7 +382,6 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
startTun = mkStartScript {
|
startTun = mkStartScript {
|
||||||
name = "proxy-suite-start-tun";
|
|
||||||
runtimeDir = "/run/proxy-suite-tun";
|
runtimeDir = "/run/proxy-suite-tun";
|
||||||
configFile = tunFile;
|
configFile = tunFile;
|
||||||
routingMark = if pureXrayEnabled then globalTproxy.proxyMark else null;
|
routingMark = if pureXrayEnabled then globalTproxy.proxyMark else null;
|
||||||
@@ -395,7 +392,6 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
startPerAppTun = mkStartScript {
|
startPerAppTun = mkStartScript {
|
||||||
name = "proxy-suite-start-per-app-tun";
|
|
||||||
runtimeDir = "/run/proxy-suite-per-app-tun";
|
runtimeDir = "/run/proxy-suite-per-app-tun";
|
||||||
configFile = perAppTunFile;
|
configFile = perAppTunFile;
|
||||||
routingMark = if xrayEnabled || globalTproxy.enable then globalTproxy.proxyMark else null;
|
routingMark = if xrayEnabled || globalTproxy.enable then globalTproxy.proxyMark else null;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ let
|
|||||||
s = cfg.sshProxy;
|
s = cfg.sshProxy;
|
||||||
destination = if s.server.user == null then s.server.host else "${s.server.user}@${s.server.host}";
|
destination = if s.server.user == null then s.server.host else "${s.server.user}@${s.server.host}";
|
||||||
extraArgs = lib.concatMapStrings (arg: " args+=(${lib.escapeShellArg arg})\n") s.extraArgs;
|
extraArgs = lib.concatMapStrings (arg: " args+=(${lib.escapeShellArg arg})\n") s.extraArgs;
|
||||||
startScript = pkgs.writeShellScript "proxy-suite-ssh-proxy-start" ''
|
startScript = pkgs.writeShellScript "proxy-suite-ssh-proxy" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
args=(
|
args=(
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ let
|
|||||||
dcArgs = lib.concatMapStrings (id: mkValueArg "--dc-ip" "${id}:${t.dcIps.${id}}") (
|
dcArgs = lib.concatMapStrings (id: mkValueArg "--dc-ip" "${id}:${t.dcIps.${id}}") (
|
||||||
builtins.attrNames t.dcIps
|
builtins.attrNames t.dcIps
|
||||||
);
|
);
|
||||||
startScript = pkgs.writeShellScript "proxy-suite-tg-ws-proxy-start" ''
|
startScript = pkgs.writeShellScript "proxy-suite-tg-ws-proxy" ''
|
||||||
args=(
|
args=(
|
||||||
--port=${toString t.listener.port}
|
--port=${toString t.listener.port}
|
||||||
--host=${lib.escapeShellArg t.listener.address}
|
--host=${lib.escapeShellArg t.listener.address}
|
||||||
@@ -48,7 +48,7 @@ let
|
|||||||
exec ${tgPkg}/bin/tg-ws-proxy "''${args[@]}"
|
exec ${tgPkg}/bin/tg-ws-proxy "''${args[@]}"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
bypassUpScript = pkgs.writeShellScript "proxy-suite-tg-ws-proxy-bypass-up" ''
|
bypassUpScript = pkgs.writeShellScript "proxy-suite-tg-ws-proxy" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
add_bypass_rule() {
|
add_bypass_rule() {
|
||||||
@@ -61,7 +61,7 @@ let
|
|||||||
add_bypass_rule -6
|
add_bypass_rule -6
|
||||||
'';
|
'';
|
||||||
|
|
||||||
bypassDownScript = pkgs.writeShellScript "proxy-suite-tg-ws-proxy-bypass-down" ''
|
bypassDownScript = pkgs.writeShellScript "proxy-suite-tg-ws-proxy" ''
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
while ${ip} -4 rule del pref ${toString bypassRulePriority} fwmark ${toString t.fwmark} lookup main 2>/dev/null; do :; done
|
while ${ip} -4 rule del pref ${toString bypassRulePriority} fwmark ${toString t.fwmark} lookup main 2>/dev/null; do :; done
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ let
|
|||||||
w = derived.warpCfg;
|
w = derived.warpCfg;
|
||||||
listener = cfg.proxy.listener;
|
listener = cfg.proxy.listener;
|
||||||
auth = listener.auth;
|
auth = listener.auth;
|
||||||
|
scriptsDir = builtins.path {
|
||||||
|
name = "proxy-suite-scripts";
|
||||||
|
path = ../../scripts;
|
||||||
|
};
|
||||||
host =
|
host =
|
||||||
if
|
if
|
||||||
builtins.elem listener.address [
|
builtins.elem listener.address [
|
||||||
@@ -26,7 +30,7 @@ let
|
|||||||
if auth.passwordFile != null then
|
if auth.passwordFile != null then
|
||||||
auth.passwordFile
|
auth.passwordFile
|
||||||
else if auth.password != null then
|
else if auth.password != null then
|
||||||
pkgs.writeText "proxy-suite-warp-proxy-password" auth.password
|
pkgs.writeText "proxy-suite-warp" auth.password
|
||||||
else
|
else
|
||||||
null;
|
null;
|
||||||
userinfo = lib.optionalString (auth.username != null && passwordSource != null) ''
|
userinfo = lib.optionalString (auth.username != null && passwordSource != null) ''
|
||||||
@@ -34,7 +38,7 @@ let
|
|||||||
--rawfile p ${lib.escapeShellArg passwordSource} '"\($u | @uri):\($p | rtrimstr("\n") | @uri)@"')
|
--rawfile p ${lib.escapeShellArg passwordSource} '"\($u | @uri):\($p | rtrimstr("\n") | @uri)@"')
|
||||||
'';
|
'';
|
||||||
|
|
||||||
registerScript = pkgs.writeShellScript "proxy-suite-warp-register" ''
|
registerScript = pkgs.writeShellScript "proxy-suite-warp" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
[ -s wgcf-profile.conf ] && exit 0
|
[ -s wgcf-profile.conf ] && exit 0
|
||||||
|
|
||||||
@@ -73,7 +77,7 @@ let
|
|||||||
# Some lines drop a share of fresh WARP handshakes for good, and sing-box retries on the
|
# Some lines drop a share of fresh WARP handshakes for good, and sing-box retries on the
|
||||||
# same source port forever. A new process binds a new port, so the probe exits after
|
# same source port forever. A new process binds a new port, so the probe exits after
|
||||||
# repeated failures and systemd starts the tunnel again.
|
# repeated failures and systemd starts the tunnel again.
|
||||||
tunnelScript = pkgs.writeShellScript "proxy-suite-warp-tunnel" ''
|
tunnelScript = pkgs.writeShellScript "proxy-suite-warp" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
profile=${lib.escapeShellArg w.profilePath}
|
profile=${lib.escapeShellArg w.profilePath}
|
||||||
if [ ! -s "$profile" ]; then
|
if [ ! -s "$profile" ]; then
|
||||||
@@ -82,7 +86,7 @@ let
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# The profile is a secret, so it is converted here rather than baked into the store.
|
# The profile is a secret, so it is converted here rather than baked into the store.
|
||||||
endpoint=$(${pkgs.python3}/bin/python3 ${../../scripts/warp_outbound.py} --tag warp --routing-mark ${toString cfg.proxy.tproxy.proxyMark} < "$profile")
|
endpoint=$(${pkgs.python3}/bin/python3 ${scriptsDir}/warp_outbound.py --tag warp --routing-mark ${toString cfg.proxy.tproxy.proxyMark} < "$profile")
|
||||||
${pkgs.jq}/bin/jq -n --argjson ep "$endpoint" '{
|
${pkgs.jq}/bin/jq -n --argjson ep "$endpoint" '{
|
||||||
log: {level: "warn"},
|
log: {level: "warn"},
|
||||||
dns: {servers: [${builtins.toJSON dnsServer}]},
|
dns: {servers: [${builtins.toJSON dnsServer}]},
|
||||||
|
|||||||
@@ -46,13 +46,13 @@ let
|
|||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
perAppZapretMarkUpScript = pkgs.writeShellScript "proxy-suite-per-app-zapret-mark-up" ''
|
perAppZapretMarkUpScript = pkgs.writeShellScript "proxy-suite-zapret" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
${nft} delete table inet proxy_suite_per_app_zapret_mark 2>/dev/null || true
|
${nft} delete table inet proxy_suite_per_app_zapret_mark 2>/dev/null || true
|
||||||
${nft} -f ${perAppZapretRulesFile}
|
${nft} -f ${perAppZapretRulesFile}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
perAppZapretMarkDownScript = pkgs.writeShellScript "proxy-suite-per-app-zapret-mark-down" ''
|
perAppZapretMarkDownScript = pkgs.writeShellScript "proxy-suite-zapret" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
${nft} delete table inet proxy_suite_per_app_zapret_mark 2>/dev/null || true
|
${nft} delete table inet proxy_suite_per_app_zapret_mark 2>/dev/null || true
|
||||||
'';
|
'';
|
||||||
@@ -125,7 +125,7 @@ in
|
|||||||
wants = [ "zapret-discord-youtube.service" ];
|
wants = [ "zapret-discord-youtube.service" ];
|
||||||
conflicts = awgServiceNames;
|
conflicts = awgServiceNames;
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
execStart = pkgs.writeShellScript "proxy-suite-zapret-vm-exempt-start" exemptStart;
|
execStart = pkgs.writeShellScript "proxy-suite-zapret" exemptStart;
|
||||||
execStop = pkgs.writeShellScript "proxy-suite-zapret-vm-exempt-stop" exemptStop;
|
execStop = pkgs.writeShellScript "proxy-suite-zapret" exemptStop;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ let
|
|||||||
tunInterfaces ? [ ],
|
tunInterfaces ? [ ],
|
||||||
scope ? "global",
|
scope ? "global",
|
||||||
}:
|
}:
|
||||||
pkgs.writeText "proxy-suite-zapret-bypass.sh" ''
|
pkgs.writeText "proxy-suite-zapret" ''
|
||||||
# Upstream presets can select iptables explicitly, in which case the nft
|
# Upstream presets can select iptables explicitly, in which case the nft
|
||||||
# hook below is never called. Use upstream helpers for idempotent start
|
# hook below is never called. Use upstream helpers for idempotent start
|
||||||
# and stop, and distinct comments so each service owns its exemptions.
|
# and stop, and distinct comments so each service owns its exemptions.
|
||||||
@@ -205,10 +205,10 @@ let
|
|||||||
${lib.concatMapStrings (
|
${lib.concatMapStrings (
|
||||||
rule:
|
rule:
|
||||||
let
|
let
|
||||||
domainsFile = pkgs.writeText "proxy-suite-zapret-hostlist-${rule.name}.txt" (
|
domainsFile = pkgs.writeText "proxy-suite-zapret" (
|
||||||
lib.concatStringsSep "\n" (lib.unique rule.domains) + "\n"
|
lib.concatStringsSep "\n" (lib.unique rule.domains) + "\n"
|
||||||
);
|
);
|
||||||
ipsetFile = pkgs.writeText "proxy-suite-zapret-ipset-${rule.name}.txt" (
|
ipsetFile = pkgs.writeText "proxy-suite-zapret" (
|
||||||
lib.concatStringsSep "\n" (lib.unique rule.ips) + "\n"
|
lib.concatStringsSep "\n" (lib.unique rule.ips) + "\n"
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
|
|||||||
@@ -54,15 +54,18 @@ let
|
|||||||
if upstreamPackages ? zapret then upstreamPackages.zapret else upstreamPackages.default;
|
if upstreamPackages ? zapret then upstreamPackages.zapret else upstreamPackages.default;
|
||||||
|
|
||||||
mkOptionalHostlistFile =
|
mkOptionalHostlistFile =
|
||||||
fileName: entries:
|
entries:
|
||||||
if entries != [ ] then pkgs.writeText fileName (lib.concatStringsSep "\n" entries + "\n") else null;
|
if entries != [ ] then
|
||||||
|
pkgs.writeText "proxy-suite-zapret" (lib.concatStringsSep "\n" entries + "\n")
|
||||||
|
else
|
||||||
|
null;
|
||||||
|
|
||||||
listGeneralFile = mkOptionalHostlistFile "proxy-suite-zapret-list-general-user.txt" zapretCfg.zapret-discord-youtube.domains;
|
listGeneralFile = mkOptionalHostlistFile zapretCfg.zapret-discord-youtube.domains;
|
||||||
listExcludeFile = mkOptionalHostlistFile "proxy-suite-zapret-list-exclude-user.txt" zapretCfg.zapret-discord-youtube.excludeDomains;
|
listExcludeFile = mkOptionalHostlistFile zapretCfg.zapret-discord-youtube.excludeDomains;
|
||||||
ipsetAllFile = mkOptionalHostlistFile "proxy-suite-zapret-ipset-all.txt" zapretCfg.zapret-discord-youtube.ips;
|
ipsetAllFile = mkOptionalHostlistFile zapretCfg.zapret-discord-youtube.ips;
|
||||||
ipsetExcludeFile = mkOptionalHostlistFile "proxy-suite-zapret-ipset-exclude-user.txt" zapretCfg.zapret-discord-youtube.excludeIps;
|
ipsetExcludeFile = mkOptionalHostlistFile zapretCfg.zapret-discord-youtube.excludeIps;
|
||||||
|
|
||||||
hostlistRuleSpec = pkgs.writeText "proxy-suite-zapret-hostlist-rules.json" (
|
hostlistRuleSpec = pkgs.writeText "proxy-suite-zapret" (
|
||||||
builtins.toJSON {
|
builtins.toJSON {
|
||||||
includeExtraUpstreamLists = zapretCfg.zapret-discord-youtube.includeExtraUpstreamLists;
|
includeExtraUpstreamLists = zapretCfg.zapret-discord-youtube.includeExtraUpstreamLists;
|
||||||
entries = map (rule: {
|
entries = map (rule: {
|
||||||
@@ -81,10 +84,12 @@ let
|
|||||||
);
|
);
|
||||||
|
|
||||||
selectedConfigName = lib.strings.sanitizeDerivationName zapretCfg.zapret-discord-youtube.configName;
|
selectedConfigName = lib.strings.sanitizeDerivationName zapretCfg.zapret-discord-youtube.configName;
|
||||||
patchConfigScriptSrc = builtins.path {
|
patchConfigScriptSrc = "${
|
||||||
path = ../../../scripts/patch-zapret-config.py;
|
builtins.path {
|
||||||
name = "patch-zapret-config.py";
|
name = "proxy-suite-scripts";
|
||||||
};
|
path = ../../../scripts;
|
||||||
|
}
|
||||||
|
}/patch-zapret-config.py";
|
||||||
patchConfigScript = "${pkgs.python3}/bin/python3 ${patchConfigScriptSrc}";
|
patchConfigScript = "${pkgs.python3}/bin/python3 ${patchConfigScriptSrc}";
|
||||||
|
|
||||||
packageBuilder = import ./package-builder.nix {
|
packageBuilder = import ./package-builder.nix {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ let
|
|||||||
|
|
||||||
# Wrapped apps opted in: MODE_FILTER=none applies every profile to all their traffic.
|
# Wrapped apps opted in: MODE_FILTER=none applies every profile to all their traffic.
|
||||||
perAppRuntime = runtime.mkRuntime {
|
perAppRuntime = runtime.mkRuntime {
|
||||||
name = "proxy-suite-per-app-zapret2";
|
name = "proxy-suite-zapret2";
|
||||||
qnum = perAppZapretCfg.qnum;
|
qnum = perAppZapretCfg.qnum;
|
||||||
desyncMark = 134217728; # 0x8000000
|
desyncMark = 134217728; # 0x8000000
|
||||||
desyncMarkPostnat = 67108864; # 0x4000000
|
desyncMarkPostnat = 67108864; # 0x4000000
|
||||||
@@ -87,13 +87,13 @@ let
|
|||||||
;
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
perAppZapretMarkUpScript = pkgs.writeShellScript "proxy-suite-per-app-zapret2-mark-up" ''
|
perAppZapretMarkUpScript = pkgs.writeShellScript "proxy-suite-zapret2" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
${nft} delete table inet proxy_suite_per_app_zapret_mark 2>/dev/null || true
|
${nft} delete table inet proxy_suite_per_app_zapret_mark 2>/dev/null || true
|
||||||
${nft} -f ${perAppZapretRulesFile}
|
${nft} -f ${perAppZapretRulesFile}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
perAppZapretMarkDownScript = pkgs.writeShellScript "proxy-suite-per-app-zapret2-mark-down" ''
|
perAppZapretMarkDownScript = pkgs.writeShellScript "proxy-suite-zapret2" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
${nft} delete table inet proxy_suite_per_app_zapret_mark 2>/dev/null || true
|
${nft} delete table inet proxy_suite_per_app_zapret_mark 2>/dev/null || true
|
||||||
'';
|
'';
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ let
|
|||||||
|
|
||||||
# $1 asn.txt, $2 sni.txt, $3 AS-to-prefix map; prints a sing-box source rule-set
|
# $1 asn.txt, $2 sni.txt, $3 AS-to-prefix map; prints a sing-box source rule-set
|
||||||
# with the prefixes of every cut-off network that no whitelisted name fixes.
|
# with the prefixes of every cut-off network that no whitelisted name fixes.
|
||||||
proxyRules = pkgs.writeShellScript "proxy-suite-zapret2-cutoff-rules" ''
|
proxyRules = pkgs.writeShellScript "proxy-suite-zapret2" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
${pkgs.gawk}/bin/awk -F'\t' '
|
${pkgs.gawk}/bin/awk -F'\t' '
|
||||||
FILENAME == ARGV[1] { if ($1 ~ /^[0-9]+$/) cut[$1] = 1; next }
|
FILENAME == ARGV[1] { if ($1 ~ /^[0-9]+$/) cut[$1] = 1; next }
|
||||||
@@ -48,7 +48,7 @@ let
|
|||||||
| {version: 1, rules: (if length > 0 then [{ip_cidr: .}] else [] end)}'
|
| {version: 1, rules: (if length > 0 then [{ip_cidr: .}] else [] end)}'
|
||||||
'';
|
'';
|
||||||
|
|
||||||
probe = pkgs.writeShellScript unit ''
|
probe = pkgs.writeShellScript "proxy-suite-zapret2" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
export PATH=${
|
export PATH=${
|
||||||
lib.makeBinPath [
|
lib.makeBinPath [
|
||||||
@@ -130,7 +130,7 @@ let
|
|||||||
# The probe measures this line, so its traffic leaves directly: proxyMark keeps it
|
# The probe measures this line, so its traffic leaves directly: proxyMark keeps it
|
||||||
# out of TUN/TProxy like the backend's own, and the conntrack bit keeps zapret2 from
|
# out of TUN/TProxy like the backend's own, and the conntrack bit keeps zapret2 from
|
||||||
# touching or learning it.
|
# touching or learning it.
|
||||||
exempt = pkgs.writeShellScript "${unit}-exempt" ''
|
exempt = pkgs.writeShellScript "proxy-suite-zapret2" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
${nft} delete table inet ${table} 2>/dev/null || true
|
${nft} delete table inet ${table} 2>/dev/null || true
|
||||||
${nft} -f - <<EOF
|
${nft} -f - <<EOF
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ let
|
|||||||
if zapret2Cfg.profiles == null && isZ2k then
|
if zapret2Cfg.profiles == null && isZ2k then
|
||||||
"${z2kGenerated}/profiles"
|
"${z2kGenerated}/profiles"
|
||||||
else
|
else
|
||||||
pkgs.writeText "proxy-suite-zapret2-profiles" (
|
pkgs.writeText "proxy-suite-zapret2" (
|
||||||
lib.concatStringsSep " --new " (map renderProfile (orSource zapret2Cfg.profiles source.profiles))
|
lib.concatStringsSep " --new " (map renderProfile (orSource zapret2Cfg.profiles source.profiles))
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ let
|
|||||||
if isZ2k then
|
if isZ2k then
|
||||||
"${z2kGenerated}/blobs"
|
"${z2kGenerated}/blobs"
|
||||||
else
|
else
|
||||||
pkgs.writeText "proxy-suite-zapret2-blobs" (lib.concatStringsSep " " source.blobArgs);
|
pkgs.writeText "proxy-suite-zapret2" (lib.concatStringsSep " " source.blobArgs);
|
||||||
|
|
||||||
# The state layer wraps circular, so it loads after the source's Lua. z2k-tcp16
|
# The state layer wraps circular, so it loads after the source's Lua. z2k-tcp16
|
||||||
# does nothing until the cutoff probe has written its maps.
|
# does nothing until the cutoff probe has written its maps.
|
||||||
@@ -138,7 +138,7 @@ let
|
|||||||
modeFilter,
|
modeFilter,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
header = pkgs.writeText "proxy-suite-zapret2-config-header" (
|
header = pkgs.writeText "proxy-suite-zapret2" (
|
||||||
lib.concatStringsSep "\n" (
|
lib.concatStringsSep "\n" (
|
||||||
[
|
[
|
||||||
"# Generated by proxy-suite. Do not edit."
|
"# Generated by proxy-suite. Do not edit."
|
||||||
@@ -175,7 +175,7 @@ let
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
pkgs.runCommand "proxy-suite-zapret2-config"
|
pkgs.runCommand "proxy-suite-zapret2"
|
||||||
{
|
{
|
||||||
nativeBuildInputs = [ pkgs.gawk ];
|
nativeBuildInputs = [ pkgs.gawk ];
|
||||||
inherit circularFill optPrefix;
|
inherit circularFill optPrefix;
|
||||||
@@ -259,7 +259,7 @@ let
|
|||||||
) exemptCidrs
|
) exemptCidrs
|
||||||
) chains;
|
) chains;
|
||||||
in
|
in
|
||||||
pkgs.writeText "proxy-suite-zapret2-custom.sh" (
|
pkgs.writeText "proxy-suite-zapret2" (
|
||||||
lib.concatStringsSep "\n" (
|
lib.concatStringsSep "\n" (
|
||||||
[ "zapret_custom_firewall_nft() {" ]
|
[ "zapret_custom_firewall_nft() {" ]
|
||||||
++ rules
|
++ rules
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ pkgs.testers.runNixOSTest {
|
|||||||
server.succeed(f"jq -e '.inbounds[] | select(.tag == \"ss-in\" and .port == 8388)' {cfg}")
|
server.succeed(f"jq -e '.inbounds[] | select(.tag == \"ss-in\" and .port == 8388)' {cfg}")
|
||||||
# Credentials live only in the runtime config, never in the store.
|
# Credentials live only in the runtime config, never in the store.
|
||||||
server.succeed(f"test $(stat -c %a {cfg}) = 600")
|
server.succeed(f"test $(stat -c %a {cfg}) = 600")
|
||||||
server.fail("grep -r '${uuid}' /nix/store/*proxy-suite-inbounds-*.json")
|
server.fail("grep -r '${uuid}' /nix/store/*-proxy-suite-inbounds")
|
||||||
|
|
||||||
with subtest("safety rules are present and ordered first"):
|
with subtest("safety rules are present and ordered first"):
|
||||||
cfg = "/run/proxy-suite-inbounds/config.json"
|
cfg = "/run/proxy-suite-inbounds/config.json"
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ let
|
|||||||
# writeText paths are content-addressed: finding one in the start script pins the
|
# writeText paths are content-addressed: finding one in the start script pins the
|
||||||
# JSON. The context is dropped so the check may mention it.
|
# JSON. The context is dropped so the check may mention it.
|
||||||
expectedOutboundFile =
|
expectedOutboundFile =
|
||||||
backend: value:
|
value:
|
||||||
builtins.unsafeDiscardStringContext "${
|
builtins.unsafeDiscardStringContext "${
|
||||||
pkgs.writeText "proxy-suite-ob-ssh-proxy-${backend}.json" (builtins.toJSON value)
|
pkgs.writeText "proxy-suite-core" (builtins.toJSON value)
|
||||||
}";
|
}";
|
||||||
|
|
||||||
# SingBox dials SSH natively: no unit, no local SOCKS listener.
|
# SingBox dials SSH natively: no unit, no local SOCKS listener.
|
||||||
@@ -47,7 +47,7 @@ let
|
|||||||
sshNativeSingBoxStart = generated.readDerivation (
|
sshNativeSingBoxStart = generated.readDerivation (
|
||||||
sshNativeSingBox.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart
|
sshNativeSingBox.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart
|
||||||
);
|
);
|
||||||
expectedNativeSingBoxOutbound = expectedOutboundFile "sing-box" {
|
expectedNativeSingBoxOutbound = expectedOutboundFile {
|
||||||
type = "ssh";
|
type = "ssh";
|
||||||
tag = "ssh-proxy";
|
tag = "ssh-proxy";
|
||||||
server = "ssh.example.com";
|
server = "ssh.example.com";
|
||||||
@@ -151,7 +151,7 @@ let
|
|||||||
);
|
);
|
||||||
xrayService = sshXray.config.systemd.services."proxy-suite-ssh-proxy";
|
xrayService = sshXray.config.systemd.services."proxy-suite-ssh-proxy";
|
||||||
xrayStartScript = generated.readDerivation xrayService.serviceConfig.ExecStart;
|
xrayStartScript = generated.readDerivation xrayService.serviceConfig.ExecStart;
|
||||||
expectedXrayOutbound = expectedOutboundFile "xray" {
|
expectedXrayOutbound = expectedOutboundFile {
|
||||||
protocol = "socks";
|
protocol = "socks";
|
||||||
tag = "ssh-proxy";
|
tag = "ssh-proxy";
|
||||||
settings = {
|
settings = {
|
||||||
@@ -186,7 +186,7 @@ let
|
|||||||
sshHybridStart = generated.readDerivation (
|
sshHybridStart = generated.readDerivation (
|
||||||
sshHybrid.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart
|
sshHybrid.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart
|
||||||
);
|
);
|
||||||
expectedHybridOutbound = expectedOutboundFile "hybrid" {
|
expectedHybridOutbound = expectedOutboundFile {
|
||||||
type = "ssh";
|
type = "ssh";
|
||||||
tag = "ssh-proxy";
|
tag = "ssh-proxy";
|
||||||
server = "ssh.example.com";
|
server = "ssh.example.com";
|
||||||
@@ -512,7 +512,7 @@ let
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
(
|
(
|
||||||
assert pkgs.lib.hasInfix "proxy-suite-ob-ssh-proxy-xray.json" sshUrltestStart;
|
assert pkgs.lib.hasInfix "# outbound: ssh-proxy (OpenSSH SOCKS5 listener)" sshUrltestStart;
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ in
|
|||||||
test "$(grep -c 'ct mark and 0x2000000 != 0 return' "${globalRuntime}/init.d/sysv/custom.d/50-proxy-suite-custom.sh")" = 4
|
test "$(grep -c 'ct mark and 0x2000000 != 0 return' "${globalRuntime}/init.d/sysv/custom.d/50-proxy-suite-custom.sh")" = 4
|
||||||
|
|
||||||
# Cut-off networks without a name become the proxy's rule-set; named ones stay with zapret2.
|
# Cut-off networks without a name become the proxy's rule-set; named ones stay with zapret2.
|
||||||
rules=$(grep -o '/nix/store/[^ ]*-proxy-suite-zapret2-cutoff-rules' ${cutoffProbe} | head -n1)
|
rules=$(grep -oE '/nix/store/[^ ]+-proxy-suite-zapret2 asn.txt' ${cutoffProbe} | cut -d' ' -f1)
|
||||||
printf '# networks\n24940\n14061\n' >asn.txt
|
printf '# networks\n24940\n14061\n' >asn.txt
|
||||||
printf '24940\t300.ya.ru\n' >sni.txt
|
printf '24940\t300.ya.ru\n' >sni.txt
|
||||||
printf '# map\n24940\t5.9.0.0/16\n14061\t104.131.0.0/16\n14061\t2604:a880::/32\n7777\t1.2.0.0/16\n' >nets.txt
|
printf '# map\n24940\t5.9.0.0/16\n14061\t104.131.0.0/16\n14061\t2604:a880::/32\n7777\t1.2.0.0/16\n' >nets.txt
|
||||||
|
|||||||
Reference in new issue
Block a user