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
@@ -95,7 +95,7 @@ null or package
*Default:*
```nix
<derivation amneziawg-3.1.20260812>
<derivation amneziawg-3.1.20260828>
```
<a id="services-proxy-suite-amneziawg-profiles"></a>
+4 -1
View File
@@ -60,9 +60,12 @@
nixosModules.zapret = zapret.nixosModules.default;
overlays.default = final: prev: {
inherit (import ./pkgs/default.nix { pkgs = final; })
# From prev: these override the nixpkgs packages of the same name.
inherit (import ./pkgs/default.nix { pkgs = prev; })
amneziawg-tools
amneziawg-go
;
inherit (import ./pkgs/default.nix { pkgs = final; })
mkProxyCtl
mkTgWsProxy
tg-ws-proxy
+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" ];
}
);
}
+5 -5
View File
@@ -197,8 +197,8 @@ in
awgOnly.config.environment.systemPackages;
assert builtins.elem awgOnly.config.services.proxy-suite.amneziaWg.userspacePackage
awgOnly.config.environment.systemPackages;
assert awgOnly.config.services.proxy-suite.amneziaWg.toolsPackage.version == "3.1.20260812";
assert awgOnly.config.services.proxy-suite.amneziaWg.userspacePackage.version == "3.1.20260828";
assert pkgs.lib.versionAtLeast awgOnly.config.services.proxy-suite.amneziaWg.toolsPackage.version "3.1";
assert pkgs.lib.versionAtLeast awgOnly.config.services.proxy-suite.amneziaWg.userspacePackage.version "3.1";
assert pkgs.lib.hasInfix "cmd_awg" ctl.script;
assert
ctl.awgProfiles == [
@@ -208,11 +208,11 @@ in
true
)
(
assert defaultPackages.config.services.proxy-suite.amneziaWg.toolsPackage.version == "3.1.20260812";
assert pkgs.lib.versionAtLeast defaultPackages.config.services.proxy-suite.amneziaWg.toolsPackage.version "3.1";
assert
defaultPackages.config.services.proxy-suite.amneziaWg.userspacePackage.version == "3.1.20260828";
pkgs.lib.versionAtLeast defaultPackages.config.services.proxy-suite.amneziaWg.userspacePackage.version "3.1";
assert
defaultPackages.config.services.proxy-suite.amneziaWg.kernelModulePackage.version == "3.1.20260812";
pkgs.lib.versionAtLeast defaultPackages.config.services.proxy-suite.amneziaWg.kernelModulePackage.version "3.1";
true
)
(
+6
View File
@@ -50,6 +50,12 @@ in
assert subscriptionOnlyFixture.config.systemd.timers ? "proxy-suite-subscription-update";
true
)
# A oneshot left active would swallow every later timer run.
(
assert
!subscriptionOnlyFixture.config.systemd.services."proxy-suite-subscription-update".serviceConfig.RemainAfterExit;
true
)
# StateDirectory is set on the socks service.
(
+3 -1
View File
@@ -80,7 +80,9 @@ in
# Global TUN/TProxy bypass mark keeps relay traffic out of transparent capture.
(
assert tgWithGlobalTunServiceConfig.SocketMark == "4";
assert !(tgWithGlobalTunServiceConfig ? SocketMark);
assert pkgs.lib.hasInfix "\"system.slice/proxy-suite-tg-ws-proxy.service\" meta mark set 4" tgWithGlobalTunBypassUp;
assert pkgs.lib.hasInfix "delete table inet proxy_suite_tg_ws_proxy" tgWithGlobalTunBypassDown;
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";
+5 -43
View File
@@ -1,50 +1,12 @@
# nixpkgs' AmneziaWG 3.1 packages plus this suite's patches.
{ pkgs }:
let
# Tools and the kernel module currently publish 3.1.20260812, while the
# userspace implementation has follow-up 3.1 fixes through 20260828.
# nixpkgs itself still tracks AWG 3.0.
version = "3.1.20260812";
userspaceVersion = "3.1.20260828";
{
tools = pkgs.amneziawg-tools.overrideAttrs (old: {
inherit version;
src = pkgs.fetchFromGitHub {
owner = "amnezia-vpn";
repo = "amneziawg-tools";
tag = "v${version}";
hash = "sha256-6GEb41ERhR0Hg3RbSyIHdXPSKaxugoFCmFS5S0UiZso=";
};
patches = (old.patches or [ ]) ++ [ ./patches/amneziawg-tools-force-userspace.patch ];
});
userspace = pkgs.amneziawg-go.overrideAttrs (_: {
version = userspaceVersion;
src = pkgs.fetchFromGitHub {
owner = "amnezia-vpn";
repo = "amneziawg-go";
tag = "v${userspaceVersion}";
hash = "sha256-vZb72SA+6v8FXZX247K05yiVEBWpLqAAIyw6bEE4eUQ=";
};
patches = [ ./patches/amneziawg-go-random-trailers-transport.patch ];
# The 3.1 releases keep the dependency set used by nixpkgs' 3.0 package.
vendorHash = "sha256-Y2dCwlKMVLrkzDcNKyCPxFJwMbCA2mQKkakvzwbamCY=";
userspace = pkgs.amneziawg-go.overrideAttrs (old: {
patches = (old.patches or [ ]) ++ [ ./patches/amneziawg-go-random-trailers-transport.patch ];
});
kernelModule = kernelPackages: kernelPackages.amneziawg.overrideAttrs (_: {
inherit version;
src = pkgs.fetchFromGitHub {
owner = "amnezia-vpn";
repo = "amneziawg-linux-kernel-module";
tag = "v${version}";
hash = "sha256-dJ7Au4J8iPlphSzTa3Gol/LMlroroSc2IUmXZfjA0k8=";
};
});
in
{
inherit
version
userspaceVersion
tools
userspace
kernelModule
;
kernelModule = kernelPackages: kernelPackages.amneziawg;
}
+5 -1
View File
@@ -544,6 +544,9 @@ def _overall_state(snapshot):
label = "Proxy only" if label == "Proxy" else label
elif snapshot["awg"]["active"]:
label = "AmneziaWG"
elif traffic:
# TUN runs its own backend, without proxy-suite-socks.
label = "TUN" + (" + zapret" if zapret else "")
else:
label = "Zapret only" if zapret else "Inactive"
units = snapshot.get("units") or {}
@@ -2350,7 +2353,8 @@ ALIASES = {
def cmd_logs(*units):
if units:
_exec(["journalctl", "-fu", *units])
# One -u per unit: a bare second name would be taken as a journal match.
_exec(["journalctl", "-f", *(f"--unit={u}" for u in units)])
# journalctl takes unit globs, so the default needs no unit list of its own.
_exec(["journalctl", "-f", "-u", "proxy-suite-*"])
+7 -2
View File
@@ -297,6 +297,10 @@ def _enabled(name):
return lambda _: ctl.env(name) == "1"
def _sub_url(row):
return bool(row["user"]) and bool(ctl.env("INBOUNDS_SUB_BASE_URL"))
def _zapret_toggle(row, _, states):
return ["zapret", "off" if states.get("proxy-suite-zapret") == "active" else "on"]
@@ -412,8 +416,9 @@ TABS = [
Action("c", "copy share link", lambda r, *_: _link(r), when=ROW, mode="copy"),
Action("Q", "share link as QR", lambda r, *_: _link(r, "--qr"), when=ROW, mode="dialog"),
Action("s", "subscription URL", lambda r, *_: ["inbounds", "sub", r["user"]], when=lambda r: bool(r["user"]), mode="dialog"),
Action("S", "subscription URL as QR", lambda r, *_: ["inbounds", "sub", r["user"], "--qr"], when=lambda r: bool(r["user"]), mode="dialog"),
Action("y", "copy subscription URL", lambda r, *_: ["inbounds", "sub", r["user"]], when=lambda r: bool(r["user"]), mode="copy"),
# Without subscriptions.baseUrl there is only a file path, with a hint after it: nothing to encode or copy.
Action("S", "subscription URL as QR", lambda r, *_: ["inbounds", "sub", r["user"], "--qr"], when=_sub_url, mode="dialog"),
Action("y", "copy subscription URL", lambda r, *_: ["inbounds", "sub", r["user"]], when=_sub_url, mode="copy"),
Action("t", "traffic per user", lambda r, *_: ["inbounds", "stats"], mode="dialog"),
],
),
+5 -1
View File
@@ -607,7 +607,11 @@ class ProxyTui(App):
def perform(self, action, row):
def with_text(text=""):
argv = action.argv(row, text, self.states)
try:
argv = action.argv(row, text, self.states)
except (ValueError, IndexError) as e: # an unbalanced quote in a typed command
self.feedback(f"Cannot run that: {e}", False)
return
confirm = action.confirm(row) if callable(action.confirm) else action.confirm
if confirm:
self.push_screen(Confirm(f"proxy-ctl {shlex.join(argv)}"), lambda ok: ok and self.run_argv(action.mode, argv))
+1
View File
@@ -624,6 +624,7 @@ class StatusSnapshotTest(EnvTest):
both = self.overall(socks="active", zapret="active", tun="active")
self.assertEqual((both["base"], both["label"]), ("tunnel", "Proxy + traffic + zapret"))
self.assertEqual(self.overall(awg_work="active"), {"base": "tunnel", "badge": "", "label": "AmneziaWG"})
self.assertEqual(self.overall(tun="active")["label"], "TUN")
def test_badges(self):
self.assertEqual(self.overall(socks="active", tun="failed")["badge"], "failed")
+1 -1
View File
@@ -20,7 +20,7 @@ if ! command -v jq >/dev/null 2>&1; then
fi
system="${NIXPKGS_WATCH_SYSTEM:-x86_64-linux}"
default_watch_attrs="sing-box,proxychains-ng,sing-geosite,sing-geoip,nftables,iproute2,iptables,ipset,python3,python3Packages.requests,python3Packages.websockets,python3Packages.cryptography,gtk3,libayatana-appindicator"
default_watch_attrs="sing-box,proxychains-ng,sing-geosite,sing-geoip,nftables,iproute2,iptables,ipset,python3,python3Packages.requests,python3Packages.websockets,python3Packages.cryptography,gtk4,libadwaita,amneziawg-tools,amneziawg-go,linuxPackages.amneziawg"
watch_attrs_csv="${NIXPKGS_WATCH_ATTRS:-$default_watch_attrs}"
IFS=',' read -r -a watch_attrs <<< "$watch_attrs_csv"
+3 -6
View File
@@ -5,7 +5,7 @@
# Table columns: nix-file|owner|repo|version-key|flake-attr
# version-key the `<key> = "...";` line holding the tag. A leading "=" means
# "do not query GitHub, reuse the value of that key" - for sources
# that must stay in lockstep (AWG kernel module follows tools).
# that must stay in lockstep.
# flake-attr package built to recompute vendorHash; "-" when there is none.
#
# Prints one "updated <repo>: <old> -> <new>" line per change on stdout; progress
@@ -16,9 +16,6 @@ PINS=(
"pkgs/tg-ws-proxy.nix|Flowseal|tg-ws-proxy|rev|tg-ws-proxy"
"pkgs/zapret2.nix|bol-van|zapret2|version|zapret2"
"pkgs/xray.nix|XTLS|Xray-core|version|xray"
"pkgs/amneziawg.nix|amnezia-vpn|amneziawg-tools|version|amneziawg-tools"
"pkgs/amneziawg.nix|amnezia-vpn|amneziawg-go|userspaceVersion|amneziawg-go"
"pkgs/amneziawg.nix|amnezia-vpn|amneziawg-linux-kernel-module|=version|-"
)
FAKE_HASH="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
@@ -64,7 +61,7 @@ get_key() {
# Replace `<attr> = "...";` with val. When repo is non-empty the search is scoped
# to the fetchFromGitHub block of that repo, so sibling pins in the same file
# (amneziawg.nix holds three) never clobber each other. Returns 1 if not found.
# never clobber each other. Returns 1 if not found.
set_attr() {
local file=$1 repo=$2 attr=$3 val=$4 tmp
tmp=$(mktemp)
@@ -110,7 +107,7 @@ refresh_vendor_hash() {
# `--self-test`: the one thing that must not break is set_attr's block scoping -
# amneziawg.nix holds three fetchFromGitHub blocks and a vendorHash that belongs
# a file may hold several fetchFromGitHub blocks and a vendorHash that belongs
# to exactly one of them.
self_test() {
local d f