fix: multiple fixes

This commit is contained in:
fufsob committed 2026-09-15 03:08:32 +00:00
1 parent 5c6b2b4163
commit f325e76b2f
22 files changed
+107 -92

No files matched your search

+1 -1
View File
@@ -151,7 +151,7 @@ let
implementation="$(${pkgs.python3}/bin/python3 ${configTool} \
--transport-implementation ${lib.escapeShellArg configPath})"
# The 3.1.20260812 kernel module drops RandomTrailers packets with ranged H1-H3;
# The 3.1 kernel module dropped RandomTrailers packets with ranged H1-H3 (seen on 20260812);
# userspace carries the fix.
if [[ "$implementation" == userspace ]]; then
WG_QUICK_FORCE_USERSPACE_IMPLEMENTATION=1 \
+2 -1
View File
@@ -406,7 +406,8 @@ let
"proxy-suite-socks.service"
"proxy-suite-inbounds.service"
];
wants = [ "proxy-suite-socks.service" ];
# No wants: a timer run must not start a proxy stopped on purpose; without
# its listeners the runner has nothing to do and says so.
serviceConfig = {
Type = "oneshot";
ExecStart = "${runner}${args}";
+2
View File
@@ -55,6 +55,8 @@ in
in
{
xray = import ../../pkgs/xray.nix { pkgs = upstream; };
# AWG 3.1 userspace; its kernel module has to match the system's kernel instead.
amneziaWg = import ../../pkgs/amneziawg.nix { pkgs = upstream; };
inherit (upstream) sing-box;
};
}
+2 -2
View File
@@ -1,7 +1,7 @@
{
config,
lib,
pkgs,
proxySuiteUpstream,
...
}:
@@ -12,7 +12,7 @@ let
types
;
t = import ./types.nix { inherit lib; };
awgPackages = import ../../../pkgs/amneziawg.nix { inherit pkgs; };
awgPackages = proxySuiteUpstream.amneziaWg;
in
{
options.services.proxy-suite.amneziaWg = {
+13 -12
View File
@@ -18,18 +18,18 @@ let
systemctl = "${pkgs.systemd}/bin/systemctl";
curl = "${pkgs.curl}/bin/curl";
restartActiveConfigConsumersBlock =
lib.concatMapStrings
(svc: ''
if ${systemctl} is-active --quiet ${svc}; then
${systemctl} restart ${svc}
fi
'')
[
"proxy-suite-socks"
"proxy-suite-tun"
"proxy-suite-per-app-tun"
];
restartActiveBlock = lib.concatMapStrings (svc: ''
if ${systemctl} is-active --quiet ${svc}; then
${systemctl} restart ${svc}
fi
'');
# The TUN backends are sing-box instances of their own, without a Clash API.
tunConsumers = [
"proxy-suite-tun"
"proxy-suite-per-app-tun"
];
restartActiveConfigConsumersBlock = restartActiveBlock ([ "proxy-suite-socks" ] ++ tunConsumers);
subscriptionUpdateScript = pkgs.writeShellScript "proxy-suite-core" ''
set -euo pipefail
@@ -102,6 +102,7 @@ let
if ${curl} -sf -X PUT "${clashApi}/proxies/proxy" \
-H "Content-Type: application/json" \
-d "$(${jq} -cn --arg name "$tag" '{name:$name}')" >/dev/null 2>&1; then
${restartActiveBlock tunConsumers}
exit 0
fi
fi
@@ -46,7 +46,7 @@ let
cgroup_level=$(printf '%s' "$cgroup_path" | ${awk} -F/ '{ print NF }')
handles=$(${nft} -a list chain ${nftFamily} ${nftTable} ${nftChain} 2>/dev/null \
| ${grepBin} -F "comment \"$rule_comment_prefix" \
| ${grepBin} -F "comment \"$rule_comment_prefix-mark\"" \
| ${awk} '{ print $NF }' || true)
if [ -n "$handles" ]; then
while IFS= read -r handle; do
@@ -72,7 +72,7 @@ let
uid="$1"
rule_comment_prefix="proxy-suite-${name}-user-$uid"
handles=$(${nft} -a list chain ${nftFamily} ${nftTable} ${nftChain} 2>/dev/null \
| ${grepBin} -F "comment \"$rule_comment_prefix" \
| ${grepBin} -F "comment \"$rule_comment_prefix-mark\"" \
| ${awk} '{ print $NF }' || true)
if [ -n "$handles" ]; then
while IFS= read -r handle; do
@@ -354,9 +354,10 @@ let
${singBox} run -c "$RUNTIME_DIR/config.json" &
SING_BOX_PID="$!"
# Either one going away breaks the outbounds: exit, and let systemd restart both.
SING_BOX_STATUS=0
wait "$SING_BOX_PID" || SING_BOX_STATUS="$?"
exit "$SING_BOX_STATUS"
wait -n "$XRAY_SIDECAR_PID" "$SING_BOX_PID" || SING_BOX_STATUS="$?"
exit "$(( SING_BOX_STATUS == 0 ? 1 : SING_BOX_STATUS ))"
fi
exec ${singBox} run -c "$RUNTIME_DIR/config.json"
+2
View File
@@ -229,6 +229,8 @@ let
wants = [ "network-online.target" ];
execStart = scripts.subscriptionUpdateScript;
stateDirectory = "proxy-suite";
# Run by a timer and by `proxy subs update`: a unit left "active" would never run again.
extraServiceConfig.RemainAfterExit = false;
};
}
{
+15 -1
View File
@@ -10,6 +10,8 @@ let
t = cfg.tgWsProxy;
tgPkg = packages.tg-ws-proxy;
ip = "${pkgs.iproute2}/bin/ip";
nft = "${pkgs.nftables}/bin/nft";
markTable = "proxy_suite_tg_ws_proxy";
transparentBypassEnabled =
t.bypassTransparentProxy && cfg.proxy.enable && (cfg.proxy.tun.enable || cfg.proxy.tproxy.enable);
@@ -59,6 +61,18 @@ let
add_bypass_rule -4
add_bypass_rule -6
# The relay's own sockets carry the mark. By cgroup, which is resolved when the rule
# loads: this runs again on every start. Ahead of the TProxy output chain.
${nft} delete table inet ${markTable} 2>/dev/null || true
${nft} -f - <<EOF
table inet ${markTable} {
chain output {
type route hook output priority mangle - 1; policy accept;
socket cgroupv2 level 2 "system.slice/proxy-suite-tg-ws-proxy.service" meta mark set ${toString t.fwmark}
}
}
EOF
'';
bypassDownScript = pkgs.writeShellScript "proxy-suite-tg-ws-proxy" ''
@@ -66,6 +80,7 @@ let
while ${ip} -4 rule del pref ${toString bypassRulePriority} fwmark ${toString t.fwmark} lookup main 2>/dev/null; do :; done
while ${ip} -6 rule del pref ${toString bypassRulePriority} fwmark ${toString t.fwmark} lookup main 2>/dev/null; do :; done
${nft} delete table inet ${markTable} 2>/dev/null
'';
in
{
@@ -83,7 +98,6 @@ in
// lib.optionalAttrs transparentBypassEnabled {
ExecStartPre = bypassUpScript;
ExecStopPost = bypassDownScript;
SocketMark = toString t.fwmark;
};
};
}
+19 -9
View File
@@ -119,13 +119,23 @@ in
systemd.services.proxy-suite-zapret-vm-exempt =
lib.mkIf (zapretCfg.enable && zapretCfg.cidrExemption.enable)
(mkOneshotService {
description = "Exempt CIDRs from zapret NFQUEUE";
after = [ "proxy-suite-zapret.service" ];
wants = [ "proxy-suite-zapret.service" ];
conflicts = awgServiceNames;
wantedBy = [ "multi-user.target" ];
execStart = pkgs.writeShellScript "proxy-suite-zapret" exemptStart;
execStop = pkgs.writeShellScript "proxy-suite-zapret" exemptStop;
});
(
mkOneshotService {
description = "Exempt CIDRs from zapret NFQUEUE";
after = [ "proxy-suite-zapret.service" ];
wants = [ "proxy-suite-zapret.service" ];
conflicts = awgServiceNames;
# zapret inserts its rules at the top (iptables -I): these are re-inserted after
# every zapret start or restart, or they end up below its NFQUEUE jumps.
wantedBy = [
"multi-user.target"
"proxy-suite-zapret.service"
];
execStart = pkgs.writeShellScript "proxy-suite-zapret" exemptStart;
execStop = pkgs.writeShellScript "proxy-suite-zapret" exemptStop;
}
// {
partOf = [ "proxy-suite-zapret.service" ];
}
);
}