refactor: remove duplication
This commit is contained in:
109 files changed
+2206
-3078
No files matched your search
@@ -0,0 +1,27 @@
|
||||
# Shared AmneziaWG plumbing: bringing an interface up the way both the client profiles
|
||||
# (./amnezia-wg.nix) and the server listeners (./amnezia-wg-inbounds.nix) need it.
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
awgCfg,
|
||||
}:
|
||||
{
|
||||
# The kernel module is optional; userspace works without it.
|
||||
modprobe = lib.optionalString (awgCfg.kernelModulePackage != null) ''
|
||||
${pkgs.kmod}/bin/modprobe amneziawg 2>/dev/null || true
|
||||
'';
|
||||
|
||||
# `implementation` is a shell word holding "userspace" or "kernel", `config` the .conf path.
|
||||
# The 3.1 kernel module dropped RandomTrailers packets with ranged H1-H3 (seen on 20260812);
|
||||
# userspace carries the fix, so a profile that needs it asks for userspace by name.
|
||||
awgQuickUp = implementation: config: ''
|
||||
if [[ "${implementation}" == userspace ]]; then
|
||||
WG_QUICK_FORCE_USERSPACE_IMPLEMENTATION=1 \
|
||||
WG_QUICK_USERSPACE_IMPLEMENTATION=${awgCfg.userspacePackage}/bin/amneziawg-go \
|
||||
${awgCfg.toolsPackage}/bin/awg-quick up ${config}
|
||||
else
|
||||
WG_QUICK_USERSPACE_IMPLEMENTATION=${awgCfg.userspacePackage}/bin/amneziawg-go \
|
||||
${awgCfg.toolsPackage}/bin/awg-quick up ${config}
|
||||
fi
|
||||
'';
|
||||
}
|
||||
Reference in new issue
Block a user