feat: warp/awg and hysteria2 improvements

This commit is contained in:
fufsob committed 2026-09-28 15:26:52 +00:00
1 parent d25fcb5468
commit cd3aa5a53f
24 files changed
+676 -18

No files matched your search

+16
View File
@@ -48,6 +48,12 @@ let
builtinTags
;
constants = derived.constants;
hopRedirects = lib.concatMapStrings (
ib:
lib.optionalString (ib.listener.type == "hysteria2" && ib.listener.hysteria.portHopping != null) ''
fib daddr type local udp dport ${ib.listener.hysteria.portHopping} redirect to :${toString ib.listener.port}
''
) derived.proxyInbounds;
routingScripts = import ./routing-scripts.nix { inherit (context) ctx; };
serviceUnits = import ./units.nix {
@@ -98,6 +104,16 @@ lib.mkMerge [
|| perAppZapretEnabled
) true;
# hysteria2 port hopping: the range lands on the listener's port before the firewall
# sees it, so only that port needs opening.
nftablesTables = lib.mkIf (proxyInboundsEnabled && hopRedirects != "") {
proxy-suite-hysteria-hop = ''
chain prerouting {
type nat hook prerouting priority dstnat; policy accept;
${hopRedirects}}
'';
};
# Inbound listeners are reached from outside, so their ports have to be open.
firewall = lib.mkMerge [
(lib.mkIf (proxyInboundsEnabled && cfg.inbounds.openFirewall) {
@@ -3,6 +3,7 @@
pureXrayEnabled,
selectionMode,
proxyInboundsGuardPrivate,
proxyInboundsGuardStrategy ? null,
userDnsRules ? [ ],
}:
@@ -120,7 +121,11 @@ else
# proxy rules above take stay unresolved and none reaches a direct dial unchecked. Local
# mixed-in clients lose names that resolve private. Rules for other inbounds do not count:
# autoProxy's direct probe pin would put the guard first, resolving every name, .onion too.
| [{inbound: ["mixed-in"], action: "resolve"},
| [{inbound: ["mixed-in"], action: "resolve"${
lib.optionalString (
proxyInboundsGuardStrategy != null
) ", strategy: \"${proxyInboundsGuardStrategy}\""
}},
{inbound: ["mixed-in"], ip_is_private: true, action: "reject"}] as $guard
| (.route.rules
| map((.outbound? // "") == "direct" and ((.inbound? // ["mixed-in"]) | index(["mixed-in"])) != null)
@@ -405,12 +405,29 @@ let
}
// lib.optionalAttrs (routingMark != null) { mark = routingMark; };
}
// lib.optionalAttrs (ob.domainStrategy != null) {
settings.domainStrategy =
{
prefer_ipv4 = "UseIPv4v6";
prefer_ipv6 = "UseIPv6v4";
ipv4_only = "UseIPv4";
ipv6_only = "UseIPv6";
}
.${ob.domainStrategy};
}
else
{
type = "direct";
inherit (ob) tag;
bind_interface = ob.interface;
domain_resolver = constants.awgDnsServerTag ob.tag;
domain_resolver =
if ob.domainStrategy == null then
constants.awgDnsServerTag ob.tag
else
{
server = constants.awgDnsServerTag ob.tag;
strategy = ob.domainStrategy;
};
}
// lib.optionalAttrs (routingMark != null) { routing_mark = routingMark; }
);
+2
View File
@@ -23,6 +23,7 @@ let
xray
proxyInboundsCfg
proxyInboundsGuardPrivate
proxyInboundsGuardStrategy
routeModeRulesFile
tproxyFile
tunFile
@@ -156,6 +157,7 @@ let
pureXrayEnabled
selectionMode
proxyInboundsGuardPrivate
proxyInboundsGuardStrategy
;
userDnsRules = proxyCfg.dns.singBox.rules;
};