fix: multiple fixes + cleanup and formatting
This commit is contained in:
59 files changed
+1357
-920
No files matched your search
@@ -27,7 +27,17 @@ let
|
||||
map (other: "${serviceName other}.service") (
|
||||
builtins.filter (other: other != name) globalProfileNames
|
||||
);
|
||||
inherit (import ./wg-tunnel.nix { inherit lib pkgs cfg derived; }) mkTunnel;
|
||||
inherit
|
||||
(import ./wg-tunnel.nix {
|
||||
inherit
|
||||
lib
|
||||
pkgs
|
||||
cfg
|
||||
derived
|
||||
;
|
||||
})
|
||||
mkTunnel
|
||||
;
|
||||
sourceCount =
|
||||
profile:
|
||||
builtins.length (
|
||||
@@ -84,9 +94,15 @@ let
|
||||
bypassRule =
|
||||
family: action:
|
||||
"${pkgs.iproute2}/bin/ip ${family} rule ${action} pref ${toString proxyBypassRulePriority} fwmark ${toString cfg.proxy.tproxy.proxyMark} lookup main";
|
||||
clearBypassRules = lib.concatMapStrings (family: ''
|
||||
while ${bypassRule family "del"} 2>/dev/null; do :; done
|
||||
'') [ "-4" "-6" ];
|
||||
clearBypassRules =
|
||||
lib.concatMapStrings
|
||||
(family: ''
|
||||
while ${bypassRule family "del"} 2>/dev/null; do :; done
|
||||
'')
|
||||
[
|
||||
"-4"
|
||||
"-6"
|
||||
];
|
||||
|
||||
# Some lines drop a share of fresh flows for good, handshakes included. A new source port
|
||||
# is a new flow, and moving the interface to one keeps its routes, so traffic never leaks
|
||||
@@ -118,7 +134,9 @@ let
|
||||
pingVia =
|
||||
profile:
|
||||
"${pkgs.iputils}/bin/ping -n -c 1"
|
||||
+ lib.optionalString (profile.asOutbound == "interface") " -I ${lib.escapeShellArg profile.interfaceName}";
|
||||
+ lib.optionalString (
|
||||
profile.asOutbound == "interface"
|
||||
) " -I ${lib.escapeShellArg profile.interfaceName}";
|
||||
|
||||
# An outbound interface keeps the host's routes and resolver, and marks its packets so TUN and
|
||||
# TProxy let them past.
|
||||
@@ -126,7 +144,9 @@ let
|
||||
${pkgs.python3}/bin/python3 ${configTool} \
|
||||
--manifest ${lib.escapeShellArg (toString (manifestFor profile))} \
|
||||
--output ${output}${
|
||||
lib.optionalString (profile.asOutbound == "interface") " --outbound-fwmark ${toString cfg.proxy.tproxy.proxyMark}"
|
||||
lib.optionalString (
|
||||
profile.asOutbound == "interface"
|
||||
) " --outbound-fwmark ${toString cfg.proxy.tproxy.proxyMark}"
|
||||
}
|
||||
'';
|
||||
|
||||
@@ -436,7 +456,8 @@ let
|
||||
|
||||
interfaceNames = map (name: profiles.${name}.interfaceName) profileNames;
|
||||
autostartProfiles = builtins.filter (name: profiles.${name}.autostart) globalProfileNames;
|
||||
globalAutostartCount = builtins.length autostartProfiles + (if cfg.proxy.autostart != null then 1 else 0);
|
||||
globalAutostartCount =
|
||||
builtins.length autostartProfiles + (if cfg.proxy.autostart != null then 1 else 0);
|
||||
in
|
||||
{
|
||||
services.proxy-suite.internal.packages = [
|
||||
@@ -445,9 +466,11 @@ in
|
||||
]
|
||||
++ lib.optional (builtins.any (ob: ob.kind == "userspace") tunnelOutbounds) awgCfg.wireproxyPackage;
|
||||
|
||||
services.proxy-suite.internal.kernelModulePackages = lib.optionals (awgCfg.kernelModulePackage != null) [
|
||||
awgCfg.kernelModulePackage
|
||||
];
|
||||
services.proxy-suite.internal.kernelModulePackages =
|
||||
lib.optionals (awgCfg.kernelModulePackage != null)
|
||||
[
|
||||
awgCfg.kernelModulePackage
|
||||
];
|
||||
|
||||
# Replies to the proxy's sockets come in on an interface the host has no route through.
|
||||
services.proxy-suite.internal.firewall.extraReversePathFilterRules = lib.concatMapStrings (ob: ''
|
||||
@@ -461,7 +484,9 @@ in
|
||||
(lib.mapAttrs' (
|
||||
name: profile: lib.nameValuePair "${serviceName name}-watchdog" (mkWatchdog name profile)
|
||||
) interfaceProfiles)
|
||||
(lib.listToAttrs (map (ob: lib.nameValuePair (serviceName ob.name) (mkTunnelService ob)) tunnelOutbounds))
|
||||
(lib.listToAttrs (
|
||||
map (ob: lib.nameValuePair (serviceName ob.name) (mkTunnelService ob)) tunnelOutbounds
|
||||
))
|
||||
(lib.mkIf cfg.proxy.tun.enable {
|
||||
proxy-suite-tun.conflicts = map (name: "${name}.service") globalServiceNames;
|
||||
})
|
||||
|
||||
@@ -13,10 +13,12 @@
|
||||
pkgs.writeShellScript "proxy-suite-autoproxy" ''
|
||||
set -euo pipefail
|
||||
# $1 - probe-exits.json (index -> tag -> path), $2 - state.json
|
||||
export PATH=${pkgs.lib.makeBinPath [
|
||||
pkgs.coreutils
|
||||
pkgs.jq
|
||||
]}
|
||||
export PATH=${
|
||||
pkgs.lib.makeBinPath [
|
||||
pkgs.coreutils
|
||||
pkgs.jq
|
||||
]
|
||||
}
|
||||
|
||||
jq -c '.[]' "$1" | while IFS= read -r exit; do
|
||||
tag=$(jq -r '.tag' <<<"$exit")
|
||||
|
||||
@@ -69,7 +69,9 @@ let
|
||||
curl -sS --noproxy '*' --max-time 1 "''${clash_auth[@]}" "http://$clash_api/connections" 2>/dev/null ||
|
||||
echo '{}'
|
||||
done | jq -s -r --argjson min ${toString (300 * 1024)} \
|
||||
--argjson below ${toString (apCfg.slowBelowKiBps * 1024)} -f ${jqFile ./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"
|
||||
'';
|
||||
@@ -492,25 +494,29 @@ in
|
||||
services.proxy-suite.internal.services.proxy-suite-autoproxy-learn =
|
||||
mkUnit "proxy-suite - probe the destinations asked for with proxy-ctl proxy auto learn" " --requests-only";
|
||||
|
||||
services.proxy-suite.internal.services.proxy-suite-autoproxy-sample = lib.mkIf (apCfg.slowBelowKiBps > 0) {
|
||||
description = "proxy-suite - watch live transfers for destinations that crawl directly";
|
||||
after = [ "proxy-suite-socks.service" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${sampler}";
|
||||
}
|
||||
// stateDirConfig;
|
||||
};
|
||||
services.proxy-suite.internal.services.proxy-suite-autoproxy-sample =
|
||||
lib.mkIf (apCfg.slowBelowKiBps > 0)
|
||||
{
|
||||
description = "proxy-suite - watch live transfers for destinations that crawl directly";
|
||||
after = [ "proxy-suite-socks.service" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${sampler}";
|
||||
}
|
||||
// stateDirConfig;
|
||||
};
|
||||
|
||||
services.proxy-suite.internal.timers.proxy-suite-autoproxy-sample = lib.mkIf (apCfg.slowBelowKiBps > 0) {
|
||||
description = "proxy-suite autoProxy transfer sampling";
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnActiveSec = "1m";
|
||||
OnUnitActiveSec = "1m";
|
||||
AccuracySec = "5s";
|
||||
};
|
||||
};
|
||||
services.proxy-suite.internal.timers.proxy-suite-autoproxy-sample =
|
||||
lib.mkIf (apCfg.slowBelowKiBps > 0)
|
||||
{
|
||||
description = "proxy-suite autoProxy transfer sampling";
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnActiveSec = "1m";
|
||||
OnUnitActiveSec = "1m";
|
||||
AccuracySec = "5s";
|
||||
};
|
||||
};
|
||||
|
||||
services.proxy-suite.internal.timers.proxy-suite-autoproxy = {
|
||||
description = "proxy-suite autoProxy probe schedule";
|
||||
|
||||
@@ -114,8 +114,7 @@ let
|
||||
};
|
||||
|
||||
clashApiBlock = lib.optionalAttrs clashApiEnabled {
|
||||
experimental.clash_api.external_controller =
|
||||
"127.0.0.1:${toString singBoxCfg.clashApiPort}";
|
||||
experimental.clash_api.external_controller = "127.0.0.1:${toString singBoxCfg.clashApiPort}";
|
||||
};
|
||||
|
||||
mkConfig =
|
||||
@@ -144,100 +143,104 @@ let
|
||||
let
|
||||
fakeIp = fakeIpCache != null && proxyCfg.dns.fakeIp.enable;
|
||||
in
|
||||
lib.recursiveUpdate (
|
||||
{
|
||||
log.level = "warn";
|
||||
|
||||
dns = mkDnsConfig {
|
||||
localDetour = if forceLocalDnsViaProxy then "proxy" else null;
|
||||
inherit useOutboundRoutingMark fakeIp;
|
||||
onionFakeIpInbounds =
|
||||
lib.optional enableTun "tun-in"
|
||||
++ lib.optionals enableTProxy ([ "tproxy-in" ] ++ lib.optional proxyCfg.ipv6 "tproxy-in6");
|
||||
};
|
||||
|
||||
inbounds =
|
||||
lib.optional enableXrayDnsBridge {
|
||||
type = "direct";
|
||||
tag = "xray-dns-in";
|
||||
listen = "127.0.0.1";
|
||||
listen_port = xrayDnsBridgePort;
|
||||
}
|
||||
++ lib.optional enableMixed {
|
||||
type = "mixed";
|
||||
tag = "mixed-in";
|
||||
listen = proxyCfg.listener.address;
|
||||
listen_port = proxyCfg.listener.port;
|
||||
}
|
||||
++ lib.optionals enableTProxy (
|
||||
[
|
||||
{
|
||||
type = "tproxy";
|
||||
tag = "tproxy-in";
|
||||
listen = "127.0.0.1";
|
||||
listen_port = globalTproxy.port;
|
||||
}
|
||||
]
|
||||
++ lib.optional proxyCfg.ipv6 {
|
||||
type = "tproxy";
|
||||
tag = "tproxy-in6";
|
||||
listen = "::1";
|
||||
listen_port = globalTproxy.port;
|
||||
}
|
||||
)
|
||||
++ lib.optional enableTun (
|
||||
{
|
||||
type = "tun";
|
||||
tag = "tun-in";
|
||||
interface_name = tunInterface;
|
||||
address = [ tunAddress ] ++ lib.optional (proxyCfg.ipv6 && tunIPv6Address != null) tunIPv6Address;
|
||||
mtu = tunMtu;
|
||||
auto_route = tunAutoRoute;
|
||||
auto_redirect = tunAutoRedirect;
|
||||
strict_route = tunStrictRoute;
|
||||
stack = "mixed";
|
||||
}
|
||||
// lib.optionalAttrs tunAutoRoute {
|
||||
iproute2_table_index = tunAutoRouteTableIndex;
|
||||
iproute2_rule_index = tunAutoRouteRuleIndex;
|
||||
}
|
||||
);
|
||||
|
||||
outbounds = [
|
||||
(
|
||||
{
|
||||
type = "direct";
|
||||
tag = "direct";
|
||||
}
|
||||
// lib.optionalAttrs useOutboundRoutingMark { routing_mark = globalTproxy.proxyMark; }
|
||||
)
|
||||
lib.recursiveUpdate
|
||||
(
|
||||
{
|
||||
type = "block";
|
||||
tag = "block";
|
||||
}
|
||||
];
|
||||
log.level = "warn";
|
||||
|
||||
route = {
|
||||
default_domain_resolver = "local";
|
||||
rule_set = rules.geositeRuleSets ++ rules.geoIPRuleSets;
|
||||
rules = lib.optionals enableXrayDnsBridge [ xrayDnsBridgeHijackRule ] ++ rules.singBoxRoutingRules;
|
||||
final = if (proxyCfg.routing.default == "proxy") then "proxy" else "direct";
|
||||
}
|
||||
// lib.optionalAttrs (enableTun && tunAutoRoute) {
|
||||
auto_detect_interface = true;
|
||||
};
|
||||
}
|
||||
// lib.optionalAttrs enableClashApi clashApiBlock)
|
||||
# Fake addresses handed out survive a restart, so apps still holding one keep working. The
|
||||
# start script creates the directory; nothing else is stored, since TUN configs have no
|
||||
# Clash API to switch a selector with.
|
||||
(lib.optionalAttrs fakeIp {
|
||||
experimental.cache_file = {
|
||||
enabled = true;
|
||||
path = "${constants.fakeIpCacheDir}/${fakeIpCache}.db";
|
||||
store_fakeip = true;
|
||||
};
|
||||
});
|
||||
dns = mkDnsConfig {
|
||||
localDetour = if forceLocalDnsViaProxy then "proxy" else null;
|
||||
inherit useOutboundRoutingMark fakeIp;
|
||||
onionFakeIpInbounds =
|
||||
lib.optional enableTun "tun-in"
|
||||
++ lib.optionals enableTProxy ([ "tproxy-in" ] ++ lib.optional proxyCfg.ipv6 "tproxy-in6");
|
||||
};
|
||||
|
||||
inbounds =
|
||||
lib.optional enableXrayDnsBridge {
|
||||
type = "direct";
|
||||
tag = "xray-dns-in";
|
||||
listen = "127.0.0.1";
|
||||
listen_port = xrayDnsBridgePort;
|
||||
}
|
||||
++ lib.optional enableMixed {
|
||||
type = "mixed";
|
||||
tag = "mixed-in";
|
||||
listen = proxyCfg.listener.address;
|
||||
listen_port = proxyCfg.listener.port;
|
||||
}
|
||||
++ lib.optionals enableTProxy (
|
||||
[
|
||||
{
|
||||
type = "tproxy";
|
||||
tag = "tproxy-in";
|
||||
listen = "127.0.0.1";
|
||||
listen_port = globalTproxy.port;
|
||||
}
|
||||
]
|
||||
++ lib.optional proxyCfg.ipv6 {
|
||||
type = "tproxy";
|
||||
tag = "tproxy-in6";
|
||||
listen = "::1";
|
||||
listen_port = globalTproxy.port;
|
||||
}
|
||||
)
|
||||
++ lib.optional enableTun (
|
||||
{
|
||||
type = "tun";
|
||||
tag = "tun-in";
|
||||
interface_name = tunInterface;
|
||||
address = [ tunAddress ] ++ lib.optional (proxyCfg.ipv6 && tunIPv6Address != null) tunIPv6Address;
|
||||
mtu = tunMtu;
|
||||
auto_route = tunAutoRoute;
|
||||
auto_redirect = tunAutoRedirect;
|
||||
strict_route = tunStrictRoute;
|
||||
stack = "mixed";
|
||||
}
|
||||
// lib.optionalAttrs tunAutoRoute {
|
||||
iproute2_table_index = tunAutoRouteTableIndex;
|
||||
iproute2_rule_index = tunAutoRouteRuleIndex;
|
||||
}
|
||||
);
|
||||
|
||||
outbounds = [
|
||||
(
|
||||
{
|
||||
type = "direct";
|
||||
tag = "direct";
|
||||
}
|
||||
// lib.optionalAttrs useOutboundRoutingMark { routing_mark = globalTproxy.proxyMark; }
|
||||
)
|
||||
{
|
||||
type = "block";
|
||||
tag = "block";
|
||||
}
|
||||
];
|
||||
|
||||
route = {
|
||||
default_domain_resolver = "local";
|
||||
rule_set = rules.geositeRuleSets ++ rules.geoIPRuleSets;
|
||||
rules = lib.optionals enableXrayDnsBridge [ xrayDnsBridgeHijackRule ] ++ rules.singBoxRoutingRules;
|
||||
final = if (proxyCfg.routing.default == "proxy") then "proxy" else "direct";
|
||||
}
|
||||
// lib.optionalAttrs (enableTun && tunAutoRoute) {
|
||||
auto_detect_interface = true;
|
||||
};
|
||||
}
|
||||
// lib.optionalAttrs enableClashApi clashApiBlock
|
||||
)
|
||||
# Fake addresses handed out survive a restart, so apps still holding one keep working. The
|
||||
# start script creates the directory; nothing else is stored, since TUN configs have no
|
||||
# Clash API to switch a selector with.
|
||||
(
|
||||
lib.optionalAttrs fakeIp {
|
||||
experimental.cache_file = {
|
||||
enabled = true;
|
||||
path = "${constants.fakeIpCacheDir}/${fakeIpCache}.db";
|
||||
store_fakeip = true;
|
||||
};
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
# The local proxy, ready for TProxy. A rootless host can neither take transparent
|
||||
|
||||
@@ -221,17 +221,24 @@ let
|
||||
};
|
||||
sniffing = standardSniffing;
|
||||
}
|
||||
++ lib.zipListsWith (tag: listen: {
|
||||
inherit tag listen;
|
||||
protocol = "tunnel";
|
||||
port = globalTproxy.port;
|
||||
settings = {
|
||||
allowedNetwork = "tcp,udp";
|
||||
followRedirect = true;
|
||||
};
|
||||
streamSettings.sockopt.tproxy = "tproxy";
|
||||
sniffing = standardSniffing;
|
||||
}) (lib.optionals enableTProxy tproxyInboundTags) [ "127.0.0.1" "::1" ]
|
||||
++
|
||||
lib.zipListsWith
|
||||
(tag: listen: {
|
||||
inherit tag listen;
|
||||
protocol = "tunnel";
|
||||
port = globalTproxy.port;
|
||||
settings = {
|
||||
allowedNetwork = "tcp,udp";
|
||||
followRedirect = true;
|
||||
};
|
||||
streamSettings.sockopt.tproxy = "tproxy";
|
||||
sniffing = standardSniffing;
|
||||
})
|
||||
(lib.optionals enableTProxy tproxyInboundTags)
|
||||
[
|
||||
"127.0.0.1"
|
||||
"::1"
|
||||
]
|
||||
++ lib.optional enableTun {
|
||||
tag = "tun-in";
|
||||
protocol = "tun";
|
||||
|
||||
@@ -93,24 +93,12 @@ let
|
||||
routeModeRules =
|
||||
if derived.pureXrayEnabled then rules.xrayRouteModeRules else rules.singBoxRouteModeRules;
|
||||
|
||||
tproxyFile = pkgs.writeText "proxy-suite-core" (
|
||||
builtins.toJSON selectedTemplates.tproxy
|
||||
);
|
||||
tunFile = pkgs.writeText "proxy-suite-core" (
|
||||
builtins.toJSON selectedTemplates.tun
|
||||
);
|
||||
perAppTunFile = pkgs.writeText "proxy-suite-core" (
|
||||
builtins.toJSON selectedTemplates.perAppTun
|
||||
);
|
||||
routeModeRulesFile = pkgs.writeText "proxy-suite-core" (
|
||||
builtins.toJSON routeModeRules
|
||||
);
|
||||
proxyInboundsFile = pkgs.writeText "proxy-suite-inbounds" (
|
||||
builtins.toJSON proxyInboundsTemplate
|
||||
);
|
||||
proxyInboundsSpecFile = pkgs.writeText "proxy-suite-inbounds" (
|
||||
builtins.toJSON proxyInboundsSpec
|
||||
);
|
||||
tproxyFile = pkgs.writeText "proxy-suite-core" (builtins.toJSON selectedTemplates.tproxy);
|
||||
tunFile = pkgs.writeText "proxy-suite-core" (builtins.toJSON selectedTemplates.tun);
|
||||
perAppTunFile = pkgs.writeText "proxy-suite-core" (builtins.toJSON selectedTemplates.perAppTun);
|
||||
routeModeRulesFile = pkgs.writeText "proxy-suite-core" (builtins.toJSON routeModeRules);
|
||||
proxyInboundsFile = pkgs.writeText "proxy-suite-inbounds" (builtins.toJSON proxyInboundsTemplate);
|
||||
proxyInboundsSpecFile = pkgs.writeText "proxy-suite-inbounds" (builtins.toJSON proxyInboundsSpec);
|
||||
in
|
||||
{
|
||||
inherit
|
||||
|
||||
@@ -98,8 +98,7 @@ let
|
||||
# .onion names from clients go to the local proxy, whose rule hands them to Tor, whatever
|
||||
# the listener's via. AmneziaWG listeners never pass XRay's routing.
|
||||
proxyInboundsRouteOnion =
|
||||
torRouteOnion
|
||||
&& lib.any (ib: ib.via != "block" && ib.listener.type != "amneziawg") proxyInbounds;
|
||||
torRouteOnion && lib.any (ib: ib.via != "block" && ib.listener.type != "amneziawg") proxyInbounds;
|
||||
|
||||
# Whether any listener or inbounds.routing.proxy exception relays through the local SOCKS
|
||||
# listener.
|
||||
@@ -187,7 +186,8 @@ let
|
||||
l: l.type != null && l.transport.type == "xhttp" && l.tls.enable && l.tls.alpn == [ "h3" ];
|
||||
# What an onion service can carry: TCP to a listener with a known protocol.
|
||||
proxyInboundOnionCapable =
|
||||
ib: ib.listener.type != null && ib.listener.type != "amneziawg" && !proxyInboundIsH3Only ib.listener;
|
||||
ib:
|
||||
ib.listener.type != null && ib.listener.type != "amneziawg" && !proxyInboundIsH3Only ib.listener;
|
||||
torOnionEnabled = torCfg.enable && torCfg.onionService.enable && proxyInboundsEnabled;
|
||||
torOnionInbounds =
|
||||
if !torOnionEnabled then
|
||||
|
||||
@@ -15,7 +15,7 @@ let
|
||||
tgWsProxyCfg = cfg.tgWsProxy;
|
||||
tgWsProxyBypassEnabled = tgWsProxyCfg.enable && tgWsProxyCfg.bypassTransparentProxy;
|
||||
tgWsProxyBypassMarkLine = lib.optionalString tgWsProxyBypassEnabled ''
|
||||
meta mark ${toString tgWsProxyCfg.fwmark} return
|
||||
meta mark ${toString tgWsProxyCfg.fwmark} return
|
||||
'';
|
||||
|
||||
# Shared across all three nftables rule files that do IP routing.
|
||||
@@ -54,7 +54,9 @@ let
|
||||
perAppTproxyLocalSubnetLines = mkLocalSubnetLines perAppTproxy.localSubnets;
|
||||
|
||||
# Without ipv6, IPv6 packets are left alone, as if the table were still `ip`.
|
||||
tproxyProtocols = "${lib.optionalString (!proxyCfg.ipv6) "meta nfproto ipv4 "}meta l4proto { tcp, udp }";
|
||||
tproxyProtocols = "${
|
||||
lib.optionalString (!proxyCfg.ipv6) "meta nfproto ipv4 "
|
||||
}meta l4proto { tcp, udp }";
|
||||
# Both listeners share the port; `tproxy ip`/`tproxy ip6` only match their own family.
|
||||
mkTproxyLines = prefix: suffix: ''
|
||||
${prefix}meta l4proto { tcp, udp } tproxy ip to 127.0.0.1:${toString globalTproxy.port}${suffix}
|
||||
|
||||
@@ -77,7 +77,10 @@ in
|
||||
and AmneziaWG tags work too. A pin still reaches them, and so does a selector switched by
|
||||
hand.
|
||||
'';
|
||||
example = [ "ru-vps" "warp" ];
|
||||
example = [
|
||||
"ru-vps"
|
||||
"warp"
|
||||
];
|
||||
};
|
||||
|
||||
urlTest = {
|
||||
|
||||
@@ -37,9 +37,11 @@ in
|
||||
};
|
||||
|
||||
direct = {
|
||||
domains = list "Domain suffixes sent direct. zapret hostlists join them when zapret.directSync.enable is on." [
|
||||
"internal.example"
|
||||
];
|
||||
domains =
|
||||
list "Domain suffixes sent direct. zapret hostlists join them when zapret.directSync.enable is on."
|
||||
[
|
||||
"internal.example"
|
||||
];
|
||||
ips = list "IP CIDRs sent direct." [ "10.10.0.0/16" ];
|
||||
geosites = list "Geosite names sent direct." [ "category-ru" ];
|
||||
geoips = list "Geoip names sent direct." [ "ru" ];
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
{ lib, ... }:
|
||||
|
||||
let
|
||||
p = path: [ "services" "proxy-suite" ] ++ lib.splitString "." path;
|
||||
p =
|
||||
path:
|
||||
[
|
||||
"services"
|
||||
"proxy-suite"
|
||||
]
|
||||
++ lib.splitString "." path;
|
||||
rm = path: replacement: lib.mkRemovedOptionModule (p path) replacement;
|
||||
# Top-level zapret options that moved under the engine namespace; the value is
|
||||
# the leaf name they carry there.
|
||||
|
||||
@@ -62,7 +62,9 @@ let
|
||||
zapretCustomUserIps =
|
||||
if syncZapretDirectUserIps then
|
||||
lib.unique (
|
||||
lib.concatMap (rule: lib.optionals rule.enableDirectSync rule.ips) zapretCfg.zapret-discord-youtube.hostlistRules
|
||||
lib.concatMap (
|
||||
rule: lib.optionals rule.enableDirectSync rule.ips
|
||||
) zapretCfg.zapret-discord-youtube.hostlistRules
|
||||
)
|
||||
else
|
||||
[ ];
|
||||
@@ -104,18 +106,16 @@ let
|
||||
))
|
||||
(
|
||||
lib.unique (
|
||||
map stripExactPrefix (
|
||||
zapretExcludedDomains ++ zapretCfg.zapret-discord-youtube.excludeDomains
|
||||
)
|
||||
map stripExactPrefix (zapretExcludedDomains ++ zapretCfg.zapret-discord-youtube.excludeDomains)
|
||||
)
|
||||
)
|
||||
else
|
||||
[ ];
|
||||
zapretDirectIps =
|
||||
if syncZapretDirectAnyIps then
|
||||
subtractItems (
|
||||
lib.unique (zapretDefaultIps ++ zapretUserIps ++ zapretCustomUserIps ++ zapretCustomDefaultIps)
|
||||
) zapretExcludedIps
|
||||
subtractItems (lib.unique (
|
||||
zapretDefaultIps ++ zapretUserIps ++ zapretCustomUserIps ++ zapretCustomDefaultIps
|
||||
)) zapretExcludedIps
|
||||
else
|
||||
[ ];
|
||||
in
|
||||
|
||||
@@ -167,12 +167,20 @@ let
|
||||
(mkAssertion (cfg.userControl.scopes == [ ] || cfg.userControl.enable)
|
||||
"proxy-suite: userControl.scopes is set but userControl.enable is false, so the group gets nothing"
|
||||
)
|
||||
(requireEnabled (cfg.warp.enable && cfg.warp.asOutbound != null) proxyEnabled
|
||||
"proxy-suite: warp.asOutbound requires proxy.enable = true"
|
||||
)
|
||||
(requireEnabled (
|
||||
cfg.warp.enable && builtins.elem cfg.warp.asOutbound [ "userspace" "interface" ]
|
||||
) cfg.amneziaWg.enable ''proxy-suite: warp.asOutbound = "${toString cfg.warp.asOutbound}" requires amneziaWg.enable = true'')
|
||||
cfg.warp.enable && cfg.warp.asOutbound != null
|
||||
) proxyEnabled "proxy-suite: warp.asOutbound requires proxy.enable = true")
|
||||
(requireEnabled
|
||||
(
|
||||
cfg.warp.enable
|
||||
&& builtins.elem cfg.warp.asOutbound [
|
||||
"userspace"
|
||||
"interface"
|
||||
]
|
||||
)
|
||||
cfg.amneziaWg.enable
|
||||
''proxy-suite: warp.asOutbound = "${toString cfg.warp.asOutbound}" requires amneziaWg.enable = true''
|
||||
)
|
||||
(requireEnabled (
|
||||
cfg.warp.enable && cfg.warp.asAmneziaWg
|
||||
) cfg.amneziaWg.enable "proxy-suite: warp.asAmneziaWg requires amneziaWg.enable = true")
|
||||
@@ -203,16 +211,19 @@ let
|
||||
(!(pureXrayEnabled && (proxyCfg.dns.local.type == "tls" || proxyCfg.dns.remote.type == "tls")))
|
||||
"proxy-suite: proxy.dns.*.type = \"tls\" is not supported with proxy.backend = \"xray\"; use udp/tcp DNS for XRay"
|
||||
)
|
||||
(mkAssertion (
|
||||
!pureXrayEnabled
|
||||
|| (
|
||||
proxyCfg.dns.strategy == null
|
||||
&& proxyCfg.dns.clientSubnet == null
|
||||
&& !proxyCfg.dns.fakeIp.enable
|
||||
&& proxyCfg.dns.singBox.servers == [ ]
|
||||
&& proxyCfg.dns.singBox.rules == [ ]
|
||||
(mkAssertion
|
||||
(
|
||||
!pureXrayEnabled
|
||||
|| (
|
||||
proxyCfg.dns.strategy == null
|
||||
&& proxyCfg.dns.clientSubnet == null
|
||||
&& !proxyCfg.dns.fakeIp.enable
|
||||
&& proxyCfg.dns.singBox.servers == [ ]
|
||||
&& proxyCfg.dns.singBox.rules == [ ]
|
||||
)
|
||||
)
|
||||
) "proxy-suite: proxy.dns.strategy, clientSubnet, fakeIp and singBox require proxy.backend = \"sing-box\" or \"hybrid\"")
|
||||
"proxy-suite: proxy.dns.strategy, clientSubnet, fakeIp and singBox require proxy.backend = \"sing-box\" or \"hybrid\""
|
||||
)
|
||||
(requireEnabled globalTun.enable proxyEnabled
|
||||
"proxy-suite: proxy.tun.enable requires proxy.enable = true"
|
||||
)
|
||||
@@ -300,43 +311,40 @@ let
|
||||
] "proxy-suite: tgWsProxy requires exactly one of secret or secretFile")
|
||||
];
|
||||
|
||||
outboundAssertions = lib.concatMap (ob: [
|
||||
(exactlyOneOf proxyEnabled
|
||||
[
|
||||
outboundAssertions =
|
||||
lib.concatMap (ob: [
|
||||
(exactlyOneOf proxyEnabled [
|
||||
ob.urlFile
|
||||
ob.url
|
||||
ob.singBoxJson
|
||||
ob.xrayJson
|
||||
]
|
||||
"proxy-suite: outbound '${ob.tag}': set exactly one of urlFile, url, singBoxJson, or xrayJson"
|
||||
)
|
||||
(mkAssertion (
|
||||
!singBoxEnabled || hybridEnabled || ob.xrayJson == null
|
||||
) "proxy-suite: outbound '${ob.tag}': xrayJson requires proxy.backend = xray or hybrid")
|
||||
(mkAssertion (
|
||||
!xrayEnabled || hybridEnabled || ob.singBoxJson == null
|
||||
) "proxy-suite: outbound '${ob.tag}': singBoxJson requires proxy.backend = sing-box or hybrid")
|
||||
(mkAssertion (
|
||||
!(ob.backend == "xray") || xrayEnabled
|
||||
) "proxy-suite: outbound '${ob.tag}': backend = \"xray\" requires proxy.backend = xray or hybrid")
|
||||
(mkAssertion (!(ob.backend == "sing-box") || singBoxEnabled)
|
||||
"proxy-suite: outbound '${ob.tag}': backend = \"sing-box\" requires proxy.backend = sing-box or hybrid"
|
||||
)
|
||||
(mkAssertion (
|
||||
ob.detour != ob.tag
|
||||
) "proxy-suite: outbound '${ob.tag}': detour cannot name the outbound itself")
|
||||
])
|
||||
proxyCfg.outbounds
|
||||
++ map (
|
||||
e:
|
||||
mkAssertion (
|
||||
!builtins.elem e.detour [
|
||||
"proxy"
|
||||
"direct"
|
||||
"block"
|
||||
]
|
||||
) "proxy-suite: '${e.tag}': detour must name a real outbound, not proxy, direct or block"
|
||||
) (builtins.filter (e: e.detour != null) (proxyCfg.outbounds ++ proxyCfg.subscriptions));
|
||||
] "proxy-suite: outbound '${ob.tag}': set exactly one of urlFile, url, singBoxJson, or xrayJson")
|
||||
(mkAssertion (
|
||||
!singBoxEnabled || hybridEnabled || ob.xrayJson == null
|
||||
) "proxy-suite: outbound '${ob.tag}': xrayJson requires proxy.backend = xray or hybrid")
|
||||
(mkAssertion (
|
||||
!xrayEnabled || hybridEnabled || ob.singBoxJson == null
|
||||
) "proxy-suite: outbound '${ob.tag}': singBoxJson requires proxy.backend = sing-box or hybrid")
|
||||
(mkAssertion (
|
||||
!(ob.backend == "xray") || xrayEnabled
|
||||
) "proxy-suite: outbound '${ob.tag}': backend = \"xray\" requires proxy.backend = xray or hybrid")
|
||||
(mkAssertion (!(ob.backend == "sing-box") || singBoxEnabled)
|
||||
"proxy-suite: outbound '${ob.tag}': backend = \"sing-box\" requires proxy.backend = sing-box or hybrid"
|
||||
)
|
||||
(mkAssertion (
|
||||
ob.detour != ob.tag
|
||||
) "proxy-suite: outbound '${ob.tag}': detour cannot name the outbound itself")
|
||||
]) proxyCfg.outbounds
|
||||
++ map (
|
||||
e:
|
||||
mkAssertion (
|
||||
!builtins.elem e.detour [
|
||||
"proxy"
|
||||
"direct"
|
||||
"block"
|
||||
]
|
||||
) "proxy-suite: '${e.tag}': detour must name a real outbound, not proxy, direct or block"
|
||||
) (builtins.filter (e: e.detour != null) (proxyCfg.outbounds ++ proxyCfg.subscriptions));
|
||||
|
||||
proxyInboundsCfg = derived.proxyInboundsCfg;
|
||||
proxyInboundsEnabled = derived.proxyInboundsEnabled;
|
||||
@@ -489,24 +497,30 @@ let
|
||||
(mkAssertion (
|
||||
!proxyInboundsEnabled || l.xrayJson == null || (l.xrayJson.port or l.port) == l.port
|
||||
) "${prefix}: xrayJson.port and port differ; the firewall and the port checks go by port")
|
||||
(mkAssertion (
|
||||
!proxyInboundsEnabled
|
||||
|| !proxyInboundsCfg.shareLinks
|
||||
|| !l.reality.enable
|
||||
|| builtins.elem l.type [
|
||||
"vless"
|
||||
"trojan"
|
||||
]
|
||||
) "${prefix}: share links carry reality only for vless and trojan; set inbounds.shareLinks = false to serve it anyway")
|
||||
(mkAssertion (
|
||||
!proxyInboundsEnabled
|
||||
|| !proxyInboundsCfg.shareLinks
|
||||
|| !l.tls.enable
|
||||
|| !builtins.elem l.type [
|
||||
"shadowsocks"
|
||||
"socks"
|
||||
]
|
||||
) "${prefix}: share links cannot carry tls for ${toString l.type}; set inbounds.shareLinks = false to serve it anyway")
|
||||
(mkAssertion
|
||||
(
|
||||
!proxyInboundsEnabled
|
||||
|| !proxyInboundsCfg.shareLinks
|
||||
|| !l.reality.enable
|
||||
|| builtins.elem l.type [
|
||||
"vless"
|
||||
"trojan"
|
||||
]
|
||||
)
|
||||
"${prefix}: share links carry reality only for vless and trojan; set inbounds.shareLinks = false to serve it anyway"
|
||||
)
|
||||
(mkAssertion
|
||||
(
|
||||
!proxyInboundsEnabled
|
||||
|| !proxyInboundsCfg.shareLinks
|
||||
|| !l.tls.enable
|
||||
|| !builtins.elem l.type [
|
||||
"shadowsocks"
|
||||
"socks"
|
||||
]
|
||||
)
|
||||
"${prefix}: share links cannot carry tls for ${toString l.type}; set inbounds.shareLinks = false to serve it anyway"
|
||||
)
|
||||
(exactlyOneOf (proxyInboundsEnabled && l.reality.enable) [
|
||||
l.reality.privateKey
|
||||
l.reality.privateKeyFile
|
||||
@@ -577,19 +591,16 @@ let
|
||||
(uniqueValues awgListenersEnabled awgInterfaces
|
||||
"proxy-suite: AmneziaWG inbounds listeners and amneziaWg.profiles must each use a distinct interfaceName"
|
||||
)
|
||||
(mkAssertion (!awgListenersEnabled || !lib.any (name: builtins.elem name otherInterfaces) awgInterfaces)
|
||||
(mkAssertion
|
||||
(!awgListenersEnabled || !lib.any (name: builtins.elem name otherInterfaces) awgInterfaces)
|
||||
"proxy-suite: an AmneziaWG inbounds listener's interfaceName is taken by proxy.tun or perAppRouting.tun"
|
||||
)
|
||||
(mkAssertion
|
||||
(
|
||||
!awgListenersEnabled
|
||||
|| lib.all (
|
||||
ib:
|
||||
lib.all (other: ib.tag == other.tag || !ipv4Overlap ib.subnet other.subnet) awgSubnets
|
||||
) awgSubnets
|
||||
)
|
||||
"proxy-suite: AmneziaWG inbounds listeners must each use a subnet of their own"
|
||||
)
|
||||
(mkAssertion (
|
||||
!awgListenersEnabled
|
||||
|| lib.all (
|
||||
ib: lib.all (other: ib.tag == other.tag || !ipv4Overlap ib.subnet other.subnet) awgSubnets
|
||||
) awgSubnets
|
||||
) "proxy-suite: AmneziaWG inbounds listeners must each use a subnet of their own")
|
||||
(mkAssertion
|
||||
(
|
||||
!awgListenersEnabled
|
||||
@@ -644,18 +655,18 @@ let
|
||||
];
|
||||
in
|
||||
lib.optionals (proxyInboundsEnabled && l.type == "amneziawg") [
|
||||
(mkAssertion (lib.all (user: user.name != "") l.users)
|
||||
"${prefix}: AmneziaWG users each need a name, which their keys and address are kept under"
|
||||
(mkAssertion (lib.all (user: user.name != "")
|
||||
l.users
|
||||
) "${prefix}: AmneziaWG users each need a name, which their keys and address are kept under")
|
||||
(mkAssertion (builtins.stringLength awg.interfaceName <= 15)
|
||||
"${prefix}: amneziaWg.interfaceName '${awg.interfaceName}' is longer than the kernel's 15 characters"
|
||||
)
|
||||
(mkAssertion (
|
||||
builtins.stringLength awg.interfaceName <= 15
|
||||
) "${prefix}: amneziaWg.interfaceName '${awg.interfaceName}' is longer than the kernel's 15 characters")
|
||||
(mkAssertion (
|
||||
!l.tls.enable && !l.reality.enable && l.flow == null && l.transport.type == "raw"
|
||||
) "${prefix}: AmneziaWG takes no tls, reality, flow or transport")
|
||||
(mkAssertion (subnet != null && subnet.size >= 4)
|
||||
"${prefix}: amneziaWg.subnet '${awg.subnet}' must be an IPv4 CIDR of /30 or wider"
|
||||
)
|
||||
(mkAssertion (
|
||||
subnet != null && subnet.size >= 4
|
||||
) "${prefix}: amneziaWg.subnet '${awg.subnet}' must be an IPv4 CIDR of /30 or wider")
|
||||
(mkAssertion (subnet == null || lib.all inSubnet addresses)
|
||||
"${prefix}: each user address must be a host address inside amneziaWg.subnet, other than its first (this host's)"
|
||||
)
|
||||
@@ -931,7 +942,8 @@ let
|
||||
];
|
||||
|
||||
torCfg = cfg.tor;
|
||||
torOnionListeners = if torCfg.onionService.listeners == null then [ ] else torCfg.onionService.listeners;
|
||||
torOnionListeners =
|
||||
if torCfg.onionService.listeners == null then [ ] else torCfg.onionService.listeners;
|
||||
torOnionUnfit = map (ib: ib.tag) (
|
||||
builtins.filter (ib: !derived.proxyInboundOnionCapable ib) derived.torOnionInbounds
|
||||
);
|
||||
@@ -940,14 +952,26 @@ let
|
||||
) derived.torOnionInbounds;
|
||||
torSnowflake = lib.any (line: lib.hasPrefix "snowflake " line) torCfg.bridges.lines;
|
||||
torAssertions = [
|
||||
(mkAssertion (!torCfg.enable || torCfg.asOutbound || torCfg.onionService.enable)
|
||||
"proxy-suite: tor.enable = true needs tor.asOutbound or tor.onionService.enable"
|
||||
)
|
||||
(requireEnabled (torCfg.enable && torCfg.asOutbound) proxyEnabled
|
||||
"proxy-suite: tor.asOutbound requires proxy.enable = true"
|
||||
)
|
||||
(requireEnabled (torCfg.enable && torCfg.upstream == "proxy") proxyEnabled
|
||||
''proxy-suite: tor.upstream = "proxy" requires proxy.enable = true''
|
||||
(mkAssertion (
|
||||
!torCfg.enable || torCfg.asOutbound || torCfg.onionService.enable
|
||||
) "proxy-suite: tor.enable = true needs tor.asOutbound or tor.onionService.enable")
|
||||
(requireEnabled (
|
||||
torCfg.enable && torCfg.asOutbound
|
||||
) proxyEnabled "proxy-suite: tor.asOutbound requires proxy.enable = true")
|
||||
(requireEnabled (
|
||||
torCfg.enable && torCfg.upstream == "proxy"
|
||||
) proxyEnabled ''proxy-suite: tor.upstream = "proxy" requires proxy.enable = true'')
|
||||
# Tor as the one outbound would be what the local proxy dials Tor's own relays through.
|
||||
(mkAssertion
|
||||
(
|
||||
!(
|
||||
derived.torOutboundEnabled
|
||||
&& torCfg.upstream == "proxy"
|
||||
&& lib.subtractLists [ derived.torOutboundTag ] effectiveOutboundTags == [ ]
|
||||
&& !derived.hasSubscriptions
|
||||
)
|
||||
)
|
||||
''proxy-suite: tor.upstream = "proxy" needs an outbound besides "tor" to reach Tor through; with tor the only one, Tor would dial its relays through itself''
|
||||
)
|
||||
(mkAssertion (!(torCfg.enable && torCfg.upstream == "proxy" && torSnowflake))
|
||||
''proxy-suite: tor.bridges.lines has a snowflake bridge, which cannot follow tor.upstream = "proxy"; use obfs4, webtunnel or meek_lite bridges, or upstream = "direct"''
|
||||
@@ -955,17 +979,20 @@ let
|
||||
(mkAssertion (!(derived.torOutboundEnabled && builtins.elem derived.torOutboundTag outboundTags))
|
||||
"proxy-suite: the outbound tag \"tor\" belongs to tor.asOutbound; rename the proxy.outbounds entry"
|
||||
)
|
||||
(requireEnabled (torCfg.enable && torCfg.onionService.enable) cfg.inbounds.enable
|
||||
"proxy-suite: tor.onionService.enable requires inbounds.enable = true"
|
||||
)
|
||||
(mkAssertion (
|
||||
!derived.torOnionEnabled
|
||||
|| builtins.all (tag: builtins.hasAttr tag cfg.inbounds.listeners) torOnionListeners
|
||||
) "proxy-suite: tor.onionService.listeners names listeners not in inbounds.listeners: ${
|
||||
lib.concatStringsSep ", " (
|
||||
builtins.filter (tag: !builtins.hasAttr tag cfg.inbounds.listeners) torOnionListeners
|
||||
(requireEnabled (
|
||||
torCfg.enable && torCfg.onionService.enable
|
||||
) cfg.inbounds.enable "proxy-suite: tor.onionService.enable requires inbounds.enable = true")
|
||||
(mkAssertion
|
||||
(
|
||||
!derived.torOnionEnabled
|
||||
|| builtins.all (tag: builtins.hasAttr tag cfg.inbounds.listeners) torOnionListeners
|
||||
)
|
||||
}")
|
||||
"proxy-suite: tor.onionService.listeners names listeners not in inbounds.listeners: ${
|
||||
lib.concatStringsSep ", " (
|
||||
builtins.filter (tag: !builtins.hasAttr tag cfg.inbounds.listeners) torOnionListeners
|
||||
)
|
||||
}"
|
||||
)
|
||||
(mkAssertion (!derived.torOnionEnabled || derived.torOnionInbounds != [ ])
|
||||
"proxy-suite: tor.onionService has no listener to serve: amneziawg, h3-only xhttp and raw JSON listeners cannot go over an onion"
|
||||
)
|
||||
|
||||
@@ -264,10 +264,22 @@ rec {
|
||||
fwmark,
|
||||
table,
|
||||
}:
|
||||
lib.concatMapStrings (family: ''
|
||||
${mkIpRuleDeleteByFwmark { inherit ip family fwmark table; }}
|
||||
${mkIpLocalDefaultRouteDelete { inherit ip family table; }}
|
||||
'') [ "-4" "-6" ];
|
||||
lib.concatMapStrings
|
||||
(family: ''
|
||||
${mkIpRuleDeleteByFwmark {
|
||||
inherit
|
||||
ip
|
||||
family
|
||||
fwmark
|
||||
table
|
||||
;
|
||||
}}
|
||||
${mkIpLocalDefaultRouteDelete { inherit ip family table; }}
|
||||
'')
|
||||
[
|
||||
"-4"
|
||||
"-6"
|
||||
];
|
||||
|
||||
mkTproxyRoutingUp =
|
||||
{
|
||||
|
||||
@@ -140,9 +140,7 @@ let
|
||||
set -euo pipefail
|
||||
${subscriptionCacheHelpersBlock}
|
||||
|
||||
KEEP="|${
|
||||
lib.concatMapStrings (sub: "${sub.tag}|") proxyCfg.subscriptions
|
||||
}"
|
||||
KEEP="|${lib.concatMapStrings (sub: "${sub.tag}|") proxyCfg.subscriptions}"
|
||||
while IFS=$'\t' read -r TAG _; do
|
||||
[ -n "$TAG" ] || continue
|
||||
KEEP="$KEEP$TAG|"
|
||||
|
||||
@@ -44,7 +44,11 @@ let
|
||||
|
||||
${builders.cidrNetworkFunction}
|
||||
|
||||
${builders.mkNftDeleteTable { inherit nft; family = "inet"; table = "proxy_suite_per_app_tun"; }}
|
||||
${builders.mkNftDeleteTable {
|
||||
inherit nft;
|
||||
family = "inet";
|
||||
table = "proxy_suite_per_app_tun";
|
||||
}}
|
||||
${builders.mkIpRuleDeleteByFwmark {
|
||||
inherit ip;
|
||||
family = "-4";
|
||||
@@ -57,8 +61,16 @@ let
|
||||
fwmark = perAppRoutingTun.fwmark;
|
||||
table = perAppRoutingTun.routeTable;
|
||||
}}
|
||||
${builders.mkIpRouteFlushTable { inherit ip; family = "-4"; table = perAppRoutingTun.routeTable; }}
|
||||
${builders.mkIpRouteFlushTable { inherit ip; family = "-6"; table = perAppRoutingTun.routeTable; }}
|
||||
${builders.mkIpRouteFlushTable {
|
||||
inherit ip;
|
||||
family = "-4";
|
||||
table = perAppRoutingTun.routeTable;
|
||||
}}
|
||||
${builders.mkIpRouteFlushTable {
|
||||
inherit ip;
|
||||
family = "-6";
|
||||
table = perAppRoutingTun.routeTable;
|
||||
}}
|
||||
${nft} -f ${perAppTunChainFile}
|
||||
${perAppTunWaitForInterface}
|
||||
tun_addr="''${tun_cidr%%/*}"
|
||||
@@ -89,7 +101,11 @@ let
|
||||
set +e
|
||||
|
||||
# Best-effort cleanup for graceful stops and for unclean previous exits.
|
||||
${builders.mkNftDeleteTable { inherit nft; family = "inet"; table = "proxy_suite_per_app_tun"; }}
|
||||
${builders.mkNftDeleteTable {
|
||||
inherit nft;
|
||||
family = "inet";
|
||||
table = "proxy_suite_per_app_tun";
|
||||
}}
|
||||
${builders.mkIpRuleDeleteByFwmark {
|
||||
inherit ip;
|
||||
family = "-4";
|
||||
@@ -102,16 +118,31 @@ let
|
||||
fwmark = perAppRoutingTun.fwmark;
|
||||
table = perAppRoutingTun.routeTable;
|
||||
}}
|
||||
${builders.mkIpRouteFlushTable { inherit ip; family = "-4"; table = perAppRoutingTun.routeTable; }}
|
||||
${builders.mkIpRouteFlushTable { inherit ip; family = "-6"; table = perAppRoutingTun.routeTable; }}
|
||||
${builders.mkIpLinkDelete { inherit ip; interface = perAppRoutingTun.interface; }}
|
||||
${builders.mkIpRouteFlushTable {
|
||||
inherit ip;
|
||||
family = "-4";
|
||||
table = perAppRoutingTun.routeTable;
|
||||
}}
|
||||
${builders.mkIpRouteFlushTable {
|
||||
inherit ip;
|
||||
family = "-6";
|
||||
table = perAppRoutingTun.routeTable;
|
||||
}}
|
||||
${builders.mkIpLinkDelete {
|
||||
inherit ip;
|
||||
interface = perAppRoutingTun.interface;
|
||||
}}
|
||||
${builders.flushResolvedCaches}
|
||||
'';
|
||||
|
||||
perAppTproxyUpScript = pkgs.writeShellScript "proxy-suite-per-app" ''
|
||||
set -euo pipefail
|
||||
|
||||
${builders.mkNftDeleteTable { inherit nft; family = "inet"; table = "proxy_suite_per_app_tproxy"; }}
|
||||
${builders.mkNftDeleteTable {
|
||||
inherit nft;
|
||||
family = "inet";
|
||||
table = "proxy_suite_per_app_tproxy";
|
||||
}}
|
||||
${builders.mkTproxyRoutingDown {
|
||||
inherit ip;
|
||||
fwmark = perAppRoutingTproxy.fwmark;
|
||||
@@ -130,7 +161,11 @@ let
|
||||
perAppTproxyDownScript = pkgs.writeShellScript "proxy-suite-per-app" ''
|
||||
set +e
|
||||
|
||||
${builders.mkNftDeleteTable { inherit nft; family = "inet"; table = "proxy_suite_per_app_tproxy"; }}
|
||||
${builders.mkNftDeleteTable {
|
||||
inherit nft;
|
||||
family = "inet";
|
||||
table = "proxy_suite_per_app_tproxy";
|
||||
}}
|
||||
${builders.mkTproxyRoutingDown {
|
||||
inherit ip;
|
||||
fwmark = perAppRoutingTproxy.fwmark;
|
||||
|
||||
@@ -41,7 +41,7 @@ let
|
||||
|
||||
serverAddressBlock =
|
||||
if proxyInboundsCfg.serverAddress != null then
|
||||
''SERVER_ADDRESS=${lib.escapeShellArg proxyInboundsCfg.serverAddress}''
|
||||
"SERVER_ADDRESS=${lib.escapeShellArg proxyInboundsCfg.serverAddress}"
|
||||
else if proxyInboundsCfg.shareLinks then
|
||||
''
|
||||
${builders.mkDefaultUplinkIPv4Source {
|
||||
@@ -95,9 +95,7 @@ let
|
||||
''
|
||||
# via outbound: ${ob.tag} (static xray json)
|
||||
OB_JSON=$(cat ${
|
||||
pkgs.writeText "proxy-suite-inbounds" (
|
||||
builtins.toJSON (ob.xrayJson // { inherit (ob) tag; })
|
||||
)
|
||||
pkgs.writeText "proxy-suite-inbounds" (builtins.toJSON (ob.xrayJson // { inherit (ob) tag; }))
|
||||
})
|
||||
${dialerBlock}
|
||||
OUTBOUNDS_JSON=$(${jq} --argjson ob "$OB_JSON" '. + [$ob]' <<< "$OUTBOUNDS_JSON")
|
||||
|
||||
@@ -25,17 +25,23 @@ let
|
||||
globalTunIPv6RoutePrefix
|
||||
;
|
||||
|
||||
deleteXrayTunRules = lib.concatMapStrings (
|
||||
family:
|
||||
lib.concatMapStrings (priority: builders.mkIpRuleDeleteByPriority { inherit ip family priority; }) [
|
||||
xrayTunMarkBypassRulePriority
|
||||
xrayTunServiceUserRulePriority
|
||||
xrayTunPerAppTunRulePriority
|
||||
xrayTunDnsRulePriority
|
||||
xrayTunMainRulePriority
|
||||
tunAutoRouteRulePriority
|
||||
]
|
||||
) [ "-4" "-6" ];
|
||||
deleteXrayTunRules =
|
||||
lib.concatMapStrings
|
||||
(
|
||||
family:
|
||||
lib.concatMapStrings (priority: builders.mkIpRuleDeleteByPriority { inherit ip family priority; }) [
|
||||
xrayTunMarkBypassRulePriority
|
||||
xrayTunServiceUserRulePriority
|
||||
xrayTunPerAppTunRulePriority
|
||||
xrayTunDnsRulePriority
|
||||
xrayTunMainRulePriority
|
||||
tunAutoRouteRulePriority
|
||||
]
|
||||
)
|
||||
[
|
||||
"-4"
|
||||
"-6"
|
||||
];
|
||||
|
||||
# Replies to connections from outside (sshd, a game server, anything listening) take
|
||||
# proxyMark, so the fwmark rule sends them back out the way they came instead of into
|
||||
@@ -119,7 +125,11 @@ in
|
||||
# Start from a clean policy-routing state. `ip rule add` permits duplicate
|
||||
# rules on some iproute2 versions, and a stale rule can keep packets routed
|
||||
# into a dead local table after a failed restart.
|
||||
${builders.mkNftDeleteTable { inherit nft; family = "inet"; table = "singbox"; }}
|
||||
${builders.mkNftDeleteTable {
|
||||
inherit nft;
|
||||
family = "inet";
|
||||
table = "singbox";
|
||||
}}
|
||||
${builders.mkTproxyRoutingDown {
|
||||
inherit ip;
|
||||
fwmark = globalTproxy.fwmark;
|
||||
@@ -138,7 +148,11 @@ in
|
||||
tproxyDownScript = pkgs.writeShellScript "proxy-suite-routing" ''
|
||||
set +e
|
||||
|
||||
${builders.mkNftDeleteTable { inherit nft; family = "inet"; table = "singbox"; }}
|
||||
${builders.mkNftDeleteTable {
|
||||
inherit nft;
|
||||
family = "inet";
|
||||
table = "singbox";
|
||||
}}
|
||||
${builders.mkTproxyRoutingDown {
|
||||
inherit ip;
|
||||
fwmark = globalTproxy.fwmark;
|
||||
@@ -152,14 +166,37 @@ in
|
||||
# SingBox normally removes these on graceful shutdown, but stale
|
||||
# auto_route/auto_redirect state leaves the host routing through a dead TUN
|
||||
# interface after `proxy-ctl proxy tun off` or an unclean service stop.
|
||||
${builders.mkNftDeleteTable { inherit nft; family = "inet"; table = "sing-box"; }}
|
||||
${builders.mkIpRuleDeleteByTable { inherit ip; family = "-4"; table = tunAutoRouteTableIndex; }}
|
||||
${builders.mkIpRuleDeleteByTable { inherit ip; family = "-6"; table = tunAutoRouteTableIndex; }}
|
||||
${builders.mkNftDeleteTable {
|
||||
inherit nft;
|
||||
family = "inet";
|
||||
table = "sing-box";
|
||||
}}
|
||||
${builders.mkIpRuleDeleteByTable {
|
||||
inherit ip;
|
||||
family = "-4";
|
||||
table = tunAutoRouteTableIndex;
|
||||
}}
|
||||
${builders.mkIpRuleDeleteByTable {
|
||||
inherit ip;
|
||||
family = "-6";
|
||||
table = tunAutoRouteTableIndex;
|
||||
}}
|
||||
${deleteXrayTunRules}
|
||||
${deleteXrayTunReplyTable}
|
||||
${builders.mkIpRouteFlushTable { inherit ip; family = "-4"; table = tunAutoRouteTableIndex; }}
|
||||
${builders.mkIpRouteFlushTable { inherit ip; family = "-6"; table = tunAutoRouteTableIndex; }}
|
||||
${builders.mkIpLinkDelete { inherit ip; interface = globalTun.interface; }}
|
||||
${builders.mkIpRouteFlushTable {
|
||||
inherit ip;
|
||||
family = "-4";
|
||||
table = tunAutoRouteTableIndex;
|
||||
}}
|
||||
${builders.mkIpRouteFlushTable {
|
||||
inherit ip;
|
||||
family = "-6";
|
||||
table = tunAutoRouteTableIndex;
|
||||
}}
|
||||
${builders.mkIpLinkDelete {
|
||||
inherit ip;
|
||||
interface = globalTun.interface;
|
||||
}}
|
||||
${builders.flushResolvedCaches}
|
||||
'';
|
||||
}
|
||||
@@ -25,13 +25,17 @@ lib.optionalString hybridEnabled ''
|
||||
local batch
|
||||
batch=$(${jq} -c \
|
||||
--argjson base "$XRAY_SIDECAR_NEXT_PORT" \
|
||||
--argjson mark ${if xraySidecarRoutingMark == null then "null" else toString xraySidecarRoutingMark} '
|
||||
--argjson mark ${
|
||||
if xraySidecarRoutingMark == null then "null" else toString xraySidecarRoutingMark
|
||||
} '
|
||||
to_entries | map(
|
||||
($base + .key) as $port
|
||||
| ("proxy-suite-xray-" + ($port | tostring)) as $auth
|
||||
| .value.tag as $tag
|
||||
| {outbound: (.value
|
||||
${lib.optionalString (xraySidecarRoutingMark != null) "| .streamSettings.sockopt.mark = $mark"}
|
||||
${lib.optionalString (
|
||||
xraySidecarRoutingMark != null
|
||||
) "| .streamSettings.sockopt.mark = $mark"}
|
||||
| .streamSettings.sockopt.domainStrategy = (.streamSettings.sockopt.domainStrategy // "UseIP")),
|
||||
inbound: {tag: ($tag + "-inbound"), listen: "127.0.0.1", port: $port, protocol: "socks",
|
||||
settings: {auth: "password", udp: true, accounts: [{user: $auth, pass: $auth}]}},
|
||||
|
||||
@@ -163,7 +163,9 @@ let
|
||||
|
||||
_proxy_suite_parse_xray_url() {
|
||||
${parse "--backend xray" (
|
||||
lib.optionalString (xraySidecarRoutingMark != null) " --routing-mark ${toString xraySidecarRoutingMark}"
|
||||
lib.optionalString (
|
||||
xraySidecarRoutingMark != null
|
||||
) " --routing-mark ${toString xraySidecarRoutingMark}"
|
||||
)}
|
||||
}
|
||||
''
|
||||
@@ -238,7 +240,11 @@ let
|
||||
|
||||
singBoxRawOutboundJson =
|
||||
ob: tag: routingMark:
|
||||
ob.singBoxJson // { inherit tag; } // lib.optionalAttrs (routingMark != null) { routing_mark = routingMark; };
|
||||
ob.singBoxJson
|
||||
// {
|
||||
inherit tag;
|
||||
}
|
||||
// lib.optionalAttrs (routingMark != null) { routing_mark = routingMark; };
|
||||
|
||||
mkHybridOutboundBlock =
|
||||
ob: routingMark: tag:
|
||||
@@ -435,7 +441,10 @@ let
|
||||
|
||||
# Declared detours, resolved once every outbound - subscription entries included - exists.
|
||||
detourMap =
|
||||
entries: lib.listToAttrs (map (e: lib.nameValuePair e.tag e.detour) (lib.filter (e: e.detour != null) entries));
|
||||
entries:
|
||||
lib.listToAttrs (
|
||||
map (e: lib.nameValuePair e.tag e.detour) (lib.filter (e: e.detour != null) entries)
|
||||
);
|
||||
detours = {
|
||||
outbounds = detourMap proxyCfg.outbounds;
|
||||
subscriptions = detourMap proxyCfg.subscriptions;
|
||||
@@ -645,9 +654,7 @@ let
|
||||
# Real exits for autoProxy, taken after the wrapper may have renamed one to
|
||||
# "proxy".
|
||||
exitTagsBlock = ''
|
||||
EXIT_TAGS_JSON=$(${jq} -c '[.[] | select(.type != "selector" and .type != "urltest"${
|
||||
lib.optionalString torOutboundEnabled " and (.tag | ltrimstr(\"proxy-suite-ob-\")) != \"tor\""
|
||||
}) | .tag]' <<< "$OUTBOUNDS_JSON")
|
||||
EXIT_TAGS_JSON=$(${jq} -c '[.[] | select(.type != "selector" and .type != "urltest"${lib.optionalString torOutboundEnabled " and (.tag | ltrimstr(\"proxy-suite-ob-\")) != \"tor\""}) | .tag]' <<< "$OUTBOUNDS_JSON")
|
||||
'';
|
||||
in
|
||||
mkUrlOutboundHelpersBlock routingMark
|
||||
|
||||
@@ -25,11 +25,7 @@ let
|
||||
subscriptionCacheDir = "${stateDir}/subscriptions/${backend}";
|
||||
|
||||
mkSubscriptionUrlSource =
|
||||
sub:
|
||||
if sub.urlFile != null then
|
||||
sub.urlFile
|
||||
else
|
||||
pkgs.writeText "proxy-suite-core" sub.url;
|
||||
sub: if sub.urlFile != null then sub.urlFile else pkgs.writeText "proxy-suite-core" sub.url;
|
||||
|
||||
# Defined in every script that touches a cache: the start scripts and the
|
||||
# update unit.
|
||||
@@ -145,14 +141,10 @@ let
|
||||
}
|
||||
'';
|
||||
|
||||
mkSubscriptionBlock =
|
||||
sub: _routingMark:
|
||||
''
|
||||
# subscription: ${sub.tag}
|
||||
_proxy_suite_load_subscription ${lib.escapeShellArg sub.tag} ${
|
||||
lib.escapeShellArg (mkSubscriptionUrlSource sub)
|
||||
}
|
||||
'';
|
||||
mkSubscriptionBlock = sub: _routingMark: ''
|
||||
# subscription: ${sub.tag}
|
||||
_proxy_suite_load_subscription ${lib.escapeShellArg sub.tag} ${lib.escapeShellArg (mkSubscriptionUrlSource sub)}
|
||||
'';
|
||||
|
||||
runtimeSubscriptionsBlock = ''
|
||||
# subscriptions added at runtime
|
||||
@@ -162,17 +154,13 @@ let
|
||||
done < <(_proxy_suite_runtime_subscriptions)
|
||||
'';
|
||||
|
||||
mkSubscriptionFetchBlock =
|
||||
sub:
|
||||
''
|
||||
if _proxy_suite_fetch_subscription ${lib.escapeShellArg sub.tag} ${
|
||||
lib.escapeShellArg (mkSubscriptionUrlSource sub)
|
||||
}; then
|
||||
echo "Updated subscription: ${sub.tag}"
|
||||
else
|
||||
FAILED=1
|
||||
fi
|
||||
'';
|
||||
mkSubscriptionFetchBlock = sub: ''
|
||||
if _proxy_suite_fetch_subscription ${lib.escapeShellArg sub.tag} ${lib.escapeShellArg (mkSubscriptionUrlSource sub)}; then
|
||||
echo "Updated subscription: ${sub.tag}"
|
||||
else
|
||||
FAILED=1
|
||||
fi
|
||||
'';
|
||||
|
||||
runtimeSubscriptionsFetchBlock = ''
|
||||
while IFS=$'\t' read -r RUNTIME_SUB_TAG RUNTIME_SUB_SRC; do
|
||||
|
||||
@@ -34,7 +34,7 @@ let
|
||||
)
|
||||
${lib.optionalString (s.server.port != 22) "args+=(-p ${toString s.server.port})"}
|
||||
${lib.optionalString (s.identityFile != null) ''args+=(-i "$CREDENTIALS_DIRECTORY/identity")''}
|
||||
${lib.optionalString (knownHosts != null) ''args+=(-o UserKnownHostsFile=${knownHosts})''}
|
||||
${lib.optionalString (knownHosts != null) "args+=(-o UserKnownHostsFile=${knownHosts})"}
|
||||
${extraArgs}
|
||||
exec ${pkgs.openssh}/bin/ssh "''${args[@]}" ${lib.escapeShellArg destination}
|
||||
'';
|
||||
|
||||
+22
-22
@@ -80,12 +80,7 @@ let
|
||||
"ControlSocketsGroupWritable 1"
|
||||
]
|
||||
++ lib.optional t.clientOnly "ClientOnly 1"
|
||||
++ (
|
||||
if t.asOutbound then
|
||||
[ "SocksPort 127.0.0.1:${toString t.socksPort}" ]
|
||||
else
|
||||
[ "SocksPort 0" ]
|
||||
)
|
||||
++ (if t.asOutbound then [ "SocksPort 127.0.0.1:${toString t.socksPort}" ] else [ "SocksPort 0" ])
|
||||
++ lib.optionals bridgesEnabled [
|
||||
"UseBridges 1"
|
||||
"ClientTransportPlugin obfs4,webtunnel,meek_lite exec ${t.lyrebirdPackage}/bin/lyrebird"
|
||||
@@ -104,6 +99,22 @@ let
|
||||
-g ${lib.escapeShellArg cfg.userControl.group} "$dir"
|
||||
'';
|
||||
|
||||
# Before ExecStart, which is when proxy-suite-inbounds may start reading the hostname: a
|
||||
# stale one must be gone by then.
|
||||
onionKeyScript = pkgs.writeShellScript "proxy-suite-tor-onion-key" ''
|
||||
set -euo pipefail
|
||||
umask 0077
|
||||
# Tor wants the service directory private to it.
|
||||
${pkgs.coreutils}/bin/install -d -m 0700 "$STATE_DIRECTORY/onion"
|
||||
if ! ${pkgs.diffutils}/bin/cmp -s "$CREDENTIALS_DIRECTORY/onion-secret-key" "$STATE_DIRECTORY/onion/hs_ed25519_secret_key"; then
|
||||
# Another key: the old address and its public key must not be served with it.
|
||||
${pkgs.coreutils}/bin/rm -f "$STATE_DIRECTORY/onion/hs_ed25519_public_key" "$STATE_DIRECTORY/onion/hostname"
|
||||
${pkgs.coreutils}/bin/install -m 0600 "$CREDENTIALS_DIRECTORY/onion-secret-key" \
|
||||
"$STATE_DIRECTORY/onion/hs_ed25519_secret_key"
|
||||
fi
|
||||
'';
|
||||
onionKeyEnabled = derived.torOnionEnabled && t.onionService.secretKeyFile != null;
|
||||
|
||||
startScript = pkgs.writeShellScript "proxy-suite-tor" ''
|
||||
set -euo pipefail
|
||||
umask 0077
|
||||
@@ -133,17 +144,6 @@ let
|
||||
cat ${pkgs.writeText "proxy-suite-torrc-extra" t.extraConfig}
|
||||
} > "$torrc"
|
||||
|
||||
${lib.optionalString (derived.torOnionEnabled && t.onionService.secretKeyFile != null) ''
|
||||
# Tor wants the service directory private to it.
|
||||
${pkgs.coreutils}/bin/install -d -m 0700 "$STATE_DIRECTORY/onion"
|
||||
if ! ${pkgs.diffutils}/bin/cmp -s "$CREDENTIALS_DIRECTORY/onion-secret-key" "$STATE_DIRECTORY/onion/hs_ed25519_secret_key"; then
|
||||
# Another key: the old address and its public key must not be served with it.
|
||||
${pkgs.coreutils}/bin/rm -f "$STATE_DIRECTORY/onion/hs_ed25519_public_key" "$STATE_DIRECTORY/onion/hostname"
|
||||
${pkgs.coreutils}/bin/install -m 0600 "$CREDENTIALS_DIRECTORY/onion-secret-key" \
|
||||
"$STATE_DIRECTORY/onion/hs_ed25519_secret_key"
|
||||
fi
|
||||
''}
|
||||
|
||||
exec ${t.package}/bin/tor -f "$torrc"
|
||||
'';
|
||||
in
|
||||
@@ -171,15 +171,15 @@ in
|
||||
LoadCredential =
|
||||
lib.optional withProxyAuth "proxy-password:${passwordSource}"
|
||||
++ lib.optional (t.bridges.file != null) "bridges:${t.bridges.file}"
|
||||
++ lib.optional (
|
||||
derived.torOnionEnabled && t.onionService.secretKeyFile != null
|
||||
) "onion-secret-key:${t.onionService.secretKeyFile}";
|
||||
++ lib.optional onionKeyEnabled "onion-secret-key:${t.onionService.secretKeyFile}";
|
||||
Restart = "always";
|
||||
RestartSec = 5;
|
||||
LimitNOFILE = 65536;
|
||||
}
|
||||
// lib.optionalAttrs controlGroup {
|
||||
ExecStartPre = "+${controlDirScript}";
|
||||
// lib.optionalAttrs (controlGroup || onionKeyEnabled) {
|
||||
ExecStartPre =
|
||||
lib.optional controlGroup "+${controlDirScript}"
|
||||
++ lib.optional onionKeyEnabled "${onionKeyScript}";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -85,7 +85,17 @@ let
|
||||
}
|
||||
'';
|
||||
|
||||
inherit (import ./wg-tunnel.nix { inherit lib pkgs cfg derived; }) mkTunnel;
|
||||
inherit
|
||||
(import ./wg-tunnel.nix {
|
||||
inherit
|
||||
lib
|
||||
pkgs
|
||||
cfg
|
||||
derived
|
||||
;
|
||||
})
|
||||
mkTunnel
|
||||
;
|
||||
viaAmneziaWg = builtins.elem w.asOutbound [
|
||||
"userspace"
|
||||
"interface"
|
||||
@@ -135,7 +145,9 @@ in
|
||||
StateDirectoryMode = "0700";
|
||||
WorkingDirectory = "${derived.constants.stateDir}/warp";
|
||||
UMask = "0077";
|
||||
LoadCredential = lib.optional (cfg.proxy.enable && withProxyAuth) "proxy-password:${passwordSource}";
|
||||
LoadCredential = lib.optional (
|
||||
cfg.proxy.enable && withProxyAuth
|
||||
) "proxy-password:${passwordSource}";
|
||||
ExecStart = registerScript;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -50,45 +50,27 @@ let
|
||||
discord = [ "discord-voice" ];
|
||||
};
|
||||
|
||||
expandDefaultDomains =
|
||||
groups:
|
||||
lib.unique (
|
||||
lib.concatMap (group: domainGroups.${group}) groups
|
||||
);
|
||||
expandDefaultDomains = groups: lib.unique (lib.concatMap (group: domainGroups.${group}) groups);
|
||||
|
||||
expandDefaultIps =
|
||||
groups:
|
||||
lib.unique (
|
||||
lib.concatMap (group: ipGroups.${group}) groups
|
||||
);
|
||||
expandDefaultIps = groups: lib.unique (lib.concatMap (group: ipGroups.${group}) groups);
|
||||
|
||||
inferPresets =
|
||||
groups:
|
||||
lib.unique (map (group: groupPresets.${group}) groups);
|
||||
inferPresets = groups: lib.unique (map (group: groupPresets.${group}) groups);
|
||||
|
||||
effectiveRuleDomains =
|
||||
rule:
|
||||
lib.unique (expandDefaultDomains rule.defaultDomains ++ rule.domains);
|
||||
effectiveRuleDomains = rule: lib.unique (expandDefaultDomains rule.defaultDomains ++ rule.domains);
|
||||
|
||||
effectiveRuleIps =
|
||||
rule:
|
||||
lib.unique (expandDefaultIps rule.defaultIps ++ rule.ips);
|
||||
effectiveRuleIps = rule: lib.unique (expandDefaultIps rule.defaultIps ++ rule.ips);
|
||||
|
||||
effectiveRulePresets =
|
||||
rule:
|
||||
if rule.preset != null then [ rule.preset ] else inferPresets rule.defaultDomains;
|
||||
rule: if rule.preset != null then [ rule.preset ] else inferPresets rule.defaultDomains;
|
||||
|
||||
effectiveRuleIpsetFamilies =
|
||||
rule:
|
||||
lib.optional (effectiveRuleIps rule != [ ]) "all";
|
||||
effectiveRuleIpsetFamilies = rule: lib.optional (effectiveRuleIps rule != [ ]) "all";
|
||||
|
||||
effectiveRuleProtocolFamilies =
|
||||
rule:
|
||||
lib.optionals (rule.configName != null) (
|
||||
lib.unique (
|
||||
lib.concatMap (
|
||||
group:
|
||||
if builtins.hasAttr group protocolGroups then protocolGroups.${group} else [ ]
|
||||
group: if builtins.hasAttr group protocolGroups then protocolGroups.${group} else [ ]
|
||||
) rule.defaultDomains
|
||||
)
|
||||
);
|
||||
|
||||
@@ -63,9 +63,13 @@ let
|
||||
profiles = [
|
||||
# Its first UDP strategy's fake has no blob, which zapret2 rejects on every
|
||||
# packet; nfqws1's default for unknown UDP was 64 zero bytes.
|
||||
(replaceStrings [ "--lua-desync=fake:repeats=6:strategy=1" ] [
|
||||
"--lua-desync=fake:blob=0x${lib.fixedWidthString 128 "0" ""}:repeats=6:strategy=1"
|
||||
] (args "NFQWS_ARGS_UDP"))
|
||||
(replaceStrings
|
||||
[ "--lua-desync=fake:repeats=6:strategy=1" ]
|
||||
[
|
||||
"--lua-desync=fake:blob=0x${lib.fixedWidthString 128 "0" ""}:repeats=6:strategy=1"
|
||||
]
|
||||
(args "NFQWS_ARGS_UDP")
|
||||
)
|
||||
"${args "NFQWS_ARGS_QUIC"} <HOSTLIST_NOAUTO> ${lists}"
|
||||
"${withSniPick (args "NFQWS_ARGS")} <HOSTLIST> ${lists}"
|
||||
];
|
||||
|
||||
Reference in new issue
Block a user