refined docs
This commit is contained in:
6 files changed
+3405
-561
No files matched your search
@@ -1,10 +1,10 @@
|
|||||||
# proxy-suite-flake
|
# proxy-suite-flake
|
||||||
|
|
||||||
Declarative proxy stack for NixOS. One flake, one module, done.
|
Declarative proxy stack for NixOS.
|
||||||
|
|
||||||
Bundles [sing-box](https://github.com/SagerNet/sing-box), [zapret-discord-youtube](https://github.com/kartavkun/zapret-discord-youtube), and [tg-ws-proxy](https://github.com/Flowseal/tg-ws-proxy). Built specifically for dealing with Roskomnadzor (RKN) and the usual Russian ISP nonsense.
|
Bundles [sing-box](https://github.com/SagerNet/sing-box), [zapret-discord-youtube](https://github.com/kartavkun/zapret-discord-youtube), and [tg-ws-proxy](https://github.com/Flowseal/tg-ws-proxy). Built specifically for dealing with Roskomnadzor (RKN) and the usual Russian ISP nonsense.
|
||||||
|
|
||||||
The goal is to replace GUI clients like v2rayN, throne and their ilk – you configure your proxies in Nix, rebuild, and they just work as systemd services.
|
The goal is to replace GUI clients like v2rayN and throne – you configure your proxies in Nix, rebuild, and they just work as systemd services.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -18,8 +18,8 @@ The goal is to replace GUI clients like v2rayN, throne and their ilk – you con
|
|||||||
- **Per-outbound routing** – route specific domains, IPs, or geo sets to specific servers
|
- **Per-outbound routing** – route specific domains, IPs, or geo sets to specific servers
|
||||||
- **Protocol support**: vless (Reality, TLS), vmess, trojan, shadowsocks, hysteria2, TUIC v5, socks5, socks4, http/https proxy
|
- **Protocol support**: vless (Reality, TLS), vmess, trojan, shadowsocks, hysteria2, TUIC v5, socks5, socks4, http/https proxy
|
||||||
- **`proxy-ctl`** – control script for managing services, switching outbounds, and following logs
|
- **`proxy-ctl`** – control script for managing services, switching outbounds, and following logs
|
||||||
- **DPI bypass** via zapret – handles YouTube, Discord, and other sites that are blocked by packet inspection rather than IP
|
- **DPI bypass** via zapret – handles YouTube, Discord, and other sites defined by the project
|
||||||
- **Telegram proxy** – local MTProto WebSocket proxy using tg-ws-proxy
|
- **Telegram proxy** – running local MTProto WebSocket proxy using tg-ws-proxy
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -41,491 +41,8 @@ imports = [ inputs.proxy-suite.nixosModules.default ];
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Basic configuration
|
## Options
|
||||||
|
|
||||||
```nix
|
To see options and documentation, check out the [options reference](./docs/options.md).
|
||||||
services.proxy-suite = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
singBox = {
|
Options are autogenerated from [options.nix](./modules/proxy-suite/options.nix) using `nix run .#update-options-doc`.
|
||||||
outbounds = [
|
|
||||||
{
|
|
||||||
tag = "vps";
|
|
||||||
# Runtime secret – not in the nix store.
|
|
||||||
# Works with sops-nix, agenix, or anything that gives you a file path.
|
|
||||||
urlFile = config.sops.secrets.proxy_url.path;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
routing = {
|
|
||||||
# Default: send RU geosite/geoip traffic direct.
|
|
||||||
enableRuDirect = true;
|
|
||||||
direct.domains = [ "reddit.com" ];
|
|
||||||
};
|
|
||||||
routing.proxy.geosites = [ "google" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
zapret = {
|
|
||||||
enable = true;
|
|
||||||
# Default: mirror zapret domain lists into sing-box direct routing.
|
|
||||||
syncDirectRouting = true;
|
|
||||||
# Upstream zapret IP ranges are much broader, so keep them opt-in.
|
|
||||||
syncDirectRoutingUpstreamIps = false;
|
|
||||||
# User-defined ipsetAll/ipsetExclude still map into sing-box by default.
|
|
||||||
syncDirectRoutingUserIps = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
After `nixos-rebuild switch`, you have a SOCKS proxy at `localhost:1080`.
|
|
||||||
|
|
||||||
If you intentionally want to expose it on another interface, set:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
services.proxy-suite.singBox.listenAddress = "0.0.0.0";
|
|
||||||
```
|
|
||||||
|
|
||||||
To also start transparent proxying:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
systemctl start proxy-suite-tproxy
|
|
||||||
```
|
|
||||||
|
|
||||||
TProxy installs its own nftables interception rules and can coexist with the NixOS firewall.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Outbound formats
|
|
||||||
|
|
||||||
Each outbound needs exactly one of `urlFile`, `url`, or `json`.
|
|
||||||
|
|
||||||
### urlFile (recommended for real credentials)
|
|
||||||
|
|
||||||
```nix
|
|
||||||
outbounds = [{
|
|
||||||
tag = "vps";
|
|
||||||
urlFile = config.sops.secrets.my_vps_url.path;
|
|
||||||
}];
|
|
||||||
```
|
|
||||||
|
|
||||||
The URL is read at service start time. Never touches the nix store.
|
|
||||||
|
|
||||||
### url (convenient, not secret)
|
|
||||||
|
|
||||||
```nix
|
|
||||||
outbounds = [{
|
|
||||||
tag = "vps";
|
|
||||||
url = "hy2://yourpassword@your-server.com:443?sni=your-server.com";
|
|
||||||
}];
|
|
||||||
```
|
|
||||||
|
|
||||||
The URL string ends up in `/nix/store`. Fine for non-sensitive configs or testing.
|
|
||||||
|
|
||||||
### json (full sing-box outbound attrset)
|
|
||||||
|
|
||||||
```nix
|
|
||||||
outbounds = [{
|
|
||||||
tag = "vps";
|
|
||||||
json = {
|
|
||||||
type = "vless";
|
|
||||||
server = "your-server.com";
|
|
||||||
server_port = 443;
|
|
||||||
uuid = "your-uuid";
|
|
||||||
tls = {
|
|
||||||
enabled = true;
|
|
||||||
server_name = "your-server.com";
|
|
||||||
reality = {
|
|
||||||
enabled = true;
|
|
||||||
public_key = "your-public-key";
|
|
||||||
short_id = "abc123";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}];
|
|
||||||
```
|
|
||||||
|
|
||||||
Embedded at build time. Good when you generate the config programmatically.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Multiple outbounds
|
|
||||||
|
|
||||||
```nix
|
|
||||||
singBox = {
|
|
||||||
outbounds = [
|
|
||||||
{ tag = "de"; urlFile = config.sops.secrets.vps_de.path; }
|
|
||||||
{ tag = "nl"; urlFile = config.sops.secrets.vps_nl.path; }
|
|
||||||
];
|
|
||||||
|
|
||||||
# Auto-select the fastest (checks every 3 minutes)
|
|
||||||
selection = "urltest";
|
|
||||||
|
|
||||||
# Or expose a Clash-compatible API for manual switching:
|
|
||||||
# selection = "selector";
|
|
||||||
# clashApiPort = 9090; # then use a Clash controller UI
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Subscription URLs
|
|
||||||
|
|
||||||
A subscription URL is an HTTP endpoint that returns a base64-encoded newline-separated list of proxy URIs — the standard format used by v2rayN, Clash, and similar clients. All supported proxy schemes (VLESS, VMess, Trojan, Shadowsocks, Hysteria2, TUIC, SOCKS5, HTTP…) can appear in the same subscription.
|
|
||||||
|
|
||||||
```nix
|
|
||||||
singBox = {
|
|
||||||
subscriptions = [
|
|
||||||
{
|
|
||||||
tag = "community";
|
|
||||||
url = "https://example.com/sub/your-token";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
# urltest is strongly recommended for subscriptions: sing-box probes all proxies
|
|
||||||
# concurrently and routes through the fastest working one. With selection = "first"
|
|
||||||
# a single dead server in position 0 breaks everything.
|
|
||||||
selection = "urltest";
|
|
||||||
subscriptionUpdateInterval = "6h"; # refresh every 6 hours (default: 1d)
|
|
||||||
|
|
||||||
# Optional: test against a URL that is actually blocked in your region.
|
|
||||||
# Only proxies that bypass the block will win — not just any reachable server.
|
|
||||||
# Defaults to https://www.gstatic.com/generate_204 (reachability check only).
|
|
||||||
urlTest.url = "https://telegram.org/";
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
Use `urlFile` instead of `url` to keep the subscription URL out of the nix store:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
subscriptions = [{
|
|
||||||
tag = "private";
|
|
||||||
urlFile = config.sops.secrets.sub_url.path;
|
|
||||||
}];
|
|
||||||
```
|
|
||||||
|
|
||||||
### How it works
|
|
||||||
|
|
||||||
**First start:** the service fetches the subscription URL live and writes the parsed outbounds to `/var/lib/proxy-suite/subscriptions/<tag>.json`.
|
|
||||||
|
|
||||||
**Subsequent starts:** the cache file is used directly — no network access on restart.
|
|
||||||
|
|
||||||
**Periodic refresh:** a systemd timer (`proxy-suite-subscription-update`) fires on boot (after 5 minutes) and then every `subscriptionUpdateInterval`. On success it updates the cache files and restarts `proxy-suite-socks` (and `proxy-suite-tun` if it is active).
|
|
||||||
|
|
||||||
### urltest startup behavior
|
|
||||||
|
|
||||||
When `selection = "urltest"`, sing-box starts probing all proxies **concurrently** the moment the service comes up. Until the first test result arrives (typically within a few seconds), traffic uses the first proxy in the list. As tests complete, sing-box progressively switches to faster winners. Dead proxies are skipped as their tests time out.
|
|
||||||
|
|
||||||
**Practical consequence:** the first few requests after a (re)start may go through a slow or unreachable proxy. This resolves quickly — usually within 5–20 seconds — without any manual action.
|
|
||||||
|
|
||||||
To minimize this window, set `urlTest.url` to a URL that must actually be reachable through a working proxy (e.g. a blocked site in your region). This way the first working test result corresponds to a proxy that genuinely serves your traffic, not just any reachable server.
|
|
||||||
|
|
||||||
### Tag generation
|
|
||||||
|
|
||||||
Each proxy URI in the subscription gets a sing-box outbound tag derived from its `#remark` fragment:
|
|
||||||
|
|
||||||
```
|
|
||||||
<subscription-tag>-<slugified-remark>
|
|
||||||
```
|
|
||||||
|
|
||||||
For example, a subscription with `tag = "sub"` and a proxy remarked `Server DE #1` becomes `sub-Server-DE--1`. URIs without a remark get `sub-0`, `sub-1`, etc. Duplicate tags are suffixed with `-2`, `-3`, and so on.
|
|
||||||
|
|
||||||
### Routing domains through subscription proxies
|
|
||||||
|
|
||||||
Routing rules that point to `"proxy"` automatically use whatever subscription proxy is currently active. With `selection = "urltest"`, the fastest subscription proxy handles those domains. With `selection = "selector"`, the manually chosen one does.
|
|
||||||
|
|
||||||
```nix
|
|
||||||
singBox = {
|
|
||||||
subscriptions = [{ tag = "community"; url = "https://example.com/sub/token"; }];
|
|
||||||
selection = "urltest";
|
|
||||||
|
|
||||||
# These domains go through whichever community proxy wins the latency test.
|
|
||||||
routing.proxy.domains = [ "telegram.org" "twitter.com" ];
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
You **cannot** route specific domains to "a named group of proxies from subscription X" — subscription tags are generated at runtime and are unknown at Nix eval time. If you need to pin a domain to a specific proxy, use `selection = "selector"`, switch to that proxy via `proxy-ctl select <tag>`, and all routing rules pointing to `"proxy"` will follow.
|
|
||||||
|
|
||||||
### Mixing subscriptions with static outbounds
|
|
||||||
|
|
||||||
Subscriptions and static outbound declarations can coexist. Subscription outbounds are appended after static ones, so with `selection = "selector"` or `"urltest"` all of them are available:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
singBox = {
|
|
||||||
outbounds = [
|
|
||||||
{ tag = "own-vps"; urlFile = config.sops.secrets.vps.path; }
|
|
||||||
];
|
|
||||||
subscriptions = [
|
|
||||||
{ tag = "backup"; url = "https://example.com/sub/token"; }
|
|
||||||
];
|
|
||||||
selection = "urltest";
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
### `selection = "first"` with subscriptions
|
|
||||||
|
|
||||||
With `selection = "first"` and static outbounds, the first static outbound is used (as usual). With `selection = "first"` and **subscriptions only**, the first proxy from the first subscription is used as `proxy`.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Per-outbound routing
|
|
||||||
|
|
||||||
By default all proxied traffic goes to whatever the active outbound is (the selector, urltest winner, or single "first" outbound). You can override this per-outbound or with explicit rules to send specific traffic to a specific server.
|
|
||||||
|
|
||||||
Global direct routing also has two built-in behaviors:
|
|
||||||
|
|
||||||
- `singBox.routing.enableRuDirect = true` sends `geosite-category-ru` and `geoip-ru` direct by default.
|
|
||||||
- If `zapret.enable = true`, then `zapret.syncDirectRouting = true` mirrors zapret's upstream domain hostlists into sing-box direct rules. `zapret.syncDirectRoutingUpstreamIps = false` by default, so upstream zapret IP ranges are not mirrored unless you opt in, while `zapret.syncDirectRoutingUserIps = true` keeps user `ipsetAll`/`ipsetExclude` mirrored by default.
|
|
||||||
|
|
||||||
**Attached to an outbound:**
|
|
||||||
|
|
||||||
```nix
|
|
||||||
outbounds = [
|
|
||||||
{
|
|
||||||
tag = "de";
|
|
||||||
urlFile = config.sops.secrets.vps_de.path;
|
|
||||||
# Only meaningful with selection = "selector" or "urltest"
|
|
||||||
routing.geosites = [ "netflix" ];
|
|
||||||
routing.geoips = [ "us" ];
|
|
||||||
routing.domains = [ "hulu.com" "peacocktv.com" ];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
tag = "nl";
|
|
||||||
urlFile = config.sops.secrets.vps_nl.path;
|
|
||||||
routing.domains = [ "discord.com" "discordapp.com" ];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
```
|
|
||||||
|
|
||||||
**Explicit rules list** – also works for `direct` and `block`, in any selection mode:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
singBox.routing.rules = [
|
|
||||||
# Block ad networks before anything else
|
|
||||||
{ outbound = "block"; geosites = [ "category-ads-all" ]; }
|
|
||||||
# Internal traffic goes direct
|
|
||||||
{ outbound = "direct"; domains = [ "corp.internal" ]; ips = [ "10.0.0.0/8" ]; }
|
|
||||||
# Route US ips and Netflix to a specific server
|
|
||||||
{ outbound = "de"; geoips = [ "us" ]; geosites = [ "netflix" ]; }
|
|
||||||
];
|
|
||||||
```
|
|
||||||
|
|
||||||
Rules from `outbound.routing` and `routing.rules` are evaluated **before** the global `routing.proxy` / `routing.direct` / `routing.block` lists, so they always take priority.
|
|
||||||
|
|
||||||
Within a single rule, `domains`, `ips`, `geosites`, and `geoips` are treated as independent matches. In practice that means one rule with multiple fields behaves like OR, not AND.
|
|
||||||
|
|
||||||
In `first` selection mode, per-outbound tags are resolved to `"proxy"` automatically (there's only one proxy outbound in that mode, so routing to a specific tag doesn't make sense).
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## proxy-ctl
|
|
||||||
|
|
||||||
A control script is installed into your system packages automatically. Run it as root or with the right polkit permissions.
|
|
||||||
|
|
||||||
```
|
|
||||||
proxy-ctl status show status of all proxy-suite services
|
|
||||||
proxy-ctl tproxy on|off enable/disable TProxy transparent mode
|
|
||||||
proxy-ctl tun on|off enable/disable TUN mode
|
|
||||||
proxy-ctl restart restart proxy-suite-socks, and proxy-suite-tun if it is active
|
|
||||||
proxy-ctl logs [service] follow logs (default: proxy-suite-socks)
|
|
||||||
proxy-ctl outbounds list outbounds and current selection (needs Clash API)
|
|
||||||
proxy-ctl select <tag> switch to a specific outbound (selector mode)
|
|
||||||
proxy-ctl subscription list show subscriptions, cache age, and proxy count
|
|
||||||
proxy-ctl subscription update force-refresh all subscription caches and restart
|
|
||||||
```
|
|
||||||
|
|
||||||
`outbounds` works with `selection = "selector"` or `"urltest"`. `select` requires `selection = "selector"` and talks to the Clash-compatible REST API embedded in sing-box.
|
|
||||||
|
|
||||||
`subscription list` and `subscription update` are only meaningful when `singBox.subscriptions` is non-empty.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Protocol URL formats
|
|
||||||
|
|
||||||
| Protocol | Example URL |
|
|
||||||
| --------------- | ------------------------------------------------------------------------------------------------ |
|
|
||||||
| VLESS + Reality | `vless://uuid@host:443?security=reality&pbk=KEY&fp=chrome&sni=SNI&sid=abc&flow=xtls-rprx-vision` |
|
|
||||||
| VLESS + TLS | `vless://uuid@host:443?security=tls&sni=SNI&type=ws&path=/path` |
|
|
||||||
| VMess | `vmess://BASE64_JSON` (standard V2 link format) |
|
|
||||||
| Trojan | `trojan://password@host:443?sni=SNI&fp=chrome` |
|
|
||||||
| Shadowsocks | `ss://BASE64(method:password)@host:port` or `ss://method:password@host:port` |
|
|
||||||
| Hysteria2 | `hy2://password@host:443?sni=SNI` |
|
|
||||||
| TUIC v5 | `tuic://uuid:password@host:443?sni=SNI&congestion_control=bbr` |
|
|
||||||
| SOCKS5 | `socks5://user:pass@host:1080` or `socks5://host:1080` |
|
|
||||||
| SOCKS4 | `socks4://host:1080` |
|
|
||||||
| HTTP proxy | `http://user:pass@host:8080` |
|
|
||||||
| HTTPS proxy | `https://host:8080` (HTTP CONNECT over TLS) |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Zapret
|
|
||||||
|
|
||||||
zapret handles DPI-based blocking by mangling packets at the netfilter level. It's separate from the proxy, but by default this module also mirrors zapret-covered domains into sing-box direct routing so the proxy does not fight zapret for the same traffic.
|
|
||||||
|
|
||||||
```nix
|
|
||||||
zapret = {
|
|
||||||
enable = true;
|
|
||||||
configName = "general(ALT)";
|
|
||||||
syncDirectRouting = true; # default: sync upstream domain lists
|
|
||||||
syncDirectRoutingUpstreamIps = false; # default: do not sync upstream IP ranges
|
|
||||||
syncDirectRoutingUserIps = true; # default: do sync user ipsetAll/ipsetExclude
|
|
||||||
|
|
||||||
# Extra domains beyond zapret's built-in list
|
|
||||||
listGeneral = [ "pixiv.net" "pximg.net" ];
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
When `syncDirectRouting = true`, the module always reuses zapret's upstream `hostlists/list-general.txt` and `list-google.txt`, adds your `listGeneral`, and subtracts both upstream and user domain exclusions before generating sing-box direct rules. If `zapret.includeExtraUpstreamLists = true`, it also includes upstream `list-instagram.txt`, `list-soundcloud.txt`, and `list-twitter.txt` in both zapret handling and sing-box direct sync.
|
|
||||||
|
|
||||||
Custom `zapret.hostlistRules` domains also join this direct-domain sync by default. Set `enableDirectSync = false` on a custom hostlist if you want zapret to handle it but do not want sing-box direct-routing rules generated from it.
|
|
||||||
|
|
||||||
The generated zapret config can also auto-activate upstream `list-instagram.txt`, `list-soundcloud.txt`, and `list-twitter.txt` when the selected upstream preset does not already reference them. They are attached using the active config's `general` rule family so those hostlists are actually handled by zapret instead of just existing on disk. This is disabled by default; set `zapret.includeExtraUpstreamLists = true;` to opt in.
|
|
||||||
|
|
||||||
When `syncDirectRoutingUpstreamIps = true`, the module also mirrors zapret's upstream `ipset-all.txt`. This is disabled by default because the upstream IP set is intentionally broad.
|
|
||||||
|
|
||||||
When `syncDirectRoutingUserIps = true`, the module mirrors your `ipsetAll` and `ipsetExclude` values into sing-box direct routing even if upstream IP sync stays disabled. This is enabled by default.
|
|
||||||
|
|
||||||
If zapret corrupts traffic for some subnet (e.g. a VM behind a libvirt bridge):
|
|
||||||
|
|
||||||
```nix
|
|
||||||
zapret.cidrExemption = {
|
|
||||||
enable = true;
|
|
||||||
cidrs = [ "192.168.123.0/24" ]; # your VM's bridge network(s)
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also define custom zapret hostlists with per-list rules:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
zapret.hostlistRules = [
|
|
||||||
{
|
|
||||||
name = "googlevideo";
|
|
||||||
domains = [ "googlevideo.com" "ggpht.com" ];
|
|
||||||
preset = "google";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
name = "example";
|
|
||||||
domains = [ "example.com" "example.de" ];
|
|
||||||
nfqwsArgs = [
|
|
||||||
"--filter-tcp=443 --dpi-desync=fake,multisplit"
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
name = "social-extra";
|
|
||||||
domains = [ "x.example" ];
|
|
||||||
preset = "twitter";
|
|
||||||
nfqwsArgs = [
|
|
||||||
"--filter-udp=443 --dpi-desync=fake --dpi-desync-repeats=6"
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
```
|
|
||||||
|
|
||||||
Each entry generates `hostlists/list-<name>.txt`. `preset` clones the active zapret config's matching family rules for that hostlist, while `nfqwsArgs` appends custom NFQWS rule fragments. The module injects the generated `--hostlist=...`, standard zapret exclude files, and trailing `--new` automatically.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Telegram proxy
|
|
||||||
|
|
||||||
Runs a WebSocket MTProto relay. Useful for sharing with others on mobile or for clients that need a dedicated Telegram proxy.
|
|
||||||
|
|
||||||
```nix
|
|
||||||
tgWsProxy = {
|
|
||||||
enable = true;
|
|
||||||
# Generate a secret: openssl rand -hex 16
|
|
||||||
secretFile = config.sops.secrets.tg_ws_proxy_secret.path;
|
|
||||||
port = 1076;
|
|
||||||
host = "0.0.0.0"; # configurable bind address
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
`secretFile` is the recommended form because it keeps the secret out of the nix store. The legacy inline `secret = "...";` form still works for testing.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Services
|
|
||||||
|
|
||||||
| Service | Auto-starts | Description |
|
|
||||||
| --------------------------------- | ------------------ | ------------------------------------------------ |
|
|
||||||
| `proxy-suite-socks` | yes | SOCKS5/HTTP proxy, always running |
|
|
||||||
| `proxy-suite-tproxy` | no | TProxy transparent mode (start manually) |
|
|
||||||
| `proxy-suite-tun` | no | TUN mode (start manually, conflicts with tproxy) |
|
|
||||||
| `proxy-suite-tg-ws-proxy` | yes (if enabled) | Telegram proxy |
|
|
||||||
| `proxy-suite-zapret-vm-exempt` | yes (if enabled) | VM subnet exemption |
|
|
||||||
| `proxy-suite-subscription-update` | timer (if sub set) | Refresh subscription caches and restart |
|
|
||||||
|
|
||||||
TProxy and TUN are mutually exclusive. Start one, the other refuses to start.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Secret management
|
|
||||||
|
|
||||||
This module doesn't care how you manage secrets. Anything that gives you a file path works:
|
|
||||||
|
|
||||||
**sops-nix:**
|
|
||||||
|
|
||||||
```nix
|
|
||||||
sops.secrets.proxy_url.sopsFile = ./secrets/proxy.yaml;
|
|
||||||
|
|
||||||
services.proxy-suite.singBox.outbounds = [{
|
|
||||||
tag = "vps";
|
|
||||||
urlFile = config.sops.secrets.proxy_url.path;
|
|
||||||
}];
|
|
||||||
```
|
|
||||||
|
|
||||||
**agenix:**
|
|
||||||
|
|
||||||
```nix
|
|
||||||
age.secrets.proxy_url.file = ./secrets/proxy_url.age;
|
|
||||||
|
|
||||||
services.proxy-suite.singBox.outbounds = [{
|
|
||||||
tag = "vps";
|
|
||||||
urlFile = config.age.secrets.proxy_url.path;
|
|
||||||
}];
|
|
||||||
```
|
|
||||||
|
|
||||||
**Plain file (not recommended but works):**
|
|
||||||
|
|
||||||
```nix
|
|
||||||
# Create /run/proxy-url with your URL, ensure it's readable by root
|
|
||||||
urlFile = "/run/proxy-url";
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## System tray
|
|
||||||
|
|
||||||
Optional tray indicator for desktop environments. Shows proxy status and provides quick toggles.
|
|
||||||
|
|
||||||
```nix
|
|
||||||
services.proxy-suite = {
|
|
||||||
tray = {
|
|
||||||
enable = true;
|
|
||||||
autostart = true; # Install XDG autostart for all graphical users (default)
|
|
||||||
pollInterval = 5; # Status refresh interval in seconds
|
|
||||||
};
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
Features:
|
|
||||||
|
|
||||||
- **Status icon**: `network-vpn` (active), `network-vpn-acquiring` (partial), `network-vpn-disconnected` (stopped)
|
|
||||||
- **Quick controls window**: Opens on secondary activation and on hosts that emit StatusNotifier `Activate` on left-click (including niri)
|
|
||||||
- **Enable/Disable Proxy**: Toggles `proxy-suite-socks`; disabling proxy also stops active TProxy/TUN first
|
|
||||||
- **Toggle TProxy/TUN**: Only shown if the service is enabled in your config
|
|
||||||
- **Close window**: Hides the floating controls window without exiting the tray
|
|
||||||
- **Update Subscriptions**: Triggers `proxy-suite-subscription-update` to re-fetch all subscription caches; only shown when subscriptions are configured
|
|
||||||
- **Restart services**: Restarts `proxy-suite-socks`, and `proxy-suite-tun` if it is active
|
|
||||||
- **Polkit authentication**: Prompts for password when toggling services
|
|
||||||
|
|
||||||
When enabled, the tray app is installed system-wide and autostarts for all graphical users via XDG autostart unless you set `tray.autostart = false;`.
|
|
||||||
|
|
||||||
The tray uses libayatana-appindicator and requires StatusNotifier/AppIndicator support. KDE generally works out of the box; GNOME may need shell support or an extension that exposes AppIndicators.
|
|
||||||
|
|
||||||
To enable TProxy/TUN toggles in the tray, you need to enable the services in your config:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
services.proxy-suite.singBox = {
|
|
||||||
tproxy.enable = true; # Show TProxy toggle
|
|
||||||
tun.enable = true; # Show TUN toggle
|
|
||||||
};
|
|
||||||
```
|
|
||||||
+2975
File diff suppressed because it is too large.
Load diff
@@ -23,6 +23,65 @@
|
|||||||
forAll = nixpkgs.lib.genAttrs systems;
|
forAll = nixpkgs.lib.genAttrs systems;
|
||||||
pkgsFor = system: import nixpkgs { inherit system; };
|
pkgsFor = system: import nixpkgs { inherit system; };
|
||||||
proxySuiteModule = import ./modules/proxy-suite { inherit zapret; };
|
proxySuiteModule = import ./modules/proxy-suite { inherit zapret; };
|
||||||
|
mkOptionsDoc =
|
||||||
|
system:
|
||||||
|
let
|
||||||
|
pkgs = pkgsFor system;
|
||||||
|
lib = pkgs.lib;
|
||||||
|
eval = import "${nixpkgs}/nixos/lib/eval-config.nix" {
|
||||||
|
inherit system;
|
||||||
|
modules = [
|
||||||
|
proxySuiteModule
|
||||||
|
{
|
||||||
|
system.stateVersion = lib.trivial.release;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
defaultConfigText = lib.generators.toPretty { } eval.config.services.proxy-suite;
|
||||||
|
repoRoot = toString ./.;
|
||||||
|
repoUrl = "https://github.com/FUFSoB/proxy-suite-flake/blob/main";
|
||||||
|
transformDeclaration =
|
||||||
|
decl:
|
||||||
|
let
|
||||||
|
declStr = toString decl;
|
||||||
|
subpath = lib.removePrefix "/" (lib.removePrefix repoRoot declStr);
|
||||||
|
in
|
||||||
|
if lib.hasPrefix repoRoot declStr then
|
||||||
|
{
|
||||||
|
url = "${repoUrl}/${subpath}";
|
||||||
|
name = subpath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
decl;
|
||||||
|
optionDocs = pkgs.nixosOptionsDoc {
|
||||||
|
options = {
|
||||||
|
services = {
|
||||||
|
"proxy-suite" = eval.options.services.proxy-suite;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
documentType = "none";
|
||||||
|
variablelistId = "proxy-suite-options";
|
||||||
|
optionIdPrefix = "proxy-suite-opt-";
|
||||||
|
transformOptions = opt: opt // { declarations = map transformDeclaration opt.declarations; };
|
||||||
|
};
|
||||||
|
in
|
||||||
|
pkgs.runCommand "proxy-suite-options.md" { } ''
|
||||||
|
cat >"$out" <<'EOF'
|
||||||
|
# proxy-suite options
|
||||||
|
|
||||||
|
This file is generated from the `services.proxy-suite` option descriptions in [`modules/proxy-suite/options.nix`](modules/proxy-suite/options.nix).
|
||||||
|
Update module option docs there instead of editing this file by hand.
|
||||||
|
|
||||||
|
## Complete default config
|
||||||
|
|
||||||
|
```nix
|
||||||
|
services.proxy-suite = ${defaultConfigText};
|
||||||
|
```
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat ${optionDocs.optionsCommonMark} >>"$out"
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# Main module – bakes in the zapret flake so consumers don't need it as a separate input.
|
# Main module – bakes in the zapret flake so consumers don't need it as a separate input.
|
||||||
@@ -36,9 +95,47 @@
|
|||||||
proxy-suite-tray = import ./pkgs/proxy-suite-tray.nix { pkgs = final; };
|
proxy-suite-tray = import ./pkgs/proxy-suite-tray.nix { pkgs = final; };
|
||||||
};
|
};
|
||||||
|
|
||||||
packages = forAll (system: {
|
packages = forAll (
|
||||||
tg-ws-proxy = import ./pkgs/tg-ws-proxy.nix { pkgs = pkgsFor system; };
|
system:
|
||||||
proxy-suite-tray = import ./pkgs/proxy-suite-tray.nix { pkgs = pkgsFor system; };
|
let
|
||||||
|
pkgs = pkgsFor system;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
tg-ws-proxy = import ./pkgs/tg-ws-proxy.nix { inherit pkgs; };
|
||||||
|
proxy-suite-tray = import ./pkgs/proxy-suite-tray.nix { inherit pkgs; };
|
||||||
|
optionsDoc = mkOptionsDoc system;
|
||||||
|
update-options-doc = pkgs.writeShellApplication {
|
||||||
|
name = "update-options-doc";
|
||||||
|
runtimeInputs = [
|
||||||
|
pkgs.coreutils
|
||||||
|
pkgs.git
|
||||||
|
pkgs.nix
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
repo_root="$(git rev-parse --show-toplevel 2>/dev/null || true)"
|
||||||
|
|
||||||
|
if [[ -z "''${repo_root}" || ! -f "''${repo_root}/flake.nix" ]]; then
|
||||||
|
echo "run this helper from inside the proxy-suite-flake repository" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
output_path="$(nix build --no-link --print-out-paths "''${repo_root}#optionsDoc")"
|
||||||
|
target_path="''${repo_root}/docs/options.md"
|
||||||
|
|
||||||
|
install -Dm644 "''${output_path}" "''${target_path}"
|
||||||
|
echo "updated ''${target_path}"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
apps = forAll (system: {
|
||||||
|
update-options-doc = {
|
||||||
|
type = "app";
|
||||||
|
program = "${self.packages.${system}.update-options-doc}/bin/update-options-doc";
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
checks = forAll (
|
checks = forAll (
|
||||||
@@ -50,6 +147,7 @@
|
|||||||
proxySuiteModule
|
proxySuiteModule
|
||||||
zapret
|
zapret
|
||||||
;
|
;
|
||||||
|
generatedOptionsDoc = mkOptionsDoc system;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+315
-67
@@ -9,7 +9,10 @@ let
|
|||||||
domains = mkOption {
|
domains = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "Domain suffixes to match.";
|
description = ''
|
||||||
|
Domain suffixes to match in this routing rule.
|
||||||
|
Leave empty to skip domain-based matching for this rule entry.
|
||||||
|
'';
|
||||||
example = [
|
example = [
|
||||||
"youtube.com"
|
"youtube.com"
|
||||||
"discord.com"
|
"discord.com"
|
||||||
@@ -18,13 +21,19 @@ let
|
|||||||
ips = mkOption {
|
ips = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "IP CIDRs to match.";
|
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" ];
|
example = [ "1.1.1.0/24" ];
|
||||||
};
|
};
|
||||||
geosites = mkOption {
|
geosites = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "sing-geosite rule-set names to match.";
|
description = ''
|
||||||
|
sing-geosite rule-set names to match in this routing rule.
|
||||||
|
Each name becomes a sing-box geosite rule-set reference.
|
||||||
|
'';
|
||||||
example = [
|
example = [
|
||||||
"netflix"
|
"netflix"
|
||||||
"google"
|
"google"
|
||||||
@@ -33,7 +42,10 @@ let
|
|||||||
geoips = mkOption {
|
geoips = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "sing-geoip rule-set names to match.";
|
description = ''
|
||||||
|
sing-geoip rule-set names to match in this routing rule.
|
||||||
|
Each name becomes a sing-box geoip rule-set reference.
|
||||||
|
'';
|
||||||
example = [
|
example = [
|
||||||
"us"
|
"us"
|
||||||
"de"
|
"de"
|
||||||
@@ -50,6 +62,10 @@ let
|
|||||||
Target outbound tag. Can be a specific server tag (only useful with
|
Target outbound tag. Can be a specific server tag (only useful with
|
||||||
selection = "selector" or "urltest"), or one of the built-in tags:
|
selection = "selector" or "urltest"), or one of the built-in tags:
|
||||||
"proxy" (the active proxy outbound), "direct", "block".
|
"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";
|
example = "vps-de";
|
||||||
};
|
};
|
||||||
@@ -62,9 +78,9 @@ let
|
|||||||
tag = mkOption {
|
tag = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
description = ''
|
description = ''
|
||||||
Unique identifier for this subscription. Used as a prefix for all
|
Unique identifier for this subscription.
|
||||||
outbound tags generated from its proxy list, e.g. "my-sub" →
|
Used as a prefix for all outbound tags generated from its proxy list,
|
||||||
tags like "my-sub-Server-DE".
|
e.g. "my-sub" -> tags like "my-sub-Server-DE".
|
||||||
'';
|
'';
|
||||||
example = "community-list";
|
example = "community-list";
|
||||||
};
|
};
|
||||||
@@ -76,7 +92,9 @@ let
|
|||||||
Literal subscription URL. The response must be a base64-encoded
|
Literal subscription URL. The response must be a base64-encoded
|
||||||
newline-separated list of proxy URIs (standard v2rayN format) or
|
newline-separated list of proxy URIs (standard v2rayN format) or
|
||||||
a plain-text list of the same.
|
a plain-text list of the same.
|
||||||
The URL will end up in the nix store. Use urlFile for actual secrets.
|
|
||||||
|
This value is embedded in the Nix store. Prefer urlFile for private
|
||||||
|
subscription links or tokens.
|
||||||
'';
|
'';
|
||||||
example = "https://example.com/sub/token123";
|
example = "https://example.com/sub/token123";
|
||||||
};
|
};
|
||||||
@@ -87,9 +105,11 @@ let
|
|||||||
description = ''
|
description = ''
|
||||||
Runtime path to a file containing the subscription URL.
|
Runtime path to a file containing the subscription URL.
|
||||||
Intended for use with secret managers (sops-nix, agenix, etc.).
|
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.
|
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/my-sub-url";
|
example = "/run/secrets/proxy-subscription-url";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -98,7 +118,14 @@ let
|
|||||||
options = {
|
options = {
|
||||||
tag = mkOption {
|
tag = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
description = "Outbound tag. Used in routing rules and multi-outbound selection.";
|
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";
|
example = "vps-de";
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -108,11 +135,11 @@ let
|
|||||||
description = ''
|
description = ''
|
||||||
Runtime path to a file containing the proxy URL.
|
Runtime path to a file containing the proxy URL.
|
||||||
Intended for use with secret managers (sops-nix, agenix, etc.).
|
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.
|
The file is read at service start time and never lands in the Nix store.
|
||||||
|
|
||||||
Example with sops-nix:
|
Set exactly one of urlFile, url, or json for each outbound.
|
||||||
urlFile = config.sops.secrets.my_proxy_url.path;
|
|
||||||
'';
|
'';
|
||||||
|
example = "/run/secrets/my-proxy-url";
|
||||||
};
|
};
|
||||||
|
|
||||||
url = mkOption {
|
url = mkOption {
|
||||||
@@ -120,7 +147,10 @@ let
|
|||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
Literal proxy URL. Convenient for non-secret configs, but the URL
|
Literal proxy URL. Convenient for non-secret configs, but the URL
|
||||||
will end up in the nix store. Use urlFile for actual credentials.
|
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";
|
example = "hy2://password@example.com:443?sni=example.com";
|
||||||
};
|
};
|
||||||
@@ -132,6 +162,10 @@ let
|
|||||||
Raw sing-box outbound configuration as a Nix attribute set.
|
Raw sing-box outbound configuration as a Nix attribute set.
|
||||||
Embedded directly into the config at build time. The tag field
|
Embedded directly into the config at build time. The tag field
|
||||||
is overridden by the outbound's tag option.
|
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 = {
|
example = {
|
||||||
type = "vless";
|
type = "vless";
|
||||||
@@ -161,14 +195,20 @@ let
|
|||||||
options = {
|
options = {
|
||||||
name = mkOption {
|
name = mkOption {
|
||||||
type = types.strMatching "^[a-z0-9][a-z0-9-]*$";
|
type = types.strMatching "^[a-z0-9][a-z0-9-]*$";
|
||||||
description = "Custom hostlist name. Used to generate list-<name>.txt.";
|
description = ''
|
||||||
|
Custom hostlist name. Used to generate hostlists/list-<name>.txt
|
||||||
|
inside the derived zapret config directory.
|
||||||
|
'';
|
||||||
example = "cloudflare";
|
example = "cloudflare";
|
||||||
};
|
};
|
||||||
|
|
||||||
domains = mkOption {
|
domains = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "Domains written into the generated custom zapret hostlist.";
|
description = ''
|
||||||
|
Domains written into the generated custom zapret hostlist file.
|
||||||
|
Must be non-empty for every hostlistRules entry.
|
||||||
|
'';
|
||||||
example = [
|
example = [
|
||||||
"example.com"
|
"example.com"
|
||||||
"example.de"
|
"example.de"
|
||||||
@@ -178,7 +218,10 @@ let
|
|||||||
preset = mkOption {
|
preset = mkOption {
|
||||||
type = types.nullOr zapretPresetType;
|
type = types.nullOr zapretPresetType;
|
||||||
default = null;
|
default = null;
|
||||||
description = "Clone the active zapret config's built-in rule family for this hostlist.";
|
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";
|
example = "google";
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -188,6 +231,8 @@ let
|
|||||||
description = ''
|
description = ''
|
||||||
Additional NFQWS argument fragments for this hostlist.
|
Additional NFQWS argument fragments for this hostlist.
|
||||||
The module injects --hostlist=... and trailing --new automatically.
|
The module injects --hostlist=... and trailing --new automatically.
|
||||||
|
|
||||||
|
Each hostlistRules entry must define preset, nfqwsArgs, or both.
|
||||||
'';
|
'';
|
||||||
example = [
|
example = [
|
||||||
"--filter-tcp=443 --dpi-desync=fake,multisplit"
|
"--filter-tcp=443 --dpi-desync=fake,multisplit"
|
||||||
@@ -197,7 +242,10 @@ let
|
|||||||
enableDirectSync = mkOption {
|
enableDirectSync = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "Whether this custom hostlist should also be mirrored into sing-box direct domain routing.";
|
description = ''
|
||||||
|
Whether this custom hostlist should also be mirrored into sing-box
|
||||||
|
direct domain routing when zapret.syncDirectRouting = true.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -211,16 +259,33 @@ in
|
|||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "Whether to configure and run sing-box.";
|
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 {
|
outbounds = mkOption {
|
||||||
type = types.listOf outboundType;
|
type = types.listOf outboundType;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = ''
|
description = ''
|
||||||
List of proxy outbounds. Set exactly one of urlFile, url, or json per entry.
|
List of static proxy outbounds.
|
||||||
At least one outbound (or one subscription) is required when singBox.enable = true.
|
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 {
|
subscriptions = mkOption {
|
||||||
@@ -231,11 +296,13 @@ in
|
|||||||
Each URL must return a base64-encoded newline-separated list of proxy URIs
|
Each URL must return a base64-encoded newline-separated list of proxy URIs
|
||||||
(standard v2rayN / Clash subscription format) or plain text of the same.
|
(standard v2rayN / Clash subscription format) or plain text of the same.
|
||||||
|
|
||||||
On first service start the subscription is fetched live. Subsequent starts
|
On first service start, each subscription is fetched live and cached
|
||||||
use the on-disk cache under /var/lib/proxy-suite/subscriptions/.
|
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
|
A systemd timer (proxy-suite-subscription-update) refreshes all caches on
|
||||||
the interval set by subscriptionUpdateInterval and restarts the service.
|
the interval set by subscriptionUpdateInterval and restarts the running
|
||||||
|
sing-box services after a successful refresh.
|
||||||
'';
|
'';
|
||||||
example = [
|
example = [
|
||||||
{
|
{
|
||||||
@@ -256,7 +323,9 @@ in
|
|||||||
How often the proxy-suite-subscription-update timer fires and refreshes
|
How often the proxy-suite-subscription-update timer fires and refreshes
|
||||||
all subscription caches. Accepts any systemd time span string
|
all subscription caches. Accepts any systemd time span string
|
||||||
(e.g. "1h", "6h", "1d", "12h").
|
(e.g. "1h", "6h", "1d", "12h").
|
||||||
Only used when subscriptions is non-empty.
|
|
||||||
|
Only used when singBox.subscriptions is non-empty. The timer also runs
|
||||||
|
once shortly after boot.
|
||||||
'';
|
'';
|
||||||
example = "6h";
|
example = "6h";
|
||||||
};
|
};
|
||||||
@@ -269,11 +338,24 @@ in
|
|||||||
];
|
];
|
||||||
default = "first";
|
default = "first";
|
||||||
description = ''
|
description = ''
|
||||||
How to pick between multiple outbounds:
|
How to pick between multiple proxy outbounds:
|
||||||
- "first": use the first outbound only (no overhead, simplest)
|
|
||||||
- "selector": expose a Clash-compatible API for manual switching
|
- "first": route through a single active outbound tagged "proxy".
|
||||||
- "urltest": measure latency periodically and auto-switch to the fastest
|
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 = {
|
urlTest = {
|
||||||
@@ -287,7 +369,7 @@ in
|
|||||||
Set this to a URL that is actually blocked in your region (e.g.
|
Set this to a URL that is actually blocked in your region (e.g.
|
||||||
"https://telegram.org") so that only proxies that bypass the
|
"https://telegram.org") so that only proxies that bypass the
|
||||||
blocking get selected. If left at the default, any responding proxy
|
blocking get selected. If left at the default, any responding proxy
|
||||||
wins — including ones that might not unblock your target site.
|
wins – including ones that might not unblock your target site.
|
||||||
'';
|
'';
|
||||||
example = "https://telegram.org";
|
example = "https://telegram.org";
|
||||||
};
|
};
|
||||||
@@ -297,7 +379,8 @@ in
|
|||||||
default = "3m";
|
default = "3m";
|
||||||
description = ''
|
description = ''
|
||||||
How often sing-box re-tests all outbounds. Accepts a Go duration
|
How often sing-box re-tests all outbounds. Accepts a Go duration
|
||||||
string (e.g. "1m", "3m", "10m"). Only used when selection = "urltest".
|
string (e.g. "1m", "3m", "10m").
|
||||||
|
Only used when selection = "urltest".
|
||||||
'';
|
'';
|
||||||
example = "1m";
|
example = "1m";
|
||||||
};
|
};
|
||||||
@@ -308,6 +391,7 @@ in
|
|||||||
description = ''
|
description = ''
|
||||||
Latency tolerance in milliseconds. The current proxy is only replaced
|
Latency tolerance in milliseconds. The current proxy is only replaced
|
||||||
when a competing one is faster by more than this value.
|
when a competing one is faster by more than this value.
|
||||||
|
|
||||||
Only used when selection = "urltest".
|
Only used when selection = "urltest".
|
||||||
'';
|
'';
|
||||||
example = 100;
|
example = 100;
|
||||||
@@ -317,7 +401,12 @@ in
|
|||||||
clashApiPort = mkOption {
|
clashApiPort = mkOption {
|
||||||
type = types.port;
|
type = types.port;
|
||||||
default = 9090;
|
default = 9090;
|
||||||
description = "Port for the Clash-compatible REST API. Only used when selection is selector or urltest.";
|
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 {
|
listenAddress = mkOption {
|
||||||
@@ -325,44 +414,78 @@ in
|
|||||||
default = "127.0.0.1";
|
default = "127.0.0.1";
|
||||||
description = ''
|
description = ''
|
||||||
Address for the SOCKS5/HTTP mixed inbound to bind to.
|
Address for the SOCKS5/HTTP mixed inbound to bind to.
|
||||||
Use "0.0.0.0" only if you intentionally want to expose the proxy.
|
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 {
|
port = mkOption {
|
||||||
type = types.port;
|
type = types.port;
|
||||||
default = 1080;
|
default = 1080;
|
||||||
description = "SOCKS5/HTTP mixed inbound listen port.";
|
description = ''
|
||||||
|
Listen port for the always-on SOCKS5/HTTP mixed inbound provided by
|
||||||
|
proxy-suite-socks.
|
||||||
|
'';
|
||||||
|
example = 1080;
|
||||||
};
|
};
|
||||||
|
|
||||||
tproxyPort = mkOption {
|
tproxyPort = mkOption {
|
||||||
type = types.port;
|
type = types.port;
|
||||||
default = 1081;
|
default = 1081;
|
||||||
description = "Transparent proxy (TProxy) inbound listen port.";
|
description = ''
|
||||||
|
Listen port for the local sing-box TProxy inbound.
|
||||||
|
Only relevant when singBox.tproxy.enable = true.
|
||||||
|
'';
|
||||||
|
example = 1081;
|
||||||
};
|
};
|
||||||
|
|
||||||
fwmark = mkOption {
|
fwmark = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 1;
|
default = 1;
|
||||||
description = "Netfilter mark set on packets intercepted by TProxy for policy routing.";
|
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 {
|
proxyMark = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 2;
|
default = 2;
|
||||||
description = "Netfilter mark set on sing-box's own outbound packets so they bypass TProxy re-interception.";
|
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 {
|
routeTable = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 100;
|
default = 100;
|
||||||
description = "Policy routing table used to redirect TProxy-marked packets to the loopback interface.";
|
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 {
|
proxyByDefault = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "If true, traffic not matching any routing rule goes through the proxy. If false, it goes direct.";
|
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 = {
|
tun = {
|
||||||
@@ -371,19 +494,31 @@ in
|
|||||||
interface = mkOption {
|
interface = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "singtun0";
|
default = "singtun0";
|
||||||
description = "TUN interface name.";
|
description = ''
|
||||||
|
Name of the TUN interface created by proxy-suite-tun.
|
||||||
|
Only relevant when singBox.tun.enable = true.
|
||||||
|
'';
|
||||||
|
example = "singtun0";
|
||||||
};
|
};
|
||||||
|
|
||||||
address = mkOption {
|
address = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "172.19.0.1/30";
|
default = "172.19.0.1/30";
|
||||||
description = "TUN interface address (CIDR).";
|
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 {
|
mtu = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 1400;
|
default = 1400;
|
||||||
description = "TUN interface MTU.";
|
description = ''
|
||||||
|
MTU for the TUN interface created by proxy-suite-tun.
|
||||||
|
Only relevant when singBox.tun.enable = true.
|
||||||
|
'';
|
||||||
|
example = 1400;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -395,8 +530,11 @@ in
|
|||||||
default = [ "192.168.0.0/16" ];
|
default = [ "192.168.0.0/16" ];
|
||||||
description = ''
|
description = ''
|
||||||
Subnets whose traffic bypasses TProxy interception, except DNS (port 53).
|
Subnets whose traffic bypasses TProxy interception, except DNS (port 53).
|
||||||
Typically your LAN subnet(s). VM bridge networks should go here too,
|
Only relevant when singBox.tproxy.enable = true.
|
||||||
or use zapret.cidrExemption for subnet-specific NFQUEUE exemption.
|
|
||||||
|
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 = [
|
example = [
|
||||||
"192.168.0.0/16"
|
"192.168.0.0/16"
|
||||||
@@ -409,7 +547,13 @@ in
|
|||||||
enableRuDirect = mkOption {
|
enableRuDirect = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "Automatically send sing-geosite category-ru and sing-geoip ru traffic direct.";
|
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;
|
proxy = routingFields;
|
||||||
@@ -418,22 +562,40 @@ in
|
|||||||
domains = mkOption {
|
domains = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "Domain suffixes to send direct (bypass proxy).";
|
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 {
|
ips = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "IP CIDRs to send direct.";
|
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 {
|
geosites = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "sing-geosite names to send direct.";
|
description = ''
|
||||||
|
sing-geosite names to send direct.
|
||||||
|
"category-ru" is added automatically when enableRuDirect = true.
|
||||||
|
'';
|
||||||
|
example = [ "category-ru" ];
|
||||||
};
|
};
|
||||||
geoips = mkOption {
|
geoips = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "sing-geoip names to send direct.";
|
description = ''
|
||||||
|
sing-geoip names to send direct.
|
||||||
|
"ru" is added automatically when enableRuDirect = true.
|
||||||
|
'';
|
||||||
|
example = [ "ru" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -442,21 +604,25 @@ in
|
|||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "Domain suffixes to block entirely.";
|
description = "Domain suffixes to block entirely.";
|
||||||
|
example = [ "ads.example.com" ];
|
||||||
};
|
};
|
||||||
ips = mkOption {
|
ips = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "IP CIDRs to block.";
|
description = "IP CIDRs to block.";
|
||||||
|
example = [ "203.0.113.0/24" ];
|
||||||
};
|
};
|
||||||
geosites = mkOption {
|
geosites = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "sing-geosite names to block.";
|
description = "sing-geosite names to block.";
|
||||||
|
example = [ "category-ads-all" ];
|
||||||
};
|
};
|
||||||
geoips = mkOption {
|
geoips = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "sing-geoip names to block.";
|
description = "sing-geoip names to block.";
|
||||||
|
example = [ "cn" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -478,12 +644,16 @@ in
|
|||||||
|
|
||||||
The outbound can be a configured outbound tag (useful with selector/urltest),
|
The outbound can be a configured outbound tag (useful with selector/urltest),
|
||||||
or one of: "proxy" (active proxy), "direct", "block".
|
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 = [
|
example = [
|
||||||
{
|
{
|
||||||
outbound = "vps-de";
|
outbound = "vps-de";
|
||||||
|
domains = [ "netflix.com" ];
|
||||||
geosites = [ "netflix" ];
|
geosites = [ "netflix" ];
|
||||||
geoips = [ "us" ];
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
outbound = "direct";
|
outbound = "direct";
|
||||||
@@ -504,55 +674,99 @@ in
|
|||||||
syncDirectRouting = mkOption {
|
syncDirectRouting = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "When zapret is enabled, mirror its upstream domain hostlists into sing-box direct routing.";
|
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 {
|
syncDirectRoutingUpstreamIps = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "When zapret is enabled, mirror its upstream ipset ranges into sing-box direct routing.";
|
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 {
|
syncDirectRoutingUserIps = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "When zapret is enabled, mirror user-defined ipsetAll/ipsetExclude entries into sing-box direct routing.";
|
description = ''
|
||||||
|
When zapret.enable = true, mirror user-defined zapret.ipsetAll and
|
||||||
|
zapret.ipsetExclude entries into sing-box direct IP routing.
|
||||||
|
'';
|
||||||
|
example = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
configName = mkOption {
|
configName = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "general(ALT)";
|
default = "general(ALT)";
|
||||||
description = "zapret strategy preset name.";
|
description = ''
|
||||||
|
zapret strategy preset name passed through to the generated zapret
|
||||||
|
configuration.
|
||||||
|
Only relevant when zapret.enable = true.
|
||||||
|
'';
|
||||||
|
example = "general(ALT)";
|
||||||
};
|
};
|
||||||
|
|
||||||
gameFilter = mkOption {
|
gameFilter = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "null";
|
default = "null";
|
||||||
description = ''zapret game traffic filter mode: "all", "tcp", "udp", or "null" to disable.'';
|
description = ''
|
||||||
|
zapret game traffic filter mode: "all", "tcp", "udp", or "null" to disable.
|
||||||
|
Only relevant when zapret.enable = true.
|
||||||
|
'';
|
||||||
|
example = "null";
|
||||||
};
|
};
|
||||||
|
|
||||||
listGeneral = mkOption {
|
listGeneral = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "Extra domains to include in zapret's interception list.";
|
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 {
|
listExclude = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "Domains to exclude from zapret interception.";
|
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 {
|
ipsetAll = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "Extra IPs/CIDRs to add to zapret's ipset.";
|
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 {
|
ipsetExclude = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "IPs/CIDRs to exclude from zapret's ipset.";
|
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 {
|
includeExtraUpstreamLists = mkOption {
|
||||||
@@ -562,7 +776,11 @@ in
|
|||||||
Automatically activate upstream list-instagram.txt, list-soundcloud.txt,
|
Automatically activate upstream list-instagram.txt, list-soundcloud.txt,
|
||||||
and list-twitter.txt in the generated zapret config when the selected
|
and list-twitter.txt in the generated zapret config when the selected
|
||||||
upstream preset does not already reference them.
|
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 {
|
hostlistRules = mkOption {
|
||||||
@@ -572,6 +790,9 @@ in
|
|||||||
Additional named zapret hostlists with per-list DPI mitigation rules.
|
Additional named zapret hostlists with per-list DPI mitigation rules.
|
||||||
Each entry generates hostlists/list-<name>.txt and can clone a built-in
|
Each entry generates hostlists/list-<name>.txt and can clone a built-in
|
||||||
zapret family, add custom NFQWS rule fragments, or both.
|
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 = [
|
example = [
|
||||||
{
|
{
|
||||||
@@ -588,6 +809,7 @@ in
|
|||||||
"example.com"
|
"example.com"
|
||||||
"example.de"
|
"example.de"
|
||||||
];
|
];
|
||||||
|
preset = "general";
|
||||||
nfqwsArgs = [
|
nfqwsArgs = [
|
||||||
"--filter-tcp=443 --dpi-desync=fake,multisplit"
|
"--filter-tcp=443 --dpi-desync=fake,multisplit"
|
||||||
];
|
];
|
||||||
@@ -607,6 +829,8 @@ in
|
|||||||
];
|
];
|
||||||
description = ''
|
description = ''
|
||||||
Subnets to exempt from zapret's NFQUEUE mangle rules.
|
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
|
Useful when a VM (libvirt, etc.) is behind NAT and zapret
|
||||||
would corrupt its traffic through the host's nftables.
|
would corrupt its traffic through the host's nftables.
|
||||||
'';
|
'';
|
||||||
@@ -620,13 +844,22 @@ in
|
|||||||
pollInterval = mkOption {
|
pollInterval = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 5;
|
default = 5;
|
||||||
description = "Status polling interval in seconds.";
|
description = ''
|
||||||
|
Status polling interval in seconds for the tray application.
|
||||||
|
Only relevant when tray.enable = true.
|
||||||
|
'';
|
||||||
|
example = 5;
|
||||||
};
|
};
|
||||||
|
|
||||||
autostart = mkOption {
|
autostart = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "Whether to autostart the tray application for all graphical users via XDG desktop autostart.";
|
description = ''
|
||||||
|
Whether to install an XDG autostart entry for the tray application for
|
||||||
|
graphical users.
|
||||||
|
Only relevant when tray.enable = true.
|
||||||
|
'';
|
||||||
|
example = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -636,13 +869,21 @@ in
|
|||||||
port = mkOption {
|
port = mkOption {
|
||||||
type = types.port;
|
type = types.port;
|
||||||
default = 1076;
|
default = 1076;
|
||||||
description = "Port to listen on.";
|
description = ''
|
||||||
|
Listen port for the tg-ws-proxy service.
|
||||||
|
Only relevant when tgWsProxy.enable = true.
|
||||||
|
'';
|
||||||
|
example = 1076;
|
||||||
};
|
};
|
||||||
|
|
||||||
host = mkOption {
|
host = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "0.0.0.0";
|
default = "0.0.0.0";
|
||||||
description = "Address to bind to.";
|
description = ''
|
||||||
|
Address to bind tg-ws-proxy to.
|
||||||
|
Only relevant when tgWsProxy.enable = true.
|
||||||
|
'';
|
||||||
|
example = "0.0.0.0";
|
||||||
};
|
};
|
||||||
|
|
||||||
secret = mkOption {
|
secret = mkOption {
|
||||||
@@ -650,7 +891,9 @@ in
|
|||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
MTProto proxy secret (hex string). Legacy inline form; this value ends up
|
MTProto proxy secret (hex string). Legacy inline form; this value ends up
|
||||||
in the nix store. Prefer secretFile for real deployments.
|
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
|
Generate one with: openssl rand -hex 16
|
||||||
'';
|
'';
|
||||||
example = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
example = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||||
@@ -661,7 +904,9 @@ in
|
|||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
Runtime path to a file containing the MTProto proxy secret.
|
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.
|
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";
|
example = "/run/secrets/tg-ws-proxy-secret";
|
||||||
};
|
};
|
||||||
@@ -672,7 +917,10 @@ in
|
|||||||
"2" = "149.154.167.220";
|
"2" = "149.154.167.220";
|
||||||
"4" = "149.154.167.220";
|
"4" = "149.154.167.220";
|
||||||
};
|
};
|
||||||
description = "Map of Telegram DC ID to IP address for relay.";
|
description = ''
|
||||||
|
Map of Telegram DC ID to IP address for relay.
|
||||||
|
Only relevant when tgWsProxy.enable = true.
|
||||||
|
'';
|
||||||
example = {
|
example = {
|
||||||
"1" = "149.154.175.50";
|
"1" = "149.154.175.50";
|
||||||
"2" = "149.154.167.51";
|
"2" = "149.154.167.51";
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
system,
|
system,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
proxySuiteModule,
|
proxySuiteModule,
|
||||||
|
generatedOptionsDoc,
|
||||||
zapret,
|
zapret,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@@ -1007,4 +1008,9 @@ in
|
|||||||
fi
|
fi
|
||||||
touch "$out"
|
touch "$out"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
options-doc = pkgs.runCommand "proxy-suite-options-doc-check" { nativeBuildInputs = [ pkgs.diffutils ]; } ''
|
||||||
|
diff -u ${../docs/options.md} ${generatedOptionsDoc}
|
||||||
|
touch "$out"
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ let
|
|||||||
src = pkgs.fetchFromGitHub {
|
src = pkgs.fetchFromGitHub {
|
||||||
owner = "Flowseal";
|
owner = "Flowseal";
|
||||||
repo = "tg-ws-proxy";
|
repo = "tg-ws-proxy";
|
||||||
rev = "b48ac67b9f0b6818fc8a98e3cf06765926c94c92";
|
rev = "v1.6.1";
|
||||||
hash = "sha256-7dFHrD8lrxzQsjGanCWao5zEIIx+swcKRKo+mI/fMlQ=";
|
hash = "sha256-7dFHrD8lrxzQsjGanCWao5zEIIx+swcKRKo+mI/fMlQ=";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user