935 lines
29 KiB
Nix
935 lines
29 KiB
Nix
# All option declarations for services.proxy-suite
|
||
{ config, lib, ... }:
|
||
|
||
let
|
||
inherit (lib) mkOption mkEnableOption types;
|
||
|
||
# Shared routing-rule fields (reused in both outboundType.routing and routing.rules entries)
|
||
routingFields = {
|
||
domains = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = ''
|
||
Domain suffixes to match in this routing rule.
|
||
Leave empty to skip domain-based matching for this rule entry.
|
||
'';
|
||
example = [
|
||
"youtube.com"
|
||
"discord.com"
|
||
];
|
||
};
|
||
ips = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = ''
|
||
IP CIDRs to match in this routing rule.
|
||
Leave empty to skip IP-based matching for this rule entry.
|
||
'';
|
||
example = [ "1.1.1.0/24" ];
|
||
};
|
||
geosites = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = ''
|
||
sing-geosite rule-set names to match in this routing rule.
|
||
Each name becomes a sing-box geosite rule-set reference.
|
||
'';
|
||
example = [
|
||
"netflix"
|
||
"google"
|
||
];
|
||
};
|
||
geoips = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = ''
|
||
sing-geoip rule-set names to match in this routing rule.
|
||
Each name becomes a sing-box geoip rule-set reference.
|
||
'';
|
||
example = [
|
||
"us"
|
||
"de"
|
||
];
|
||
};
|
||
};
|
||
|
||
# An explicit routing rule – associates traffic patterns with a named outbound.
|
||
routingRuleType = types.submodule {
|
||
options = {
|
||
outbound = mkOption {
|
||
type = types.str;
|
||
description = ''
|
||
Target outbound tag. Can be a specific server tag (only useful with
|
||
selection = "selector" or "urltest"), or one of the built-in tags:
|
||
"proxy" (the active proxy outbound), "direct", "block".
|
||
|
||
With selection = "first", named proxy outbounds are collapsed into the
|
||
single active "proxy" outbound at runtime, so per-tag routing no longer
|
||
distinguishes between individual proxy servers.
|
||
'';
|
||
example = "vps-de";
|
||
};
|
||
}
|
||
// routingFields;
|
||
};
|
||
|
||
subscriptionType = types.submodule {
|
||
options = {
|
||
tag = mkOption {
|
||
type = types.str;
|
||
description = ''
|
||
Unique identifier for this subscription.
|
||
Used as a prefix for all outbound tags generated from its proxy list,
|
||
e.g. "my-sub" -> tags like "my-sub-Server-DE".
|
||
'';
|
||
example = "community-list";
|
||
};
|
||
|
||
url = mkOption {
|
||
type = types.nullOr types.str;
|
||
default = null;
|
||
description = ''
|
||
Literal subscription URL. The response must be a base64-encoded
|
||
newline-separated list of proxy URIs (standard v2rayN format) or
|
||
a plain-text list of the same.
|
||
|
||
This value is embedded in the Nix store. Prefer urlFile for private
|
||
subscription links or tokens.
|
||
'';
|
||
example = "https://example.com/sub/token123";
|
||
};
|
||
|
||
urlFile = mkOption {
|
||
type = types.nullOr types.str;
|
||
default = null;
|
||
description = ''
|
||
Runtime path to a file containing the subscription URL.
|
||
Intended for use with secret managers (sops-nix, agenix, etc.).
|
||
The file is read at service start time and never lands in the Nix store.
|
||
|
||
Set exactly one of urlFile or url for each subscription entry.
|
||
'';
|
||
example = "/run/secrets/proxy-subscription-url";
|
||
};
|
||
};
|
||
};
|
||
|
||
outboundType = types.submodule {
|
||
options = {
|
||
tag = mkOption {
|
||
type = types.str;
|
||
description = ''
|
||
Outbound tag used in routing rules and multi-outbound selection.
|
||
|
||
With selection = "selector" or "urltest", each outbound keeps its own
|
||
tag and can be selected directly. With selection = "first", sing-box
|
||
routes through a single active outbound tagged "proxy", so individual
|
||
proxy tags are mainly useful for documentation and config structure.
|
||
'';
|
||
example = "vps-de";
|
||
};
|
||
|
||
urlFile = mkOption {
|
||
type = types.nullOr types.str;
|
||
default = null;
|
||
description = ''
|
||
Runtime path to a file containing the proxy URL.
|
||
Intended for use with secret managers (sops-nix, agenix, etc.).
|
||
The file is read at service start time and never lands in the Nix store.
|
||
|
||
Set exactly one of urlFile, url, or json for each outbound.
|
||
'';
|
||
example = "/run/secrets/my-proxy-url";
|
||
};
|
||
|
||
url = mkOption {
|
||
type = types.nullOr types.str;
|
||
default = null;
|
||
description = ''
|
||
Literal proxy URL. Convenient for non-secret configs, but the URL
|
||
will end up in the Nix store.
|
||
|
||
Set exactly one of urlFile, url, or json for each outbound.
|
||
Prefer urlFile for real credentials.
|
||
'';
|
||
example = "hy2://password@example.com:443?sni=example.com";
|
||
};
|
||
|
||
json = mkOption {
|
||
type = types.nullOr types.attrs;
|
||
default = null;
|
||
description = ''
|
||
Raw sing-box outbound configuration as a Nix attribute set.
|
||
Embedded directly into the config at build time. The tag field
|
||
is overridden by the outbound's tag option.
|
||
|
||
Set exactly one of urlFile, url, or json for each outbound.
|
||
Use this when the proxy definition is easier to generate as native Nix
|
||
than as a single URL string.
|
||
'';
|
||
example = {
|
||
type = "vless";
|
||
server = "example.com";
|
||
server_port = 443;
|
||
uuid = "...";
|
||
};
|
||
};
|
||
|
||
# Shorthand for attaching routing rules directly to an outbound definition.
|
||
# Traffic matching these patterns is sent to this specific outbound.
|
||
# Only meaningful when selection = "selector" or "urltest" (with "first",
|
||
# all proxy traffic goes to the single "proxy" outbound anyway).
|
||
routing = routingFields;
|
||
};
|
||
};
|
||
|
||
zapretPresetType = types.enum [
|
||
"general"
|
||
"google"
|
||
"instagram"
|
||
"soundcloud"
|
||
"twitter"
|
||
];
|
||
|
||
zapretHostlistRuleType = types.submodule {
|
||
options = {
|
||
name = mkOption {
|
||
type = types.strMatching "^[a-z0-9][a-z0-9-]*$";
|
||
description = ''
|
||
Custom hostlist name. Used to generate hostlists/list-<name>.txt
|
||
inside the derived zapret config directory.
|
||
'';
|
||
example = "cloudflare";
|
||
};
|
||
|
||
domains = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = ''
|
||
Domains written into the generated custom zapret hostlist file.
|
||
Must be non-empty for every hostlistRules entry.
|
||
'';
|
||
example = [
|
||
"example.com"
|
||
"example.de"
|
||
];
|
||
};
|
||
|
||
preset = mkOption {
|
||
type = types.nullOr zapretPresetType;
|
||
default = null;
|
||
description = ''
|
||
Clone the active zapret config's built-in NFQWS rule family for this
|
||
hostlist. Can be combined with nfqwsArgs for additional custom rules.
|
||
'';
|
||
example = "google";
|
||
};
|
||
|
||
nfqwsArgs = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = ''
|
||
Additional NFQWS argument fragments for this hostlist.
|
||
The module injects --hostlist=... and trailing --new automatically.
|
||
|
||
Each hostlistRules entry must define preset, nfqwsArgs, or both.
|
||
'';
|
||
example = [
|
||
"--filter-tcp=443 --dpi-desync=fake,multisplit"
|
||
];
|
||
};
|
||
|
||
enableDirectSync = mkOption {
|
||
type = types.bool;
|
||
default = true;
|
||
description = ''
|
||
Whether this custom hostlist should also be mirrored into sing-box
|
||
direct domain routing when zapret.syncDirectRouting = true.
|
||
'';
|
||
};
|
||
};
|
||
};
|
||
|
||
in
|
||
{
|
||
options.services.proxy-suite = {
|
||
enable = mkEnableOption "proxy suite (sing-box + zapret + tg-ws-proxy)";
|
||
|
||
singBox = {
|
||
enable = mkOption {
|
||
type = types.bool;
|
||
default = true;
|
||
description = ''
|
||
Whether to configure and run sing-box services for proxy-suite.
|
||
When disabled, singBox.* options are ignored even if proxy-suite itself
|
||
is enabled.
|
||
'';
|
||
};
|
||
|
||
outbounds = mkOption {
|
||
type = types.listOf outboundType;
|
||
default = [ ];
|
||
description = ''
|
||
List of static proxy outbounds.
|
||
Set exactly one of urlFile, url, or json per entry.
|
||
|
||
At least one outbound or one subscription is required when
|
||
singBox.enable = true.
|
||
'';
|
||
example = [
|
||
{
|
||
tag = "de-vps";
|
||
urlFile = "/run/secrets/proxy-de-url";
|
||
}
|
||
{
|
||
tag = "nl-vps";
|
||
url = "hy2://password@example.com:443?sni=example.com";
|
||
}
|
||
];
|
||
};
|
||
|
||
subscriptions = mkOption {
|
||
type = types.listOf subscriptionType;
|
||
default = [ ];
|
||
description = ''
|
||
Subscription URLs that provide dynamic lists of proxy outbounds.
|
||
Each URL must return a base64-encoded newline-separated list of proxy URIs
|
||
(standard v2rayN / Clash subscription format) or plain text of the same.
|
||
|
||
On first service start, each subscription is fetched live and cached
|
||
under /var/lib/proxy-suite/subscriptions/<tag>.json. Later restarts
|
||
reuse the cache, so ordinary service restarts do not need network access.
|
||
|
||
A systemd timer (proxy-suite-subscription-update) refreshes all caches on
|
||
the interval set by subscriptionUpdateInterval and restarts the running
|
||
sing-box services after a successful refresh.
|
||
'';
|
||
example = [
|
||
{
|
||
tag = "community";
|
||
url = "https://example.com/sub/token";
|
||
}
|
||
{
|
||
tag = "private";
|
||
urlFile = "/run/secrets/private-sub-url";
|
||
}
|
||
];
|
||
};
|
||
|
||
subscriptionUpdateInterval = mkOption {
|
||
type = types.str;
|
||
default = "1d";
|
||
description = ''
|
||
How often the proxy-suite-subscription-update timer fires and refreshes
|
||
all subscription caches. Accepts any systemd time span string
|
||
(e.g. "1h", "6h", "1d", "12h").
|
||
|
||
Only used when singBox.subscriptions is non-empty. The timer also runs
|
||
once shortly after boot.
|
||
'';
|
||
example = "6h";
|
||
};
|
||
|
||
selection = mkOption {
|
||
type = types.enum [
|
||
"first"
|
||
"selector"
|
||
"urltest"
|
||
];
|
||
default = "first";
|
||
description = ''
|
||
How to pick between multiple proxy outbounds:
|
||
|
||
- "first": route through a single active outbound tagged "proxy".
|
||
The first static outbound is used, or the first subscription
|
||
outbound if only subscriptions are configured.
|
||
- "selector": create a Clash-compatible selector outbound tagged
|
||
"proxy" and keep all configured outbounds available for manual
|
||
switching via the Clash API.
|
||
- "urltest": create an automatic latency-testing outbound tagged
|
||
"proxy" and keep all configured outbounds available so sing-box
|
||
can periodically probe and switch to a faster one.
|
||
|
||
clashApiPort is only used with "selector" or "urltest".
|
||
urlTest.* options are only used with "urltest".
|
||
Per-outbound tags are only individually meaningful with "selector"
|
||
or "urltest".
|
||
'';
|
||
example = "urltest";
|
||
};
|
||
|
||
urlTest = {
|
||
url = mkOption {
|
||
type = types.str;
|
||
default = "https://www.gstatic.com/generate_204";
|
||
description = ''
|
||
URL that sing-box fetches through each proxy to measure latency.
|
||
Only used when selection = "urltest".
|
||
|
||
Set this to a URL that is actually blocked in your region (e.g.
|
||
"https://telegram.org") so that only proxies that bypass the
|
||
blocking get selected. If left at the default, any responding proxy
|
||
wins – including ones that might not unblock your target site.
|
||
'';
|
||
example = "https://telegram.org";
|
||
};
|
||
|
||
interval = mkOption {
|
||
type = types.str;
|
||
default = "3m";
|
||
description = ''
|
||
How often sing-box re-tests all outbounds. Accepts a Go duration
|
||
string (e.g. "1m", "3m", "10m").
|
||
Only used when selection = "urltest".
|
||
'';
|
||
example = "1m";
|
||
};
|
||
|
||
tolerance = mkOption {
|
||
type = types.int;
|
||
default = 50;
|
||
description = ''
|
||
Latency tolerance in milliseconds. The current proxy is only replaced
|
||
when a competing one is faster by more than this value.
|
||
|
||
Only used when selection = "urltest".
|
||
'';
|
||
example = 100;
|
||
};
|
||
};
|
||
|
||
clashApiPort = mkOption {
|
||
type = types.port;
|
||
default = 9090;
|
||
description = ''
|
||
Port for the Clash-compatible REST API exposed by sing-box.
|
||
Only used when selection is "selector" or "urltest". Ignored in
|
||
"first" mode because there is no selector-style outbound to control.
|
||
'';
|
||
example = 9090;
|
||
};
|
||
|
||
listenAddress = mkOption {
|
||
type = types.str;
|
||
default = "127.0.0.1";
|
||
description = ''
|
||
Address for the SOCKS5/HTTP mixed inbound to bind to.
|
||
This affects the always-on proxy-suite-socks service.
|
||
|
||
Use "0.0.0.0" only if you intentionally want to expose the proxy to
|
||
other machines on your network.
|
||
'';
|
||
example = "127.0.0.1";
|
||
};
|
||
|
||
port = mkOption {
|
||
type = types.port;
|
||
default = 1080;
|
||
description = ''
|
||
Listen port for the always-on SOCKS5/HTTP mixed inbound provided by
|
||
proxy-suite-socks.
|
||
'';
|
||
example = 1080;
|
||
};
|
||
|
||
tproxyPort = mkOption {
|
||
type = types.port;
|
||
default = 1081;
|
||
description = ''
|
||
Listen port for the local sing-box TProxy inbound.
|
||
Only relevant when singBox.tproxy.enable = true.
|
||
'';
|
||
example = 1081;
|
||
};
|
||
|
||
fwmark = mkOption {
|
||
type = types.int;
|
||
default = 1;
|
||
description = ''
|
||
Netfilter mark set on packets intercepted by TProxy so policy routing
|
||
can send them to the local loopback route table.
|
||
Only relevant when singBox.tproxy.enable = true.
|
||
'';
|
||
example = 1;
|
||
};
|
||
|
||
proxyMark = mkOption {
|
||
type = types.int;
|
||
default = 2;
|
||
description = ''
|
||
Netfilter mark set on sing-box's own outbound packets so they bypass
|
||
TProxy re-interception loops.
|
||
Only relevant when singBox.tproxy.enable = true.
|
||
'';
|
||
example = 2;
|
||
};
|
||
|
||
routeTable = mkOption {
|
||
type = types.int;
|
||
default = 100;
|
||
description = ''
|
||
Policy routing table used to redirect TProxy-marked packets to the
|
||
loopback interface.
|
||
Only relevant when singBox.tproxy.enable = true.
|
||
'';
|
||
example = 100;
|
||
};
|
||
|
||
proxyByDefault = mkOption {
|
||
type = types.bool;
|
||
default = true;
|
||
description = ''
|
||
Whether traffic that does not match any explicit routing rule should
|
||
go through the proxy or go direct.
|
||
|
||
This affects both sing-box route.final and the default DNS resolver
|
||
choice in the generated config.
|
||
'';
|
||
example = true;
|
||
};
|
||
|
||
tun = {
|
||
enable = mkEnableOption "TUN mode service (opt-in, mutually exclusive with proxy-suite-tproxy)";
|
||
|
||
interface = mkOption {
|
||
type = types.str;
|
||
default = "singtun0";
|
||
description = ''
|
||
Name of the TUN interface created by proxy-suite-tun.
|
||
Only relevant when singBox.tun.enable = true.
|
||
'';
|
||
example = "singtun0";
|
||
};
|
||
|
||
address = mkOption {
|
||
type = types.str;
|
||
default = "172.19.0.1/30";
|
||
description = ''
|
||
Address assigned to the TUN interface in CIDR notation.
|
||
Only relevant when singBox.tun.enable = true.
|
||
'';
|
||
example = "172.19.0.1/30";
|
||
};
|
||
|
||
mtu = mkOption {
|
||
type = types.int;
|
||
default = 1400;
|
||
description = ''
|
||
MTU for the TUN interface created by proxy-suite-tun.
|
||
Only relevant when singBox.tun.enable = true.
|
||
'';
|
||
example = 1400;
|
||
};
|
||
};
|
||
|
||
tproxy = {
|
||
enable = mkEnableOption "TProxy mode service (opt-in, transparent proxy via nftables)";
|
||
|
||
localSubnets = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ "192.168.0.0/16" ];
|
||
description = ''
|
||
Subnets whose traffic bypasses TProxy interception, except DNS (port 53).
|
||
Only relevant when singBox.tproxy.enable = true.
|
||
|
||
Typically this should include your LAN subnet(s). VM bridge networks
|
||
should usually go here too, or use zapret.cidrExemption for
|
||
subnet-specific NFQUEUE exemption on the zapret side.
|
||
'';
|
||
example = [
|
||
"192.168.0.0/16"
|
||
"10.0.0.0/8"
|
||
];
|
||
};
|
||
};
|
||
|
||
routing = {
|
||
enableRuDirect = mkOption {
|
||
type = types.bool;
|
||
default = true;
|
||
description = ''
|
||
Automatically append "category-ru" to routing.direct.geosites and
|
||
"ru" to routing.direct.geoips.
|
||
|
||
This is additive: user-defined routing.direct.* entries still apply.
|
||
'';
|
||
example = true;
|
||
};
|
||
|
||
proxy = routingFields;
|
||
|
||
direct = {
|
||
domains = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = ''
|
||
Domain suffixes to send direct (bypass proxy).
|
||
Merged with zapret-synced direct domains when zapret direct sync
|
||
options are enabled.
|
||
'';
|
||
example = [ "internal.example" ];
|
||
};
|
||
ips = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = ''
|
||
IP CIDRs to send direct.
|
||
Merged with zapret-synced direct IPs when the corresponding zapret
|
||
sync options are enabled.
|
||
'';
|
||
example = [ "10.10.0.0/16" ];
|
||
};
|
||
geosites = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = ''
|
||
sing-geosite names to send direct.
|
||
"category-ru" is added automatically when enableRuDirect = true.
|
||
'';
|
||
example = [ "category-ru" ];
|
||
};
|
||
geoips = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = ''
|
||
sing-geoip names to send direct.
|
||
"ru" is added automatically when enableRuDirect = true.
|
||
'';
|
||
example = [ "ru" ];
|
||
};
|
||
};
|
||
|
||
block = {
|
||
domains = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = "Domain suffixes to block entirely.";
|
||
example = [ "ads.example.com" ];
|
||
};
|
||
ips = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = "IP CIDRs to block.";
|
||
example = [ "203.0.113.0/24" ];
|
||
};
|
||
geosites = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = "sing-geosite names to block.";
|
||
example = [ "category-ads-all" ];
|
||
};
|
||
geoips = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = "sing-geoip names to block.";
|
||
example = [ "cn" ];
|
||
};
|
||
};
|
||
|
||
# Per-outbound and per-action routing rules.
|
||
# These are evaluated before the global proxy/direct/block lists above.
|
||
# Use this for fine-grained control: route specific services to specific
|
||
# servers, or override the default for particular domains/IPs/geos.
|
||
#
|
||
# Alternatively, attach routing directly to an outbound via outbound.routing.*
|
||
# which is equivalent to adding an entry here with outbound = <that tag>.
|
||
#
|
||
# Order within this list is preserved (first matching rule wins in sing-box).
|
||
rules = mkOption {
|
||
type = types.listOf routingRuleType;
|
||
default = [ ];
|
||
description = ''
|
||
Explicit routing rules evaluated before global proxy/direct/block lists.
|
||
Each rule routes matching traffic to a specific outbound tag.
|
||
|
||
The outbound can be a configured outbound tag (useful with selector/urltest),
|
||
or one of: "proxy" (active proxy), "direct", "block".
|
||
|
||
Order is preserved. The first matching rule wins in sing-box.
|
||
With selection = "first", non-built-in outbound tags are effectively
|
||
routed to the single active "proxy" outbound.
|
||
'';
|
||
example = [
|
||
{
|
||
outbound = "vps-de";
|
||
domains = [ "netflix.com" ];
|
||
geosites = [ "netflix" ];
|
||
}
|
||
{
|
||
outbound = "direct";
|
||
domains = [ "internal.corp" ];
|
||
}
|
||
{
|
||
outbound = "block";
|
||
domains = [ "ads.example.com" ];
|
||
}
|
||
];
|
||
};
|
||
};
|
||
};
|
||
|
||
zapret = {
|
||
enable = mkEnableOption "zapret DPI bypass";
|
||
|
||
syncDirectRouting = mkOption {
|
||
type = types.bool;
|
||
default = true;
|
||
description = ''
|
||
When zapret.enable = true, mirror zapret's upstream domain hostlists
|
||
into sing-box direct domain routing.
|
||
|
||
This includes the default zapret domain lists and any custom
|
||
hostlistRules entries with enableDirectSync = true.
|
||
'';
|
||
example = true;
|
||
};
|
||
|
||
syncDirectRoutingUpstreamIps = mkOption {
|
||
type = types.bool;
|
||
default = false;
|
||
description = ''
|
||
When zapret.enable = true, mirror zapret's upstream ipset ranges
|
||
(such as ipset-all.txt minus exclusions) into sing-box direct IP routing.
|
||
'';
|
||
example = false;
|
||
};
|
||
|
||
syncDirectRoutingUserIps = mkOption {
|
||
type = types.bool;
|
||
default = true;
|
||
description = ''
|
||
When zapret.enable = true, mirror user-defined zapret.ipsetAll and
|
||
zapret.ipsetExclude entries into sing-box direct IP routing.
|
||
'';
|
||
example = true;
|
||
};
|
||
|
||
configName = mkOption {
|
||
type = types.str;
|
||
default = "general(ALT)";
|
||
description = ''
|
||
zapret strategy preset name passed through to the generated zapret
|
||
configuration.
|
||
Only relevant when zapret.enable = true.
|
||
'';
|
||
example = "general(ALT)";
|
||
};
|
||
|
||
gameFilter = mkOption {
|
||
type = types.str;
|
||
default = "null";
|
||
description = ''
|
||
zapret game traffic filter mode: "all", "tcp", "udp", or "null" to disable.
|
||
Only relevant when zapret.enable = true.
|
||
'';
|
||
example = "null";
|
||
};
|
||
|
||
listGeneral = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = ''
|
||
Extra domains to include in zapret's interception list.
|
||
When syncDirectRouting = true, these domains are also mirrored into
|
||
sing-box direct routing.
|
||
'';
|
||
example = [ "youtube.com" ];
|
||
};
|
||
|
||
listExclude = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = ''
|
||
Domains to exclude from zapret interception.
|
||
When syncDirectRouting = true, these exclusions also remove matching
|
||
domains from the zapret-derived sing-box direct-routing set.
|
||
'';
|
||
example = [ "music.youtube.com" ];
|
||
};
|
||
|
||
ipsetAll = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = ''
|
||
Extra IPs/CIDRs to add to zapret's ipset.
|
||
Mirrored into sing-box direct IP routing when
|
||
syncDirectRoutingUserIps = true.
|
||
'';
|
||
example = [ "203.0.113.0/24" ];
|
||
};
|
||
|
||
ipsetExclude = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
description = ''
|
||
IPs/CIDRs to exclude from zapret's ipset.
|
||
Also excluded from zapret-derived sing-box direct IP routing when
|
||
syncDirectRoutingUserIps = true.
|
||
'';
|
||
example = [ "203.0.113.10/32" ];
|
||
};
|
||
|
||
includeExtraUpstreamLists = mkOption {
|
||
type = types.bool;
|
||
default = false;
|
||
description = ''
|
||
Automatically activate upstream list-instagram.txt, list-soundcloud.txt,
|
||
and list-twitter.txt in the generated zapret config when the selected
|
||
upstream preset does not already reference them.
|
||
|
||
When syncDirectRouting = true, domains from these extra lists are also
|
||
mirrored into sing-box direct routing.
|
||
'';
|
||
example = false;
|
||
};
|
||
|
||
hostlistRules = mkOption {
|
||
type = types.listOf zapretHostlistRuleType;
|
||
default = [ ];
|
||
description = ''
|
||
Additional named zapret hostlists with per-list DPI mitigation rules.
|
||
Each entry generates hostlists/list-<name>.txt and can clone a built-in
|
||
zapret family, add custom NFQWS rule fragments, or both.
|
||
|
||
Each entry must define at least one domain and at least one of preset
|
||
or nfqwsArgs.
|
||
'';
|
||
example = [
|
||
{
|
||
name = "googlevideo";
|
||
domains = [
|
||
"googlevideo.com"
|
||
"ggpht.com"
|
||
];
|
||
preset = "google";
|
||
}
|
||
{
|
||
name = "example";
|
||
domains = [
|
||
"example.com"
|
||
"example.de"
|
||
];
|
||
preset = "general";
|
||
nfqwsArgs = [
|
||
"--filter-tcp=443 --dpi-desync=fake,multisplit"
|
||
];
|
||
}
|
||
];
|
||
};
|
||
|
||
cidrExemption = {
|
||
enable = mkEnableOption "CIDR exemption from zapret NFQUEUE";
|
||
|
||
cidrs = mkOption {
|
||
type = types.listOf types.str;
|
||
default = [ ];
|
||
example = [
|
||
"192.168.123.0/24"
|
||
"10.0.0.0/8"
|
||
];
|
||
description = ''
|
||
Subnets to exempt from zapret's NFQUEUE mangle rules.
|
||
Only relevant when zapret.enable = true and cidrExemption.enable = true.
|
||
|
||
Useful when a VM (libvirt, etc.) is behind NAT and zapret
|
||
would corrupt its traffic through the host's nftables.
|
||
'';
|
||
};
|
||
};
|
||
};
|
||
|
||
tray = {
|
||
enable = mkEnableOption "system tray indicator for proxy-suite";
|
||
|
||
pollInterval = mkOption {
|
||
type = types.int;
|
||
default = 5;
|
||
description = ''
|
||
Status polling interval in seconds for the tray application.
|
||
Only relevant when tray.enable = true.
|
||
'';
|
||
example = 5;
|
||
};
|
||
|
||
autostart = mkOption {
|
||
type = types.bool;
|
||
default = true;
|
||
description = ''
|
||
Whether to install an XDG autostart entry for the tray application for
|
||
graphical users.
|
||
Only relevant when tray.enable = true.
|
||
'';
|
||
example = true;
|
||
};
|
||
};
|
||
|
||
tgWsProxy = {
|
||
enable = mkEnableOption "Telegram MTProto WebSocket proxy";
|
||
|
||
port = mkOption {
|
||
type = types.port;
|
||
default = 1076;
|
||
description = ''
|
||
Listen port for the tg-ws-proxy service.
|
||
Only relevant when tgWsProxy.enable = true.
|
||
'';
|
||
example = 1076;
|
||
};
|
||
|
||
host = mkOption {
|
||
type = types.str;
|
||
default = "0.0.0.0";
|
||
description = ''
|
||
Address to bind tg-ws-proxy to.
|
||
Only relevant when tgWsProxy.enable = true.
|
||
'';
|
||
example = "0.0.0.0";
|
||
};
|
||
|
||
secret = mkOption {
|
||
type = types.nullOr types.str;
|
||
default = null;
|
||
description = ''
|
||
MTProto proxy secret (hex string). Legacy inline form; this value ends up
|
||
in the Nix store. Prefer secretFile for real deployments.
|
||
|
||
Set exactly one of secret or secretFile when tgWsProxy.enable = true.
|
||
Generate one with: openssl rand -hex 16
|
||
'';
|
||
example = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||
};
|
||
|
||
secretFile = mkOption {
|
||
type = types.nullOr types.str;
|
||
default = null;
|
||
description = ''
|
||
Runtime path to a file containing the MTProto proxy secret.
|
||
Intended for use with secret managers so the secret stays out of the Nix store.
|
||
|
||
Set exactly one of secretFile or secret when tgWsProxy.enable = true.
|
||
'';
|
||
example = "/run/secrets/tg-ws-proxy-secret";
|
||
};
|
||
|
||
dcIps = mkOption {
|
||
type = types.attrsOf types.str;
|
||
default = {
|
||
"2" = "149.154.167.220";
|
||
"4" = "149.154.167.220";
|
||
};
|
||
description = ''
|
||
Map of Telegram DC ID to IP address for relay.
|
||
Only relevant when tgWsProxy.enable = true.
|
||
'';
|
||
example = {
|
||
"1" = "149.154.175.50";
|
||
"2" = "149.154.167.51";
|
||
"3" = "149.154.175.100";
|
||
"4" = "149.154.167.91";
|
||
"5" = "91.108.56.130";
|
||
};
|
||
};
|
||
};
|
||
};
|
||
}
|