Author SHA1 Message Date
faumarayandClaude Opus 5.5 fe291fab2b windows: component archives download on a slow line
Windows release / build (push) Successful in 1h9m39s
Windows release / publish (push) Successful in 50s
A component's archive (sing-box's is 15 MB) had a minute for the
whole transfer, which a slow line misses (CI run #9 timed out on it).
Now a minute without a byte fails it, the whole has no limit, and a
transfer cut short is taken up where it stopped (an HTTP range), eight
times at most; the pinned hash checks the result as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 19:13:34 +03:00
faumarayandClaude Opus 5.5 7cdd33f05e windows: the release notes for 0.2.0-pre.1, the downloads first
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 18:23:44 +03:00
faumarayandClaude Opus 5.5 36532bcf47 windows: no app logs beside the README's screenshots
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 18:22:58 +03:00
faumarayandClaude Opus 5.5 e71f6bf5aa windows: screenshots of every page, in the README
tools/screenshots.sh's demo shows zapret2 with z2k, autoProxy,
AmneziaWG and whitelist-bypass; nothing in it warns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 18:22:46 +03:00
faumarayandClaude Opus 5.5 514ffb97ca windows: zapret2's verdicts route the proxy; options kept to what they are
As upstream's direct-sync: from zapret2's lists and the detector's
verdicts, two rule-sets sing-box reloads, rebuilt every ten seconds and
before it starts: what zapret2 cannot fix (every strategy failed for a
site, or an address leaves connections unanswered) through the proxy
(zapret2.proxyFallback), after the explicit rules and autoProxy's; what
it fixes direct, so it sees it (directSync), unless learned from
transfers cut short. all-bypass and all-proxy as upstream.

The options file winws2 reads (one a line) refuses an option holding a
control character, which would read as more options than it is; and
zapret2.ports.extraTcp/extraUdp, which join its options as written, are
ports or ranges within 1-65535 (validated, and filtered again).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 18:16:48 +03:00
faumarayandClaude Opus 5.5 9eed225ccc windows: zapret2 with z2k's strategies and upstream's Lua layers
The zapret2-extras component (tools/build-zapret2-extras.sh): z2k at
upstream's pinned commit, its strategies made by its own generator as
upstream's z2k-profiles.template.sh runs it, with tokens where upstream
fills in the configuration at build time; its Lua, lists and fakes; and
upstream's own Lua: the extended detector (detect.lua), the per-site key
by public suffix, the fail stamp, every-change persistence and the
strategy log.

winws2 now runs, as upstream's nfqws2 does, with z2k's Lua for its
strategies, then the layers: each site's working strategy kept across
restarts (z2k's state layer), strategies keyed by site, and with
autoHostlist.extendedDetection the detector learning in place of
nfqws2's own (its last TLS profile, the stall watch where the learned
sites are). Lua arguments name paths as Cygwin does (no colon); what
winws2 writes stays under the Low-integrity folder. The server's TLS
handshake and alert records reach the detectors through a WinDivert
filter part: WinDivert has no per-flow packet window to hand them over
by. Options go to winws2 in a file (@file): z2k's alone are 55 KB, past
a Windows command line.

Both sources, with every layer, verified by winws2's --dry-run under
Wine (tools/winws-dry-run.sh). The DPI page picks the strategies and
switches the detection. proxyFallback and the cutoff probe are said to
be not on Windows yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 18:10:57 +03:00
faumarayandClaude Opus 5.5 0a7d8d99c0 windows: the AmneziaWG tunnel in the release, checked under Wine
package.sh builds the amneziawg component (awg-tunnel.exe, Wintun);
the setup test adds a system-wide profile and checks its tunnel service
registered (Wine's sc has no qc: its registry key), started (the tunnel
runs as a service up to Wintun, which Wine lacks; its log read back),
and removed with its profile. README and notes say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 17:39:27 +03:00
faumarayandClaude Opus 5.5 5cf3a237e6 windows: AmneziaWG as a system-wide VPN
Each profile without asOutbound is a tunnel service of its own,
AmneziaWGTunnel$<interface>, as amneziawg-windows's client installs one:
amneziawg-go on Wintun, its routes and DNS, and for one peer that takes
everything its firewall blocking what would leave outside the tunnel.
It runs awg-tunnel.exe, amneziawg-windows built from its pinned commit
with a main of ours (its Run(), its log in a file) instead of its
tunnel.dll, beside Wintun's signed DLL (tools/build-amneziawg.sh).

The service writes each profile's .conf below its state root, registers
the tunnel (unrestricted service SID, which its firewall exempts it by),
starts the autostart ones with itself, and removes the tunnels of
profiles gone, and all of them on uninstall. proxy-ctl awg
list|on|off|log, and the app's AmneziaWG page: profiles (a system-wide
one switched on and off, its log), one added from a vpn:// link or a
.conf, or removed.

tools/lib.sh: clone_commit, and fetch_pinned, which fetches in pieces a
download that stalls (some networks cut TLS after about 16 KB, as
wintun.net's here).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 17:23:11 +03:00
faumarayandClaude Opus 5.5 95ec15e14a windows: autoProxy routes slow sites, and has a page in the app
As upstream's sampler and slow judge: every minute, eleven Clash API
snapshots a second apart; a site whose best direct transfer never beat
slowBelowKiBps three times is owed an exit, and gets the first, in probe
order, that answers it as well as direct does (probe --via); routed
slow, it moves on after crawling twice there, and with no exit left it
stays direct for a TTL. Here the Clash API is always on, so it works
whatever the selection.

The app's autoProxy page: on or off, a site probed or learned, the sites
routed (forget one or all), the exits (bad ones marked), the exclusions
and the slowness threshold. tools/screenshots.sh takes every page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 16:47:45 +03:00
faumarayandClaude Opus 5.5 694e176353 windows: autoProxy keeps to its exclusions, and its listing to its scope
proxy.autoProxy.exclude is never probed or routed: learn and probe
requests for an excluded host are refused, and a site learned whole
(example.com) routes no excluded name under it (intranet.example.com):
the learned rule skips them.

Without the secrets scope, proxy-ctl proxy auto lists the sites routed
and counts: the hosts probed, those left to zapret and the sites behind
each strike are browsing history, as the logs are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 16:36:00 +03:00
faumarayandClaude Opus 5.5 5a89b8d11d windows: autoProxy
As upstream's prober: the sites apps reach directly (the Clash API's
direct connections here; upstream's inbound access log) are probed
through each exit, direct first, every interval and at once for
proxy-ctl proxy auto learn. One blocked directly but reached through an
exit is routed through it: its exit's local rule-set, which sing-box
reloads. Upstream's judgement, ported and tested: block pages, the walk
over paths and exits, one exit per network first, strikes against exits
that refuse, a new egress discarding what was learned, rechecks once per
TTL. Blocks zapret can fix stay direct.

The config gains a loopback probe listener per exit (with the hop login,
pinned behind the loopback guard) and the learned rules after the user's.
proxy-ctl proxy auto list|probe|learn|forget|clear over new API requests
(autoProxy scope). Slow sites (slowBelowKiBps) are not routed yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 16:31:29 +03:00
faumarayandClaude Opus 5.5 69e70d6f74 windows: CI gives the SSH test's sshd its privilege separation
The job runs as root in the runner's container, where sshd separates
privileges and needs /var/empty (root's, not writable by others) and the
sshd user; the image lacks the directory, so the test's sshd exited and
an_ssh_tunnel failed. A step makes both. The test now waits for its sshd
and, should it exit, says why.

Checked as root in docker.gitea.com/runner-images:ubuntu-24.04: the
end-to-end tests pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:35:49 +03:00
faumarayandClaude Opus 5.5 8d9705cd3a windows: uninstall.cmd leaves the install folder before removing it
Opened from Explorer, its window's working directory is the install
folder, which Windows then cannot remove while the window waits at its
pause: the files went, the folder stayed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:47:45 +03:00
faumarayandClaude Opus 5.5 ae58bd1f12 windows: a setup program, and an uninstall entry in Settings > Apps
ProxySuite-<version>-windows-x64-setup.exe (NSIS, English and Russian):
it unpacks the release into its temporary folder and runs the release's
own proxy-suite-service.exe install from there, as install.cmd does from
the zip (unpacked straight into Program Files, an upgrade would find its
files in use). It refuses 32-bit Windows and anything before 10 1903, and
offers Windows' OpenSSH Client, unchecked, for the SSH tunnel.

install now writes the entry in Settings > Apps (uninstall.cmd; quietly,
the service's uninstall), and uninstall removes it, with WinDivert's
driver service when it is the suite's own.

The release workflow publishes the setup beside the zip. The app's
icon and GPUI's manifest share one resource (llvm-rc for both); the
build scripts' clones retry, and are kept for the next build.
Tested under Wine: tools/wine-setup-test.sh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:45:09 +03:00
faumarayandClaude Opus 5.5 ae31e499ca windows: the app's whitelist-bypass page, and its icon
A page for whitelist-bypass: on or off; joiners with their state and the
call link to join; creators with theirs, their call link to copy, a new
call, and their login (a cookies export picked from disk, or DION's and
Bitrix's email and password); adding and removing either.

The app carries an icon now (tools/make-icon.py draws it; llvm-rc makes
it the exe's resource 1, where GPUI, Explorer and the Start Menu take it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:21:49 +03:00
faumarayandClaude Opus 5.5 b6e54f963d windows: whitelist-bypass names its files only after plain names
The names were checked only while whitelist-bypass was on, but proxy-ctl
wl names files after them either way: a configuration saved with it off
could name a creator 'C:\...\x' (on Windows a join with an absolute
path replaces the directory) and have the service write or delete a file
of that name as SYSTEM. They are checked on or off now, and every state
file goes through one helper that checks the name again.

Names (of rule sets, groups, profiles, devices, ...) can no longer be
Windows devices either (CON, NUL, COM1, ...): a file named so is the
device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:05:22 +03:00
faumarayandClaude Opus 5.5 610e36a28b windows: whitelist-bypass
Creators and joiners, built from upstream's tag with upstream's patches
(links and passwords from the environment, never argv), run by the
service as whitelist-bypass.nix runs them: joiners while the proxy runs,
as its outbounds, creators while the suite is on, their logins kept in
a working copy they refresh. proxy-ctl wl list|link|auth|join|new|restart
over new API requests (whitelistBypass scope).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:01:10 +03:00
faumarayandClaude Opus 5.5 1f4fcf540d windows: the programs carry their C runtime
Statically linked (+crt-static): no vcruntime140.dll, so no Visual C++
Redistributable to install first. LNK4099 (the runtime's own PDBs) ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:01:10 +03:00
faumarayandClaude Opus 5.5 2c4cdee7d3 windows: AmneziaWG outbounds, and WARP through wireproxy
- ps_core::awg: upstream's scripts/amneziawg_config.py, ported: a profile
  from a .conf, an AmneziaVPN vpn:// link (qCompress'd JSON or the compact
  .conf form, containers and DNS placeholders as upstream reads them) or
  declarative settings (with obfuscationFile's secrets); AWG 3's MTU
  default, the endpoint override, upstream's checks (no wg-quick hooks
  unless allowed, no control characters, one [Interface]); and the
  wireproxy configuration. Checked against links made by upstream's own
  encoder, output byte for byte.
- wireproxy-awg for Windows, built from upstream's tag (pinned to its
  commit) with upstream's patches, by tools/build-wireproxy-awg.sh; in
  the release as a bundled component. Go joins the dev shell.
- The service runs one per "userspace" AmneziaWG outbound and WARP
  device, on its loopback port with the hop login, its configuration
  below the protected state root; "singBox" profiles reach the renderer.
  wireproxy goes direct under the TUN.
- End to end on Linux (an_amneziawg_tunnel): sing-box as the WireGuard
  server, the service's wireproxy as the client; a page through its
  listener and through the proxy's outbound, named inside the tunnel.
- What is still to come and said: AmneziaWG as a system-wide VPN.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 12:32:43 +03:00
faumarayandClaude Opus 5.5 62adadc207 windows: WARP as a sing-box outbound
- Devices registered as wgcf registers them: an X25519 key made by the
  service, its public half posted to Cloudflare's client API (through the
  local proxy first, as upstream, then directly, then warp.generatorUrl),
  the answer made into wgcf's profile and kept below the protected state
  root; or a profile given (config, configFile). The renderer's endpoint
  for it was there; the service now supplies the profiles.
- Registration runs outside the service's lock, at start, after a change,
  and every ten minutes until it succeeds; the proxy is applied again
  with the new device.
- Checked: a device registered live with Cloudflare, its profile rendered
  as a sing-box WireGuard endpoint and the proxy running with it.
  WARP through AmneziaWG (userspace, interface) is still to come, and said.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 08:13:29 +03:00
faumarayandClaude Opus 5.5 d9d52c49b6 windows: no unquoted value can add a directive to Tor's torrc
proxy.listener.address went into the torrc unquoted (Socks5Proxy, with
upstream = "proxy"): a newline in it, set by a user who may change the
configuration, would add a directive, ClientTransportPlugin among them,
which runs a program as SYSTEM (found by the commit security review).
The address is written from its parsed IpAddr now; a bridge line with a
control character in it is refused; and the validator holds every
listen address (the proxy's, the SSH tunnel's, tg-ws-proxy's) to an IP
address, which they all are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 08:06:42 +03:00
faumarayandClaude Opus 5.5 ed2159f7b6 windows: the not-ported test names WARP, now that Tor is there
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 08:03:09 +03:00
faumarayandClaude Opus 5.5 40221e7981 windows: Tor
- tor: the Tor Project's Expert Bundle for Windows (15.0.26) as a
  component, pinned by the hash of the release whose signature was
  checked against the Tor Browser Developers' key; the installer takes
  gzipped tars now (plain files only: a link could point anywhere).
- The torrc upstream's tor.nix writes: SOCKS for the tor outbound,
  bridges with the bundle's lyrebird (obfs4, webtunnel, meek, snowflake)
  and conjure, the local proxy as upstream (upstream = "proxy") with its
  login, extraConfig. The control port is on loopback with cookie
  authentication (upstream's is a Unix socket only Tor's user opens).
  Values are quoted with control characters escaped: a newline in, say,
  the proxy's login would otherwise start a directive (one that runs a
  program, as SYSTEM).
- Tor's own connections go direct under the TUN unless upstream =
  "proxy". The onion service (for the inbounds) is still to come and is
  said to be.
- Checked: Windows' tor.exe, under Wine, takes a torrc of this shape,
  bridges and escaped values included; on Linux the service runs Tor and
  it bootstraps as far as this network lets it without bridges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 08:02:24 +03:00
faumarayandClaude Opus 5.5 82fe4d8e65 windows: the SSH tunnel's host and user cannot be read as ssh options
sshProxy.server.host and .user are ordinary settings the signed-in user
may change, and they reached ssh.exe's command line, which the service
runs as SYSTEM: a host of -oProxyCommand=<program> would have run that
program as SYSTEM (found by the commit security review). The user now
goes as -l's value and the host after "--", so neither can be an
option; the validator holds the host to a host name or IP address, the
user to a login name, and host keys to one line each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 07:41:39 +03:00
faumarayandClaude Opus 5.5 fb6c5962d0 windows: zapret's hostlistRules, and the SSH tunnel
- hostlistRules (zapret-discord-youtube): a group of sites with its own
  strategy, as upstream's patch-zapret-config.py makes them: the
  preset's profiles for the rule's family (or another preset's, with
  configName; Discord's voice profile with it), pointed at the rule's own
  list with the standard excludes, or the rule's nfqwsArgs; ahead of the
  preset's own. WinDivert's filter takes the ports they add. Rules with
  enableDirectSync join the direct list. Names of zapret's own lists, and
  the instagram/soundcloud/twitter families (not in Flowseal's Windows
  release), are refused. Every preset with sample rules checked by
  winws.exe --dry-run (tools/winws-dry-run.sh); one without the profile
  a rule copies is refused, as upstream refuses it.
- The SSH tunnel (sshProxy): Windows' own OpenSSH (System32) as ssh -N -D,
  with upstream's options and only the configured key offered
  (IdentitiesOnly: an agent's keys used up the server's tries); the key
  copied below the protected state root, as Windows' OpenSSH wants it and
  sing-box's SSH outbound reads it; the server's keys from hostKey,
  hostKeyFile or knownHostsFile. End to end on Linux against an sshd of
  the test's own: a page through each, two logins with the copied key.
- The dev shell has OpenSSH, for that test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 07:37:29 +03:00
faumarayandClaude Opus 5.5 88c8b88a49 windows: what is not on Windows yet is said, for as long as it holds
The configuration accepted the kill switch, AmneziaWG, WARP, Tor, the SSH
tunnel, whitelist-bypass, serving inbounds, autoProxy, the xray backend,
zapret's hostlistRules, z2k and zapret2's extended detection, and the
service silently did nothing with them: a kill switch turned on looked
like protection that was not there. The validator now warns for each, and
for TUN with zapret together; the status carries the configuration's
warnings as well as the rendering's, so the app's overview and
proxy-ctl status show them until they no longer hold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 07:08:14 +03:00
faumarayandClaude Opus 5.5 c0b089dea8 windows: the app leaves a system proxy set by hand alone; a calmer tray
- The check for a system proxy a killed app left on the local proxy ran
  on every refresh while the option was off, so a proxy the user pointed
  at the listener by hand was switched off within two seconds. It now
  runs once, at the start. The registry sits behind a small trait, and
  the state machine has tests.
- The tray's tooltip and menu are only touched when what they say
  changes (a menu rebuilt while open would close).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 02:24:01 +03:00
faumarayandClaude Opus 5.5 adcd734479 windows: 0.2.0-pre.1: the app in the release, README
- package.sh builds the app (on its own, so its crates' features leave
  the service's build as it was) and puts proxy-suite.exe in the zip;
  THIRD-PARTY.md names GPUI, GPUI Kit and Lucide.
- README: the app, what has been verified of it and how (every page on
  Linux, headless; the Windows build; not drawn on Windows yet), install
  and first run with it, the system proxy, building and trying it.
- Release notes for 0.2.0-pre.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 02:17:49 +03:00
faumarayandClaude Opus 5.5 6ed7a3b1c6 windows: install puts the app in the Start Menu and starts it at sign-in
- install copies proxy-suite.exe with the rest, closes running copies
  before replacing files, makes an all-users Start Menu shortcut, starts
  the app at every sign-in in the tray (HKLM Run, --hidden), and starts it
  now as the signed-in user (through Explorer, not elevated).
- uninstall closes it, removes the shortcut and the sign-in start, and
  turns off the user's system proxy if the app left it on the local
  proxy (another proxy of theirs is left alone).
- The app does not take its own left-over system proxy for the user's.
- Lints: the last of clippy's, in the app, the service and a test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 02:12:02 +03:00
faumarayandClaude Opus 5.5 757bebbb1d windows: clippy's suggestions in the service and client (collapsible ifs, next_back)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 02:08:25 +03:00
faumarayandClaude Opus 5.5 7565e62571 windows: the app sets the system proxy; ps-core lint fixes
- The app points the signed-in user's system proxy (WinINet: browsers
  and most programs follow it) at the local proxy while it runs and
  proxy.systemProxy.enable asks; the user's own settings are kept and put
  back when the proxy stops, the service goes, the option is turned off
  or the app quits; one left behind by a killed app is cleared. A switch
  for it on the overview. Elsewhere than Windows it does nothing.
- ps-core: clippy's collapsible ifs, comparisons without owned values, a
  range loop without indexing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 02:07:02 +03:00
faumarayandClaude Opus 5.5 77becc235c windows: the app's tray, and its Windows build from Linux
- Tray (gpui-tray): a shield coloured by how things are (working, one
  failed, all off, no service), its tooltip saying which; the menu opens
  the window and switches the local proxy, the DPI bypass and the Telegram
  proxy, with their states checked; Quit. Closing the window leaves the
  app in the tray (no tray: it quits); --hidden starts it there.
- The app builds for Windows from Linux: GPUI compiles its HLSL shaders
  with fxc.exe only when the building machine is Windows, so its Windows
  backend is vendored with that one check made on the target instead
  (vendor/gpui-pre-windows/PATCHED.md, tools/vendor-gpui-windows.py), and
  tools/fxc-wine.sh runs Microsoft's fxc.exe under Wine: the compiler from
  the Windows SDK 10.0.26100 installer, pinned by hash, kept on the build
  machine; only the compiled shaders go into the app.
- gui-shot.sh keeps the app off the desktop's session bus.

Under Wine the app starts but cannot draw text (Wine's DirectWrite does
not implement font-set matching), so its Windows rendering is untested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 02:03:18 +03:00
faumarayandClaude Opus 5.5 a7bf347859 windows: the app's Components page; the connection in the sidebar
- Components: each program's pinned version, the one installed (or
  missing), its license and source; fetching them all again, which the
  service allows administrators only, with each failure named.
- The sidebar's foot says whether the service is reachable, and
  "Applying…" while a change is under way; when it is not running, the
  overview says how to start it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:46:58 +03:00
faumarayandClaude Opus 5.5 69759cfbce windows: the app's Settings page: the whole configuration
Upstream's option tree as JSON in a code editor (highlighted, folding),
loaded with its revision; Check asks the service to validate without
taking it; Save sends it against the revision loaded, so a change made
elsewhere meanwhile is refused, not overwritten, and the page says so.
The validator's notes and an apply failure are shown under the editor;
redacted secrets are explained (left as they are, they keep their
values). Every option the other pages do not show is editable here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:44:55 +03:00
faumarayandClaude Opus 5.5 23c1687118 windows: the app's Logs page; on Linux, units end with the service
- Logs: every unit's as they come (the last 500 first, 5000 kept), one
  unit's on its own, following or held; terminal colours stripped; a
  virtual list, so thousands of lines cost nothing. The follow starts
  when the page is first opened and reconnects by itself.
- Linux (development, tests): the service's children get SIGKILL when it
  dies (PR_SET_PDEATHSIG), as the Job Object does on Windows; a killed
  service no longer leaves sing-box running (the e2e test leaked one per
  run).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:41:12 +03:00
faumarayandClaude Opus 5.5 a839d48e02 windows: the app's Outbounds page
Adding an outbound from a share link or a backend's JSON (checked here
first, by the same parser as proxy-ctl; tagged from the link unless
named); the list with each one's source, backend and detour, pinned or
left out, its delay on request, and remove for the user's own; the
routing mode; subscriptions added, updated and removed.

dev-service.sh: the demo server resolves names over HTTPS (sing-box needs
a resolver for its direct outbound, and plain DNS may be blocked).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:37:02 +03:00
faumarayandClaude Opus 5.5 7dfb3129f4 windows: the app's Telegram proxy page
tg-ws-proxy on or off and its state; its tg:// links, to copy or open in
Telegram (none without the secrets scope, and the page says so); whether
other devices may connect; its port and fake-TLS domain (which adds the
ee link). Long links are cut short rather than widening the page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:33:10 +03:00
faumarayandClaude Opus 5.5 c9ce7a1982 windows: the app's DPI bypass page
zapret on or off and its engine; for Flowseal's presets, the preset (the
release's own list, matched as the service matches names) and game
traffic; for zapret2, learning, IPv6 and the strategy log; the sites to
handle besides the engine's lists and the sites to leave alone; TCP
timestamps. News from the service replaces what the user has not
changed, never what they are typing; a save shows the list as saved.

ps-client: set_path for any one option, set_zapret_sites (tidied,
deduplicated). gui-shot.sh takes ordered steps: click, type, key, wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:30:25 +03:00
faumarayandClaude Opus 5.5 d3ba00087d windows: the app's skeleton: the service from GPUI, an overview
- bridge: ps-client on a tokio runtime of its own, awaited from GPUI's
  executor; log following as a channel that reconnects.
- model: status polled every 2 s (outbounds every fifth round and on a
  reconnect), the zapret presets and tg links on connecting, and changes
  sent through ps-client's edits; what came of each is a notification,
  the service's own words when it refuses or cannot apply.
- The window: a sidebar of pages; the overview shows the local proxy, the
  DPI bypass and the Telegram proxy with their states and switches, and
  what the service warns of. The other pages come next.
- Icons: the components' own and the few the app adds, not all of Lucide.
- zapret's engines by upstream's names (zapret-discord-youtube, zapret2).
- gui-shot.sh can click before the shot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:25:11 +03:00
faumarayandClaude Opus 5.5 63aede0dc1 windows: the service names zapret's presets and tg-ws-proxy's links
- zapret-presets: the presets of the installed zapret release and the one
  configured; proxy-ctl zapret presets.
- tg-links: tg-ws-proxy's tg:// links (dd, and ee with a fake-TLS
  domain), as it prints them; they carry its secret, so the secrets scope.
  proxy-ctl tg link. No more reading them out of its log.
- tools/dev-service.sh: the service on Linux with a demo outbound, for
  working on the app.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:18:59 +03:00
faumarayandClaude Opus 5.5 4ae30dac3c windows: ps-client shared by proxy-ctl and the app; the app's first window
- ps-client: the service's client side, moved out of proxy-ctl: calls,
  configuration edits against the revision read (retried on a concurrent
  change), log following, and the edits themselves as functions on the
  configuration (outbounds, subscriptions, rules, zapret, tg-ws-proxy),
  now unit-tested. proxy-ctl does what it did, through it; a refused log
  follow is now an error instead of nothing.
- ps-gui: proxy-suite, the desktop app on GPUI (gpui-kit 0.8.1); only a
  first window yet. Not in default-members: plain cargo build/test and the
  release workflow's tests leave GPUI out.
- tools/gui-shot.sh: runs the app on Xvfb with Mesa's software Vulkan and
  screenshots it, to check the GUI on Linux without a display.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:13:28 +03:00
faumarayandClaude Opus 5.5 da6aafaf1d windows: release through Gitea Actions
Windows release / build (push) Successful in 3m37s
Windows release / publish (push) Successful in 15s
.gitea/workflows/windows-release.yml builds the Windows release in the
repository's own Nix dev shell (pinned Nix installer, checked by hash),
tests, packages, and on a tag windows-v<version> publishes the zip and
its .sha256 to a Gitea release with windows/release-notes/<version>.md.
Run by hand it only builds. As upstream's workflow: the job that runs
fetched code holds no token that can write; only the publishing job sees
RELEASE_TOKEN, and it runs curl and jq on the first job's artifact.

rust-toolchain.toml pins the toolchain the release is built with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 00:54:49 +03:00
faumarayandClaude Opus 5.5 363caf912a windows: a failed check of the state root is made again (0.1.0-pre.2)
The once-per-process guard recorded the root before ensure_root ran. A
first check that failed (the service log's create_all ignores its error)
left the root marked as checked, so run()'s create_all skipped the check
and the service went on with a root it could not secure, and runs what
is under its bin\ as SYSTEM. Now only a check that passed is recorded,
under the lock, and a failed one fails again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 00:51:32 +03:00
faumarayandClaude Opus 5.5 e84d42a10c windows: 0.1.0-pre.1: README, install.cmd, release packaging
- README for the Windows port: what this release does, what has been
  verified and how, install, first run, who may change what, caveats.
- install.cmd / uninstall.cmd ask for administrator rights and run the
  service's own install/uninstall.
- tools/package.sh builds the release zip with every component staged
  and pinned; tools/wine-install-test.sh exercises install, the pipe and
  uninstall under Wine's Service Control Manager.
- Release profile: thin LTO, stripped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 00:41:53 +03:00
faumarayandClaude Opus 5.5 8af7b2e628 windows: authorize streamed requests, self-removal on uninstall, tun on
- Every request is authorized before it is handled, including `logs -f`,
  which skipped the check.
- The state root is checked once per process: a second check under Wine
  moved the live root (and its log) aside.
- uninstall removes Program Files after it exits: cmd got a garbled
  quoted command line; it now runs raw, outside the folder, windowless.
- install no longer fails when the first start does; it says how to start.
- `proxy-ctl proxy tun on` also turns on proxy.tun.enable.
- build-tg-ws-proxy.sh resolves its output path before changing directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 00:41:53 +03:00
faumarayandClaude Opus 5.5 28cc7b2cbe windows: install into Program Files, seed components, log as a service
install copies the release into %ProgramFiles%\ProxySuite (upgrading in
place when the service exists), registers it there, and puts it on the
system PATH: a copy in Downloads could be replaced by any user, and the
service runs it as SYSTEM. uninstall removes the service, the PATH
entry and the program files, and leaves the state.

At every start the service copies the release's components into bin\
when they are newer, staged and verified file by file, and only from a
service running in Program Files. Under the Service Control Manager it
logs to logs\service.log, reports StartPending until the API listens,
and a failed start as a service-specific error.

zapret refuses to start while Flowseal's, the win bundle's or
GoodbyeDPI's service holds WinDivert, and says which to remove.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 00:10:26 +03:00
faumarayandClaude Opus 5.5 d1bce9db94 windows: zapret site names and addresses are validated
A zapret2 domain is split into winws2's arguments: one carrying
whitespace could add an argument of its own (a --lua-init running as
SYSTEM). Names and addresses are checked in validation and filtered
again where the command line is built.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 00:07:38 +03:00
faumarayandClaude Opus 5.5 bceb754e65 windows: zapret2 on winws2 with nfqws2-keenetic's strategies
ps-core::zapret2 reads nfqws2-keenetic's nfqws2.conf and patches it as
upstream's sources.nix does, expands the hostlist markers as zapret2's
list.sh does (autohostlist with its detector settings, the configured
domains), fills circular's unset detector settings from autoHostlist,
merges the extra ports into the profiles that tell traffic by protocol,
and gives winws2 WinDivert port filters in place of the queue's rules.
The service runs it with the learned list in a directory labelled Low
integrity, where winws2 can still write once it drops to Low. winws2
verifies the whole command line under Wine.

detect.lua, z2k and the cutoff probe are not there yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 00:04:21 +03:00
faumarayandClaude Opus 5.5 9b0d7021f9 windows: zapret-discord-youtube and tg-ws-proxy
zapret: Flowseal's release run as its service.bat runs it: the preset's
winws.exe line (continuations, cmd's caret escapes, %BIN%, %LISTS%, the
game filter) as winws's arguments, the user's domains and addresses in
the lists upstream's module puts them in (kept in the service's own run
directory, the verified release untouched), TCP timestamps on, and
zapret's sites in the proxy's direct list. tools/winws-dry-run.sh has
the release's own winws.exe verify every preset's arguments under Wine:
all 22, both game filters.

tg-ws-proxy: Flowseal's headless proxy on the embeddable CPython 3.12
with hash-pinned win_amd64 wheels (tools/build-tg-ws-proxy.sh), run with
upstream's flags; its relay goes direct under the TUN. Runs under Wine.

proxy-ctl: zapret status|on|off|preset|game-filter, components
list|install.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 23:55:45 +03:00
faumarayandClaude Opus 5.5 817de77d28 windows: wine-e2e reads the logs before matching them
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 23:35:15 +03:00
faumarayandClaude Opus 5.5 68b496cafa windows: the component manager, verified programs, a Wine test
components.json pins sing-box, XRay, Flowseal's zapret, bol-van's
winws2 bundle with nfqws2-keenetic's strategies, and tg-ws-proxy (built
with the release): release assets by archive hash, commit snapshots by
the hash of every file taken. The service installs them (admin only),
staged and swapped in, refusing archive paths that leave the directory,
and checks each program against the hashes recorded at install before
running it. stage-components does the same for building a release.

The state root is created with its protected descriptor in one call,
or, existing, checked through a handle that does not follow links.

tools/wine-e2e.sh runs the Windows build under Wine: the service, the
named pipe, impersonation, the component check, rendering and the
supervisor all work; Wine lacks an iphlpapi call sing-box needs, so
proxying itself needs real Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 23:33:55 +03:00
faumarayandClaude Opus 5.5 b878dd93db windows: an OWNER RIGHTS entry Windows accepts
An empty access mask is refused as an invalid ACL; read-control alone
still takes the owner's implicit WRITE_DAC away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 23:19:50 +03:00
faumarayandClaude Opus 5.5 cd0bcae4c9 windows: never adopt a state directory someone else made
A root not owned by SYSTEM or Administrators is moved aside; the root
gets SYSTEM as owner and an OWNER RIGHTS entry, so owning a file below
it grants nothing. Adds the pinned component manifest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 23:19:19 +03:00
faumarayandClaude Opus 5.5 d678976c2d windows: protect the state directory, names that become files, logs
The state directory gets a protected DACL (SYSTEM and Administrators)
at every start; on Windows programs run only from its bin\, never from
PATH; rule-set and geodata names are validated before they become file
names, and checked again where they do; logs need the secrets scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 23:16:40 +03:00
faumarayandClaude Opus 5.5 41c8ed4406 windows: the service, its API and proxy-ctl
ps-ipc: line-delimited JSON over a named pipe whose ACL admits SYSTEM,
Administrators and (with userControl) the interactive user; the caller
is identified by impersonation, never by what it claims. A Unix socket
stands in off Windows.

ps-service (proxy-suite-service.exe): a Windows service, or --console.
Keeps the configuration with revisions, runtime state and generated
secrets; renders, checks with sing-box check before replacing what
runs, and supervises the backends (restart with backoff, start limit,
logs in a ring and a file, a Job Object on Windows). Enforces scopes,
admin-only edits and secret redaction that round-trips. Fetches
subscriptions and rule sets through the proxy or directly with
upstream's redirect rules, on timers.

ps-ctl (proxy-ctl.exe): status, restart, logs [-f], config get/set/
validate, and proxy on/off, outbounds, pin, mode, subs, rules,
rulesets, tun and config.

An end-to-end test runs it all offline: a sing-box Shadowsocks server,
the service, proxy-ctl adding the outbound, a page fetched through the
local proxy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 23:13:19 +03:00
faumarayandClaude Opus 5.5 918cdc9a75 windows: rules and per-app profiles fail closed
A rule, an outbound's own routing or a per-app profile whose outbound is
not running blocks what it matches instead of letting it fall through.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 22:58:28 +03:00
faumarayandClaude Opus 5.5 130c020151 windows: refuse loopback through the proxy; Clash API always has a secret
Per-app rules naming an outbound that is not running are left out with a
warning instead of failing the start, and failover renders as sing-box's
own urltest until the service drives it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 22:57:06 +03:00
faumarayandClaude Opus 5.5 3665f7f5a0 windows: render sing-box and hybrid configs
ps-core::render builds what upstream's start scripts assemble with bash
and jq: every outbound (declared, subscriptions, SSH, Tor, WARP and AWG
as WireGuard endpoints, joiners, wireproxy hops), chains, groups, the
pin and the 'proxy' selector per selection mode, routing sections by
priority with route modes and the DNS mirror, rule sets, TUN with fake
IP, the Clash API, per-app rules by program, and the hybrid XRay
sidecar. Integration tests run sing-box check and xray -test on the
results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 22:51:30 +03:00
faumarayandClaude Opus 5.5 c01538fec9 windows: raw backend JSON is always admin-only; WireGuard profiles
Telling path-shaped values from addresses on Windows (drive letters,
UNC, device paths, sockets) is too easy to get wrong, so raw sing-box
and XRay JSON now needs an administrator outright. ps-core::wg parses
WireGuard/AmneziaWG profiles into sing-box endpoints, as upstream's
warp_outbound.py does. Routing rules gain name, priority and disabled
for proxy-ctl proxy rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 22:44:31 +03:00
faumarayandClaude Opus 5.5 96958c4e61 windows: close gaps in the admin-only edit check
Null-to-object changes are looked into, keys named just 'file' count,
raw inbound XRay JSON is admin-only outright, and raw outbound JSON is
admin-only when it runs Tor or holds a path-like value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 22:41:57 +03:00
faumarayandClaude Opus 5.5 77d4cefe0e windows: share-link and subscription parsing, admin-only edits
ps-core::links ports upstream's proxy_url_parsers.py and proxy_parsing.py:
every scheme, each backend's refusals, XRay rendering, subscription
decoding, tags and the server checks. Upstream's build-outbound tests
are ported case for case, and tools/parity/links.py runs ~750 links
through both implementations: no differences.

config::privileged_changes names the edits only an administrator may
make: anything that runs a program, passes arguments through, or names
a local file, since the service runs as LocalSystem. Names that become
paths or service names are validated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 22:38:56 +03:00
faumarayandClaude Opus 5.5 c837db1c18 windows: workspace, dev shell and the config model
Start of the native Windows port. windows/ holds a Rust workspace; this
first piece is ps-core's model of the services.proxy-suite option tree,
with upstream's names and defaults, Windows-only additions documented,
validation ported from the module's assertions, and the derived tags and
loopback ports the tunnels add.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 22:28:10 +03:00
FUFSoB 9d81e975ea fix: disabling z2 autolearn behavior 2026-10-25 19:00:36 +05:00
FUFSoB a60b2a1286 fix: stale xray hash 2026-10-24 13:21:54 +05:00
FUFSoB 564ea9e24f fix: zapret2 fixes and xray update 2026-10-23 23:56:33 +05:00
FUFSoB 20f1bdd110 fix: zapret2 file permission fixes 2026-10-21 21:51:39 +05:00
FUFSoB a41fbc10e6 feat: xhttp xmux 2026-10-18 16:53:08 +05:00
fufsob 2fc8ef5567 chore(ci): bump gh actions (#16 #17 #18 #19), group dependabot updates 2026-10-18 05:46:25 +00:00
fufsob c39921a72c fix: z2k deps + better ci 2026-10-18 05:19:40 +00:00
FUFSoB 9f7ad91f39 feat: better inbounds user management 2026-10-14 21:41:49 +05:00
github-actions[bot]andFUFSoB 2f8414455d chore(deps): refresh flake inputs and pinned sources (#15)
Co-authored-by: FUFSoB <32937947+FUFSoB@users.noreply.github.com>
2026-10-12 19:48:23 +05:00
fufsob 2be98214ed feat: tor keep awake 2026-10-12 03:24:23 +00:00
fufsob 7d96e7c6f8 feat: hysteria2 x-forward 2026-10-11 16:27:16 +00:00
fufsob cae589626a feat: hy2 host rewrite 2026-10-11 16:27:16 +00:00
FUFSoB 5045c13153 fix: chained proxy bug 2026-10-11 21:14:04 +05:00
FUFSoB e293efd1c1 feat: debug options 2026-10-11 11:18:48 +05:00
FUFSoB cacd51595c feat: params in gui/tui 2026-10-10 23:17:44 +05:00
fufsob 584c8ba0a0 feat: runtime routing 2026-10-10 16:33:24 +00:00
FUFSoB d70bcb317f feat: per-app keep-running 2026-10-10 16:19:54 +05:00
FUFSoB 91f2397ac5 feat: zapret2 lists domain for learned to proxy ips 2026-10-06 20:42:00 +05:00
github-actions[bot]andFUFSoB 57fdbf3e08 chore(deps): refresh flake inputs and pinned sources (#14)
Co-authored-by: FUFSoB <32937947+FUFSoB@users.noreply.github.com>
2026-10-06 10:30:53 +05:00
fufsob 41d3575345 fix: update workflow fixes 2026-10-06 05:04:50 +00:00
FUFSoB a435942b4f fix: hardening 2026-10-05 22:44:09 +05:00
FUFSoB 017a947a18 fix: zapret2 improvements 2026-10-04 19:43:32 +05:00
FUFSoB 2452d6fbe1 fix: better logs and zapret2 2026-10-04 17:43:33 +05:00
FUFSoB 552bfd53b1 fix: zapret2 improvements 2026-10-04 17:07:45 +05:00
FUFSoB 65082aad88 feat: per-app awg and custom via 2026-10-04 15:39:56 +05:00
fufsob af5b3ff27a refactor: move out large code blocks out of nix 2026-10-04 11:54:04 +05:00
fufsob e8ace6523d fix: h3 showed ping timeout 2026-10-03 16:42:00 +00:00
fufsob 1fc6c27489 feat: share-variants 2026-10-03 16:24:11 +00:00
fufsob 194742c956 fix: sub updater restart sing-box only if smth updated 2026-10-03 14:26:40 +00:00
FUFSoB 0d13822175 feat: zapret2 shows strategies applied 2026-09-30 22:25:40 +05:00
FUFSoB 730671ea0c fix: z2k strategies fix 2026-09-30 19:31:26 +05:00
fufsob c1e4425d18 fix: more hardening 2026-09-30 13:27:55 +00:00
fufsob 18a2049a1c fix: hardening 2026-09-30 09:16:21 +00:00
FUFSoB f609334849 fix: proxy-ctl test fix 2026-09-29 19:47:51 +05:00
fufsob fa0015d829 feat: outbound groups 2026-09-29 13:01:31 +00:00
fufsob c42bcb2f4f feat: follow logs is scrollable 2026-09-29 09:30:54 +00:00
fufsob 3e141b46fc refactor: better binds in tui/gui 2026-09-29 09:16:07 +00:00
fufsob 9bbffe24b4 feat: runtime users and inbounds 2026-09-29 08:11:29 +00:00
fufsob a4752049ef refactor: users single-point 2026-09-29 05:39:33 +00:00
fufsob c8b9b3de46 feat: add connectivity fix options + hardening 2026-09-29 03:14:24 +00:00
fufsob 364bed8d51 feat: awg runtime add 2026-09-28 18:51:47 +00:00
fufsob cd3aa5a53f feat: warp/awg and hysteria2 improvements 2026-09-28 15:26:52 +00:00
fufsob d25fcb5468 fix: awg & warp fixes 2026-09-28 02:52:13 +00:00
FUFSoB 08b00cf449 fix: more iso toolings 2026-09-27 21:50:47 +05:00
FUFSoB cbdd0d543e fix: iso minification 2026-09-27 20:43:52 +05:00
FUFSoB 6b9f8e44c9 fix: use disko for iso 2026-09-27 18:04:01 +05:00
FUFSoB a24d2a976b fix: remember iso answers 2026-09-27 17:08:08 +05:00
FUFSoB 845291ee49 fix: tun and tproxy+zapret regressions 2026-09-27 13:34:24 +05:00
FUFSoB d5e926b034 fix: zapret refusing remove ips learned 2026-09-26 23:30:37 +05:00
github-actions[bot]andFUFSoB b9488f5fec chore(deps): refresh flake inputs and pinned sources (#13)
Co-authored-by: FUFSoB <32937947+FUFSoB@users.noreply.github.com>
2026-09-26 23:21:56 +05:00
FUFSoB 6a014c6eb3 fix: depends action failed at nixfmt 2026-09-26 23:11:29 +05:00
FUFSoB b91994e150 fix: close some utilities gaps 2026-09-26 22:34:25 +05:00
FUFSoB 2255e1f9f0 fix: behavior and docs fixes 2026-09-26 18:35:32 +05:00
FUFSoB e4458dcae8 docs: improve some parts 2026-09-25 23:23:54 +05:00
fufsob 878983147c feat: helper functions; docs: more complex examples 2026-09-25 11:00:55 +00:00
fufsob 63d9dffcae docs: improve the wording, add targeted examples 2026-09-25 09:54:12 +00:00
fufsob 53fc86dd83 feat(inbounds): fallbacks 2026-09-25 08:09:13 +00:00
fufsob ba5f960b2e feat(wl): runtime auth 2026-09-25 04:57:30 +00:00
fufsob f3e9140f62 feat: whitelists bypass methods 2026-09-25 02:24:05 +00:00
FUFSoB 11c44deb61 feat: add restart/toggle actions 2026-09-23 23:52:13 +05:00
FUFSoB 5f29f30790 feat: warp endpoint; fix: hardening 2026-09-23 11:50:22 +05:00
fufsob 8f65fa9c25 fix: tor userControl conflict 2026-09-23 02:34:10 +00:00
FUFSoB ae8f65da2e feat: tproxy lan gateway, killswitch; fix: zapret2 fixes, various other 2026-09-23 01:12:31 +05:00
FUFSoB 4bcc168b2a fix: proxy tools improvements 2026-09-18 22:59:40 +05:00
FUFSoB 8a4ba2db6a refactor: remove duplication 2026-09-18 21:39:18 +05:00
FUFSoB f7036f6075 fix: tun/tproxy routing 2026-09-18 08:36:45 +05:00
FUFSoB c62000821a fix: multiple fixes + cleanup and formatting 2026-09-17 22:51:31 +05:00
FUFSoB 321e9ca468 feat: tor support 2026-09-17 20:12:17 +05:00
FUFSoB 97332c1774 fix: multiple fixes 2026-09-17 18:15:55 +05:00
FUFSoB ffc7816289 feat: awg inbounds 2026-09-17 15:19:30 +05:00
FUFSoB 3b568bb54e feat: allow using suite on non-nixos systems 2026-09-17 13:27:08 +05:00
FUFSoB e852bef400 feat: install-iso creator 2026-09-17 08:15:00 +05:00
FUFSoB f991f4d685 chore: update docs and actions 2026-09-16 22:25:52 +05:00
FUFSoB e40e79a47f fix: pkexec wrapper 2026-09-16 21:49:26 +05:00
fufsob 65fc4a7915 fix: more fixes 2026-09-16 15:59:25 +00:00
fufsob 32341ba323 fix: overall tun/tproxy improvements 2026-09-16 14:18:16 +00:00
fufsob ff04debf90 fix: xray tun improvements 2026-09-16 10:46:57 +00:00
fufsob 027dc7b1a9 fix: bug fixes 2026-09-16 08:43:53 +00:00
fufsob 9cdd6dada7 fix: root actions in tui/gui & userControl 2026-09-15 20:02:43 +00:00
fufsob 2ce8da3f43 fix: various fixes 2026-09-15 17:52:49 +00:00
fufsob 303821f43a fix: tools improvements 2026-09-15 14:44:24 +00:00
fufsob e9b1542085 fix: various fixes and additions 2026-09-15 13:46:02 +00:00
fufsob ea1922243a feat: cahining + stats 2026-09-15 11:53:49 +00:00
fufsob 9c9658baa7 feat/wip: better awg to outbounds config 2026-09-15 10:34:42 +00:00
fufsob a82417a2bd fix: hardening and fixes 2026-09-15 08:56:33 +00:00
fufsob aa19042ee5 feat: json exports/imports 2026-09-15 04:53:39 +00:00
fufsob d7108abf0c feat: support warp config generators 2026-09-15 04:08:18 +00:00
fufsob f325e76b2f fix: multiple fixes 2026-09-15 03:08:32 +00:00
fufsob 5c6b2b4163 fix: better bad-rep detector 2026-09-14 19:40:38 +00:00
FUFSoB 7de094078c feat: proxy-gui 2026-09-15 00:15:53 +05:00
fufsob 8ed4ab9a8d fix: improve tui ui/ux 2026-09-14 15:43:03 +00:00
fufsob 00b27e94ce feat: better cli where cmd 2026-09-14 14:10:23 +00:00
fufsob e2da83ba56 fix: zapret2 & naming fixes 2026-09-14 13:15:06 +00:00
fufsob eab3adf893 feat: proxy-tui 2026-09-14 11:06:16 +00:00
fufsob e6b92ecac7 chore: collapse packages 2026-09-14 09:55:24 +00:00
fufsob ab2167ff9c feat: improve warp, outbounds reputation 2026-09-14 09:06:59 +00:00
fufsob 85c3e6cfaf feat: better proxy-ctl completions 2026-09-14 05:48:36 +00:00
fufsob b8903a094d feat: add proxy tests 2026-09-14 05:31:20 +00:00
fufsob 0af4104fdb fix: rewrite proxy-ctl to python 2026-09-14 05:02:14 +00:00
fufsob 006ac60b9a fix: improve proxy-ctl 2026-09-14 04:37:17 +00:00
fufsob 7f76c4ffbb feat: warp 2026-09-14 03:14:35 +00:00
fufsob 09e9945351 feat: z2k 16kb probe 2026-09-13 20:15:20 +00:00
fufsob 441be87b61 feat: select zapret2 strategies source 2026-09-13 19:33:26 +00:00
FUFSoB fdb2b08790 refactor: overhaul of options and features
Includes, but not limited to:
- zapret2 support
- declarative inbounds
- proxy-ctl revamp
- automatic proxy learning
2026-09-13 22:37:45 +05:00
fufsob b892384527 fix: subs fixes 2026-09-10 09:42:25 +00:00
fufsob 2a319d1f88 feat/wip/fix: add inbounds support, fix ssh-proxy 2026-09-09 16:38:52 +00:00
fufsob ea7916dffb fix: small ssh-proxy fixes 2026-09-08 19:41:58 +00:00
FUFSoB 7a106326ea feat/wip: ssh-proxy 2026-09-08 23:36:47 +05:00
github-actions[bot]andFUFSoB 9a1604554d chore(deps): refresh flakes and external pins (#12)
Co-authored-by: FUFSoB <32937947+FUFSoB@users.noreply.github.com>
2026-09-08 14:30:15 +05:00
FUFSoB 8cdef28f21 feat(awg): obfuscation file 2026-09-06 09:57:16 +05:00
FUFSoB 1ac17f281d fix; xray tun 2026-09-05 18:04:42 +05:00
FUFSoB a456534801 feat(wip): amnezia-wg 3.1 support 2026-08-30 18:07:43 +05:00
github-actions[bot]andFUFSoB 539f6a13ee chore(deps): refresh flakes and external pins (#11)
Co-authored-by: FUFSoB <32937947+FUFSoB@users.noreply.github.com>
2026-08-17 11:59:43 +05:00
github-actions[bot]andFUFSoB 47a07d971c chore(deps): refresh flakes and external pins (#9)
Co-authored-by: FUFSoB <32937947+FUFSoB@users.noreply.github.com>
2026-08-03 15:23:32 +05:00
fufsob 9f4e45b58a Revert "fix: temp migration of zapret and tg-ws-proxy to archive.org"
This reverts commit 835651c460.
2026-08-03 06:45:43 +00:00
FUFSoB e54c9463dd chore: refactoring (split) 2026-07-11 10:54:37 +05:00
FUFSoB 835651c460 fix: temp migration of zapret and tg-ws-proxy to archive.org 2026-07-10 18:48:06 +05:00
FUFSoB 57a3426c85 fix: per-site config was not working properly 2026-07-02 19:18:55 +05:00
FUFSoB 459a864478 feat: allow setting zapret configs per default domains and default configs 2026-06-29 23:17:00 +05:00
FUFSoB 5b185114b6 fix: remove tgwsproxy keepalive option - removed from upstream 2026-06-29 22:29:28 +05:00
github-actions[bot]andFUFSoB 89fbff9eb1 chore(deps): refresh flakes and external pins (#5)
Co-authored-by: FUFSoB <32937947+FUFSoB@users.noreply.github.com>
2026-06-29 22:09:56 +05:00
FUFSoB b493a11e5a fix: accept zapret config names with any amount of spaces, fixes #6 2026-06-27 10:34:51 +05:00
FUFSoB 7ca7f4000b fix: various fixes 2026-06-24 23:08:16 +05:00
FUFSoB 22ebfa171d chore: remove xray warning 2026-06-20 18:05:50 +05:00
FUFSoB 190ba24ce6 feat: update tg-ws-proxy and its options 2026-06-20 17:48:22 +05:00
FUFSoB 1f5e050cb2 fix: various fixes 2026-06-20 17:11:35 +05:00
FUFSoB 5b5598d12e fix: attempt to mitigate client<-server dropped packages 2026-06-18 20:15:05 +05:00
FUFSoB ce86e5669b fix: different xray fixes 2026-06-18 12:53:35 +05:00
FUFSoB 759bde8b29 fix: xhttp-reality parsing 2026-06-18 12:19:17 +05:00
FUFSoB 433a13ccad fix: truly fixing xray tun 2026-06-09 19:35:48 +05:00
FUFSoB f060c4cd5e fix: tun not working on xray backend 2026-06-08 00:00:08 +05:00
FUFSoB 39ce4d6be2 feat(wip): xray proxy backend 2026-06-07 18:15:37 +05:00
FUFSoB 377d974a18 fix: remove global zapret enable req for perApp zapret 2026-06-07 13:21:09 +05:00
FUFSoB 32bf2266c0 fix: vless fixes 2026-06-06 13:47:59 +05:00
github-actions[bot]andFUFSoB 334755fd0e chore(deps): refresh flakes and external pins (#4)
Co-authored-by: FUFSoB <32937947+FUFSoB@users.noreply.github.com>
2026-06-05 08:32:58 +05:00
FUFSoB 6025e463a5 fix: zapret and other services started before network was fully established 2026-05-30 18:31:48 +05:00
FUFSoB 110e33bc27 fix: tun not working 2026-05-18 18:25:08 +05:00
FUFSoB 86e229ff4c other fixes 2026-05-18 11:03:10 +05:00
FUFSoB 70c0454446 various fixes 2026-05-18 09:18:21 +05:00
github-actions[bot]andFUFSoB 1198a63f3e chore(deps): refresh flakes and external pins (#3)
Co-authored-by: FUFSoB <32937947+FUFSoB@users.noreply.github.com>
2026-05-13 23:08:42 +05:00
FUFSoB fc95f71292 feat: toggle current proxy mode 2026-04-30 19:49:58 +05:00
github-actions[bot]andFUFSoB 148f2bf2a2 chore(deps): refresh flakes and external pins (#2)
Co-authored-by: FUFSoB <32937947+FUFSoB@users.noreply.github.com>
2026-04-27 13:33:01 +05:00
FUFSoB bcc64b3a1b add license file 2026-04-26 21:18:22 +05:00
FUFSoB 43935daeb1 add optional user/password for sing-box 2026-04-22 17:29:12 +05:00
FUFSoB b696821d8c small fixes 2026-04-22 16:02:31 +05:00
FUFSoB 65e815e6dc change tunnel tray icon color 2026-04-19 14:02:57 +05:00
579 changed files with 139484 additions and 12208 deletions

No files matched your search

+175
View File
@@ -0,0 +1,175 @@
name: Windows release
# The Windows port (windows/). On a tag windows-v<version> it builds the setup program and the
# release zip and publishes them as a Gitea release, with the notes in
# windows/release-notes/<version>.md. Run by hand, it only builds: they are the run's artifact.
#
# Two jobs, as upstream's dependency updates: the one that runs fetched code (crates,
# components, wheels, the Nix closure) holds no token that can write. Only the publishing job
# sees RELEASE_TOKEN (write:repository), and it runs nothing it fetched: curl and jq on the
# first job's artifact. Gitea ignores `permissions:`; they are here to say what each job needs.
on:
push:
tags: ["windows-v*"]
workflow_dispatch:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-24.04
timeout-minutes: 150
env:
# Single-user Nix without a daemon: the job's container has no init to run one, nor
# the namespaces a build sandbox needs. Set for the job, so the installer has it too.
NIX_CONFIG: |
experimental-features = nix-command flakes
sandbox = false
build-users-group =
defaults:
run:
shell: bash
steps:
# Full history: the flake is windows/ inside this repository, fetched by Nix as git.
- name: Check out
uses: https://github.com/actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Check the version
working-directory: windows
run: |
set -euo pipefail
version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
[[ "$GITHUB_REF_NAME" == "windows-v$version" ]] ||
{ echo "::error::the tag is $GITHUB_REF_NAME, but windows/Cargo.toml says $version"; exit 1; }
[ -f "release-notes/$version.md" ] ||
{ echo "::error::no windows/release-notes/$version.md"; exit 1; }
fi
echo "Proxy Suite for Windows $version"
# Pinned: this installer checks the hash of the Nix it downloads, and is checked here.
- name: Install Nix
env:
NIX_VERSION: 2.34.9
NIX_INSTALL_SHA256: a03ce2e9eaf4ea1560260b9a93e311dbaf589d28fb5c9318f8d9e768ee6339d8
run: |
set -euo pipefail
# The runner may run as root (no sudo in the image) or as a user with sudo.
as_root() { if [ "$(id -u)" -eq 0 ]; then "$@"; else sudo "$@"; fi; }
if ! command -v xz >/dev/null 2>&1; then
as_root apt-get update -qq
as_root apt-get install -y -qq xz-utils
fi
as_root install -d -m 0755 -o "$(id -u)" -g "$(id -g)" /nix
tmp=$(mktemp -d)
curl -sSfL -o "$tmp/install" "https://releases.nixos.org/nix/nix-$NIX_VERSION/install"
echo "$NIX_INSTALL_SHA256 $tmp/install" | sha256sum -c --quiet
USER=${USER:-$(id -un)} sh "$tmp/install" --no-daemon --no-modify-profile --no-channel-add
echo "$HOME/.nix-profile/bin" >> "$GITHUB_PATH"
- name: Dev shell and Rust toolchain
working-directory: windows
run: nix develop --command rustup toolchain install
# The SSH tunnel's end-to-end test runs an sshd of its own. As root (the job's user in the
# runner's container) sshd separates privileges: it needs its empty, root-owned directory
# and its unprivileged user, which the image does not have.
- name: Test prerequisites
run: |
set -euo pipefail
if [ "$(id -u)" = 0 ]; then
install -d -m 0755 -o root -g root /var/empty
id sshd >/dev/null 2>&1 || useradd --system --no-create-home --home-dir /var/empty --shell /usr/sbin/nologin sshd
fi
# The default members: the service, proxy-ctl, the client and core (the app's crate is
# built by Package).
- name: Test
working-directory: windows
run: nix develop --command cargo test --locked
- name: Package
working-directory: windows
run: nix develop --command tools/package.sh
- name: Collect
working-directory: windows
run: |
set -euo pipefail
version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
mkdir -p ../release
for f in "ProxySuite-$version-windows-x64-setup.exe" "ProxySuite-$version-windows-x64.zip"; do
cp "dist/$f" "dist/$f.sha256" ../release/
done
if [ -f "release-notes/$version.md" ]; then cp "release-notes/$version.md" ../release/notes.md; fi
- name: Upload
uses: https://github.com/actions/upload-artifact@v4
with:
name: windows-release
path: release/
if-no-files-found: error
publish:
needs: build
if: startsWith(github.ref, 'refs/tags/windows-v')
runs-on: ubuntu-24.04
timeout-minutes: 20
permissions:
contents: write
defaults:
run:
shell: bash
steps:
- name: Download
uses: https://github.com/actions/download-artifact@v4
with:
name: windows-release
path: release
# The release for the tag, made if it is not there yet (a pre-release for a version with
# a "-"), and its assets, replacing any of the same name, so a rerun is harmless.
- name: Publish
env:
TOKEN: ${{ secrets.RELEASE_TOKEN }}
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
TAG: ${{ github.ref_name }}
SHA: ${{ github.sha }}
run: |
set -euo pipefail
as_root() { if [ "$(id -u)" -eq 0 ]; then "$@"; else sudo "$@"; fi; }
if ! command -v jq >/dev/null 2>&1; then
as_root apt-get update -qq
as_root apt-get install -y -qq jq
fi
[ -n "$TOKEN" ] || { echo "::error::the RELEASE_TOKEN secret is not set"; exit 1; }
api() { curl -sS --fail-with-body -H "Authorization: token $TOKEN" "$@"; }
version=${TAG#windows-v}
code=$(curl -sS -o found.json -w '%{http_code}' -H "Authorization: token $TOKEN" "$API/releases/tags/$TAG")
case $code in
200) id=$(jq -r .id found.json) ;;
404)
pre=false
[[ "$version" == *-* ]] && pre=true
id=$(jq -n --arg tag "$TAG" --arg sha "$SHA" --arg name "Proxy Suite for Windows $version" \
--rawfile body release/notes.md --argjson pre "$pre" \
'{tag_name: $tag, target_commitish: $sha, name: $name, body: $body, prerelease: $pre, draft: false}' |
api -H 'Content-Type: application/json' --data-binary @- "$API/releases" | jq -r .id)
echo "made the release for $TAG" ;;
*) echo "::error::looking up the release for $TAG: HTTP $code: $(cat found.json)"; exit 1 ;;
esac
for f in release/*.exe release/*.zip release/*.sha256; do
name=$(basename "$f")
for old in $(api "$API/releases/$id/assets" | jq -r --arg n "$name" '.[] | select(.name == $n) | .id'); do
api -X DELETE "$API/releases/$id/assets/$old" >/dev/null
done
api -F "attachment=@$f" "$API/releases/$id/assets?name=$name" >/dev/null
echo "uploaded $name"
done
echo "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/$TAG"
+19
View File
@@ -0,0 +1,19 @@
# The workflows pin actions by commit SHA; Dependabot moves the SHA and its version
# comment together. Nix inputs and pinned sources are dependency-updates.yml's job.
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
day: monday
labels:
- dependencies
- github-actions
commit-message:
prefix: "chore(ci)"
# Every action bump in one pull request, not one each.
groups:
github-actions:
patterns:
- "*"
+241 -33
View File
@@ -4,10 +4,17 @@ on:
schedule:
- cron: "0 6 * * 1"
workflow_dispatch:
inputs:
force_nixpkgs:
description: "Update nixpkgs even when no watched package version changed"
type: boolean
default: false
# Read-only by default: the job that runs fetched code (flake updates, update-pins.sh, nix
# builds and checks) never holds a token that can push. Only the last job may, and it runs
# nothing it fetched: it applies the first job's diff and opens the pull request.
permissions:
contents: write
pull-requests: write
contents: read
concurrency:
group: dependency-updates
@@ -15,75 +22,276 @@ concurrency:
jobs:
update-dependencies:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
outputs:
has_changes: ${{ steps.changes.outputs.has_changes }}
# A skipped pin, failed package build or failed check: the pull request opens as a
# draft and the run ends red.
failed: ${{ (steps.pins.outputs.skipped == 'true' || steps.builds.outputs.failed == 'true' || steps.checks.outputs.failed == 'true') && 'true' || 'false' }}
steps:
# No token left in .git/config for the steps that run fetched code (flake updates,
# update-pins.sh, nix builds); create-pull-request authenticates on its own.
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v22
uses: DeterminateSystems/nix-installer-action@3138316df39ed29be04236d7ffc686fa525866aa # v23
- name: Decide whether nixpkgs should be updated
id: nixpkgs_gate
run: |
set -euo pipefail
chmod +x scripts/check-nixpkgs-relevance.sh
scripts/check-nixpkgs-relevance.sh >> "$GITHUB_OUTPUT"
# Step outputs and inputs reach scripts through the environment, never spliced into them.
- name: Update flake inputs
env:
SHOULD_UPDATE_NIXPKGS: ${{ steps.nixpkgs_gate.outputs.should_update_nixpkgs }}
FORCE_NIXPKGS: ${{ inputs.force_nixpkgs }}
run: |
set -euo pipefail
if [[ "${{ steps.nixpkgs_gate.outputs.should_update_nixpkgs }}" == "true" ]]; then
nix flake lock --update-input nixpkgs
if [[ "$SHOULD_UPDATE_NIXPKGS" == "true" || "$FORCE_NIXPKGS" == "true" ]]; then
nix flake update nixpkgs
else
echo "Skipping nixpkgs update: watched package versions on nixos-unstable are unchanged."
fi
nix flake lock --update-input zapret
# Every other input, every run; update-pins.sh then refreshes the hashes of the
# sources that follow one (z2k-detect follows z2k).
nix flake update zapret z2k nfqws2-keenetic disko
- name: Update tg-ws-proxy pin
# A pin that cannot be updated is put back and listed as "skipped"; the rest go through.
- name: Update pinned sources
id: pins
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
chmod +x scripts/update-tg-ws-proxy.sh
scripts/update-tg-ws-proxy.sh
scripts/update-pins.sh --self-test
scripts/update-pins.sh | tee "$RUNNER_TEMP/pin-updates.txt"
if grep -q '^skipped ' "$RUNNER_TEMP/pin-updates.txt"; then
echo "skipped=true" >> "$GITHUB_OUTPUT"
else
echo "skipped=false" >> "$GITHUB_OUTPUT"
fi
# A nixpkgs bump can bring a nixfmt whose style differs; restyle the tree with
# it so the nix-format check passes and the restyle rides along in the PR.
- name: Reformat Nix files
run: nix fmt
- name: Detect dependency file changes
id: changes
run: |
set -euo pipefail
if git diff --quiet -- flake.lock pkgs/tg-ws-proxy.nix; then
if git diff --quiet -- flake.lock pkgs; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
echo "has_changes=true" >> "$GITHUB_OUTPUT"
fi
- name: Run flake checks
# One build per package, so a failure names it; like the checks, a failure makes the
# pull request a draft instead of holding the update back.
- name: Build updated packages
id: builds
if: steps.changes.outputs.has_changes == 'true'
run: nix flake check
run: |
set -uo pipefail
mapfile -t attrs < <(scripts/update-pins.sh --attrs)
: > "$RUNNER_TEMP/failed-builds.txt"
for attr in "${attrs[@]}"; do
echo "::group::nix build ${attr}"
nix build --no-link --print-build-logs "$attr" || echo "${attr#.#}" >> "$RUNNER_TEMP/failed-builds.txt"
echo "::endgroup::"
done
if [[ -s "$RUNNER_TEMP/failed-builds.txt" ]]; then
echo "failed=true" >> "$GITHUB_OUTPUT"
else
echo "failed=false" >> "$GITHUB_OUTPUT"
fi
# A failing check does not hold the update back: the pull request opens as a draft
# naming the failures, and the run still ends red (open-pull-request's last step).
- name: Run flake checks
id: checks
if: steps.changes.outputs.has_changes == 'true'
run: |
set -uo pipefail
log="$RUNNER_TEMP/flake-check.log"
if nix flake check --keep-going --print-build-logs 2>&1 | tee "$log"; then
echo "failed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "failed=true" >> "$GITHUB_OUTPUT"
# The check attributes nix marks failed; else the derivations it could not build.
{
grep -oE '❌ checks\.[^[:space:]]+' "$log" | sed 's/^❌ //' ||
grep -oE "Cannot build '/nix/store/[a-z0-9]{32}-[^']+\.drv'" "$log" |
sed -E "s|^.*/[a-z0-9]{32}-||; s|\.drv'$||"
} | sort -u > "$RUNNER_TEMP/failed-checks.txt" || true
- name: Compose pull request body
if: steps.changes.outputs.has_changes == 'true'
env:
SHOULD_UPDATE_NIXPKGS: ${{ steps.nixpkgs_gate.outputs.should_update_nixpkgs }}
CHANGED_WATCH_ATTRS: ${{ steps.nixpkgs_gate.outputs.nixpkgs_changed_watch_attrs }}
PINS_SKIPPED: ${{ steps.pins.outputs.skipped }}
BUILDS_FAILED: ${{ steps.builds.outputs.failed }}
CHECKS_FAILED: ${{ steps.checks.outputs.failed }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -euo pipefail
{
echo "## Automated dependency update"
echo
echo "Managed by CI; the \`ci/update-dependencies\` branch is reused across runs."
echo
echo "### Pinned sources"
if [[ "$PINS_SKIPPED" == "true" ]]; then
echo "Some could not be updated and were kept, so this pull request is a draft ([run log]($RUN_URL))."
fi
if [[ -s "$RUNNER_TEMP/pin-updates.txt" ]]; then
sed 's/^/- /' "$RUNNER_TEMP/pin-updates.txt"
else
echo "- no pin changes"
fi
echo
echo "### Flake inputs"
echo "- nixpkgs updated: \`$SHOULD_UPDATE_NIXPKGS\`"
echo "- changed watched attrs: \`$CHANGED_WATCH_ATTRS\`"
# The locked revs that moved, against the checked-out lock file.
git show HEAD:flake.lock | jq -r --slurpfile new flake.lock '
.nodes as $old | $new[0].nodes | to_entries[]
| select(.value.locked.rev? != null)
| (.value.locked.rev) as $rev | ($old[.key].locked.rev // "none") as $prev
| select($rev != $prev)
| "- \(.key): `\($prev[0:7])` -> `\($rev[0:7])`"'
echo
echo "### Package builds"
if [[ "$BUILDS_FAILED" == "true" ]]; then
echo "Failed, so this pull request is a draft ([run log]($RUN_URL)):"
while IFS= read -r attr; do echo "- \`$attr\`"; done < "$RUNNER_TEMP/failed-builds.txt"
else
echo "- all built"
fi
echo
echo "### Flake checks"
if [[ "$CHECKS_FAILED" == "true" ]]; then
echo "Failed, so this pull request is a draft ([run log]($RUN_URL)):"
if [[ -s "$RUNNER_TEMP/failed-checks.txt" ]]; then
while IFS= read -r check; do echo "- \`$check\`"; done < "$RUNNER_TEMP/failed-checks.txt"
else
echo "- no failing check named in the log; see the run"
fi
else
echo "- all passed"
fi
echo
echo '```'
git diff --stat
echo '```'
} > "$RUNNER_TEMP/pr-body.md"
cat "$RUNNER_TEMP/pr-body.md" >> "$GITHUB_STEP_SUMMARY"
# The changes as a patch, new files included, for the job that may push.
- name: Export the changes
if: steps.changes.outputs.has_changes == 'true'
run: |
set -euo pipefail
git add -A -- flake.lock '*.nix'
git diff --cached --binary > "$RUNNER_TEMP/dependency-updates.patch"
cp "$RUNNER_TEMP/pr-body.md" "$RUNNER_TEMP/dependency-updates.md"
- name: Upload the changes
if: steps.changes.outputs.has_changes == 'true'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: dependency-updates
path: |
${{ runner.temp }}/dependency-updates.patch
${{ runner.temp }}/dependency-updates.md
retention-days: 1
# With nothing else to propose there is no pull request to carry a skipped pin.
- name: No dependency changes
if: steps.changes.outputs.has_changes != 'true'
env:
PINS_SKIPPED: ${{ steps.pins.outputs.skipped }}
run: |
set -euo pipefail
if [[ "$PINS_SKIPPED" == "true" ]]; then
grep '^skipped ' "$RUNNER_TEMP/pin-updates.txt" | sed 's/^/::error::/'
exit 1
fi
echo "No dependency updates detected."
open-pull-request:
needs: update-dependencies
if: needs.update-dependencies.outputs.has_changes == 'true'
runs-on: ubuntu-24.04
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Download the changes
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dependency-updates
path: ${{ runner.temp }}/dependency-updates
# Data only: git applies the diff; nothing from it runs.
- name: Apply the changes
run: |
set -euo pipefail
git apply --index "$RUNNER_TEMP/dependency-updates/dependency-updates.patch"
# The commit takes the whole index, whatever add-paths says: refuse a patch
# that reaches past the lock file and the Nix files the updates and nix fmt touch.
if git diff --cached --name-only | grep -vxE 'flake\.lock|.+\.nix'; then
echo "The patch changes files other than flake.lock and *.nix (above)." >&2
exit 1
fi
- name: Create or update pull request
if: steps.changes.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@v8
id: pr
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
# always-true also turns an open pull request back into a draft.
draft: ${{ needs.update-dependencies.outputs.failed == 'true' && 'always-true' || 'false' }}
branch: ci/update-dependencies
delete-branch: false
commit-message: "chore(deps): refresh flakes and external pins"
title: "chore(deps): refresh flakes and external pins"
add-paths: |
flake.lock
pkgs
*.nix
commit-message: "chore(deps): refresh flake inputs and pinned sources"
title: "chore(deps): refresh flake inputs and pinned sources"
body-path: ${{ runner.temp }}/dependency-updates/dependency-updates.md
labels: |
dependencies
nix
body: |
## Automated dependency update
This PR is managed by CI and the same branch is reused across runs.
# draft: false leaves an existing draft alone; once nothing was skipped or failed, mark it ready.
- name: Mark the pull request ready for review
if: needs.update-dependencies.outputs.failed != 'true' && steps.pr.outputs.pull-request-operation == 'updated'
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ steps.pr.outputs.pull-request-number }}
run: |
set -euo pipefail
if [[ "$(gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json isDraft --jq .isDraft)" == "true" ]]; then
gh pr ready "$PR_NUMBER" --repo "$GITHUB_REPOSITORY"
fi
### Included updates
- `flake.lock` updates (`zapret` always, `nixpkgs` only when watched package versions change on `nixos-unstable`)
- `pkgs/tg-ws-proxy.nix` pin refresh (`rev` + `hash`)
### Nixpkgs gate result
- should update nixpkgs: `${{ steps.nixpkgs_gate.outputs.should_update_nixpkgs }}`
- changed watched attrs: `${{ steps.nixpkgs_gate.outputs.nixpkgs_changed_watch_attrs }}`
- name: No dependency changes
if: steps.changes.outputs.has_changes != 'true'
run: echo "No dependency updates detected."
- name: Fail the run on skipped pins, failed builds or checks
if: needs.update-dependencies.outputs.failed == 'true'
env:
PR_URL: ${{ steps.pr.outputs.pull-request-url }}
run: |
echo "::error::Pins were skipped, or package builds or flake checks failed; the update is a draft pull request: $PR_URL"
exit 1
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 FUFSoB
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+252 -94
View File
@@ -1,148 +1,306 @@
# proxy-suite-flake
Declarative proxy stack for NixOS.
A declarative proxy stack for NixOS. Route this host's traffic through proxies, serve proxies to others, or both, all from one Nix config that runs as systemd services. Also runs on other Linux distributions (system-manager, home-manager) and on Android (Nix-on-Droid).
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.
> [!IMPORTANT]
> For study and research only: learning how proxies, tunnels and traffic routing work. No warranty; the authors are not responsible for how it is used.
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.
> [!NOTE]
> Much of the code and documentation was written with AI tools, then reviewed and tested on real setups.
---
Bundles [sing-box](https://github.com/SagerNet/sing-box), [XRay](https://github.com/XTLS/Xray-core), [AmneziaWG](https://github.com/amnezia-vpn/amneziawg-go), [zapret-discord-youtube](https://github.com/kartavkun/zapret-discord-youtube), [zapret2](https://github.com/bol-van/zapret2), [tg-ws-proxy](https://github.com/Flowseal/tg-ws-proxy) and [whitelist-bypass](https://github.com/kulikov0/whitelist-bypass); see their repositories for licenses and docs. Inspired by [Throne](https://github.com/throneproj/Throne) (formerly NekoRay), [3x-ui](https://github.com/MHSanaei/3x-ui) and similar projects.
## What it gives you
## Features
- **SOCKS5/HTTP proxy** on `127.0.0.1:1080` by default – always running, always available to apps
- **Transparent proxy (TProxy)** – redirect all system traffic through sing-box without configuring each app; start/stop on demand or autostart at boot
- **TUN mode** – full tunnel via a virtual network interface; useful when TProxy doesn't cover something, with optional boot-time autostart
- **Per-app wrapping** – run selected apps through the local proxy with `proxy-ctl wrap <profile> -- <command>`, without enabling global TProxy or TUN
- **Subscription URLs** – point at a v2rayN/Clash-format subscription endpoint; the module fetches, decodes, and imports all proxies automatically, with a periodic refresh timer
- **Multiple outbounds** with automatic latency-based switching or manual selection
- **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
- **`proxy-ctl`** – control script for managing services, switching outbounds, and following logs
- **DPI bypass** via zapret – handles YouTube, Discord, and other sites defined by the project
- **Telegram proxy** – running local MTProto WebSocket proxy using tg-ws-proxy
---
- Local SOCKS5/HTTP proxy on `127.0.0.1:1080`, on sing-box, XRay, or both
- System-wide TUN or TProxy mode, on demand or at boot
- Kill switch: nothing leaks while a global tunnel restarts or after it fails
- Per-app routing: `proxy-ctl apps run <profile> -- <cmd>`, or packages wrapped to always use the proxy
- Outbounds from links, raw JSON or subscriptions, picked by hand or by latency
- vless (REALITY, TLS), vmess, trojan, shadowsocks, hysteria2, socks, http; TUIC, AnyTLS and NaïveProxy on sing-box; XHTTP and ECH on XRay
- Proxy chains: any outbound can connect through another
- autoProxy: finds an exit that reaches each blocked site and routes it there
- zapret DPI bypass, including zapret2, which learns blocked sites on its own
- AmneziaWG 1.x–3.x from `.conf`, `vpn://` or Nix
- Cloudflare WARP, Tor (with bridges and an onion service), an SSH tunnel and a Telegram proxy
- Tunnels through video-call servers, to get past mobile internet whitelists
- Server inbounds (XRay protocols, hysteria2, AmneziaWG) with share links, QR codes, subscriptions in each client's format (links, Clash, sing-box, a web page) and traffic stats; users with expiry, traffic, device and speed limits
- A desktop GUI with a tray icon, the `proxy-ctl` CLI and the `proxy-tui` terminal UI
## Setup
Add to your flake inputs:
```nix
inputs.proxy-suite.url = "github:FUFSoB/proxy-suite-flake";
```
No need to add zapret separately – it comes along as a transitive input.
Add the module to your NixOS configuration:
```nix
modules = [ inputs.proxy-suite.nixosModules.default ];
```
Feature-complete starter config:
A starter config:
```nix
services.proxy-suite = {
enable = true;
singBox = {
proxy = {
enable = true;
port = 1080;
backend = "sing-box"; # or "xray", "hybrid"
# Individual proxy example
outbounds = [
{
tag = "nl-vps";
# Inline url is convenient for testing, but ends up in the Nix store.
# For real use, prefer urlFile with a url file.
url = "hy2://password@example.com:443?sni=example.com";
}
];
# `url` ends up in the Nix store; use `urlFile` for secrets.
outbounds = [ { tag = "nl-vps"; url = "hy2://password@example.com:443?sni=example.com"; } ];
subscriptions = [ { tag = "main-sub"; urlFile = "/run/secrets/sub-url"; } ];
selection = "urltest"; # pick the fastest; default "first"
# Subscription example
subscriptions = [
{
tag = "main-sub";
# urlFile is also available to keep the URL out of the Nix store.
url = "https://example.com/subscription-list.txt";
}
];
# Automatic switching of outbound based on latency.
# Default is "first", which just uses the first one in the list.
selection = "urltest";
# Keep both available; autostart only one global tunnel.
tproxy = {
enable = true;
autostart = false;
perApp.enable = true;
};
tun = {
enable = true;
autostart = false;
perApp.enable = true;
};
};
zapret = {
enable = true;
perApp.enable = true;
tproxy.enable = true;
tun.enable = true;
};
perAppRouting = {
enable = true;
createDefaultProfiles = true;
proxychains.enable = true;
tun.enable = true;
tproxy.enable = true;
zapret.enable = true;
};
tray = {
zapret.enable = true;
sshProxy = {
enable = true;
autostart = true;
server = {
user = "root";
host = "ssh.example.com";
};
identityFile = "/run/secrets/proxy-suite-ssh-key";
hostKeyFile = "/run/secrets/proxy-suite-ssh-known-hosts";
};
# Only one global tunnel (AWG, TUN or TProxy) runs at a time.
amneziaWg = {
enable = true;
profiles.home.configFile = "/run/secrets/home-amneziawg.conf";
profiles.work.vpnFile = "/run/secrets/work-amnezia.vpn";
# Or use a profile as an outbound, tagged "de":
profiles.de = {
asOutbound = "interface"; # or "userspace" (no root), "singBox" (plain WireGuard)
configFile = "/run/secrets/de-amneziawg.conf";
};
};
warp = {
enable = true;
asOutbound = "singBox"; # outbound tagged "warp"
# asAmneziaWg = true; # or a global profile: proxy-ctl awg on warp
};
# Outbound tagged "tor"; .onion names always go there.
tor = {
enable = true;
asOutbound = true;
# bridges.file = "/run/secrets/tor-bridges";
# upstream = "proxy"; # reach Tor through the proxy
};
tgWsProxy = {
enable = true;
port = 1443;
# Inline secret is convenient for testing, but ends up in the Nix store.
# For real use, prefer secretFile with a secret file.
secret = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
secretFile = "/run/secrets/tg-ws-proxy-secret";
};
# Tunnel through a video call. A creator runs on a free server and logs the call link;
# the joiner here is an outbound tagged "wl".
whitelistBypass = {
enable = true;
creators.phone = { platform = "wbstream"; cookiesFile = "/run/secrets/wb-cookies.json"; };
# joiners.wl = { platform = "wbstream"; linkFile = "/run/secrets/wb-link"; };
};
gui.enable = true;
};
```
---
## Options
## Docs
To see options and documentation, check out the [options reference](./docs/options.md).
Options and generated README help are refreshed with `nix run .#update-docs`.
---
- [Usage guides](./docs/usage/index.md): common setups, step by step, and complete examples.
- [Options reference](./docs/options/index.md): every option. Regenerate it and the help below with `nix run .#update-docs`.
## `proxy-ctl help`
Generated from current `proxy-ctl help` output.
<!-- proxy-ctl-help:start -->
```text
Usage: proxy-ctl <command> [args]
Usage: proxy-ctl <group> [verb] [args]
A group alone shows its status or list.
Groups with on|off also take toggle and restart.
Changes and secrets need root or the userControl group.
Commands:
help show this help message
status [--tray] show status of all proxy-suite services
proxy on|off enable/disable the sing-box proxy stack
tproxy on|off enable/disable TProxy transparent mode
tun on|off enable/disable TUN mode
zapret on|off enable/disable zapret-discord-youtube
restart restart active global proxy-suite services
logs [service] follow service logs (default: proxy-suite-socks)
outbounds list outbounds and current selection
select <tag> switch to a specific outbound (selector mode)
apps list configured per-app routing profiles
wrap <profile> -- <cmd> run a command via a perAppRouting profile
subscription list show subscriptions, cache age, and proxy count
subscription update force-refresh all subscription caches and restart active sing-box services
status [--json] services and routing mode (--tray: deprecated)
restart restart running services
logs [unit...] follow logs (default: all proxy-suite units); in a
terminal, in lnav: scroll back, G follows, q quits
where <domain> how a domain is routed right now
debug conns [--backend socks|tun|per-app-tun] [--host <domain|address>]... [--inbound <tag>]...
[--stall <s>] [--interval <s>]
the backend's connections as they open, stall and
close, with their rule, exit and bytes (needs root or
the secrets scope); --host, --inbound: only these;
--backend tun, per-app-tun: the TUN ones (root, and
debug.connectionLog on)
proxy [status|on|off] local proxy
proxy outbounds [list] outbounds, their source, and the current pick
proxy outbounds add [tag] <url|json|-> [--detour <tag>]
add an outbound from a link or JSON (-: stdin);
--detour: connect through another outbound
proxy outbounds add [tag] <vpn://…|file.conf|-> [--container <name>]
add an AmneziaWG outbound (runs in wireproxy)
proxy outbounds chain <tag> <through-tag> [new tag]
add a copy of an outbound that connects through another
proxy outbounds rm <tag> remove a runtime outbound
proxy outbounds disable|enable <tag> exclude from automatic use (selection, autoProxy), or undo
proxy outbounds test [tag...] [--ping] [--delay] [--download]
test ping, delay, download speed (default: ping, delay)
proxy outbounds link <tag> [--qr|--json|--config]
its link, QR code, JSON, or client config
proxy pin [tag] [--in <group>] always use this outbound (no tag: pick from a menu);
--in: hold a group on one of its members
proxy unpin [--in <group>] go back to automatic selection
proxy groups [list] outbound groups, their members, and what each uses
proxy groups add <tag> [member...] [--sub <sub>]... [--match <pattern>]...
[--strategy failover|urltest|selector] [--no-failback] [--interval <d>]
add a group (failover by default)
proxy groups rm <tag> remove a group added with groups add
proxy groups members <tag> add|rm <member...>
proxy groups members <tag> set [member...]
exactly these members, in this order
proxy groups strategy <tag> failover|urltest|selector
proxy priority [list] the top level in the order it is picked in
proxy priority <tag> <n>|up|down|--clear
lower goes first; up/down renumbers the top level
proxy mode [default|whitelist|blacklist|all-proxy|all-bypass]
show or override the routing mode
proxy rules [list] routing rules, the configuration's and runtime ones,
in the order they are checked
proxy rules add <target> <match...> [--name <name>] [--priority <n>]
send domains, addresses, geosite:x, geoip:x or ruleset:x
to proxy, direct, block or an outbound; no --name: the
rule named after the target, extended (priority 50:
ahead of the configuration's, at 100 to 500)
proxy rules matches <name> add|rm <match...>
proxy rules matches <name> set [match...]
exactly these matches
proxy rules target <name> <target>
proxy rules priority <name> <n>|up|down
lower goes first; up/down moves past the next row
proxy rules disable|enable|rm <name>
proxy subs [list|update] subscriptions; update refetches them
proxy subs add [tag] <url|-> add a subscription (no tag: named after its host; -: stdin)
proxy subs rm <tag> remove a runtime subscription
proxy subs link <tag> [--qr] its URL
proxy rulesets [list|update] rule sets and when they were fetched; update refetches
proxy config [--raw] client config to use elsewhere; --raw: as running
proxy tun [status|on|off] global TUN mode
proxy tproxy [status|on|off] global TProxy mode
proxy auto [list] what autoProxy routed, and through which exit
proxy auto probe <domain>[/path] [--json] [--keep-going] [--exits a,b | --via tag]
find an exit that reaches a domain
proxy auto learn <domain> probe now, and route it if an exit works
proxy auto forget <domain> forget it (direct until learned again)
proxy auto relearn <domain> forget it and probe again now
proxy auto clear forget everything learned
proxy auto queue [count] destinations waiting to be probed
zapret [status|on|off] DPI bypass
zapret auto [list] sites zapret2 learned as blocked
zapret auto add|forget|exclude <domain>
treat a site as blocked, forget it, or never touch it
zapret auto unpin|include <domain> undo add or exclude
zapret auto retry <domain|ip> give zapret2 another try where it sent the proxy
zapret auto clear forget learned sites and strategies
zapret cutoff [status] networks cut off at 16 KB, and names that pass
zapret cutoff probe probe again now
awg [list] AmneziaWG profiles
awg on <profile> | off [profile] | toggle [profile] | restart [profile]
awg add [name] <vpn://…|file.conf|-> [--container <name>]
add a global profile (-: stdin)
awg rm <profile> remove a profile added with awg add
killswitch [status|on|off] block traffic outside the global tunnel;
stays on until turned off here or with the tunnel
ssh [status|on|off] SSH tunnel
warp [status|on|off] [device] WARP tunnel (every device, or the one named)
tor [status|on|off] Tor
tor newnym new circuits for new connections
tg [status|on|off] Telegram proxy
wl [list] whitelist-bypass creators and joiners
wl link <creator> [--qr] the call link for its joiner
wl auth <creator> [file|-] replace its login: cookies, or prompt (DION, Bitrix)
wl join <joiner> <link|-> set the call to join
wl new <creator> start a new call
wl on|off|toggle|restart [name] one creator or joiner, or all
apps [list] per-app routing profiles
apps run <profile> -- <cmd> [args] run a command through a profile
apps run --via <outbound> -- <cmd> run a command through one outbound
(--route tun|tproxy picks the method)
apps add <name> [--route r] [--via o] add a profile without a rebuild
apps rm <name> remove one added that way
inbounds [list] server inbounds
inbounds link <tag> [user] [--onion|--variant=<name>] [--qr|--json]
share link or client JSON; --onion: via the onion
service; --variant: one of the listener's shareVariants
inbounds link <tag> [user] --config [--qr]
AmneziaWG client .conf or its QR code
inbounds link <tag> --server-json the server's inbound JSON
inbounds sub [user] [--qr] subscription users, or one user's URL
inbounds stats [days] [--by user|inbound|outbound]
traffic by user, listener or exit
inbounds users [list] users: order, serverSource address, listeners
(the rest below needs inbounds.runtime)
inbounds users add <name> [--order N] [--listener <tag>]...
add a user at runtime, with generated secrets
inbounds users rm <name> remove a runtime user
inbounds users order <name> <N> a runtime user's order (serverSource number)
inbounds bind|unbind <user> <tag> put a user on a listener, or take it off
(a runtime user, or a runtime listener)
inbounds users listeners <user> [tag...]
put a user on exactly these listeners
inbounds users on <tag> [user...] put exactly these users on a listener
inbounds add <tag> <type> [--port N] [--via V] [--transport T] [--path P] [--host H]
[--reality SNI[,SNI]] [--tls <cert>] [--alpn a,b] [--flow vision] [--method M]
[--listen A] [--user U]... [more: see inbounds add --help]
add a listener at runtime
inbounds add <tag> <file.json|-> add one from JSON shaped like inbounds.listeners.<tag>
inbounds rm <tag> remove a runtime listener
inbounds show <tag> a runtime listener's JSON
inbounds online who is online, and when others were last seen
With inbounds.manager (users' policies; the API proxy-ctl and bots use):
inbounds users [list] [--json] users, whether they may connect, traffic, expiry
inbounds users show <name> [--json] one user: policy, traffic, online, subscription
inbounds users add <name> [...] [policy flags]
add a runtime user with a policy
inbounds users set <name> [--expires 2026-12-31|+30d] [--on-hold 30d] [--traffic 50G]
[--period monthly] [--ips 2] [--speed 20M/5M] [--enable|--disable] [--meta key=value]...
change a user's policy (declared users too);
--on-hold: a term that starts on the first connection
inbounds users unset <name> <expires|hold|traffic|period|ips|speed|meta|enabled>...
back to the config's value, or none
inbounds users enable|disable <name> switch a user on or off
inbounds users reset <name> start their traffic over
inbounds users extend <name> 30d [--reset]
move the expiry on (from now, or from it if later;
on hold: a longer term); --reset: traffic anew too
inbounds users extend <name> --until <time> [--reset]
inbounds users rotate-sub <name> a new subscription URL, the old one stops answering
inbounds bans [rm <address>] addresses banned past a user's ipLimit
inbounds export [file] [--no-stats] users, policies, keys and traffic, to move them
inbounds import <file|-> [--replace] take them in on this server
inbounds events [N] what the manager did and told its webhooks
```
<!-- proxy-ctl-help:end -->
+83
View File
@@ -0,0 +1,83 @@
# The disk layout of an installed server, for disko: GPT with a BIOS boot partition (GRUB
# on BIOS), an ESP on /boot (GRUB on UEFI) and btrfs over the rest, compressed, with a
# subvolume per mount point and a swap file. Subvolumes follow the @ convention: @ is /,
# @<name> the rest. services.proxy-suite-server.disko uses it
# for the installed system; proxy-suite-install passes it to the disko CLI to partition.
{
device,
swapSize ? "2G",
...
}:
let
mountOptions = [
"compress=zstd:3"
"noatime"
];
in
{
disko.devices.disk.main = {
type = "disk";
inherit device;
content = {
type = "gpt";
partitions = {
bios = {
size = "1M";
type = "EF02";
priority = 1;
};
ESP = {
size = "512M";
type = "EF00";
priority = 2;
content = {
type = "filesystem";
format = "vfat";
extraArgs = [
"-n"
"ESP"
];
mountpoint = "/boot";
mountOptions = [ "umask=077" ];
};
};
root = {
size = "100%";
content = {
type = "btrfs";
extraArgs = [
"-f"
"-L"
"nixos"
];
subvolumes = {
"@" = {
mountpoint = "/";
inherit mountOptions;
};
"@nix" = {
mountpoint = "/nix";
inherit mountOptions;
};
"@varlog" = {
mountpoint = "/var/log";
inherit mountOptions;
};
"@home" = {
mountpoint = "/home";
inherit mountOptions;
};
# btrfs filesystem mkswapfile makes the file NOCOW, so it is never compressed.
"@swap" = {
mountpoint = "/swap";
mountOptions = [ "noatime" ];
swap.swapfile.size = swapSize;
};
};
};
};
};
};
};
}
+60
View File
@@ -0,0 +1,60 @@
# proxy-suite-install: the installer the ISO runs on tty1 (deploy/installer.sh).
{
lib,
writeShellApplication,
xray,
disko,
diskLayout,
flakeRev,
flakeSource,
stateVersion,
coreutils,
curl,
gawk,
getent,
gnugrep,
gnused,
iproute2,
iputils,
jq,
mkpasswd,
nix,
nixos-install-tools,
openssh,
openssl,
systemd,
util-linux,
xkcdpass,
}:
import ./script.nix { inherit lib writeShellApplication; } {
name = "proxy-suite-install";
script = ./installer.sh;
runtimeInputs = [
coreutils
curl
disko
gawk
getent
gnugrep
gnused
iproute2
iputils
jq
mkpasswd
nix
nixos-install-tools
openssh
openssl
systemd
util-linux
xkcdpass
xray
];
runtimeEnv = {
PSI_FLAKE_REV = flakeRev;
PSI_FLAKE_SRC = "${flakeSource}";
PSI_STATE_VERSION = stateVersion;
PSI_DISK_LAYOUT = "${diskLayout}";
};
}
+426
View File
@@ -0,0 +1,426 @@
# proxy-suite-install: turn a VPS booted from the installer ISO into a proxy-suite
# server. Everything asked here ends up in /etc/nixos/host.nix on the target.
#
# Baked in by deploy/installer.nix: PSI_FLAKE_REV (the ISO's commit, or empty for a
# dirty tree or a path: build), PSI_FLAKE_SRC (this flake's source in the store),
# PSI_STATE_VERSION.
# Unattended: PSI_UNATTENDED=1 plus PSI_<NAME> for every answer (see ask in net-lib.sh).
: "${PSI_FLAKE_REV?}" "${PSI_FLAKE_SRC:?}" "${PSI_STATE_VERSION:?}"
MNT=/mnt
SECRETS_DIR=/var/lib/proxy-suite-server
# On the live system: kept until the ISO reboots, so a rerun offers the same answers.
ANSWERS=/var/lib/proxy-suite-install/answers
if [[ $(id -u) != 0 ]]; then
echo "proxy-suite-install: run it as root (sudo -i)" >&2
exit 1
fi
# yes installs; edit asks everything again, offering the current answers; anything
# else is asked again, so a typo does not throw the answers away.
confirm_install() {
local reply
if [[ -n ${PSI_UNATTENDED-} ]]; then
return 0
fi
while true; do
read -r -p "Type yes to install, edit to change the answers, or quit: " reply || reply=quit
case ${reply,,} in
yes) return 0 ;;
edit) return 1 ;;
quit | q)
say "Aborted; nothing was written. sudo proxy-suite-install offers these answers again."
exit 1
;;
*) warn "Type yes, edit or quit." ;;
esac
done
}
step() { printf '\n\033[1;36m== %s ==\033[0m\n' "$*"; }
# A stable name for disko and GRUB, where the disk has one.
stable_disk_path() {
local link
for link in /dev/disk/by-id/*; do
[[ $link == *-part* || $link == */nvme-eui.* ]] && continue
if [[ $(readlink -f "$link") == "$1" ]]; then
printf '%s' "$link"
return 0
fi
done
printf '%s' "$1"
}
clear
bold "proxy-suite server installer"
say "Installs NixOS with VLESS REALITY, TLS and WS inbounds for one user, and SSH."
say "Every question has a default in [brackets]: press Enter to take it."
say "Ctrl+C aborts; sudo proxy-suite-install starts over, offering the answers given."
if [[ -z ${PSI_UNATTENDED-} ]] && load_answers "$ANSWERS"; then
say "The defaults are the answers from the last run."
fi
# The questions, again from the top on edit: each offers the answer given before.
ask_all() {
local local_ip seen_ip default_ip disks
# --- Network ------------------------------------------------------------------
step "Network"
setup_network || exit 1
step "Public address"
if [[ $NET_DHCP == false ]]; then
local_ip=${NET_V4%/*}
else
local_ip=$(ip -4 route get 1.1.1.1 | awk '{ for (i = 1; i < NF; i++) if ($i == "src") { print $(i + 1); exit } }')
fi
seen_ip=$(curl -4 -s --max-time 10 https://api.ipify.org || true)
default_ip=$local_ip
if [[ -n $seen_ip && $seen_ip != "$local_ip" ]] && is_ipv4 "$seen_ip"; then
say "This server's address is $local_ip, but the internet sees it as $seen_ip (NAT)."
default_ip=$seen_ip
fi
while true; do
ask PUBLIC_IP "Public IPv4 clients connect to" "$default_ip"
is_ipv4 "$PUBLIC_IP" && break
reject "Not an IPv4 address." PUBLIC_IP
done
if ipv4_is_private "$PUBLIC_IP"; then
warn "$PUBLIC_IP is a private address: clients outside cannot reach it, and no certificate"
warn "can be issued for it. Use a domain, and forward the ports to this server."
fi
# --- Server -------------------------------------------------------------------
step "Server"
while true; do
ask HOST_NAME "Hostname" "proxy-$(openssl rand -hex 2)"
[[ $HOST_NAME =~ ^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$ ]] && break
reject "Lowercase letters, digits and dashes only." HOST_NAME
done
while true; do
ask ADMIN_USER "Admin user name (SSH login, sudo)" "admin"
[[ $ADMIN_USER =~ ^[a-z_][a-z0-9_-]{0,31}$ && $ADMIN_USER != root ]] && break
reject "Lowercase letters, digits, - and _; not root." ADMIN_USER
done
while true; do
ask SSH_PORT "SSH port" "22"
# No leading zero: bash would read 0443 as octal, Nix as 443.
if [[ $SSH_PORT =~ ^[1-9][0-9]{0,4}$ ]] && ((SSH_PORT <= 65535)) &&
[[ ! " 80 443 2053 8443 18533 18534 18535 " == *" $SSH_PORT "* ]]; then
break
fi
reject "A free port from 1 to 65535 (80, 443, 2053 and 8443 are taken)." SSH_PORT
done
say "With a public key, SSH takes no passwords (the console still does)."
while true; do
ask SSH_KEY "SSH public key for $ADMIN_USER (empty: the password)" ""
[[ -z $SSH_KEY || $SSH_KEY =~ ^(ssh-|ecdsa-sha2-|sk-)[a-z0-9@.-]+\ [A-Za-z0-9+/]+=*(\ [^[:cntrl:]]*)?$ ]] && break
reject "Not an OpenSSH public key (ssh-ed25519 AAAA... comment)." SSH_KEY
done
ask_yes QEMU_GUEST "QEMU guest agent (lets the VPS panel see the server's state)" "y"
# --- Proxy --------------------------------------------------------------------
step "Proxy"
while true; do
ask PROXY_USER "Proxy user name (label of the share links)" "user"
[[ $PROXY_USER =~ ^[A-Za-z0-9_.-]{1,32}$ ]] && break
reject "Letters, digits, dot, dash and underscore." PROXY_USER
done
say ""
say "The TLS and WS inbounds need a certificate from Let's Encrypt. With a domain"
say "(its A record pointing at $PUBLIC_IP) it is issued for the domain; without one,"
say "for the IP itself (a six-day certificate, renewed automatically). Port 80 must be open."
while true; do
ask DOMAIN "Domain (empty: certificate for the IP)" ""
if [[ -z $DOMAIN ]]; then
break
fi
DOMAIN=${DOMAIN,,}
if [[ ! $DOMAIN =~ ^([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$ ]]; then
reject "Not a domain name." DOMAIN
continue
fi
if getent ahostsv4 "$DOMAIN" | awk '{ print $1 }' | grep -qx "$PUBLIC_IP"; then
break
fi
warn "$DOMAIN does not resolve to $PUBLIC_IP (yet). The certificate order retries until it does."
ask_yes KEEP_DOMAIN "Keep $DOMAIN anyway" "y"
[[ $KEEP_DOMAIN == true ]] && break
retry "Give another domain, or none." DOMAIN KEEP_DOMAIN
forget KEEP_DOMAIN
done
while true; do
ask ACME_EMAIL "Email for Let's Encrypt (optional)" ""
[[ -z $ACME_EMAIL || $ACME_EMAIL =~ ^[^[:space:]\"@]+@[^[:space:]\"@]+$ ]] && break
reject "Not an email address." ACME_EMAIL
done
say ""
say "REALITY impersonates another site's TLS. Pick a big HTTPS site, ideally hosted"
say "near this server and not blocked where your clients are."
while true; do
ask REALITY_SNI "REALITY site" "www.microsoft.com"
if [[ ! $REALITY_SNI =~ ^([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z]{2,}$ ]]; then
reject "Not a domain name." REALITY_SNI
continue
fi
if curl -s -o /dev/null --max-time 10 --tlsv1.3 --http2 "https://$REALITY_SNI/"; then
break
fi
warn "$REALITY_SNI did not answer over TLS 1.3 from here; REALITY needs TLS 1.3 and HTTP/2."
ask_yes KEEP_SNI "Keep $REALITY_SNI anyway" "n"
[[ $KEEP_SNI == true ]] && break
retry "Give another REALITY site." REALITY_SNI KEEP_SNI
forget KEEP_SNI
done
# --- Disk ---------------------------------------------------------------------
step "Disk"
# The medium this installer runs from, which some VPS panels attach as a writable disk
# rather than a CD: erasing it would kill the install halfway.
local live_majmin live_disk=""
if live_majmin=$(findmnt -no MAJ:MIN /iso 2>/dev/null) && [[ -e /dev/block/$live_majmin ]]; then
live_disk=$(lsblk -ndpo PKNAME "/dev/block/$live_majmin" 2>/dev/null || true)
[[ -n $live_disk ]] || live_disk=$(readlink -f "/dev/block/$live_majmin")
fi
mapfile -t disks < <(lsblk -dnpo NAME,TYPE,RO | awk -v live="$live_disk" '$2 == "disk" && $3 == 0 && $1 != live && $1 !~ /\/(zram|loop|sr|fd)[0-9]/ { print $1 }')
if ((${#disks[@]} == 0)); then
warn "No writable disk found."
exit 1
fi
lsblk -dpo NAME,SIZE,MODEL "${disks[@]}"
# Unattended, the disk to erase is never guessed, even when there is only one.
if [[ -n ${PSI_UNATTENDED-} && -z ${PSI_DISK-} ]]; then
warn "PSI_UNATTENDED: set PSI_DISK to the disk to erase."
exit 1
fi
while true; do
ask DISK "Disk to install on (ERASED)" "$(if ((${#disks[@]} == 1)); then printf '%s' "${disks[0]}"; fi)"
[[ -b $DISK && " ${disks[*]} " == *" $DISK "* ]] && break
reject "Not one of the disks above." DISK
done
}
# --- Summary --------------------------------------------------------------------
show_summary() {
local net_summary
step "Summary"
if [[ $NET_DHCP == true ]]; then
net_summary="DHCP on $NET_IFACE ($NET_MAC)"
else
net_summary="$NET_V4 via $NET_V4_GW${NET_V6:+, $NET_V6 via $NET_V6_GW} on $NET_IFACE ($NET_MAC)"
fi
cat <<SUMMARY
Disk $DISK (everything on it is erased; btrfs, 2G swap file)
Network $net_summary
DNS $NET_DNS
Public IP $PUBLIC_IP
Hostname $HOST_NAME
SSH $ADMIN_USER@$PUBLIC_IP port $SSH_PORT ($(if [[ -n $SSH_KEY ]]; then echo "your key; password for the console"; else echo "password shown at the end"; fi))
Guest agent $(if [[ $QEMU_GUEST == true ]]; then echo yes; else echo no; fi)
Proxy user $PROXY_USER
Certificate ${DOMAIN:-$PUBLIC_IP (IP certificate)}${ACME_EMAIL:+, $ACME_EMAIL}
REALITY 443 as $REALITY_SNI
TLS / WS 8443 / 2053
SUMMARY
}
ask_all
while true; do
show_summary
if confirm_install; then
break
fi
ask_all
done
# --- Partition ------------------------------------------------------------------
step "Partitioning $DISK"
boot_disk=$(stable_disk_path "$DISK")
swapoff -a || true
umount -R "$MNT" 2>/dev/null || true
# The layout host.nix enables (services.proxy-suite-server.disko), mounted on $MNT.
disko --mode destroy,format,mount --yes-wipe-all-disks --root-mountpoint "$MNT" \
--argstr device "$boot_disk" "$PSI_DISK_LAYOUT"
# The filesystems and swap come from disko in host.nix, not from here.
nixos-generate-config --root "$MNT" --no-filesystems
rm -f "$MNT/etc/nixos/configuration.nix"
# Evaluating NixOS takes more memory than the smallest VPS plans have: the installed
# system's swap file, which disko made, serves the install too.
swapon "$MNT/swap/swapfile"
# --- Secrets --------------------------------------------------------------------
step "Generating keys"
install -d -m 0700 "$MNT$SECRETS_DIR"
keys=$(xray x25519)
# XRay prints "Private key:/Public key:", or from 25.x "PrivateKey:/Password (PublicKey):".
private_key=$(sed -n 's/^Private *[Kk]ey: *//p' <<<"$keys")
public_key=$(sed -n 's/^\(Public key\|Password (PublicKey)\|Password\): *//p' <<<"$keys" | head -n 1)
if [[ -z $private_key || -z $public_key ]]; then
warn "Could not read the output of xray x25519:"
printf '%s\n' "$keys" >&2
exit 1
fi
(
umask 077
xray uuid >"$MNT$SECRETS_DIR/uuid"
printf '%s\n' "$private_key" >"$MNT$SECRETS_DIR/reality-key"
)
# The SSH host keys, made here rather than by sshd on the first boot, so the first
# login (with the password, when no key was given) can be checked against them.
install -d -m 0755 "$MNT/etc/ssh"
ssh-keygen -q -t ed25519 -N "" -C "root@$HOST_NAME" -f "$MNT/etc/ssh/ssh_host_ed25519_key"
ssh-keygen -q -t rsa -b 4096 -N "" -C "root@$HOST_NAME" -f "$MNT/etc/ssh/ssh_host_rsa_key"
short_id=$(openssl rand -hex 8)
ws_path="/$(openssl rand -hex 6)"
# --- Configuration --------------------------------------------------------------
step "Writing /etc/nixos"
etc_nixos="$MNT/etc/nixos"
# Root's alone: it names the REALITY shortId and the WS path, which a local user could
# otherwise read and probe with.
install -m 0600 /dev/null "$etc_nixos/host.nix"
cat >"$etc_nixos/host.nix" <<HOST
# Written by proxy-suite-install on $(date -u +%Y-%m-%d). Edit it, then apply with:
# sudo nixos-rebuild switch --flake /etc/nixos
# Options: deploy/server-module.nix in the proxy-suite-flake repository.
{
networking.hostName = $(nix_str "$HOST_NAME");
time.timeZone = "UTC";
system.stateVersion = $(nix_str "$PSI_STATE_VERSION");
services.qemuGuest.enable = $QEMU_GUEST;
services.proxy-suite-server = {
enable = true;
bootDisk = $(nix_str "$boot_disk");
disko.enable = true;
adminUser = $(nix_str "$ADMIN_USER");
sshPort = $SSH_PORT;
sshKeys = [ $(if [[ -n $SSH_KEY ]]; then nix_str "$SSH_KEY"; fi) ];
$(print_network_nix " ")
publicAddress = $(nix_str "$PUBLIC_IP");
domain = $(if [[ -n $DOMAIN ]]; then nix_str "$DOMAIN"; else printf null; fi);
acmeEmail = $(if [[ -n $ACME_EMAIL ]]; then nix_str "$ACME_EMAIL"; else printf null; fi);
user = $(nix_str "$PROXY_USER");
reality = {
sni = $(nix_str "$REALITY_SNI");
publicKey = $(nix_str "$public_key");
shortId = $(nix_str "$short_id");
};
wsPath = $(nix_str "$ws_path");
};
}
HOST
write_flake() {
cat >"$etc_nixos/flake.nix" <<FLAKE
{
inputs = {
proxy-suite.url = $(nix_str "$1");
nixpkgs.follows = "proxy-suite/nixpkgs";
};
outputs =
{ nixpkgs, proxy-suite, ... }:
{
nixosConfigurations.$(nix_str "$HOST_NAME") = nixpkgs.lib.nixosSystem {
modules = [
proxy-suite.nixosModules.server
./hardware-configuration.nix
./host.nix
];
};
};
}
FLAKE
}
# Upstream on GitHub, locked to the ISO's commit, so `nix flake update` follows upstream
# later. Only if GitHub has that commit with the very source on this ISO: otherwise (not
# pushed, a dirty tree, a path: build) the source is copied next to the flake instead,
# so what is installed is always what the ISO carries.
flake_repo=github:FUFSoB/proxy-suite-flake
locked=false
if [[ -n $PSI_FLAKE_REV ]]; then
write_flake "$flake_repo/$PSI_FLAKE_REV"
if nix flake lock "$etc_nixos" &&
[[ $(jq -r '.nodes["proxy-suite"].locked.narHash' "$etc_nixos/flake.lock") == "$(nix hash path "$PSI_FLAKE_SRC")" ]]; then
# Unpinned in flake.nix, as `nix flake lock` would have left it had upstream been
# at this commit.
write_flake "$flake_repo"
jq '.nodes["proxy-suite"].original |= del(.rev)' "$etc_nixos/flake.lock" >"$etc_nixos/flake.lock.tmp"
mv "$etc_nixos/flake.lock.tmp" "$etc_nixos/flake.lock"
locked=true
else
warn "GitHub does not have this ISO's commit $PSI_FLAKE_REV; using the copy of proxy-suite on this ISO instead."
fi
fi
if [[ $locked == false ]]; then
rm -f "$etc_nixos/flake.lock"
cp -r --no-preserve=mode "$PSI_FLAKE_SRC" "$etc_nixos/proxy-suite"
write_flake "path:./proxy-suite"
nix flake lock "$etc_nixos"
fi
# --- Install --------------------------------------------------------------------
step "Installing (takes a few minutes)"
mkdir -p "$MNT/tmp"
TMPDIR="$MNT/tmp" nixos-install \
--root "$MNT" \
--flake "$etc_nixos#$HOST_NAME" \
--no-root-passwd \
--no-channel-copy
rm -rf "$MNT/tmp"
step "Setting the admin password"
# Four words: three of 4-6 letters and two digits come to some 40 bits, which SSH takes
# guesses against whenever no key was given.
password="$(xkcdpass -n 4 --min 4 --max 6 -d -)-$((RANDOM % 90 + 10))"
password=${password,,}
hash=$(mkpasswd -m yescrypt --stdin <<<"$password")
nixos-enter --root "$MNT" -- usermod -p "$hash" "$ADMIN_USER"
swapoff "$MNT/swap/swapfile"
# --- Done -----------------------------------------------------------------------
clear
bold "Installed."
cat <<DONE
SSH: ssh -p $SSH_PORT $ADMIN_USER@$PUBLIC_IP
User: $ADMIN_USER
Host keys (compare with what ssh shows on the first login):
$(for key in "$MNT"/etc/ssh/ssh_host_{ed25519,rsa}_key.pub; do printf ' %s\n' "$(ssh-keygen -lf "$key")"; done)
DONE
printf ' Password: \033[1;32m%s\033[0m\n\n' "$password"
cat <<DONE
Write the password down now: it is not stored anywhere readable.
Change it after logging in with: passwd
Share links, after the reboot (as $ADMIN_USER):
proxy-ctl inbounds link vless-reality --qr
proxy-ctl inbounds link vless-tls --qr
proxy-ctl inbounds link vless-ws --qr
The TLS and WS links work once the certificate is issued (a minute or two;
check with: systemctl status acme-order-renew-${DOMAIN:-$PUBLIC_IP}).
Configuration: /etc/nixos/host.nix, applied with
sudo nixos-rebuild switch --flake /etc/nixos
Network broken after the reboot? Log in here and run: sudo proxy-suite-net
Detach the ISO in the VPS panel so the server boots from its disk.
DONE
if [[ -z ${PSI_UNATTENDED-} ]]; then
read -r -p "Press Enter to reboot (Ctrl+C to stay in the installer)... " _ || true
umount -R "$MNT"
reboot
fi
+204
View File
@@ -0,0 +1,204 @@
# Installer ISO for a proxy-suite VPS (packages.<system>.installer-iso). Boots to the
# console installer on tty1; everything per server is asked there, nothing is baked in.
{ self, serverModule }:
{
config,
lib,
pkgs,
modulesPath,
...
}:
let
inherit (pkgs.stdenv.hostPlatform) system;
# The configuration the installer writes, with placeholders for what it asks. Its
# closure goes on the ISO, so installing downloads little and builds nothing big.
# Evaluated like the installed flake evaluates it, so the two share their store paths.
template = self.inputs.nixpkgs.lib.nixosSystem {
modules = [
serverModule
{
nixpkgs.hostPlatform = system;
networking.hostName = "proxy-template";
system.stateVersion = config.system.nixos.release;
# Asked by the installer, on by default.
services.qemuGuest.enable = true;
services.proxy-suite-server = {
enable = true;
bootDisk = "/dev/vda";
disko.enable = true;
network = {
mac = "52:54:00:00:00:01";
ipv4 = {
address = "192.0.2.1/24";
gateway = "192.0.2.254";
};
};
publicAddress = "192.0.2.1";
reality = {
publicKey = "template";
shortId = "0123456789abcdef";
};
wsPath = "/template";
};
}
];
};
# This flake's source without what a path: build picks up besides the tracked files.
flakeSource = lib.cleanSourceWith {
name = "source";
src = self;
filter =
path: type:
lib.cleanSourceFilter path type
&& !(lib.elem (baseNameOf path) [
"__pycache__"
".ruff_cache"
".direnv"
]);
};
# The sources of the flakes this one is locked to, so locking /etc/nixos finds them
# here. Non-flake inputs (z2k alone is 270M) are fetched when evaluation needs them,
# which the server never does.
inputSources =
flake:
lib.concatMap (input: [ input.outPath ] ++ inputSources input) (
lib.filter (input: input._type or null == "flake") (lib.attrValues (flake.inputs or { }))
);
# Tells ISOs apart: the commit, and a hash of the tree when it differs from it (dirty,
# or built from path:). The file name adds the build time.
treeId = builtins.substring 0 8 (builtins.hashString "sha256" self.narHash);
sourceId =
if self ? rev then
self.shortRev
else if self ? dirtyShortRev then
"${self.dirtyShortRev}-${treeId}"
else
treeId;
installer = pkgs.callPackage ./installer.nix {
xray = import ../pkgs/xray.nix { inherit pkgs; };
# Evaluates the layout against the nixpkgs source on the ISO, not a copy of it.
disko = self.inputs.disko.packages.${system}.disko.override {
path = self.inputs.nixpkgs.outPath;
};
diskLayout = ./disk-layout.nix;
# The installer pins this commit on GitHub when it holds what flakeSource does, and
# installs flakeSource itself otherwise (not pushed, dirty, or built from path:).
flakeRev = self.rev or "";
inherit flakeSource;
stateVersion = config.system.nixos.release;
};
in
{
imports = [ "${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix" ];
# The generic installer's extras, none of which a VPS console needs: rescue and disk
# tools with zfs and bcachefs (base.nix), a copy of nixpkgs as a channel, and the
# ISO's own configuration in /etc/nixos.
disabledModules = [
"profiles/base.nix"
"installer/cd-dvd/channel.nix"
"profiles/clone-config.nix"
];
isoImage = {
edition = "proxy-suite";
# The template's disko script brings the partitioning tools (btrfs-progs, sgdisk...).
storeContents = [
template.config.system.build.toplevel
template.config.system.build.diskoScript
flakeSource
]
++ lib.unique (inputSources self);
# Smaller than the default zstd, at the cost of a slower boot and build.
squashfsCompression =
"xz -Xdict-size 100%" + lib.optionalString pkgs.stdenv.hostPlatform.isx86 " -Xbcj x86";
};
image.baseName = lib.mkForce "proxy-suite-installer-${sourceId}-${system}";
# The ISO under a name with its build time. The store path keeps the plain name, so an
# unchanged ISO is not rebuilt and keeps its first build time.
system.build.installerIso = config.system.build.isoImage.overrideAttrs (old: {
buildCommandPath = pkgs.writeText "make-iso9660-image-stamped.sh" ''
isoName="proxy-suite-installer-$(date -u +%Y%m%d-%H%M)-${sourceId}-${system}.iso"
source ${old.buildCommandPath}
'';
});
# Smaller: no firmware (a VM needs none, 800M+), docs, RAID or memtest.
hardware.enableRedistributableFirmware = lib.mkForce false;
documentation = {
enable = lib.mkForce false;
man.enable = lib.mkForce false;
doc.enable = lib.mkForce false;
info.enable = lib.mkForce false;
nixos.enable = lib.mkForce false;
};
environment.defaultPackages = lib.mkForce [ ];
boot.swraid.enable = lib.mkForce false;
boot.loader.grub.memtest86.enable = lib.mkForce false;
# What the installer mounts: disko's ESP and btrfs.
boot.supportedFilesystems = [
"btrfs"
"vfat"
];
# The same stack the installed system uses, so settings tested here carry over.
networking = {
hostName = "proxy-suite-installer";
networkmanager.enable = lib.mkForce false;
wireless.enable = lib.mkForce false;
useNetworkd = true;
useDHCP = true;
};
systemd.network.wait-online.enable = false;
services.openssh.enable = lib.mkForce false;
# Lets the VPS panel see the installer's address.
services.qemuGuest.enable = true;
# No channel here (channel.nix is off): without this NIX_PATH still names root's
# channels, and every lookup warns that they do not exist. <nixpkgs> is the flake's.
nix.channel.enable = false;
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
# VNC consoles are small and blurry.
console = {
earlySetup = true;
font = "${pkgs.terminus_font}/share/consolefonts/ter-v24n.psf.gz";
packages = [ pkgs.terminus_font ];
};
# The installed server's shell and tools, which the template brings anyway.
programs.fish.enable = true;
users.defaultUserShell = pkgs.fish;
programs.vim.enable = true;
programs.git.enable = true;
environment.systemPackages = [
installer
(pkgs.callPackage ./net-rescue.nix { })
pkgs.htop
];
services.getty.helpLine = lib.mkForce ''
Proxy-suite installer. It starts on tty1; to run it again: sudo proxy-suite-install
'';
# Once, on tty1 only: other consoles (Alt+F2) stay plain shells. The console logs in
# as nixos, which has passwordless sudo.
programs.fish.interactiveShellInit = ''
if test (tty) = /dev/tty1; and not test -e /tmp/.proxy-suite-install-started
touch /tmp/.proxy-suite-install-started
sudo proxy-suite-install
end
'';
}
+394
View File
@@ -0,0 +1,394 @@
# Network prompts shared by proxy-suite-install and proxy-suite-net. The answers are
# applied through a systemd-networkd file in /run, the same way the installed system
# applies them from /etc, so settings that work here work after the reboot.
#
# Sets NET_IFACE NET_MAC NET_DHCP NET_V4 NET_V4_GW NET_V6 NET_V6_GW NET_DNS. A wrong
# answer asks that question again. Unattended runs (PSI_UNATTENDED=1) take every answer
# from PSI_<NAME> and fail instead of re-asking.
NET_RUNTIME_FILE=/run/systemd/network/05-proxy-suite-net.network
say() { printf '%s\n' "$*"; }
warn() { printf '\033[1;33m%s\033[0m\n' "$*" >&2; }
bold() { printf '\033[1m%s\033[0m\n' "$*"; }
# Answers given so far, by VAR: asking VAR again offers the last answer as the default.
# With ANSWERS_FILE set (load_answers), they also outlive the run.
declare -A REMEMBERED=()
ANSWERS_FILE=""
# load_answers FILE: keep answers in FILE, starting from those it already holds.
# Succeeds only if it held some.
load_answers() {
ANSWERS_FILE=$1
[[ -s $ANSWERS_FILE ]] || return 1
# shellcheck source=/dev/null
source "$ANSWERS_FILE"
}
save_answers() {
local name
[[ -n $ANSWERS_FILE ]] || return 0
install -d -m 0700 "$(dirname "$ANSWERS_FILE")"
for name in "${!REMEMBERED[@]}"; do
printf 'REMEMBERED[%s]=%q\n' "$name" "${REMEMBERED[$name]}"
done >"$ANSWERS_FILE.tmp"
mv "$ANSWERS_FILE.tmp" "$ANSWERS_FILE"
}
forget() {
local name
for name in "$@"; do unset "REMEMBERED[$name]"; done
save_answers
}
# ask VAR "Question" [default]. PSI_<VAR> in the environment answers it unattended.
# An earlier answer replaces the default. An empty default makes the question
# optional: "-" answers it with nothing even when an earlier answer is offered.
ask() {
local __preset="PSI_$1" __reply __default=${3-} __hint __optional=false
if [[ -n ${!__preset+x} ]]; then
__reply=${!__preset}
[[ -n $__reply ]] || __reply=$__default
printf -v "$1" '%s' "$__reply"
return 0
fi
if [[ -n ${3+x} && -z $3 ]]; then
__optional=true
fi
# Unattended never reads stdin, where it would hang on a terminal or take the default
# unseen: a missing answer takes the default, and a question without one fails.
if [[ -n ${PSI_UNATTENDED-} ]]; then
if [[ -z $__default && $__optional == false ]]; then
warn "PSI_UNATTENDED: $__preset is not set, and \"$2\" has no default."
exit 1
fi
printf -v "$1" '%s' "$__default"
return 0
fi
if [[ -n ${REMEMBERED[$1]-} ]]; then
__default=${REMEMBERED[$1]}
fi
__hint=$__default
if [[ $__optional == true && -n $__default ]]; then
__hint+=", - for none"
fi
if [[ -n $__hint ]]; then
read -r -p "$2 [$__hint]: " __reply || true
else
read -r -p "$2: " __reply || true
fi
if [[ $__optional == true && $__reply == - ]]; then
__reply=""
elif [[ -z $__reply ]]; then
__reply=$__default
fi
REMEMBERED[$1]=$__reply
save_answers
printf -v "$1" '%s' "$__reply"
}
# ask_yes VAR "Question" y|n; sets VAR to true or false.
ask_yes() {
local __yn
while true; do
ask "$1" "$2 (y/n)" "$3"
__yn=${!1}
case ${__yn,,} in
y | yes | true)
printf -v "$1" '%s' true
return 0
;;
n | no | false)
printf -v "$1" '%s' false
return 0
;;
esac
reject "Answer y or n." "$1"
done
}
# retry MESSAGE VAR...: ask VARs again, offering the answers just given; unattended,
# give up instead.
retry() {
warn "$1"
shift
if [[ -n ${PSI_UNATTENDED-} ]]; then
exit 1
fi
local name
for name in "$@"; do unset "PSI_$name"; done
}
# reject MESSAGE VAR...: like retry, but the answers are wrong, so they are not offered.
reject() {
retry "$@"
shift
forget "$@"
}
is_ipv4() {
local IFS=. octet
# No leading zeros: bash would read 010 as octal, networkd as written.
[[ $1 =~ ^(0|[1-9][0-9]{0,2})(\.(0|[1-9][0-9]{0,2})){3}$ ]] || return 1
for octet in $1; do ((octet <= 255)) || return 1; done
}
is_ipv6() { [[ $1 == *:* && $1 =~ ^[0-9A-Fa-f:.]+$ ]]; }
is_dns_list() {
local dns count=0
for dns in $1; do
is_ipv4 "$dns" || is_ipv6 "$dns" || return 1
count=$((count + 1))
done
((count > 0))
}
mask_to_prefix() {
local mask=$1 IFS=. octet bits=0
if [[ $mask =~ ^[0-9]+$ ]]; then
[[ $mask =~ ^(0|[1-9][0-9]?)$ ]] && ((mask <= 32)) && printf '%s' "$mask" && return 0
return 1
fi
is_ipv4 "$mask" || return 1
for octet in $mask; do
case $octet in
255) bits=$((bits + 8)) ;;
254) bits=$((bits + 7)) ;;
252) bits=$((bits + 6)) ;;
248) bits=$((bits + 5)) ;;
240) bits=$((bits + 4)) ;;
224) bits=$((bits + 3)) ;;
192) bits=$((bits + 2)) ;;
128) bits=$((bits + 1)) ;;
0) ;;
*) return 1 ;;
esac
done
printf '%s' "$bits"
}
ipv4_to_int() {
local IFS=. a b c d
read -r a b c d <<<"$1"
printf '%s' $(((a << 24) | (b << 16) | (c << 8) | d))
}
# ipv4_in_subnet ADDR/PREFIX GATEWAY
ipv4_in_subnet() {
local addr=${1%/*} prefix=${1#*/} mask
mask=$(((0xffffffff << (32 - prefix)) & 0xffffffff))
[[ $(($(ipv4_to_int "$addr") & mask)) == $(($(ipv4_to_int "$2") & mask)) ]]
}
# Private, CGNAT or otherwise unroutable: clients cannot reach it, and no CA will
# issue a certificate for it.
ipv4_is_private() {
local n
n=$(ipv4_to_int "$1")
(((n >> 24) == 10)) ||
(((n >> 24) == 127)) ||
(((n >> 20) == (172 << 4 | 1))) ||
(((n >> 16) == (192 << 8 | 168))) ||
(((n >> 22) == (100 << 2 | 1))) ||
(((n >> 16) == (169 << 8 | 254)))
}
# Physical interfaces only: no lo, bridges or veths.
physical_ifaces() {
local path
for path in /sys/class/net/*; do
if [[ -e $path/device ]]; then
printf '%s\n' "${path##*/}"
fi
done
}
list_ifaces() {
local name
bold "Network interfaces:"
while IFS= read -r name; do
printf ' %-12s mac %s state %s\n' "$name" "$(cat "/sys/class/net/$name/address")" \
"$(cat "/sys/class/net/$name/operstate")"
ip -o addr show dev "$name" | awk '{ printf " %s %s%s\n", $3, $4, (/dynamic/ ? " (dhcp)" : "") }'
done < <(physical_ifaces)
ip route show default | sed 's/^/ route: /'
ip -6 route show default | sed 's/^/ route: /'
}
ask_network() {
local ifaces default_iface has_lease NET_ADDR NET_MASK prefix NET_V6_IN
mapfile -t ifaces < <(physical_ifaces)
if ((${#ifaces[@]} == 0)); then
warn "No network interface found."
return 1
fi
default_iface=$(ip route show default | awk '{ for (i = 1; i < NF; i++) if ($i == "dev") { print $(i + 1); exit } }')
[[ -n $default_iface ]] || default_iface=${ifaces[0]}
list_ifaces
while true; do
ask NET_IFACE "Interface" "$default_iface"
[[ -e /sys/class/net/$NET_IFACE/address ]] && break
reject "No interface named '$NET_IFACE'." NET_IFACE
done
NET_MAC=$(cat "/sys/class/net/$NET_IFACE/address")
has_lease=n
ip -4 -o addr show dev "$NET_IFACE" | grep -q dynamic && has_lease=y
say ""
say "Most VPS panels list a static IP, netmask (or prefix) and gateway: use those."
say "Answer y only if the provider says the server gets its address over DHCP."
ask_yes NET_DHCP "Use DHCP" "$has_lease"
NET_V4="" NET_V4_GW="" NET_V6="" NET_V6_GW=""
if [[ $NET_DHCP == false ]]; then
while true; do
ask NET_ADDR "IPv4 address (203.0.113.10/24, or without /prefix)"
if [[ $NET_ADDR == */* ]]; then
prefix=${NET_ADDR#*/} NET_ADDR=${NET_ADDR%/*}
else
ask NET_MASK "Netmask or prefix length (255.255.255.0 or 24)" "24"
prefix=$(mask_to_prefix "$NET_MASK") || prefix=""
fi
if is_ipv4 "$NET_ADDR" && [[ $prefix =~ ^[0-9]+$ ]] && ((prefix >= 1 && prefix <= 32)); then
NET_V4="$NET_ADDR/$prefix"
break
fi
reject "Not an IPv4 address with a valid netmask." NET_ADDR NET_MASK
done
while true; do
ask NET_V4_GW "IPv4 gateway"
is_ipv4 "$NET_V4_GW" && break
reject "Not an IPv4 address." NET_V4_GW
done
if ! ipv4_in_subnet "$NET_V4" "$NET_V4_GW"; then
say "Gateway $NET_V4_GW is outside $NET_V4: it is routed on-link, as providers with /32 addresses expect."
fi
while true; do
ask NET_V6_IN "IPv6 address with prefix (empty to skip)" ""
[[ -n $NET_V6_IN ]] || break
[[ $NET_V6_IN == */* ]] || NET_V6_IN="$NET_V6_IN/64"
prefix=${NET_V6_IN#*/}
if is_ipv6 "${NET_V6_IN%/*}" && [[ $prefix =~ ^[0-9]+$ ]] && ((prefix >= 1 && prefix <= 128)); then
NET_V6=$NET_V6_IN
break
fi
reject "Not an IPv6 address with a valid prefix." NET_V6_IN
done
if [[ -n $NET_V6 ]]; then
while true; do
ask NET_V6_GW "IPv6 gateway" "fe80::1"
is_ipv6 "$NET_V6_GW" && break
reject "Not an IPv6 address." NET_V6_GW
done
fi
fi
while true; do
ask NET_DNS "DNS servers (space-separated)" "1.1.1.1 8.8.8.8"
is_dns_list "$NET_DNS" && break
reject "One or more IPv4 or IPv6 addresses, separated by spaces." NET_DNS
done
}
# Mirrors the systemd.network config of deploy/server-module.nix.
write_networkd() {
local file=$1 dns gw
{
printf '[Match]\nMACAddress=%s\nType=ether\n\n' "$NET_MAC"
printf '[Link]\nRequiredForOnline=routable\n\n'
printf '[Network]\n'
if [[ $NET_DHCP == true ]]; then
printf 'DHCP=yes\n'
else
printf 'DHCP=no\n'
if [[ -n $NET_V6 ]]; then
printf 'IPv6AcceptRA=no\nAddress=%s\n' "$NET_V6"
fi
printf 'Address=%s\n' "$NET_V4"
fi
for dns in $NET_DNS; do printf 'DNS=%s\n' "$dns"; done
if [[ $NET_DHCP == false ]]; then
for gw in "$NET_V4_GW" "$NET_V6_GW"; do
if [[ -n $gw ]]; then
printf '\n[Route]\nGateway=%s\nGatewayOnLink=yes\n' "$gw"
fi
done
fi
} >"$file"
}
apply_network() {
mkdir -p "$(dirname "$NET_RUNTIME_FILE")"
write_networkd "$NET_RUNTIME_FILE"
networkctl reload
networkctl reconfigure "$NET_IFACE"
for _ in {1..30}; do
ip -4 route show default dev "$NET_IFACE" | grep -q . && return 0
sleep 1
done
warn "No IPv4 default route on $NET_IFACE after 30 seconds."
return 1
}
# Each step names what failed, so a wrong gateway is told apart from a wrong DNS.
test_network() {
local gw
gw=$(ip -4 route show default dev "$NET_IFACE" | awk '{ print $3; exit }')
say "Testing the network..."
if [[ -n $gw ]] && ! ping -c 2 -W 2 "$gw" >/dev/null 2>&1; then
warn " gateway $gw does not answer ping (some providers block it; continuing)"
fi
if ! ping -c 2 -W 3 1.1.1.1 >/dev/null 2>&1 && ! curl -s -o /dev/null --max-time 8 http://1.1.1.1; then
warn " cannot reach the internet (1.1.1.1): check the address, netmask and gateway"
return 1
fi
if ! getent ahosts cache.nixos.org >/dev/null; then
warn " internet works but DNS does not: check the DNS servers"
return 1
fi
if ! curl -s -o /dev/null --max-time 15 https://cache.nixos.org/nix-cache-info; then
warn " cannot fetch https://cache.nixos.org"
return 1
fi
say " network OK"
}
setup_network() {
while true; do
ask_network || return 1
if apply_network && test_network; then
return 0
fi
retry "Network settings did not work; enter them again." \
NET_IFACE NET_DHCP NET_ADDR NET_MASK NET_V4_GW NET_V6_IN NET_V6_GW NET_DNS
done
}
# nix_str VALUE: VALUE as a Nix string literal.
nix_str() {
local s=${1//\\/\\\\}
s=${s//\"/\\\"}
s=${s//\$\{/\\\$\{}
printf '"%s"' "$s"
}
# The services.proxy-suite-server.network block for host.nix, indented by $1.
print_network_nix() {
local pad=$1 dns list=""
for dns in $NET_DNS; do list+=" $(nix_str "$dns")"; done
printf '%snetwork = {\n' "$pad"
printf '%s mac = %s;\n' "$pad" "$(nix_str "$NET_MAC")"
printf '%s dhcp = %s;\n' "$pad" "$NET_DHCP"
if [[ $NET_DHCP == false && -n $NET_V4 ]]; then
printf '%s ipv4 = { address = %s; gateway = %s; };\n' "$pad" "$(nix_str "$NET_V4")" "$(nix_str "$NET_V4_GW")"
fi
if [[ $NET_DHCP == false && -n $NET_V6 ]]; then
printf '%s ipv6 = { address = %s; gateway = %s; };\n' "$pad" "$(nix_str "$NET_V6")" "$(nix_str "$NET_V6_GW")"
fi
printf '%s dns = [%s ];\n' "$pad" "$list"
printf '%s};\n' "$pad"
}
+31
View File
@@ -0,0 +1,31 @@
# proxy-suite-net: re-enter the uplink settings from the console of an installed server
# whose network does not come up.
{
lib,
writeShellApplication,
coreutils,
curl,
gawk,
getent,
gnugrep,
gnused,
iproute2,
iputils,
systemd,
}:
import ./script.nix { inherit lib writeShellApplication; } {
name = "proxy-suite-net";
script = ./net-rescue.sh;
runtimeInputs = [
coreutils
curl
gawk
getent
gnugrep
gnused
iproute2
iputils
systemd
];
}
+50
View File
@@ -0,0 +1,50 @@
# proxy-suite-net: fix the network from the console when the installed settings do
# not work. The fix lives in /run until the next reboot; persist it in host.nix.
usage() {
cat <<USAGE
Usage: proxy-suite-net [--show | --reset]
(no argument) ask for new network settings and apply them until the next reboot
--show show interfaces, routes and the temporary settings, if any
--reset drop the temporary settings and go back to the configured ones
USAGE
}
if [[ $(id -u) != 0 ]]; then
echo "proxy-suite-net: run it as root (sudo proxy-suite-net)" >&2
exit 1
fi
case ${1-} in
-h | --help)
usage
;;
--show)
list_ifaces
if [[ -e $NET_RUNTIME_FILE ]]; then
bold "Temporary settings ($NET_RUNTIME_FILE):"
cat "$NET_RUNTIME_FILE"
fi
;;
--reset)
rm -f "$NET_RUNTIME_FILE"
networkctl reload
mapfile -t ifaces < <(physical_ifaces)
networkctl reconfigure "${ifaces[@]}"
say "Temporary settings dropped."
;;
"")
setup_network
bold "Network works. These settings last until the next reboot."
say "To keep them, replace the network block in /etc/nixos/host.nix with:"
say ""
print_network_nix " "
say ""
say "then run: sudo nixos-rebuild switch --flake /etc/nixos && sudo proxy-suite-net --reset"
;;
*)
usage >&2
exit 1
;;
esac
+16
View File
@@ -0,0 +1,16 @@
# The console helpers are net-lib.sh plus one front end, wrapped with the tools they call.
{ lib, writeShellApplication }:
{
name,
script,
runtimeInputs,
runtimeEnv ? { },
}:
writeShellApplication {
inherit name runtimeInputs runtimeEnv;
text = lib.concatStringsSep "\n" [
(builtins.readFile ./net-lib.sh)
(builtins.readFile script)
];
}
+464
View File
@@ -0,0 +1,464 @@
# A single-user VLESS server on a VPS: REALITY, TLS and WS+TLS inbounds, ACME
# certificates (for the domain, or the bare IP), SSH, and networking pinned to the
# uplink's MAC. Written for the installer ISO (deploy/iso.nix), which fills in
# host.nix, but usable on its own.
{ proxySuiteModule, diskoModule }:
{
config,
lib,
pkgs,
modulesPath,
...
}:
let
inherit (lib) mkOption types;
cfg = config.services.proxy-suite-server;
net = cfg.network;
certName = if cfg.domain != null then cfg.domain else cfg.publicAddress;
certDir = "/var/lib/acme/${certName}";
nullable =
type: description:
mkOption {
type = types.nullOr type;
default = null;
inherit description;
};
addressType = types.submodule {
options = {
address = mkOption {
type = types.str;
description = "Address with prefix length, e.g. 203.0.113.10/24.";
example = "203.0.113.10/24";
};
gateway = mkOption {
type = types.str;
description = "Default gateway. Reached on-link, so it may lie outside the subnet.";
example = "203.0.113.1";
};
};
};
user = [ cfg.user ];
tls = {
enable = true;
certificateFile = "${certDir}/fullchain.pem";
keyFile = "${certDir}/key.pem";
};
in
{
imports = [
proxySuiteModule
diskoModule
"${modulesPath}/profiles/qemu-guest.nix"
];
options.services.proxy-suite-server = {
enable = lib.mkEnableOption "the single-user VPS server profile";
adminUser = mkOption {
type = types.strMatching "[a-z_][a-z0-9_-]*";
default = "admin";
description = "Login user in wheel. Its password is set imperatively (passwd), not here.";
};
sshPort = mkOption {
type = types.port;
default = 22;
description = "SSH port.";
};
sshKeys = mkOption {
type = types.listOf (types.strMatching "(ssh-|ecdsa-sha2-|sk-)[^\n]+");
default = [ ];
description = ''
Public keys adminUser logs in with over SSH. With any, SSH takes no passwords (the
console still does); without, it takes the password, and fail2ban bans guessers.
'';
example = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA... admin@laptop" ];
};
tools.enable = mkOption {
type = types.bool;
default = true;
description = ''
Admin comforts: fish as the login shell, vim next to nano (still the default
editor), and git, htop, tmux, jq, mtr, iftop, dig, ncdu, iperf3, tcpdump,
bandwhich, nload, lsof and nvd.
'';
};
bootDisk = mkOption {
type = types.str;
description = "Disk GRUB installs its BIOS stage to.";
example = "/dev/vda";
};
disko = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Lay out bootDisk with disko (deploy/disk-layout.nix): a BIOS boot partition, a
512M ESP on /boot, and btrfs (compress=zstd:3) with subvolumes @ on /, @nix,
@varlog on /var/log, @home, and @swap holding a swap file. The filesystems then
come from here, not hardware-configuration.nix. Off for servers installed
before it, whose ext4 root hardware-configuration.nix mounts.
'';
};
swapSize = mkOption {
type = types.str;
default = "2G";
description = "Size of the swap file in the swap subvolume.";
};
};
network = {
mac = mkOption {
type = types.strMatching "([0-9a-f]{2}:){5}[0-9a-f]{2}";
description = "MAC address of the uplink; matched instead of a name, which can change between kernels.";
example = "52:54:00:12:34:56";
};
dhcp = mkOption {
type = types.bool;
default = false;
description = "Take IPv4 from DHCP (and IPv6 from RA) instead of ipv4/ipv6.";
};
ipv4 = nullable addressType "Static IPv4.";
ipv6 = nullable addressType "Static IPv6.";
dns = mkOption {
type = types.listOf types.str;
default = [
"1.1.1.1"
"8.8.8.8"
];
description = "DNS servers.";
};
};
publicAddress = mkOption {
type = types.strMatching "([0-9]{1,3}\\.){3}[0-9]{1,3}";
description = "Public IPv4 clients connect to; the certificate is issued for it when domain is null.";
example = "203.0.113.10";
};
domain = nullable (types.strMatching "[A-Za-z0-9.-]+") "Domain pointing at publicAddress. Null gets a short-lived Let's Encrypt certificate for the IP itself.";
acmeEmail = nullable types.str "ACME account email.";
user = mkOption {
type = types.strMatching "[A-Za-z0-9_.-]+";
default = "user";
description = "Proxy user name: the label of its share links.";
};
secretsDir = mkOption {
type = types.str;
default = "/var/lib/proxy-suite-server";
description = "Holds `uuid` and `reality-key` (the x25519 private key).";
};
reality = {
sni = mkOption {
type = types.str;
default = "www.microsoft.com";
description = "Site REALITY impersonates; must serve TLS 1.3 and HTTP/2 on 443.";
};
publicKey = mkOption {
type = types.str;
description = "x25519 public key matching secretsDir/reality-key.";
};
shortId = mkOption {
type = types.strMatching "[0-9a-f]{0,16}";
description = "REALITY short id.";
};
};
wsPath = mkOption {
type = types.strMatching "/[A-Za-z0-9/_-]*";
description = "Path of the WS listener.";
example = "/3f9a1c07b2e4";
};
onion.enable = mkOption {
type = types.bool;
default = false;
description = ''
Also serve the listeners as a Tor onion service, for clients that cannot reach
publicAddress. Its address is kept in /var/lib/proxy-suite/tor/onion; the links
to it come from `proxy-ctl inbounds link <tag> --onion`.
'';
};
ports = {
reality = mkOption {
type = types.port;
default = 443;
description = "VLESS REALITY port.";
};
tls = mkOption {
type = types.port;
default = 8443;
description = "VLESS TLS port.";
};
ws = mkOption {
type = types.port;
default = 2053;
description = "VLESS WS+TLS port (one Cloudflare proxies).";
};
};
};
config = lib.mkIf cfg.enable {
# Two listeners on one port: whichever binds second fails, and with it SSH may go.
assertions = [
{
assertion =
let
taken = [
80
cfg.sshPort
cfg.ports.reality
cfg.ports.tls
cfg.ports.ws
];
in
lib.unique taken == taken;
message = "proxy-suite server: sshPort, ports.reality, ports.tls, ports.ws and 80 (ACME) must all differ";
}
];
disko.devices =
lib.mkIf cfg.disko.enable
(import ./disk-layout.nix {
device = cfg.bootDisk;
inherit (cfg.disko) swapSize;
}).disko.devices;
boot.loader.grub = {
enable = true;
# disko lists the disk with the BIOS boot partition itself; twice fails an assertion.
device = lib.mkIf (!cfg.disko.enable) cfg.bootDisk;
# BIOS stage on the disk, EFI stage at the removable path: boots either way,
# and needs no NVRAM entry the VPS may not keep.
efiSupport = true;
efiInstallAsRemovable = true;
};
boot.growPartition = true;
networking = {
useDHCP = false;
useNetworkd = true;
firewall.enable = true;
firewall.allowedTCPPorts = [ 80 ];
nameservers = net.dns;
};
systemd.network = {
enable = true;
networks."10-uplink" = {
matchConfig.MACAddress = net.mac;
# Some drivers clone the MAC onto helper links; bind the real NIC only.
matchConfig.Type = "ether";
networkConfig = {
DHCP = if net.dhcp then "yes" else "no";
IPv6AcceptRA = net.dhcp || net.ipv6 == null;
};
address = lib.optionals (!net.dhcp) (
lib.optional (net.ipv4 != null) net.ipv4.address ++ lib.optional (net.ipv6 != null) net.ipv6.address
);
routes = lib.optionals (!net.dhcp) (
map (a: {
Gateway = a.gateway;
GatewayOnLink = true;
}) (lib.optional (net.ipv4 != null) net.ipv4 ++ lib.optional (net.ipv6 != null) net.ipv6)
);
linkConfig.RequiredForOnline = "routable";
};
};
services.openssh = {
enable = true;
ports = [ cfg.sshPort ];
settings = {
PasswordAuthentication = cfg.sshKeys == [ ];
KbdInteractiveAuthentication = false;
PermitRootLogin = "no";
# The one login this server has: an account some package adds later gets no SSH.
AllowUsers = [ cfg.adminUser ];
MaxAuthTries = 3;
X11Forwarding = false;
};
};
users.mutableUsers = true;
users.users.${cfg.adminUser} = {
isNormalUser = true;
extraGroups = [ "wheel" ];
openssh.authorizedKeys.keys = cfg.sshKeys;
};
boot.kernel.sysctl = {
"net.core.default_qdisc" = "fq";
"net.ipv4.tcp_congestion_control" = "bbr";
};
zramSwap.enable = true;
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
# A small disk left alone for months: old generations, store duplicates and logs are
# cleaned up, not collected until it is full.
nix.gc = {
automatic = lib.mkDefault true;
dates = lib.mkDefault "weekly";
options = lib.mkDefault "--delete-older-than 14d";
};
nix.optimise.automatic = lib.mkDefault true;
boot.loader.grub.configurationLimit = lib.mkDefault 10;
services.journald.settings.Journal.SystemMaxUse = lib.mkDefault "200M";
# Password logins on a public address: repeated failures get the address banned
# (the sshd jail follows sshPort), for longer each time it comes back.
services.fail2ban = {
enable = lib.mkDefault true;
bantime-increment.enable = lib.mkDefault true;
};
# Traffic per day and month, against the plan's quota: vnstat -m.
services.vnstat.enable = lib.mkDefault true;
security.acme = {
acceptTerms = true;
defaults.email = cfg.acmeEmail;
certs.${certName} = {
domain = certName;
listenHTTP = ":80";
group = "proxy-suite-daemon";
reloadServices = [ "proxy-suite-inbounds" ];
}
// lib.optionalAttrs (cfg.domain == null) {
# IP certificates come only from the six-day profile; check twice a day.
profile = "shortlived";
renewInterval = "*-*-* 00,12:00:00";
};
};
# A self-signed placeholder is in place before the first order, so REALITY does
# not wait on ACME, and the order's success restarts the listeners.
systemd.services.proxy-suite-inbounds = {
wants = [ "acme-${certName}.service" ];
after = [ "acme-${certName}.service" ];
};
services.proxy-suite = {
enable = true;
proxy.enable = false;
tor = lib.mkIf cfg.onion.enable {
enable = true;
onionService.enable = true;
};
userControl = {
enable = true;
group = "wheel";
};
inbounds = {
enable = true;
users.${cfg.user}.uuidFile = "${cfg.secretsDir}/uuid";
serverAddress = certName;
routing.via = "direct";
listeners = {
vless-reality = {
type = "vless";
port = cfg.ports.reality;
users = user;
flow = "xtls-rprx-vision";
reality = {
enable = true;
dest = "${cfg.reality.sni}:443";
serverNames = [ cfg.reality.sni ];
privateKeyFile = "${cfg.secretsDir}/reality-key";
inherit (cfg.reality) publicKey;
shortIds = [ cfg.reality.shortId ];
};
};
vless-tls = {
type = "vless";
port = cfg.ports.tls;
users = user;
flow = "xtls-rprx-vision";
inherit tls;
};
vless-ws = {
type = "vless";
port = cfg.ports.ws;
users = user;
transport = {
type = "ws";
path = cfg.wsPath;
};
inherit tls;
};
};
};
};
services.getty.helpLine = ''
proxy-suite server ${certName}. Share links (as ${cfg.adminUser}):
proxy-ctl inbounds link vless-reality --qr (or vless-tls, vless-ws)
''
+ lib.optionalString cfg.onion.enable " proxy-ctl inbounds link vless-reality --onion --qr (through Tor)\n"
+ ''
Network down? Log in and run: sudo proxy-suite-net
'';
environment.systemPackages = [
pkgs.qrencode
(pkgs.callPackage ./net-rescue.nix { })
]
++ lib.optionals cfg.tools.enable [
pkgs.htop
pkgs.jq
pkgs.iftop
pkgs.dig
pkgs.ncdu
pkgs.iperf3
pkgs.tcpdump
pkgs.nload
pkgs.lsof
pkgs.nvd
];
programs = lib.mkIf cfg.tools.enable {
fish.enable = true;
# Next to nano, which stays the default editor.
vim.enable = true;
git.enable = true;
tmux.enable = true;
mtr.enable = true;
# Bandwidth per process and connection, without sudo (a capability wrapper).
bandwhich.enable = true;
};
# Wheel only: the wrapper's capabilities (sys_ptrace, dac_read_search, net_raw) show
# every connection on the host, the proxy users' included, to whoever runs it.
security.wrappers = lib.mkIf cfg.tools.enable {
bandwhich = {
group = lib.mkForce "wheel";
permissions = "u+rx,g+x";
};
};
users.defaultUserShell = lib.mkIf cfg.tools.enable pkgs.fish;
# Man pages stay; the NixOS manual, info and HTML docs are a download no server needs.
documentation = {
doc.enable = lib.mkDefault false;
info.enable = lib.mkDefault false;
nixos.enable = lib.mkDefault false;
};
};
}
-4775
View File
File diff suppressed because it is too large. Load diff
+618
View File
@@ -0,0 +1,618 @@
# services.proxy-suite.amneziaWg
AmneziaWG client profiles, as a global VPN or as outbounds.
Part of the [proxy-suite options reference](./index.md).
## Options
- amneziaWg
- [enable](#services-proxy-suite-amneziawg-enable)
- [kernelModulePackage](#services-proxy-suite-amneziawg-kernelmodulepackage)
- [profiles](#services-proxy-suite-amneziawg-profiles)
- `<name>`
- [allowConfigHooks](#services-proxy-suite-amneziawg-profiles-name-allowconfighooks)
- [asOutbound](#services-proxy-suite-amneziawg-profiles-name-asoutbound)
- [autostart](#services-proxy-suite-amneziawg-profiles-name-autostart)
- [configFile](#services-proxy-suite-amneziawg-profiles-name-configfile)
- [domainStrategy](#services-proxy-suite-amneziawg-profiles-name-domainstrategy)
- [endpoint](#services-proxy-suite-amneziawg-profiles-name-endpoint)
- [interfaceName](#services-proxy-suite-amneziawg-profiles-name-interfacename)
- [settings](#services-proxy-suite-amneziawg-profiles-name-settings)
- [addresses](#services-proxy-suite-amneziawg-profiles-name-settings-addresses)
- [dns](#services-proxy-suite-amneziawg-profiles-name-settings-dns)
- [listenPort](#services-proxy-suite-amneziawg-profiles-name-settings-listenport)
- [mtu](#services-proxy-suite-amneziawg-profiles-name-settings-mtu)
- [obfuscation](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation)
- [contentPaddingAddition](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-contentpaddingaddition)
- [disableCookies](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-disablecookies)
- [h1](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-h1)
- [h2](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-h2)
- [h3](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-h3)
- [h4](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-h4)
- [headerProtectionKey](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-headerprotectionkey)
- [headerProtectionKeyFile](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-headerprotectionkeyfile)
- [i1](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-i1)
- [i2](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-i2)
- [i3](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-i3)
- [i4](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-i4)
- [i5](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-i5)
- [jc](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-jc)
- [jmax](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-jmax)
- [jmin](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-jmin)
- [keepaliveTimeout](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-keepalivetimeout)
- [maxHandshakeAttempts](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-maxhandshakeattempts)
- [randomTrailers](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-randomtrailers)
- [rejectAfterTime](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-rejectaftertime)
- [rekeyAfterTime](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-rekeyaftertime)
- [rekeyTimeout](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-rekeytimeout)
- [s1](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-s1)
- [s2](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-s2)
- [s3](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-s3)
- [s4](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-s4)
- [obfuscationFile](#services-proxy-suite-amneziawg-profiles-name-settings-obfuscationfile)
- [peers](#services-proxy-suite-amneziawg-profiles-name-settings-peers)
- item
- [advancedSecurity](#services-proxy-suite-amneziawg-profiles-name-settings-peers-advancedsecurity)
- [allowedIPs](#services-proxy-suite-amneziawg-profiles-name-settings-peers-allowedips)
- [endpoint](#services-proxy-suite-amneziawg-profiles-name-settings-peers-endpoint)
- [persistentKeepalive](#services-proxy-suite-amneziawg-profiles-name-settings-peers-persistentkeepalive)
- [presharedKey](#services-proxy-suite-amneziawg-profiles-name-settings-peers-presharedkey)
- [presharedKeyFile](#services-proxy-suite-amneziawg-profiles-name-settings-peers-presharedkeyfile)
- [publicKey](#services-proxy-suite-amneziawg-profiles-name-settings-peers-publickey)
- [privateKey](#services-proxy-suite-amneziawg-profiles-name-settings-privatekey)
- [privateKeyFile](#services-proxy-suite-amneziawg-profiles-name-settings-privatekeyfile)
- [table](#services-proxy-suite-amneziawg-profiles-name-settings-table)
- [vpn](#services-proxy-suite-amneziawg-profiles-name-vpn)
- [vpnContainer](#services-proxy-suite-amneziawg-profiles-name-vpncontainer)
- [vpnFile](#services-proxy-suite-amneziawg-profiles-name-vpnfile)
- runtime
- [enable](#services-proxy-suite-amneziawg-runtime-enable)
- [interfaceName](#services-proxy-suite-amneziawg-runtime-interfacename)
- [outboundKind](#services-proxy-suite-amneziawg-runtime-outboundkind)
- [serverUdpPorts](#services-proxy-suite-amneziawg-serverudpports)
- [toolsPackage](#services-proxy-suite-amneziawg-toolspackage)
- [userspacePackage](#services-proxy-suite-amneziawg-userspacepackage)
- [wireproxyPackage](#services-proxy-suite-amneziawg-wireproxypackage)
<a id="services-proxy-suite-amneziawg-enable"></a>
## services\.proxy-suite\.amneziaWg\.enable
Whether to enable AmneziaWG client profiles\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-amneziawg-kernelmodulepackage"></a>
## services\.proxy-suite\.amneziaWg\.kernelModulePackage
AWG 3\.1 kernel module package\. ` null `: userspace only\.
**Type:** null or package\
**Default:** ` amneziawg ` from ` boot.kernelPackages ` on NixOS, ` null ` elsewhere
<a id="services-proxy-suite-amneziawg-profiles"></a>
## services\.proxy-suite\.amneziaWg\.profiles
AmneziaWG client profiles, by name\. Each sets exactly one of ` configFile `, ` vpnFile `, ` vpn `
or ` settings `\. Only one global profile can run at a time\.
When handshakes go unanswered, a profile switches to a new source port on its own\.
Setting ` settings.listenPort ` pins the port and turns this off\.
**Type:** attribute set of (submodule)\
**Default:** `{ }`
<a id="services-proxy-suite-amneziawg-profiles-name-allowconfighooks"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.allowConfigHooks
Let imported configs run wg-quick hooks (PostUp etc\.) or use SaveConfig\. Only for trusted configs\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-amneziawg-profiles-name-asoutbound"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.asOutbound
Use the profile as a proxy outbound, tagged with its name, instead of a global VPN\. It
then always runs and leaves the host’s routes and DNS alone\. Needs ` proxy.enable `\.
- “singBox”: plain WireGuard in sing-box\. AmneziaWG obfuscation is dropped, with a warning\.
- “userspace”: wireproxy with AmneziaWG obfuscation\. Needs no root, so it is the only
mode on home-manager and Nix-on-Droid\. Its endpoint is resolved by the system
resolver, so use an IP if that resolver cannot reach the name\.
- “interface”: a real AmneziaWG interface without routes, which the outbound binds to\.
On sing-box, its DNS also goes through the tunnel\.
**Type:** null or one of “singBox”, “userspace”, “interface”\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-autostart"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.autostart
Start this profile at boot\. Only one profile can autostart\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-amneziawg-profiles-name-configfile"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.configFile
File with an AmneziaWG \.conf\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-domainstrategy"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.domainStrategy
Which address family the outbound dials a name over first\. Ignored with
` asOutbound = "userspace" `\. ` null `: the backend’s default\.
**Type:** null or one of “prefer_ipv4”, “prefer_ipv6”, “ipv4_only”, “ipv6_only”\
**Default:** `null`\
**Example:** `"prefer_ipv6"`
<a id="services-proxy-suite-amneziawg-profiles-name-endpoint"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.endpoint
host:port (IPv6 in brackets) that replaces the first peer’s endpoint\.
**Type:** null or string matching the pattern (\\\[\[0-9A-Fa-f:\.]+]|\[^]:\[]+):\[0-9]+\
**Default:** `null`\
**Example:** `"162.159.192.1:500"`
<a id="services-proxy-suite-amneziawg-profiles-name-interfacename"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.interfaceName
Interface name, at most 15 characters\.
**Type:** string matching the pattern ^\[A-Za-z0-9_\.-]{1,15}$\
**Default:** `"awg-<name>"`
<a id="services-proxy-suite-amneziawg-profiles-name-settings"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings
The client config written in Nix, instead of a file\.
**Type:** null or (submodule)\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-addresses"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.addresses
Interface addresses\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "10.8.0.2/32" ]`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-dns"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.dns
DNS servers used while this profile is active\.
**Type:** list of string\
**Default:** `[ ]`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-listenport"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.listenPort
Local UDP port\.
**Type:** null or 16 bit unsigned integer; between 0 and 65535 (both inclusive)\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-mtu"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.mtu
Interface MTU\.
**Type:** null or (unsigned integer, meaning >=0)\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation
AmneziaWG 1\.x through 3\.x obfuscation parameters\.
**Type:** submodule\
**Default:** `{ }`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-contentpaddingaddition"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.contentPaddingAddition
AWG 3 content-padding addition or range\.
**Type:** null or unsigned integer, meaning >=0, or string matching the pattern ^(\[0-9]+|\[0-9]±\[0-9]+|\\(off\\))$\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-disablecookies"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.disableCookies
AWG 3 cookie suppression (DisableCookies)\.
**Type:** null or boolean\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-h1"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.h1
Handshake-init header or range (H1)\.
**Type:** null or unsigned integer, meaning >=0, or string matching the pattern ^(\[0-9]+|\[0-9]±\[0-9]+|\\(off\\))$\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-h2"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.h2
Handshake-response header or range (H2)\.
**Type:** null or unsigned integer, meaning >=0, or string matching the pattern ^(\[0-9]+|\[0-9]±\[0-9]+|\\(off\\))$\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-h3"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.h3
Cookie-reply header or range (H3)\.
**Type:** null or unsigned integer, meaning >=0, or string matching the pattern ^(\[0-9]+|\[0-9]±\[0-9]+|\\(off\\))$\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-h4"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.h4
Transport-message header or range (H4)\.
**Type:** null or unsigned integer, meaning >=0, or string matching the pattern ^(\[0-9]+|\[0-9]±\[0-9]+|\\(off\\))$\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-headerprotectionkey"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.headerProtectionKey
AWG 3 header-protection key\. Ends up in the Nix store; prefer ` headerProtectionKeyFile `\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-headerprotectionkeyfile"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.headerProtectionKeyFile
File with the AWG 3 header-protection key\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-i1"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.i1
First custom signature packet (I1)\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-i2"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.i2
Second custom signature packet (I2)\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-i3"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.i3
Third custom signature packet (I3)\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-i4"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.i4
Fourth custom signature packet (I4)\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-i5"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.i5
Fifth custom signature packet (I5)\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-jc"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.jc
Junk packet count (Jc)\.
**Type:** null or (unsigned integer, meaning >=0)\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-jmax"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.jmax
Maximum junk packet size (Jmax)\.
**Type:** null or (unsigned integer, meaning >=0)\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-jmin"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.jmin
Minimum junk packet size (Jmin)\.
**Type:** null or (unsigned integer, meaning >=0)\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-keepalivetimeout"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.keepaliveTimeout
AWG 3 keepalive timeout or range\.
**Type:** null or unsigned integer, meaning >=0, or string matching the pattern ^(\[0-9]+|\[0-9]±\[0-9]+|\\(off\\))$\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-maxhandshakeattempts"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.maxHandshakeAttempts
AWG 3 maximum handshake attempts or range\.
**Type:** null or unsigned integer, meaning >=0, or string matching the pattern ^(\[0-9]+|\[0-9]±\[0-9]+|\\(off\\))$\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-randomtrailers"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.randomTrailers
AWG 3 random transport trailers (RandomTrailers)\.
**Type:** null or boolean\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-rejectaftertime"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.rejectAfterTime
AWG 3 reject-after interval or range\.
**Type:** null or unsigned integer, meaning >=0, or string matching the pattern ^(\[0-9]+|\[0-9]±\[0-9]+|\\(off\\))$\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-rekeyaftertime"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.rekeyAfterTime
AWG 3 rekey interval or range\.
**Type:** null or unsigned integer, meaning >=0, or string matching the pattern ^(\[0-9]+|\[0-9]±\[0-9]+|\\(off\\))$\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-rekeytimeout"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.rekeyTimeout
AWG 3 rekey timeout or range\.
**Type:** null or unsigned integer, meaning >=0, or string matching the pattern ^(\[0-9]+|\[0-9]±\[0-9]+|\\(off\\))$\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-s1"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.s1
Handshake-init padding (S1)\.
**Type:** null or (unsigned integer, meaning >=0)\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-s2"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.s2
Handshake-response padding (S2)\.
**Type:** null or (unsigned integer, meaning >=0)\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-s3"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.s3
Cookie-reply padding (S3)\.
**Type:** null or (unsigned integer, meaning >=0)\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscation-s4"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscation\.s4
Transport-message padding (S4)\.
**Type:** null or (unsigned integer, meaning >=0)\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-obfuscationfile"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.obfuscationFile
File with secret obfuscation settings as JSON, using the same fields as ` obfuscation `
(except ` headerProtectionKeyFile `)\. It is merged with ` obfuscation ` at startup and never
enters the Nix store\. A field set in both places is an error\. Restart the profile after
changing the file\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/awg-obfuscation.json"`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-peers"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.peers
AmneziaWG peers\.
**Type:** list of (submodule)\
**Default:** `[ ]`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-peers-advancedsecurity"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.peers\.\*\.advancedSecurity
AWG AdvancedSecurity setting\.
**Type:** null or boolean\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-peers-allowedips"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.peers\.\*\.allowedIPs
IP ranges routed to and accepted from this peer\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "0.0.0.0/0" "::/0" ]`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-peers-endpoint"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.peers\.\*\.endpoint
Peer address, as host:port\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"vpn.example.com:51820"`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-peers-persistentkeepalive"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.peers\.\*\.persistentKeepalive
Keepalive interval in seconds, or an AWG 3 range\.
**Type:** null or unsigned integer, meaning >=0, or string matching the pattern ^(\[0-9]+|\[0-9]±\[0-9]+|\\(off\\))$\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-peers-presharedkey"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.peers\.\*\.presharedKey
Peer preshared key\. Ends up in the Nix store; prefer ` presharedKeyFile `\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-peers-presharedkeyfile"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.peers\.\*\.presharedKeyFile
File with the peer preshared key\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-peers-publickey"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.peers\.\*\.publicKey
Peer public key\.
**Type:** string matching the pattern \[^\[:space:]]+
<a id="services-proxy-suite-amneziawg-profiles-name-settings-privatekey"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.privateKey
Client private key\. Ends up in the Nix store; prefer ` privateKeyFile `\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-privatekeyfile"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.privateKeyFile
File with the client private key\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-settings-table"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.settings\.table
Routing table: a name or number, “auto” or “off”\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-vpn"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.vpn
A vpn:// export\. Ends up in the Nix store; prefer ` vpnFile `\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-vpncontainer"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.vpnContainer
Which container to take from a vpn:// export that holds several\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-profiles-name-vpnfile"></a>
## services\.proxy-suite\.amneziaWg\.profiles\.\<name>\.vpnFile
File with a vpn:// export\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-amneziawg-runtime-enable"></a>
## services\.proxy-suite\.amneziaWg\.runtime\.enable
Let ` proxy-ctl ` add configs and ` vpn:// ` links without a rebuild: ` proxy-ctl awg add `
for a global profile (root hosts only), and ` proxy-ctl proxy outbounds add ` for an
outbound, which runs in wireproxy (needs ` proxy.enable `)\. wg-quick hooks such as
` PostUp ` are always refused in them\. With this on, ` profiles ` may be empty\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-amneziawg-runtime-interfacename"></a>
## services\.proxy-suite\.amneziaWg\.runtime\.interfaceName
Interface of the global profiles added at runtime\. Only one of them runs at a time, so they share it\.
**Type:** string matching the pattern ^\[A-Za-z0-9_\.-]{1,15}$\
**Default:** `"awg-rt"`
<a id="services-proxy-suite-amneziawg-runtime-outboundkind"></a>
## services\.proxy-suite\.amneziaWg\.runtime\.outboundKind
How an outbound added with ` proxy-ctl proxy outbounds add ` runs, unless it says
(` --interface `, ` --userspace `): in wireproxy, or as an AmneziaWG interface of its own
(root hosts only), which apps can also be run through with ` proxy-ctl apps run --via `\.
**Type:** one of “userspace”, “interface”\
**Default:** `"userspace"`
<a id="services-proxy-suite-amneziawg-serverudpports"></a>
## services\.proxy-suite\.amneziaWg\.serverUdpPorts
UDP ports of services on this host that others reach, whose packets a global profile
leaves on the host’s own routes\. A reply from a socket bound to every address would
otherwise leave through the tunnel, from the tunnel’s address\. The UDP inbound listeners
and, on NixOS, the ports the firewall opens are included already\.
**Type:** list of (16 bit unsigned integer; between 0 and 65535 (both inclusive) or string matching the pattern \[0-9]±\[0-9]+)\
**Default:** `[ ]`\
**Example:** `[ 3478 "49152-65535" ]`
<a id="services-proxy-suite-amneziawg-toolspackage"></a>
## services\.proxy-suite\.amneziaWg\.toolsPackage
AWG 3\.1 package with ` awg ` and ` awg-quick `\.
**Type:** package\
**Default:** proxy-suite’s patched ` amneziawg-tools ` (` pkgs/amneziawg.nix `)
<a id="services-proxy-suite-amneziawg-userspacepackage"></a>
## services\.proxy-suite\.amneziaWg\.userspacePackage
AWG 3\.1 userspace implementation, used when the kernel module is unavailable\.
**Type:** package\
**Default:** proxy-suite’s patched ` amneziawg-go ` (` pkgs/amneziawg.nix `)
<a id="services-proxy-suite-amneziawg-wireproxypackage"></a>
## services\.proxy-suite\.amneziaWg\.wireproxyPackage
wireproxy build with AWG 3\.1, used by profiles with ` asOutbound = "userspace" `\.
**Type:** package\
**Default:** proxy-suite’s ` wireproxy-awg ` (` pkgs/wireproxy-awg.nix `)
+125
View File
@@ -0,0 +1,125 @@
# services.proxy-suite.debug
Troubleshooting: backend log levels, a connection recorder, DNS and zapret2 logs.
Part of the [proxy-suite options reference](./index.md).
## Options
- debug
- connectionLog
- [enable](#services-proxy-suite-debug-connectionlog-enable)
- [hosts](#services-proxy-suite-debug-connectionlog-hosts)
- [inbounds](#services-proxy-suite-debug-connectionlog-inbounds)
- [interval](#services-proxy-suite-debug-connectionlog-interval)
- [stallAfter](#services-proxy-suite-debug-connectionlog-stallafter)
- [logLevel](#services-proxy-suite-debug-loglevel)
- [perAppDns](#services-proxy-suite-debug-perappdns)
- [tgWsProxy](#services-proxy-suite-debug-tgwsproxy)
- zapret2
- [autoHostlist](#services-proxy-suite-debug-zapret2-autohostlist)
- [packets](#services-proxy-suite-debug-zapret2-packets)
<a id="services-proxy-suite-debug-connectionlog-enable"></a>
## services\.proxy-suite\.debug\.connectionLog\.enable
Record the backends’ connections to the journal: each one as it opens, with its
listener, site, rule and exit, and as it closes, with the bytes each way and how long
it lasted\. For failures that come and go: look back at the time one happened\. A unit
per backend, up while it is: proxy-suite-connection-log for the local proxy and
global or per-app TProxy, proxy-suite-connection-log-tun for the global TUN and
proxy-suite-connection-log-per-app-tun for per-app TUN, whose Clash APIs this turns
on\. The same view live: ` proxy-ctl debug conns `\. Polls the Clash API, so it needs the
sing-box or hybrid backend; a connection shorter than ` interval ` can be missed\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-debug-connectionlog-hosts"></a>
## services\.proxy-suite\.debug\.connectionLog\.hosts
Record only connections to these domains and their subdomains, or these addresses\.
Empty: every connection\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "twimg.com" "x.com" ]`
<a id="services-proxy-suite-debug-connectionlog-inbounds"></a>
## services\.proxy-suite\.debug\.connectionLog\.inbounds
Record only connections that came in on listeners whose tag starts with one of
these: “tproxy” for global and per-app TProxy, “tun-in” for the global and per-app
TUN, “per-app-pin” for apps run ` --via ` an outbound through TProxy, “mixed-in” for
the local proxy\. Empty: every listener\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "tproxy" ]`
<a id="services-proxy-suite-debug-connectionlog-interval"></a>
## services\.proxy-suite\.debug\.connectionLog\.interval
Seconds between looks at the connections\.
**Type:** positive integer or floating point number, meaning >0\
**Default:** `0.5`
<a id="services-proxy-suite-debug-connectionlog-stallafter"></a>
## services\.proxy-suite\.debug\.connectionLog\.stallAfter
Seconds a connection may wait on an answer: one that has sent since it last
received, and received nothing for this long, is logged as stalled, and again
when it resumes\. Several requests share a connection (HTTP/2), so a stall shows
only when all of them wait\. 0: never\.
**Type:** unsigned integer, meaning >=0\
**Default:** `10`
<a id="services-proxy-suite-debug-loglevel"></a>
## services\.proxy-suite\.debug\.logLevel
How much the proxy backends log to the journal (` proxy-ctl logs proxy-suite-socks `):
sing-box, and XRay where it runs (XRay has no “trace”: it logs at “debug” then)\.
“info” logs every connection with its destination and the rule that routed it\.
` /run/proxy-suite/xray-loglevel ` still overrides XRay’s level at the next start\.
**Type:** one of “warn”, “info”, “debug”, “trace”\
**Default:** `"warn"`\
**Example:** `"info"`
<a id="services-proxy-suite-debug-perappdns"></a>
## services\.proxy-suite\.debug\.perAppDns
Log every lookup the per-app DNS forwarders send on (per-app TUN and TProxy, and apps
run through an AmneziaWG interface): the name, its type, the answer’s code and how long
it took, and the lookups that got no answer\. In the journals of
proxy-suite-per-app-tun-dns, proxy-suite-per-app-tproxy-dns and
proxy-suite-per-app-via@\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-debug-tgwsproxy"></a>
## services\.proxy-suite\.debug\.tgWsProxy
Log the Telegram proxy’s debug messages\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-debug-zapret2-autohostlist"></a>
## services\.proxy-suite\.debug\.zapret2\.autoHostlist
Log why sites are or are not learned (nfqws2’s own learner)\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-debug-zapret2-packets"></a>
## services\.proxy-suite\.debug\.zapret2\.packets
Log everything nfqws2 does to the journal, every packet included\. Very verbose\.
**Type:** boolean\
**Default:** `false`
+39
View File
@@ -0,0 +1,39 @@
# services.proxy-suite.geodata
Geosite and geoip databases used by routing.
Part of the [proxy-suite options reference](./index.md).
## Options
- geodata
- singBox
- [geoip](#services-proxy-suite-geodata-singbox-geoip)
- [geosite](#services-proxy-suite-geodata-singbox-geosite)
- xray
- [assets](#services-proxy-suite-geodata-xray-assets)
<a id="services-proxy-suite-geodata-singbox-geoip"></a>
## services\.proxy-suite\.geodata\.singBox\.geoip
Package with share/sing-box/rule-set/geoip-NAME\.srs (countries by default)\.
**Type:** package\
**Default:** `pkgs.sing-geoip`
<a id="services-proxy-suite-geodata-singbox-geosite"></a>
## services\.proxy-suite\.geodata\.singBox\.geosite
Package with share/sing-box/rule-set/geosite-NAME\.srs\.
**Type:** package\
**Default:** `pkgs.sing-geosite`
<a id="services-proxy-suite-geodata-xray-assets"></a>
## services\.proxy-suite\.geodata\.xray\.assets
Package with share/v2ray/{geoip,geosite}\.dat for XRay\. ` null `: XRay’s built-in data,
which only has countries, so a tag like “geoip:telegram” breaks XRay\.
**Type:** null or package\
**Default:** `pkgs.v2ray-rules-dat`
+47
View File
@@ -0,0 +1,47 @@
# services.proxy-suite.gui
The desktop app with a tray icon.
Part of the [proxy-suite options reference](./index.md).
## Options
- gui
- [enable](#services-proxy-suite-gui-enable)
- [autostart](#services-proxy-suite-gui-autostart)
- [floating](#services-proxy-suite-gui-floating)
- [refreshInterval](#services-proxy-suite-gui-refreshinterval)
<a id="services-proxy-suite-gui-enable"></a>
## services\.proxy-suite\.gui\.enable
Whether to enable Proxy Suite GUI, a desktop app with a tray icon\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-gui-autostart"></a>
## services\.proxy-suite\.gui\.autostart
Start the GUI in the tray on login to a graphical session\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-gui-floating"></a>
## services\.proxy-suite\.gui\.floating
Open the window floating, sized to the screen, where a tiling compositor (niri, sway,
Hyprland, i3) would tile it\. It opens at a fixed size, which those compositors float,
then resizes as usual\. Turn off to let the compositor tile it\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-gui-refreshinterval"></a>
## services\.proxy-suite\.gui\.refreshInterval
How often the status refreshes, in seconds\.
**Type:** positive integer, meaning >0\
**Default:** `3`
File diff suppressed because it is too large. Load diff
+510
View File
@@ -0,0 +1,510 @@
# proxy-suite options
Generated from the `services.proxy-suite` option descriptions under
[`modules/proxy-suite/options/`](/modules/proxy-suite/options/).
Update the module option docs there instead of editing these files by hand.
## Option groups
| Group | What it covers |
|---|---|
| [proxy](./proxy.md) | The local proxy: outbounds, subscriptions, selection, routing, DNS, TUN and TProxy. |
| [killSwitch](./killSwitch.md) | Block traffic outside the global tunnel. |
| [perAppRouting](./perAppRouting.md) | Route single apps through proxychains, a per-app TUN or TProxy, or zapret. |
| [zapret](./zapret.md) | DPI bypass without a proxy: zapret-discord-youtube or zapret2. |
| [amneziaWg](./amneziaWg.md) | AmneziaWG client profiles, as a global VPN or as outbounds. |
| [warp](./warp.md) | Cloudflare WARP, as an outbound or an AmneziaWG profile. |
| [tor](./tor.md) | Tor as an outbound, with bridges, and an onion service for the inbounds. |
| [sshProxy](./sshProxy.md) | An SSH SOCKS5 tunnel, optionally as an outbound. |
| [tgWsProxy](./tgWsProxy.md) | A Telegram MTProto proxy over WebSocket. |
| [whitelistBypass](./whitelistBypass.md) | Tunnels through video-call servers, past mobile internet whitelists. |
| [inbounds](./inbounds.md) | Server side: listeners for remote clients, share links, subscriptions and stats. |
| [geodata](./geodata.md) | Geosite and geoip databases used by routing. |
| [userControl](./userControl.md) | Let a group use `proxy-ctl` without root. |
| [gui](./gui.md) | The desktop app with a tray icon. |
| [tui](./tui.md) | The `proxy-tui` terminal UI. |
| [tools](./tools.md) | Heavy helpers `proxy-ctl` can do without: lnav and curl-impersonate. |
| [debug](./debug.md) | Troubleshooting: backend log levels, a connection recorder, DNS and zapret2 logs. |
<a id="services-proxy-suite-enable"></a>
## services\.proxy-suite\.enable
Whether to enable proxy-suite\.
**Type:** boolean\
**Default:** `false`
## Complete default config
<details>
<summary>Every option at its default</summary>
```nix
services.proxy-suite = {
amneziaWg = {
enable = false;
kernelModulePackage = ‹amneziawg from boot.kernelPackages on NixOS, null elsewhere›;
profiles = { };
runtime = {
enable = true;
interfaceName = "awg-rt";
outboundKind = "userspace";
};
serverUdpPorts = [ ];
toolsPackage = ‹proxy-suite's patched amneziawg-tools (pkgs/amneziawg.nix)›;
userspacePackage = ‹proxy-suite's patched amneziawg-go (pkgs/amneziawg.nix)›;
wireproxyPackage = ‹proxy-suite's wireproxy-awg (pkgs/wireproxy-awg.nix)›;
};
debug = {
connectionLog = {
enable = false;
hosts = [ ];
inbounds = [ ];
interval = 0.5;
stallAfter = 10;
};
logLevel = "warn";
perAppDns = false;
tgWsProxy = false;
zapret2 = {
autoHostlist = false;
packets = false;
};
};
enable = false;
geodata = {
singBox = {
geoip = pkgs.sing-geoip;
geosite = pkgs.sing-geosite;
};
xray = {
assets = pkgs.v2ray-rules-dat;
};
};
gui = {
autostart = true;
enable = false;
floating = true;
refreshInterval = 3;
};
inbounds = {
accessLog = false;
enable = false;
listeners = { };
manager = {
api = {
group = null;
listen = null;
tokensFile = null;
};
deleteExpiredAfter = null;
enable = false;
interval = 30;
ipLimit = {
banTime = 600;
};
notify = {
expiryDays = [
3
1
];
trafficPercent = [
80
100
];
};
speedLimits = {
enable = false;
slots = 512;
};
subscriptions = {
enable = config.services.proxy-suite.inbounds.shareLinks;
group = config.services.proxy-suite.inbounds.subscriptions.group;
listen = null;
profileTitle = "{user}";
supportUrl = null;
updateInterval = 12;
webPageUrl = null;
};
webhooks = [ ];
};
openFirewall = true;
package = ‹proxy-suite's xray (pkgs/xray.nix)›;
routing = {
blockPorts = [
25
];
blockPrivate = true;
blockRu = true;
blockTorrent = true;
proxy = {
domains = [ ];
geoips = [ ];
geosites = [ ];
ips = [ ];
};
serverSource = {
interface = "ps-self";
ipv4 = null;
ipv6 = null;
};
via = "proxy";
zapretDirect = true;
};
runtime = {
enable = false;
fallbackDests = [ ];
ports = [ ];
tlsCertificates = { };
vias = [ ];
};
serverAddress = null;
serverAliases = [ ];
serverPorts = [ ];
shareLinks = true;
subscriptions = {
baseUrl = null;
enable = false;
group = "nginx";
keyFile = null;
};
users = { };
};
killSwitch = {
allowedSubnets = config.services.proxy-suite.proxy.tproxy.localSubnets;
directFallbacks = true;
enable = false;
timeSyncUsers = ‹the users of the enabled timesyncd, chrony, ntp and openntpd on NixOS; elsewhere
[ "systemd-timesync" "chrony" "_chrony" "ntp" "ntpsec" ]
›;
};
perAppRouting = {
createDefaultProfiles = false;
enable = false;
profiles = [ ];
proxychains = {
enable = false;
proxyDns = true;
quiet = true;
};
tproxy = {
enable = false;
fwmark = 17;
keepRunning = false;
localSubnets = [
"192.168.0.0/16"
];
routeTable = 102;
};
tun = {
address = "172.20.0.1/30";
enable = false;
fwmark = 16;
interface = "psperapptun0";
keepRunning = false;
localSubnets = [
"192.168.0.0/16"
];
mtu = 1400;
routeTable = 101;
};
via = {
localSubnets = [
"192.168.0.0/16"
];
pinSlots = 8;
};
zapret = {
enable = false;
filterMark = 268435456;
keepRunning = false;
qnum = 201;
};
};
proxy = {
autoProxy = {
enable = false;
exclude = [ ];
interval = "10m";
maxExits = 12;
probeBasePort = 18540;
probesPerRun = 200;
slowBelowKiBps = 150;
ttlDays = 30;
};
autostart = null;
backend = "sing-box";
dns = {
clientSubnet = null;
fakeIp = {
enable = false;
inet4Range = "198.18.0.0/15";
};
local = {
address = "1.1.1.1";
port = 53;
type = "tcp";
};
remote = {
address = "1.1.1.1";
port = 53;
type = "udp";
};
singBox = {
rules = [ ];
servers = [ ];
};
strategy = null;
};
enable = false;
groups = { };
ipv6 = config.networking.enableIPv6;
listener = {
address = "127.0.0.1";
auth = {
password = null;
passwordFile = null;
username = null;
};
port = 1080;
};
outbounds = [ ];
priority = { };
routing = {
block = {
domains = [ ];
geoips = [ ];
geosites = [ ];
ips = [ ];
ruleSets = [ ];
};
default = "proxy";
direct = {
domains = [ ];
geoips = [ ];
geosites = [ ];
ips = [ ];
ruleSets = [ ];
};
directRu = true;
proxy = {
domains = [ ];
geoips = [ ];
geosites = [ ];
ips = [ ];
ruleSets = [ ];
};
ruleSetUpdateInterval = "1d";
ruleSets = { };
rules = [ ];
};
runtimeSubscriptions = {
allowHttp = false;
allowInsecure = false;
allowPrivateServers = false;
};
selection = "first";
selectionExclude = [ ];
singBox = {
clashApiPort = 9090;
package = ‹sing-box from proxy-suite's own nixpkgs input›;
};
subscriptionUpdateInterval = "1d";
subscriptions = [ ];
tproxy = {
enable = false;
fwmark = 1;
lanInterfaces = [ ];
localSubnets = [
"192.168.0.0/16"
];
port = 1085;
proxyMark = 2;
routeTable = 100;
};
tun = {
address = "172.19.0.1/30";
enable = false;
interface = "singtun0";
mtu = 1400;
};
urlTest = {
interval = "3m";
tolerance = 50;
url = "https://www.gstatic.com/generate_204";
};
xray = {
package = ‹proxy-suite's xray (pkgs/xray.nix)›;
xhttpXmux = null;
};
};
sshProxy = {
asOutbound = false;
domainStrategy = null;
enable = false;
extraArgs = [ ];
hostKey = [ ];
hostKeyFile = null;
identityFile = null;
knownHostsFile = null;
listener = {
address = "127.0.0.1";
port = 1091;
};
server = {
host = null;
port = 22;
user = null;
};
serviceUser = "proxy-suite-daemon";
strictHostKeyChecking = "yes";
};
tgWsProxy = {
bufferKiB = 256;
bypassTransparentProxy = true;
cloudflare = {
domains = [ ];
fallback = true;
workerDomains = [ ];
};
dcIps = { };
enable = false;
fakeTlsDomain = null;
fwmark = 4;
listener = {
address = "127.0.0.1";
port = 1443;
};
log = {
file = null;
keep = 1;
maxSizeMiB = 5.0;
};
poolSize = 4;
proxyProtocol = false;
secret = null;
secretFile = null;
};
tools = {
curlImpersonate = {
enable = ‹true, false on nix-on-droid›;
};
lnav = {
enable = ‹true, false on nix-on-droid›;
};
};
tor = {
asOutbound = false;
bridges = {
file = null;
lines = [ ];
};
clientOnly = true;
enable = false;
extraConfig = "";
keepAwake = false;
lyrebirdPackage = pkgs.lyrebird;
onionService = {
enable = false;
listeners = null;
secretKeyFile = null;
};
package = pkgs.tor;
routeOnion = true;
snowflakePackage = pkgs.snowflake;
socksPort = 18530;
upstream = "direct";
};
tui = {
enable = true;
};
userControl = {
enable = false;
group = "proxy-suite";
groups = { };
scopes = [ ];
};
warp = {
asAmneziaWg = false;
asOutbound = null;
autostart = false;
configFile = null;
devices = { };
domainStrategy = if config.networking.enableIPv6 then "prefer_ipv6" else "prefer_ipv4";
enable = false;
endpoint = null;
generatorUrl = null;
group = {
failback = true;
strategy = "failover";
};
instances = null;
};
whitelistBypass = {
creators = { };
enable = false;
joiners = { };
package = ‹proxy-suite's whitelist-bypass (pkgs/whitelist-bypass.nix)›;
};
zapret = {
cidrExemption = {
cidrs = [ ];
enable = false;
};
directSync = {
enable = true;
upstreamIps = false;
userIps = true;
};
enable = false;
engine = "zapret-discord-youtube";
global = {
enable = true;
};
zapret-discord-youtube = {
configName = "general(ALT)";
domains = [ ];
excludeDomains = [ ];
excludeIps = [ ];
gameFilter = "null";
hostlistRules = [ ];
includeExtraUpstreamLists = false;
ips = [ ];
};
zapret2 = {
autoHostlist = {
enable = true;
extendedDetection = true;
failThreshold = 3;
failTime = 300;
incomingMaxseq = 4096;
retransMaxseq = 32768;
retransReset = true;
retransThreshold = 3;
udpIn = 1;
udpOut = 4;
};
blobs = { };
cutoff = {
enable = true;
proxyFallback = true;
};
domains = [ ];
excludeDomains = [ ];
ipv6 = false;
ports = {
extraTcp = [ ];
extraUdp = [ ];
tcp = null;
udp = null;
};
profiles = null;
proxyFallback = true;
strategyLog = true;
strategySource = "nfqws2-keenetic";
};
};
};
```
</details>
+62
View File
@@ -0,0 +1,62 @@
# services.proxy-suite.killSwitch
Block traffic outside the global tunnel.
Part of the [proxy-suite options reference](./index.md).
## Options
- killSwitch
- [enable](#services-proxy-suite-killswitch-enable)
- [allowedSubnets](#services-proxy-suite-killswitch-allowedsubnets)
- [directFallbacks](#services-proxy-suite-killswitch-directfallbacks)
- [timeSyncUsers](#services-proxy-suite-killswitch-timesyncusers)
<a id="services-proxy-suite-killswitch-enable"></a>
## services\.proxy-suite\.killSwitch\.enable
Block outgoing traffic that bypasses the active global tunnel (TUN, TProxy or a global
AmneziaWG profile) from boot until the tunnel is up, while it restarts and after it
fails\. LAN, DHCP and the time daemons’ NTP stay open\. Forwarded traffic TProxy does not
divert reaches the LAN only from ` proxy.tproxy.lanInterfaces `\. With TUN or a global
AmneziaWG profile configured, containers’ and VMs’ traffic is held to the LAN too while
neither that tunnel nor TProxy is up\. Only turning the tunnel off with ` proxy-ctl `, or
` proxy-ctl killswitch off `, lifts it, until the next boot or tunnel start\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-killswitch-allowedsubnets"></a>
## services\.proxy-suite\.killSwitch\.allowedSubnets
Networks the kill switch leaves open besides the private and reserved ranges, such as
a routed IPv6 prefix on a VM bridge, whichever global mode is on\. The default keeps
what TProxy leaves out reachable; set it to open a network without also taking it out
of TProxy\.
**Type:** list of IPv4 or IPv6 address or CIDR\
**Default:** `config.services.proxy-suite.proxy.tproxy.localSubnets`\
**Example:** `[ "192.168.0.0/16" "2001:db8:1::/64" ]`
<a id="services-proxy-suite-killswitch-directfallbacks"></a>
## services\.proxy-suite\.killSwitch\.directFallbacks
Whether, with the kill switch on, a subscription that cannot be fetched through the
tunnel is fetched once more directly, and WARP registers directly when the local proxy
cannot carry it\. Either shows that server this host’s own address\. Off, both go through
the tunnel or not at all: a cold start with nothing cached then has no outbounds from
that subscription, and a WARP device that is itself the tunnel cannot register\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-killswitch-timesyncusers"></a>
## services\.proxy-suite\.killSwitch\.timeSyncUsers
Users that may send NTP (UDP port 123) past the kill switch\. Users that do not exist
are skipped when it starts\. A daemon sending from port 123 itself, as ntpd does, needs
no entry\.
**Type:** list of string\
**Default:** the users of the enabled timesyncd, chrony, ntp and openntpd on NixOS; elsewhere ` [ "systemd-timesync" "chrony" "_chrony" "ntp" "ntpsec" ] `\
**Example:** `[ "chrony" ]`
+300
View File
@@ -0,0 +1,300 @@
# services.proxy-suite.perAppRouting
Route single apps through proxychains, a per-app TUN or TProxy, or zapret.
Part of the [proxy-suite options reference](./index.md).
## Options
- perAppRouting
- [enable](#services-proxy-suite-perapprouting-enable)
- [createDefaultProfiles](#services-proxy-suite-perapprouting-createdefaultprofiles)
- [profiles](#services-proxy-suite-perapprouting-profiles)
- item
- [keepRunning](#services-proxy-suite-perapprouting-profiles-keeprunning)
- [name](#services-proxy-suite-perapprouting-profiles-name)
- [outbound](#services-proxy-suite-perapprouting-profiles-outbound)
- [route](#services-proxy-suite-perapprouting-profiles-route)
- proxychains
- [enable](#services-proxy-suite-perapprouting-proxychains-enable)
- [proxyDns](#services-proxy-suite-perapprouting-proxychains-proxydns)
- [quiet](#services-proxy-suite-perapprouting-proxychains-quiet)
- tproxy
- [enable](#services-proxy-suite-perapprouting-tproxy-enable)
- [fwmark](#services-proxy-suite-perapprouting-tproxy-fwmark)
- [keepRunning](#services-proxy-suite-perapprouting-tproxy-keeprunning)
- [localSubnets](#services-proxy-suite-perapprouting-tproxy-localsubnets)
- [routeTable](#services-proxy-suite-perapprouting-tproxy-routetable)
- tun
- [enable](#services-proxy-suite-perapprouting-tun-enable)
- [address](#services-proxy-suite-perapprouting-tun-address)
- [fwmark](#services-proxy-suite-perapprouting-tun-fwmark)
- [interface](#services-proxy-suite-perapprouting-tun-interface)
- [keepRunning](#services-proxy-suite-perapprouting-tun-keeprunning)
- [localSubnets](#services-proxy-suite-perapprouting-tun-localsubnets)
- [mtu](#services-proxy-suite-perapprouting-tun-mtu)
- [routeTable](#services-proxy-suite-perapprouting-tun-routetable)
- via
- [localSubnets](#services-proxy-suite-perapprouting-via-localsubnets)
- [pinSlots](#services-proxy-suite-perapprouting-via-pinslots)
- zapret
- [enable](#services-proxy-suite-perapprouting-zapret-enable)
- [filterMark](#services-proxy-suite-perapprouting-zapret-filtermark)
- [keepRunning](#services-proxy-suite-perapprouting-zapret-keeprunning)
- [qnum](#services-proxy-suite-perapprouting-zapret-qnum)
<a id="services-proxy-suite-perapprouting-enable"></a>
## services\.proxy-suite\.perAppRouting\.enable
Whether to enable per-app routing (` proxy-ctl apps run `)\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-perapprouting-createdefaultprofiles"></a>
## services\.proxy-suite\.perAppRouting\.createDefaultProfiles
Add a profile for each enabled method (proxychains, tun, tproxy, zapret), named after it,
unless one already exists\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-perapprouting-profiles"></a>
## services\.proxy-suite\.perAppRouting\.profiles
Profiles for ` proxy-ctl apps run <name> -- <command> `\.
**Type:** list of (submodule)\
**Default:** `[ ]`\
**Example:** `[ { name = "steam-browser"; route = "proxychains"; } ]`
<a id="services-proxy-suite-perapprouting-profiles-keeprunning"></a>
## services\.proxy-suite\.perAppRouting\.profiles\.\*\.keepRunning
Keep what this profile runs through running from boot, rather than starting it with
the first app and stopping it after the last: its ` outbound ` (an AmneziaWG
interface or profile, or a pin slot, which then stays taken), or else its ` route `’s
backend, as ` perAppRouting.<route>.keepRunning ` does\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-perapprouting-profiles-name"></a>
## services\.proxy-suite\.perAppRouting\.profiles\.\*\.name
Unique profile name\.
**Type:** string matching the pattern ^\[a-z0-9]\[a-z0-9-]\*$\
**Example:** `"steam-browser"`
<a id="services-proxy-suite-perapprouting-profiles-outbound"></a>
## services\.proxy-suite\.perAppRouting\.profiles\.\*\.outbound
Send all of the app’s traffic through this outbound, past the routing rules\. An
“interface” AmneziaWG outbound (` amneziaWg.profiles.<name>.asOutbound `), or a
global AmneziaWG profile, takes the app’s packets into its interface directly,
whatever ` route ` is; any other outbound needs ` route ` “tun” or “tproxy”\. For a name
that is both a global profile and an outbound, say which: “awg:\<name>” or
“outbound:\<name>”\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"de"`
<a id="services-proxy-suite-perapprouting-profiles-route"></a>
## services\.proxy-suite\.perAppRouting\.profiles\.\*\.route
How the app is routed: “direct” (untouched), “proxychains”, or the per-app “tun”,
“tproxy” or “zapret”\.
**Type:** one of “direct”, “proxychains”, “tun”, “tproxy”, “zapret”\
**Default:** `"proxychains"`
<a id="services-proxy-suite-perapprouting-proxychains-enable"></a>
## services\.proxy-suite\.perAppRouting\.proxychains\.enable
Whether to enable proxychains (TCP only, does not work with static binaries)\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-perapprouting-proxychains-proxydns"></a>
## services\.proxy-suite\.perAppRouting\.proxychains\.proxyDns
Resolve DNS through the proxy\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-perapprouting-proxychains-quiet"></a>
## services\.proxy-suite\.perAppRouting\.proxychains\.quiet
Hide proxychains output\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-perapprouting-tproxy-enable"></a>
## services\.proxy-suite\.perAppRouting\.tproxy\.enable
Whether to enable per-app TProxy\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-perapprouting-tproxy-fwmark"></a>
## services\.proxy-suite\.perAppRouting\.tproxy\.fwmark
Firewall mark for wrapped apps’ traffic\.
**Type:** signed integer\
**Default:** `17`
<a id="services-proxy-suite-perapprouting-tproxy-keeprunning"></a>
## services\.proxy-suite\.perAppRouting\.tproxy\.keepRunning
Keep the per-app TProxy backend running from boot, rather than starting it with the first app
and stopping it after the last: apps start without waiting for it\.
Under a global TUN or TProxy it stays down, and comes back once that stops\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-perapprouting-tproxy-localsubnets"></a>
## services\.proxy-suite\.perAppRouting\.tproxy\.localSubnets
Subnets that skip the proxy (DNS still goes through it)\.
**Type:** list of IPv4 or IPv6 address or CIDR\
**Default:** `[ "192.168.0.0/16" ]`\
**Example:** `[ "192.168.0.0/16" "10.0.0.0/8" ]`
<a id="services-proxy-suite-perapprouting-tproxy-routetable"></a>
## services\.proxy-suite\.perAppRouting\.tproxy\.routeTable
Routing table for the per-app TProxy\.
**Type:** signed integer\
**Default:** `102`
<a id="services-proxy-suite-perapprouting-tun-enable"></a>
## services\.proxy-suite\.perAppRouting\.tun\.enable
Whether to enable per-app TUN\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-perapprouting-tun-address"></a>
## services\.proxy-suite\.perAppRouting\.tun\.address
Interface IPv4 address (CIDR)\.
**Type:** IPv4 CIDR\
**Default:** `"172.20.0.1/30"`
<a id="services-proxy-suite-perapprouting-tun-fwmark"></a>
## services\.proxy-suite\.perAppRouting\.tun\.fwmark
Firewall mark for wrapped apps’ traffic\.
**Type:** signed integer\
**Default:** `16`
<a id="services-proxy-suite-perapprouting-tun-interface"></a>
## services\.proxy-suite\.perAppRouting\.tun\.interface
Interface name\.
**Type:** network interface name\
**Default:** `"psperapptun0"`
<a id="services-proxy-suite-perapprouting-tun-keeprunning"></a>
## services\.proxy-suite\.perAppRouting\.tun\.keepRunning
Keep the per-app TUN backend running from boot, rather than starting it with the first app
and stopping it after the last: apps start without waiting for it\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-perapprouting-tun-localsubnets"></a>
## services\.proxy-suite\.perAppRouting\.tun\.localSubnets
Subnets that skip the proxy (DNS still goes through it)\.
**Type:** list of IPv4 or IPv6 address or CIDR\
**Default:** `[ "192.168.0.0/16" ]`\
**Example:** `[ "192.168.0.0/16" "10.0.0.0/8" ]`
<a id="services-proxy-suite-perapprouting-tun-mtu"></a>
## services\.proxy-suite\.perAppRouting\.tun\.mtu
Interface MTU\.
**Type:** signed integer\
**Default:** `1400`
<a id="services-proxy-suite-perapprouting-tun-routetable"></a>
## services\.proxy-suite\.perAppRouting\.tun\.routeTable
Routing table for the per-app TUN\.
**Type:** signed integer\
**Default:** `101`
<a id="services-proxy-suite-perapprouting-via-localsubnets"></a>
## services\.proxy-suite\.perAppRouting\.via\.localSubnets
Subnets an app run ` --via ` an AmneziaWG interface (an “interface” outbound or a global
profile) still reaches directly; DNS still goes through the tunnel\. Every other
address goes through it, private ones included, as the server may serve them\.
**Type:** list of IPv4 or IPv6 address or CIDR\
**Default:** `[ "192.168.0.0/16" ]`\
**Example:** `[ "192.168.0.0/16" "10.0.0.0/8" ]`
<a id="services-proxy-suite-perapprouting-via-pinslots"></a>
## services\.proxy-suite\.perAppRouting\.via\.pinSlots
How many outbounds ` apps run --via ` can send apps through at once, for per-app TProxy
and again for per-app TUN; at most 16\. Apps via the same outbound share one\. An
“interface” AmneziaWG outbound takes none: apps enter it directly\.
**Type:** signed integer\
**Default:** `8`
<a id="services-proxy-suite-perapprouting-zapret-enable"></a>
## services\.proxy-suite\.perAppRouting\.zapret\.enable
Whether to enable per-app zapret, a separate zapret for wrapped apps only\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-perapprouting-zapret-filtermark"></a>
## services\.proxy-suite\.perAppRouting\.zapret\.filterMark
Firewall mark bit for wrapped apps’ traffic\.
**Type:** signed integer\
**Default:** `268435456`
<a id="services-proxy-suite-perapprouting-zapret-keeprunning"></a>
## services\.proxy-suite\.perAppRouting\.zapret\.keepRunning
Keep the per-app zapret backend running from boot, rather than starting it with the first app
and stopping it after the last: apps start without waiting for it\.
Under a global TUN, TProxy or AmneziaWG profile it stays down, and comes back once that stops\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-perapprouting-zapret-qnum"></a>
## services\.proxy-suite\.perAppRouting\.zapret\.qnum
NFQUEUE number\. Must differ from the global zapret’s\.
**Type:** signed integer\
**Default:** `201`
File diff suppressed because it is too large. Load diff
+164
View File
@@ -0,0 +1,164 @@
# services.proxy-suite.sshProxy
An SSH SOCKS5 tunnel, optionally as an outbound.
Part of the [proxy-suite options reference](./index.md).
## Options
- sshProxy
- [enable](#services-proxy-suite-sshproxy-enable)
- [asOutbound](#services-proxy-suite-sshproxy-asoutbound)
- [domainStrategy](#services-proxy-suite-sshproxy-domainstrategy)
- [extraArgs](#services-proxy-suite-sshproxy-extraargs)
- [hostKey](#services-proxy-suite-sshproxy-hostkey)
- [hostKeyFile](#services-proxy-suite-sshproxy-hostkeyfile)
- [identityFile](#services-proxy-suite-sshproxy-identityfile)
- [knownHostsFile](#services-proxy-suite-sshproxy-knownhostsfile)
- listener
- [address](#services-proxy-suite-sshproxy-listener-address)
- [port](#services-proxy-suite-sshproxy-listener-port)
- server
- [host](#services-proxy-suite-sshproxy-server-host)
- [port](#services-proxy-suite-sshproxy-server-port)
- [user](#services-proxy-suite-sshproxy-server-user)
- [serviceUser](#services-proxy-suite-sshproxy-serviceuser)
- [strictHostKeyChecking](#services-proxy-suite-sshproxy-stricthostkeychecking)
<a id="services-proxy-suite-sshproxy-enable"></a>
## services\.proxy-suite\.sshProxy\.enable
Whether to enable an SSH SOCKS5 tunnel\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-sshproxy-asoutbound"></a>
## services\.proxy-suite\.sshProxy\.asOutbound
Add the tunnel as an outbound tagged “ssh-proxy”\. On sing-box and hybrid, sing-box connects
over SSH itself and needs ` hostKey ` or ` hostKeyFile `\. Otherwise OpenSSH runs a SOCKS listener, set up
by ` listener `, ` knownHostsFile `, ` strictHostKeyChecking `, ` serviceUser ` and ` extraArgs `\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-sshproxy-domainstrategy"></a>
## services\.proxy-suite\.sshProxy\.domainStrategy
Resolve names locally instead of on the server (XRay only)\. Can make CDNs pick distant servers\.
**Type:** null or one of “prefer_ipv4”, “prefer_ipv6”, “ipv4_only”, “ipv6_only”\
**Default:** `null`\
**Example:** `"prefer_ipv4"`
<a id="services-proxy-suite-sshproxy-extraargs"></a>
## services\.proxy-suite\.sshProxy\.extraArgs
Extra OpenSSH arguments\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "-J" "jump.example.com" ]`
<a id="services-proxy-suite-sshproxy-hostkey"></a>
## services\.proxy-suite\.sshProxy\.hostKey
Accepted host keys, for sing-box, and for OpenSSH without ` knownHostsFile `\. List every
key ` ssh-keyscan ` prints, since the key type is negotiated\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI..." ]`
<a id="services-proxy-suite-sshproxy-hostkeyfile"></a>
## services\.proxy-suite\.sshProxy\.hostKeyFile
Known-hosts file to read host keys from (sing-box, and OpenSSH without ` knownHostsFile `)\. Takes priority over ` hostKey `\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/root/.ssh/known_hosts"`
<a id="services-proxy-suite-sshproxy-identityfile"></a>
## services\.proxy-suite\.sshProxy\.identityFile
File with the SSH private key\. It can stay root-only\. ` null `: the agent or OpenSSH defaults\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/proxy-suite-ssh-key"`
<a id="services-proxy-suite-sshproxy-knownhostsfile"></a>
## services\.proxy-suite\.sshProxy\.knownHostsFile
Known-hosts file for OpenSSH\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/proxy-suite-ssh-known-hosts"`
<a id="services-proxy-suite-sshproxy-listener-address"></a>
## services\.proxy-suite\.sshProxy\.listener\.address
Address of the OpenSSH SOCKS5 listener\.
**Type:** string matching the pattern \[^\[:space:]]+\
**Default:** `"127.0.0.1"`
<a id="services-proxy-suite-sshproxy-listener-port"></a>
## services\.proxy-suite\.sshProxy\.listener\.port
Port of the OpenSSH SOCKS5 listener\. It takes no login: where it is the XRay backend’s
hop (` asOutbound `) on a host with root, only proxy-suite’s daemons and root may
connect to it\. A standalone tunnel stays open to every local user\.
**Type:** 16 bit unsigned integer; between 0 and 65535 (both inclusive)\
**Default:** `1091`
<a id="services-proxy-suite-sshproxy-server-host"></a>
## services\.proxy-suite\.sshProxy\.server\.host
SSH server\.
**Type:** null or string matching the pattern \[^\[:space:]]+\
**Default:** `null`\
**Example:** `"ssh.example.com"`
<a id="services-proxy-suite-sshproxy-server-port"></a>
## services\.proxy-suite\.sshProxy\.server\.port
SSH server port\.
**Type:** 16 bit unsigned integer; between 0 and 65535 (both inclusive)\
**Default:** `22`
<a id="services-proxy-suite-sshproxy-server-user"></a>
## services\.proxy-suite\.sshProxy\.server\.user
SSH login user\.
**Type:** null or string matching the pattern \[^\[:space:]]+\
**Default:** `null`\
**Example:** `"root"`
<a id="services-proxy-suite-sshproxy-serviceuser"></a>
## services\.proxy-suite\.sshProxy\.serviceUser
User that runs OpenSSH\. The default is sandboxed; ` null ` runs it as root\. Another user’s
traffic gets past the kill switch, all of it: never a login user’s\.
**Type:** null or string matching the pattern \[a-z_]\[a-z0-9_-]\*\[$]?\
**Default:** `"proxy-suite-daemon"`\
**Example:** `"proxy"`
<a id="services-proxy-suite-sshproxy-stricthostkeychecking"></a>
## services\.proxy-suite\.sshProxy\.strictHostKeyChecking
OpenSSH host key policy\. “yes” needs the server’s keys: ` knownHostsFile `, or else
` hostKeyFile ` or ` hostKey `\. “accept-new” takes whatever key the first connection
meets, which anyone on the way can answer then\.
**Type:** one of “yes”, “accept-new”, “no”\
**Default:** `"yes"`\
**Example:** `"accept-new"`
+181
View File
@@ -0,0 +1,181 @@
# services.proxy-suite.tgWsProxy
A Telegram MTProto proxy over WebSocket.
Part of the [proxy-suite options reference](./index.md).
## Options
- tgWsProxy
- [enable](#services-proxy-suite-tgwsproxy-enable)
- [bufferKiB](#services-proxy-suite-tgwsproxy-bufferkib)
- [bypassTransparentProxy](#services-proxy-suite-tgwsproxy-bypasstransparentproxy)
- cloudflare
- [domains](#services-proxy-suite-tgwsproxy-cloudflare-domains)
- [fallback](#services-proxy-suite-tgwsproxy-cloudflare-fallback)
- [workerDomains](#services-proxy-suite-tgwsproxy-cloudflare-workerdomains)
- [dcIps](#services-proxy-suite-tgwsproxy-dcips)
- [fakeTlsDomain](#services-proxy-suite-tgwsproxy-faketlsdomain)
- [fwmark](#services-proxy-suite-tgwsproxy-fwmark)
- listener
- [address](#services-proxy-suite-tgwsproxy-listener-address)
- [port](#services-proxy-suite-tgwsproxy-listener-port)
- log
- [file](#services-proxy-suite-tgwsproxy-log-file)
- [keep](#services-proxy-suite-tgwsproxy-log-keep)
- [maxSizeMiB](#services-proxy-suite-tgwsproxy-log-maxsizemib)
- [poolSize](#services-proxy-suite-tgwsproxy-poolsize)
- [proxyProtocol](#services-proxy-suite-tgwsproxy-proxyprotocol)
- [secret](#services-proxy-suite-tgwsproxy-secret)
- [secretFile](#services-proxy-suite-tgwsproxy-secretfile)
<a id="services-proxy-suite-tgwsproxy-enable"></a>
## services\.proxy-suite\.tgWsProxy\.enable
Whether to enable the Telegram WebSocket proxy (MTProto)\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-tgwsproxy-bufferkib"></a>
## services\.proxy-suite\.tgWsProxy\.bufferKiB
Socket buffer size, in KiB\.
**Type:** integer between 4 and 2147483647 (both inclusive)\
**Default:** `256`
<a id="services-proxy-suite-tgwsproxy-bypasstransparentproxy"></a>
## services\.proxy-suite\.tgWsProxy\.bypassTransparentProxy
Keep the relay’s own connections out of TUN and TProxy, so they do not loop\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-tgwsproxy-cloudflare-domains"></a>
## services\.proxy-suite\.tgWsProxy\.cloudflare\.domains
Domains behind Cloudflare to fall back to\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "cdn.example.com" ]`
<a id="services-proxy-suite-tgwsproxy-cloudflare-fallback"></a>
## services\.proxy-suite\.tgWsProxy\.cloudflare\.fallback
Fall back to Cloudflare when a direct WebSocket fails\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-tgwsproxy-cloudflare-workerdomains"></a>
## services\.proxy-suite\.tgWsProxy\.cloudflare\.workerDomains
Cloudflare Worker domains, tried first\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "worker.example.com" ]`
<a id="services-proxy-suite-tgwsproxy-dcips"></a>
## services\.proxy-suite\.tgWsProxy\.dcIps
Relay IP for each Telegram DC ID\.
**Type:** attribute set of string\
**Default:** `{ }`\
**Example:** `{ "2" = "149.154.167.220"; }`
<a id="services-proxy-suite-tgwsproxy-faketlsdomain"></a>
## services\.proxy-suite\.tgWsProxy\.fakeTlsDomain
Domain to disguise traffic as, with Fake TLS (ee-secret links)\.
**Type:** null or string matching the pattern \.+\
**Default:** `null`\
**Example:** `"www.example.com"`
<a id="services-proxy-suite-tgwsproxy-fwmark"></a>
## services\.proxy-suite\.tgWsProxy\.fwmark
Firewall mark for ` bypassTransparentProxy `\.
**Type:** signed integer\
**Default:** `4`
<a id="services-proxy-suite-tgwsproxy-listener-address"></a>
## services\.proxy-suite\.tgWsProxy\.listener\.address
Listening address\.
**Type:** string\
**Default:** `"127.0.0.1"`
<a id="services-proxy-suite-tgwsproxy-listener-port"></a>
## services\.proxy-suite\.tgWsProxy\.listener\.port
Listening port\.
**Type:** 16 bit unsigned integer; between 0 and 65535 (both inclusive)\
**Default:** `1443`
<a id="services-proxy-suite-tgwsproxy-log-file"></a>
## services\.proxy-suite\.tgWsProxy\.log\.file
Log file, rotated\. ` null `: log to the journal\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/var/log/proxy-suite-tg-ws-proxy/tg-ws-proxy.log"`
<a id="services-proxy-suite-tgwsproxy-log-keep"></a>
## services\.proxy-suite\.tgWsProxy\.log\.keep
Number of rotated logs to keep\.
**Type:** positive integer, meaning >0\
**Default:** `1`
<a id="services-proxy-suite-tgwsproxy-log-maxsizemib"></a>
## services\.proxy-suite\.tgWsProxy\.log\.maxSizeMiB
Rotate the log at this size, in MiB\.
**Type:** positive integer or floating point number, meaning >0\
**Default:** `5.0`
<a id="services-proxy-suite-tgwsproxy-poolsize"></a>
## services\.proxy-suite\.tgWsProxy\.poolSize
Idle WebSockets kept open per DC\. 0 disables\.
**Type:** unsigned integer, meaning >=0\
**Default:** `4`
<a id="services-proxy-suite-tgwsproxy-proxyprotocol"></a>
## services\.proxy-suite\.tgWsProxy\.proxyProtocol
Accept a PROXY protocol v1 header from a reverse proxy in front\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-tgwsproxy-secret"></a>
## services\.proxy-suite\.tgWsProxy\.secret
MTProto secret (` openssl rand -hex 16 `)\. Ends up in the Nix store; prefer ` secretFile `\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"`
<a id="services-proxy-suite-tgwsproxy-secretfile"></a>
## services\.proxy-suite\.tgWsProxy\.secretFile
File with the MTProto secret\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/tg-ws-proxy-secret"`
+31
View File
@@ -0,0 +1,31 @@
# services.proxy-suite.tools
Heavy helpers `proxy-ctl` can do without: lnav and curl-impersonate.
Part of the [proxy-suite options reference](./index.md).
## Options
- tools
- curlImpersonate
- [enable](#services-proxy-suite-tools-curlimpersonate-enable)
- lnav
- [enable](#services-proxy-suite-tools-lnav-enable)
<a id="services-proxy-suite-tools-curlimpersonate-enable"></a>
## services\.proxy-suite\.tools\.curlImpersonate\.enable
Probe with curl-impersonate (` proxy-ctl proxy auto probe `, and autoProxy), which
presents a browser’s TLS fingerprint\. Without it probes use plain curl, which some
bot protection refuses, so a working exit can be judged blocked\.
**Type:** boolean\
**Default:** ` true `, ` false ` on nix-on-droid
<a id="services-proxy-suite-tools-lnav-enable"></a>
## services\.proxy-suite\.tools\.lnav\.enable
Follow ` proxy-ctl logs ` in lnav\. Without it they follow in less\.
**Type:** boolean\
**Default:** ` true `, ` false ` on nix-on-droid
+191
View File
@@ -0,0 +1,191 @@
# services.proxy-suite.tor
Tor as an outbound, with bridges, and an onion service for the inbounds.
Part of the [proxy-suite options reference](./index.md).
## Options
- tor
- [enable](#services-proxy-suite-tor-enable)
- [package](#services-proxy-suite-tor-package)
- [asOutbound](#services-proxy-suite-tor-asoutbound)
- bridges
- [file](#services-proxy-suite-tor-bridges-file)
- [lines](#services-proxy-suite-tor-bridges-lines)
- [clientOnly](#services-proxy-suite-tor-clientonly)
- [extraConfig](#services-proxy-suite-tor-extraconfig)
- [keepAwake](#services-proxy-suite-tor-keepawake)
- [lyrebirdPackage](#services-proxy-suite-tor-lyrebirdpackage)
- onionService
- [enable](#services-proxy-suite-tor-onionservice-enable)
- [listeners](#services-proxy-suite-tor-onionservice-listeners)
- [secretKeyFile](#services-proxy-suite-tor-onionservice-secretkeyfile)
- [routeOnion](#services-proxy-suite-tor-routeonion)
- [snowflakePackage](#services-proxy-suite-tor-snowflakepackage)
- [socksPort](#services-proxy-suite-tor-socksport)
- [upstream](#services-proxy-suite-tor-upstream)
<a id="services-proxy-suite-tor-enable"></a>
## services\.proxy-suite\.tor\.enable
Run Tor\. Also turn on ` asOutbound `, ` onionService.enable `, or both\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-tor-package"></a>
## services\.proxy-suite\.tor\.package
Tor package\.
**Type:** package\
**Default:** `pkgs.tor`
<a id="services-proxy-suite-tor-asoutbound"></a>
## services\.proxy-suite\.tor\.asOutbound
Add Tor as an outbound tagged “tor”\. Selection and autoProxy skip it unless it is the only
outbound; send traffic to it with ` proxy.routing.rules ` or use it as a ` detour `\.
Needs ` proxy.enable `\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-tor-bridges-file"></a>
## services\.proxy-suite\.tor\.bridges\.file
File with more bridge lines, one per line\. Blank lines and \# comments are skipped\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/tor-bridges"`
<a id="services-proxy-suite-tor-bridges-lines"></a>
## services\.proxy-suite\.tor\.bridges\.lines
Bridge lines from https://bridges\.torproject\.org, without the leading “Bridge”\. Setting
any turns bridges on\.
**Type:** list of string matching the pattern \[^ ]\*\
**Default:** `[ ]`\
**Example:**
```nix
[
"obfs4 192.0.2.1:443 0123456789ABCDEF0123456789ABCDEF01234567 cert=... iat-mode=0"
]
```
<a id="services-proxy-suite-tor-clientonly"></a>
## services\.proxy-suite\.tor\.clientOnly
Keep Tor a client, never a relay, even if ` extraConfig ` sets an ORPort\. The onion service
works either way\. Turn off only to run a relay through ` extraConfig `\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-tor-extraconfig"></a>
## services\.proxy-suite\.tor\.extraConfig
Extra torrc lines\.
**Type:** strings concatenated with “\\n”\
**Default:** `""`\
**Example:**
```nix
''
ExitNodes {de},{nl}
StrictNodes 1
''
```
<a id="services-proxy-suite-tor-keepawake"></a>
## services\.proxy-suite\.tor\.keepAwake
Never let Tor go dormant\. By default it does after a day without use, and from then on
only rebuilds its circuits when the next connection comes: the first \.onion after a quiet
spell may wait long enough to fail\. Turn on where clients expect \.onion at once, as on a
server whose inbounds route it\. A dormant Tor also starts dormant again; this wakes it\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-tor-lyrebirdpackage"></a>
## services\.proxy-suite\.tor\.lyrebirdPackage
Bridge transport for obfs4, webtunnel and meek_lite\.
**Type:** package\
**Default:** `pkgs.lyrebird`
<a id="services-proxy-suite-tor-onionservice-enable"></a>
## services\.proxy-suite\.tor\.onionService\.enable
Whether to enable an onion service for the server inbounds\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-tor-onionservice-listeners"></a>
## services\.proxy-suite\.tor\.onionService\.listeners
Listeners reachable through the onion address\. ` null `: every TCP listener (not
amneziawg, h3-only xhttp or raw JSON)\.
Get their links with ` proxy-ctl inbounds link TAG --onion `; subscriptions include them\.
Onion clients do not show up in ` proxy-ctl inbounds online `\.
**Type:** null or (list of string)\
**Default:** `null`\
**Example:** `[ "vless-reality" ]`
<a id="services-proxy-suite-tor-onionservice-secretkeyfile"></a>
## services\.proxy-suite\.tor\.onionService\.secretKeyFile
File with an hs_ed25519_secret_key, to keep a fixed onion address\. ` null `: Tor creates one\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/tor-hs_ed25519_secret_key"`
<a id="services-proxy-suite-tor-routeonion"></a>
## services\.proxy-suite\.tor\.routeOnion
Send \.onion names to the “tor” outbound in every route mode, and never resolve them with
DNS\. Inbound clients’ \.onion names go there too\. Needs ` asOutbound `\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-tor-snowflakepackage"></a>
## services\.proxy-suite\.tor\.snowflakePackage
Bridge transport for snowflake\.
**Type:** package\
**Default:** `pkgs.snowflake`
<a id="services-proxy-suite-tor-socksport"></a>
## services\.proxy-suite\.tor\.socksPort
Loopback SOCKS port of Tor\. Tor takes no login on it, so with ` asOutbound ` on a host with
root only proxy-suite’s daemons and root may connect to it; other users reach Tor
through the proxy’s own listener\.
**Type:** 16 bit unsigned integer; between 0 and 65535 (both inclusive)\
**Default:** `18530`
<a id="services-proxy-suite-tor-upstream"></a>
## services\.proxy-suite\.tor\.upstream
How Tor reaches the network\.
- “direct”: straight from the uplink, bypassing TUN and TProxy\.
- “proxy”: through the local proxy, for networks that block Tor\. Works with obfs4,
webtunnel and meek_lite bridges, but not snowflake\.
**Type:** one of “direct”, “proxy”\
**Default:** `"direct"`
+18
View File
@@ -0,0 +1,18 @@
# services.proxy-suite.tui
The `proxy-tui` terminal UI.
Part of the [proxy-suite options reference](./index.md).
## Options
- tui
- [enable](#services-proxy-suite-tui-enable)
<a id="services-proxy-suite-tui-enable"></a>
## services\.proxy-suite\.tui\.enable
Whether to enable proxy-tui, a terminal UI\.
**Type:** boolean\
**Default:** `true`
+83
View File
@@ -0,0 +1,83 @@
# services.proxy-suite.userControl
Let a group use `proxy-ctl` without root.
Part of the [proxy-suite options reference](./index.md).
## Options
- userControl
- [enable](#services-proxy-suite-usercontrol-enable)
- [group](#services-proxy-suite-usercontrol-group)
- [groups](#services-proxy-suite-usercontrol-groups)
- `<name>`
- [scopes](#services-proxy-suite-usercontrol-groups-name-scopes)
- [scopes](#services-proxy-suite-usercontrol-scopes)
<a id="services-proxy-suite-usercontrol-enable"></a>
## services\.proxy-suite\.userControl\.enable
Whether to enable ` proxy-ctl ` without root for members of ` userControl.group `\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-usercontrol-group"></a>
## services\.proxy-suite\.userControl\.group
Group whose members can run privileged ` proxy-ctl ` commands\.
**Type:** string matching the pattern ^\[a-z_]\[a-z0-9_-]\*$\
**Default:** `"proxy-suite"`
<a id="services-proxy-suite-usercontrol-groups"></a>
## services\.proxy-suite\.userControl\.groups
More groups, each with scopes of its own, alongside ` userControl.group `\. A member gets
what all of their groups allow\. ` group ` stays the one that owns proxy-suite’s files;
these are given access to them through POSIX ACLs, so the file systems of
` /var/lib/proxy-suite ` and ` /run ` must support them (the defaults do)\.
**Type:** attribute set of (submodule)\
**Default:** `{ }`\
**Example:**
```nix
{
proxy-admins.scopes = [ ];
proxy-users.scopes = [ "perApp" "routing" ];
}
```
<a id="services-proxy-suite-usercontrol-groups-name-scopes"></a>
## services\.proxy-suite\.userControl\.groups\.\<name>\.scopes
What this group may do, as in ` userControl.scopes `\. Empty allows everything\.
**Type:** list of (one of “services”, “perApp”, “routing”, “outbounds”, “secrets”, “autoProxy”, “zapret”, “stats”, “inbounds”, “whitelistBypass”, “amneziaWg”)\
**Default:** `[ ]`
<a id="services-proxy-suite-usercontrol-scopes"></a>
## services\.proxy-suite\.userControl\.scopes
What the group may do\. Empty allows everything\.
- “services”: start, stop and restart services, and ` tor newnym `\.
- “perApp”: ` proxy-ctl apps run `\.
- “routing”: ` proxy pin `, ` proxy unpin `, ` proxy mode ` and ` proxy rules `\.
- “outbounds”: add, remove, enable and disable outbounds and subscriptions\.
- “secrets”: read share links, subscription URLs and running configs\.
- “autoProxy”: see and change what autoProxy learned\.
- “zapret”: change zapret2’s learned sites, and ` zapret cutoff probe `\.
- “stats”: ` inbounds stats `\.
- “inbounds”: add, remove and bind runtime inbound users and listeners
(` inbounds.runtime `), and read the secrets they are given\.
- “whitelistBypass”: everything under ` proxy-ctl wl `\.
- “amneziaWg”: add and remove global AmneziaWG profiles (` proxy-ctl awg add `, ` awg rm `)\.
A global profile takes over the host’s routes and DNS\. Starting and stopping one is
“services”; an AmneziaWG outbound is “outbounds”\.
**Type:** list of (one of “services”, “perApp”, “routing”, “outbounds”, “secrets”, “autoProxy”, “zapret”, “stats”, “inbounds”, “whitelistBypass”, “amneziaWg”)\
**Default:** `[ ]`\
**Example:** `[ "services" "routing" ]`
+169
View File
@@ -0,0 +1,169 @@
# services.proxy-suite.warp
Cloudflare WARP, as an outbound or an AmneziaWG profile.
Part of the [proxy-suite options reference](./index.md).
## Options
- warp
- [enable](#services-proxy-suite-warp-enable)
- [asAmneziaWg](#services-proxy-suite-warp-asamneziawg)
- [asOutbound](#services-proxy-suite-warp-asoutbound)
- [autostart](#services-proxy-suite-warp-autostart)
- [configFile](#services-proxy-suite-warp-configfile)
- [devices](#services-proxy-suite-warp-devices)
- `<name>`
- [configFile](#services-proxy-suite-warp-devices-name-configfile)
- [endpoint](#services-proxy-suite-warp-devices-name-endpoint)
- [domainStrategy](#services-proxy-suite-warp-domainstrategy)
- [endpoint](#services-proxy-suite-warp-endpoint)
- [generatorUrl](#services-proxy-suite-warp-generatorurl)
- group
- [failback](#services-proxy-suite-warp-group-failback)
- [strategy](#services-proxy-suite-warp-group-strategy)
- [instances](#services-proxy-suite-warp-instances)
<a id="services-proxy-suite-warp-enable"></a>
## services\.proxy-suite\.warp\.enable
Run Cloudflare WARP\. Also set ` asOutbound ` or ` asAmneziaWg `\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-warp-asamneziawg"></a>
## services\.proxy-suite\.warp\.asAmneziaWg
Add a global AmneziaWG profile named “warp” (` proxy-ctl awg on warp `)\. Needs
` amneziaWg.enable `\. Cannot be used with ` asOutbound `\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-warp-asoutbound"></a>
## services\.proxy-suite\.warp\.asOutbound
Add WARP as an outbound tagged “warp”\.
- “singBox”: plain WireGuard in sing-box, ignoring AmneziaWG fields\. Restarts itself when
WARP stops answering\.
- “userspace”: an AmneziaWG profile, without root\. Needs ` amneziaWg.enable `\.
- “interface”: an AmneziaWG profile with its own interface\. Needs ` amneziaWg.enable `\.
**Type:** null or one of “singBox”, “userspace”, “interface”\
**Default:** `null`
<a id="services-proxy-suite-warp-autostart"></a>
## services\.proxy-suite\.warp\.autostart
Bring the “warp” AmneziaWG profile up at boot, as ` autostart ` of an ` amneziaWg ` profile
does\. Needs ` asAmneziaWg `\. Only one global mode can autostart\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-warp-configfile"></a>
## services\.proxy-suite\.warp\.configFile
File with a WARP WireGuard profile, from ` wgcf register && wgcf generate `\. AmneziaWG
fields in it only take effect in the AmneziaWG modes\.
` null `: register a new device with wgcf on first start (accepting Cloudflare’s terms),
through the local proxy if enabled\. WARP does not work until that succeeds\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/wgcf-profile.conf"`
<a id="services-proxy-suite-warp-devices"></a>
## services\.proxy-suite\.warp\.devices
Several WARP devices, each registered on its own and each an outbound with its tag\. With
two or more, the tag “warp” names a group of them (` warp.group `), so rules, pins and
chains naming “warp” fail over between them\. A device cannot be named “warp” then\.
With “interface”, a tag holds at most 11 characters (its interface is awg-\<tag>)\.
Empty: one device, “warp”, as ` configFile ` and ` endpoint ` above say\.
**Type:** attribute set of (submodule)\
**Default:** `{ }`\
**Example:** `{ warp-a = { }; warp-b.endpoint = "162.159.193.10:500"; } `
<a id="services-proxy-suite-warp-devices-name-configfile"></a>
## services\.proxy-suite\.warp\.devices\.\<name>\.configFile
This device’s WireGuard profile, as ` warp.configFile `\. ` null `: registered with wgcf\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/warp-b.conf"`
<a id="services-proxy-suite-warp-devices-name-endpoint"></a>
## services\.proxy-suite\.warp\.devices\.\<name>\.endpoint
This device’s endpoint, as ` warp.endpoint ` (which it defaults to)\.
**Type:** null or string matching the pattern (\\\[\[0-9A-Fa-f:\.]+]|\[^]:\[]+):\[0-9]+\
**Default:** `null`\
**Example:** `"162.159.192.1:500"`
<a id="services-proxy-suite-warp-domainstrategy"></a>
## services\.proxy-suite\.warp\.domainStrategy
Which address family the “warp” outbound dials a name over first\. Ignored with
` asOutbound = "userspace" `\. Also applies to names resolved by the inbounds’
` routing.blockPrivate ` check, unless ` proxy.dns.strategy ` is set\.
**Type:** null or one of “prefer_ipv4”, “prefer_ipv6”, “ipv4_only”, “ipv6_only”\
**Default:** `if config.networking.enableIPv6 then "prefer_ipv6" else "prefer_ipv4"`\
**Example:** `"prefer_ipv4"`
<a id="services-proxy-suite-warp-endpoint"></a>
## services\.proxy-suite\.warp\.endpoint
host:port (IPv6 in brackets) to use instead of the profile’s endpoint, if the default one
is blocked: another Cloudflare address, another WARP port (500, 1701, 4500, …), or a relay\.
**Type:** null or string matching the pattern (\\\[\[0-9A-Fa-f:\.]+]|\[^]:\[]+):\[0-9]+\
**Default:** `null`\
**Example:** `"162.159.192.1:500"`
<a id="services-proxy-suite-warp-generatorurl"></a>
## services\.proxy-suite\.warp\.generatorUrl
URL of a WARP profile generator, used if wgcf registration fails (for example, when the
Cloudflare API is blocked)\. It must return a WireGuard profile, or JSON with the base64
profile in ` .content `\.
Its operator sees your private key\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"https://valokda-amnezia.vercel.app/api/warp?mode=awg2"`
<a id="services-proxy-suite-warp-group-failback"></a>
## services\.proxy-suite\.warp\.group\.failback
With “failover”: go back to an earlier device once it works again\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-warp-group-strategy"></a>
## services\.proxy-suite\.warp\.group\.strategy
How the “warp” group of several devices picks one; see ` proxy.groups `\.
**Type:** one of “failover”, “urltest”, “selector”\
**Default:** `"failover"`
<a id="services-proxy-suite-warp-instances"></a>
## services\.proxy-suite\.warp\.instances
Shorthand for ` devices `: this many WARP devices, warp-1 to warp-N, each registered with
wgcf\. warp-1 keeps the registration a single “warp” device made\. Not with ` devices `\.
**Type:** null or (positive integer, meaning >0)\
**Default:** `null`\
**Example:** `2`
+145
View File
@@ -0,0 +1,145 @@
# services.proxy-suite.whitelistBypass
Tunnels through video-call servers, past mobile internet whitelists.
Part of the [proxy-suite options reference](./index.md).
## Options
- whitelistBypass
- [enable](#services-proxy-suite-whitelistbypass-enable)
- [package](#services-proxy-suite-whitelistbypass-package)
- [creators](#services-proxy-suite-whitelistbypass-creators)
- `<name>`
- [cookiesFile](#services-proxy-suite-whitelistbypass-creators-name-cookiesfile)
- [linkFile](#services-proxy-suite-whitelistbypass-creators-name-linkfile)
- [platform](#services-proxy-suite-whitelistbypass-creators-name-platform)
- [resources](#services-proxy-suite-whitelistbypass-creators-name-resources)
- [upstream](#services-proxy-suite-whitelistbypass-creators-name-upstream)
- [joiners](#services-proxy-suite-whitelistbypass-joiners)
- `<name>`
- [linkFile](#services-proxy-suite-whitelistbypass-joiners-name-linkfile)
- [platform](#services-proxy-suite-whitelistbypass-joiners-name-platform)
<a id="services-proxy-suite-whitelistbypass-enable"></a>
## services\.proxy-suite\.whitelistBypass\.enable
Tunnel through video-call servers, which mobile internet whitelists let through
([whitelist-bypass](https://github\.com/kulikov0/whitelist-bypass))\. A creator on a free
host serves one joiner on a censored one\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-whitelistbypass-package"></a>
## services\.proxy-suite\.whitelistBypass\.package
whitelist-bypass package\. It must take the call link and the proxy password from WB_LINK and WB_UPSTREAM_PASS, as ` pkgs/whitelist-bypass.nix ` patches it to\.
**Type:** package\
**Default:** proxy-suite’s ` whitelist-bypass ` (` pkgs/whitelist-bypass.nix `)
<a id="services-proxy-suite-whitelistbypass-creators"></a>
## services\.proxy-suite\.whitelistBypass\.creators
Creators, one per joiner device\. Each logs the call link its joiner needs (also ` proxy-ctl wl link `)\.
**Type:** attribute set of (submodule)\
**Default:** `{ }`\
**Example:**
```nix
{
phone = {
cookiesFile = "/run/secrets/whitelist-bypass-cookies-wbstream.json";
platform = "wbstream";
upstream = "proxy";
};
}
```
<a id="services-proxy-suite-whitelistbypass-creators-name-cookiesfile"></a>
## services\.proxy-suite\.whitelistBypass\.creators\.\<name>\.cookiesFile
File with the platform’s cookies, as exported by the upstream desktop Creator\. Read on
first start only, since the login refreshes itself afterwards\. ` proxy-ctl wl auth <name> ` replaces it at runtime (or asks for email and password on DION and Bitrix)\.
` null `: the creator waits for that\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/whitelist-bypass-cookies-wbstream.json"`
<a id="services-proxy-suite-whitelistbypass-creators-name-linkfile"></a>
## services\.proxy-suite\.whitelistBypass\.creators\.\<name>\.linkFile
File with a call link to rejoin\. ` null `: create a call once and keep reusing it, so
the joiner needs the link only once\. ` proxy-ctl wl new <name> ` starts a new call if the
platform closed the old one\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/whitelist-bypass-link"`
<a id="services-proxy-suite-whitelistbypass-creators-name-platform"></a>
## services\.proxy-suite\.whitelistBypass\.creators\.\<name>\.platform
Call platform\. Each needs an account\. “vk” only serves the upstream Android joiner app\.
**Type:** one of “wbstream”, “telemost”, “dion”, “bitrix”, “vk”\
**Example:** `"wbstream"`
<a id="services-proxy-suite-whitelistbypass-creators-name-resources"></a>
## services\.proxy-suite\.whitelistBypass\.creators\.\<name>\.resources
Memory budget: 64, 128 or 256 MB\.
**Type:** one of “moderate”, “default”, “unlimited”\
**Default:** `"moderate"`
<a id="services-proxy-suite-whitelistbypass-creators-name-upstream"></a>
## services\.proxy-suite\.whitelistBypass\.creators\.\<name>\.upstream
Where the traffic from this creator’s joiner exits\.
- “direct”: straight from this host, bypassing TUN and TProxy\.
- “proxy”: through the local proxy and its routing\.
**Type:** one of “direct”, “proxy”\
**Default:** `"direct"`
<a id="services-proxy-suite-whitelistbypass-joiners"></a>
## services\.proxy-suite\.whitelistBypass\.joiners
Joiners, each an outbound tagged with its name that tunnels through the call\. Needs
` proxy.enable `\.
**Type:** attribute set of (submodule)\
**Default:** `{ }`\
**Example:**
```nix
{
wl = {
linkFile = "/run/secrets/whitelist-bypass-link";
platform = "wbstream";
};
}
```
<a id="services-proxy-suite-whitelistbypass-joiners-name-linkfile"></a>
## services\.proxy-suite\.whitelistBypass\.joiners\.\<name>\.linkFile
File with the call link from the creator’s log\. ` proxy-ctl wl join <name> <link> ` sets
one at runtime and takes priority\. ` null `: the joiner waits for that\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/whitelist-bypass-link"`
<a id="services-proxy-suite-whitelistbypass-joiners-name-platform"></a>
## services\.proxy-suite\.whitelistBypass\.joiners\.\<name>\.platform
Call platform the creator uses\. VK has no joiner here\.
**Type:** one of “wbstream”, “telemost”, “dion”, “bitrix”\
**Example:** `"wbstream"`
+553
View File
@@ -0,0 +1,553 @@
# services.proxy-suite.zapret
DPI bypass without a proxy: zapret-discord-youtube or zapret2.
Part of the [proxy-suite options reference](./index.md).
## Options
- zapret
- [enable](#services-proxy-suite-zapret-enable)
- cidrExemption
- [enable](#services-proxy-suite-zapret-cidrexemption-enable)
- [cidrs](#services-proxy-suite-zapret-cidrexemption-cidrs)
- directSync
- [enable](#services-proxy-suite-zapret-directsync-enable)
- [upstreamIps](#services-proxy-suite-zapret-directsync-upstreamips)
- [userIps](#services-proxy-suite-zapret-directsync-userips)
- [engine](#services-proxy-suite-zapret-engine)
- global
- [enable](#services-proxy-suite-zapret-global-enable)
- zapret-discord-youtube
- [configName](#services-proxy-suite-zapret-zapret-discord-youtube-configname)
- [domains](#services-proxy-suite-zapret-zapret-discord-youtube-domains)
- [excludeDomains](#services-proxy-suite-zapret-zapret-discord-youtube-excludedomains)
- [excludeIps](#services-proxy-suite-zapret-zapret-discord-youtube-excludeips)
- [gameFilter](#services-proxy-suite-zapret-zapret-discord-youtube-gamefilter)
- [hostlistRules](#services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules)
- item
- [enableDirectSync](#services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-enabledirectsync)
- [configName](#services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-configname)
- [defaultDomains](#services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-defaultdomains)
- [defaultIps](#services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-defaultips)
- [domains](#services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-domains)
- [ips](#services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-ips)
- [name](#services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-name)
- [nfqwsArgs](#services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-nfqwsargs)
- [preset](#services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-preset)
- [includeExtraUpstreamLists](#services-proxy-suite-zapret-zapret-discord-youtube-includeextraupstreamlists)
- [ips](#services-proxy-suite-zapret-zapret-discord-youtube-ips)
- zapret2
- autoHostlist
- [enable](#services-proxy-suite-zapret-zapret2-autohostlist-enable)
- [extendedDetection](#services-proxy-suite-zapret-zapret2-autohostlist-extendeddetection)
- [failThreshold](#services-proxy-suite-zapret-zapret2-autohostlist-failthreshold)
- [failTime](#services-proxy-suite-zapret-zapret2-autohostlist-failtime)
- [incomingMaxseq](#services-proxy-suite-zapret-zapret2-autohostlist-incomingmaxseq)
- [retransMaxseq](#services-proxy-suite-zapret-zapret2-autohostlist-retransmaxseq)
- [retransReset](#services-proxy-suite-zapret-zapret2-autohostlist-retransreset)
- [retransThreshold](#services-proxy-suite-zapret-zapret2-autohostlist-retransthreshold)
- [udpIn](#services-proxy-suite-zapret-zapret2-autohostlist-udpin)
- [udpOut](#services-proxy-suite-zapret-zapret2-autohostlist-udpout)
- [blobs](#services-proxy-suite-zapret-zapret2-blobs)
- cutoff
- [enable](#services-proxy-suite-zapret-zapret2-cutoff-enable)
- [proxyFallback](#services-proxy-suite-zapret-zapret2-cutoff-proxyfallback)
- [domains](#services-proxy-suite-zapret-zapret2-domains)
- [excludeDomains](#services-proxy-suite-zapret-zapret2-excludedomains)
- [ipv6](#services-proxy-suite-zapret-zapret2-ipv6)
- ports
- [extraTcp](#services-proxy-suite-zapret-zapret2-ports-extratcp)
- [extraUdp](#services-proxy-suite-zapret-zapret2-ports-extraudp)
- [tcp](#services-proxy-suite-zapret-zapret2-ports-tcp)
- [udp](#services-proxy-suite-zapret-zapret2-ports-udp)
- [profiles](#services-proxy-suite-zapret-zapret2-profiles)
- [proxyFallback](#services-proxy-suite-zapret-zapret2-proxyfallback)
- [strategyLog](#services-proxy-suite-zapret-zapret2-strategylog)
- [strategySource](#services-proxy-suite-zapret-zapret2-strategysource)
<a id="services-proxy-suite-zapret-enable"></a>
## services\.proxy-suite\.zapret\.enable
Whether to enable zapret DPI bypass\. Needed by ` perAppRouting.zapret ` too\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-zapret-cidrexemption-enable"></a>
## services\.proxy-suite\.zapret\.cidrExemption\.enable
Whether to enable skipping zapret for some subnets, such as NATed VMs it would break\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-zapret-cidrexemption-cidrs"></a>
## services\.proxy-suite\.zapret\.cidrExemption\.cidrs
Subnets zapret skips\.
**Type:** list of IPv4 or IPv6 address or CIDR\
**Default:** `[ ]`\
**Example:** `[ "192.168.123.0/24" ]`
<a id="services-proxy-suite-zapret-directsync-enable"></a>
## services\.proxy-suite\.zapret\.directSync\.enable
Send zapret’s domains direct in the proxy routing, so zapret handles them\. With zapret2,
also the sites pinned at runtime, and the ones it learns once a strategy is seen getting
through for them, after your own rules and autoProxy’s\. The all-proxy and all-bypass
route modes leave them out, like every direct list\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-zapret-directsync-upstreamips"></a>
## services\.proxy-suite\.zapret\.directSync\.upstreamIps
Also send zapret’s upstream IP lists direct\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-zapret-directsync-userips"></a>
## services\.proxy-suite\.zapret\.directSync\.userIps
Also send ` zapret-discord-youtube.ips ` (minus ` excludeIps `) direct\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-zapret-engine"></a>
## services\.proxy-suite\.zapret\.engine
Which zapret to run:
- “zapret-discord-youtube”: ready-made presets and fixed site lists\.
- “zapret2”: learns blocked sites at runtime\.
**Type:** one of “zapret-discord-youtube”, “zapret2”\
**Default:** `"zapret-discord-youtube"`\
**Example:** `"zapret2"`
<a id="services-proxy-suite-zapret-global-enable"></a>
## services\.proxy-suite\.zapret\.global\.enable
Run zapret system-wide\. Turn off to keep zapret to apps started with
` proxy-ctl apps run zapret ` (` perAppRouting.zapret `); ` directSync `, ` cidrExemption ` and
zapret2’s learned sites then do nothing\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-zapret-zapret-discord-youtube-configname"></a>
## services\.proxy-suite\.zapret\.zapret-discord-youtube\.configName
Strategy preset name (spaces are ignored)\.
**Type:** string\
**Default:** `"general(ALT)"`\
**Example:** `"general (ALT9)"`
<a id="services-proxy-suite-zapret-zapret-discord-youtube-domains"></a>
## services\.proxy-suite\.zapret\.zapret-discord-youtube\.domains
Extra domains to unblock\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "youtube.com" ]`
<a id="services-proxy-suite-zapret-zapret-discord-youtube-excludedomains"></a>
## services\.proxy-suite\.zapret\.zapret-discord-youtube\.excludeDomains
Domains zapret never touches\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "music.youtube.com" ]`
<a id="services-proxy-suite-zapret-zapret-discord-youtube-excludeips"></a>
## services\.proxy-suite\.zapret\.zapret-discord-youtube\.excludeIps
IPs or CIDRs zapret never touches\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "203.0.113.10/32" ]`
<a id="services-proxy-suite-zapret-zapret-discord-youtube-gamefilter"></a>
## services\.proxy-suite\.zapret\.zapret-discord-youtube\.gameFilter
Which game traffic to handle, or “null” for none\.
**Type:** one of “all”, “tcp”, “udp”, “null”\
**Default:** `"null"`\
**Example:** `"all"`
<a id="services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules"></a>
## services\.proxy-suite\.zapret\.zapret-discord-youtube\.hostlistRules
Extra site lists, each with its own strategy: copied from a ` preset ` or ` configName `,
or given as raw ` nfqwsArgs `\.
**Type:** list of (submodule)\
**Default:** `[ ]`\
**Example:**
```nix
[
{
configName = "general(ALT9)";
defaultDomains = [
"youtube"
];
name = "youtube-alt9";
}
{
domains = [
"example.com"
];
name = "custom-sites";
preset = "general";
}
]
```
<a id="services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-enabledirectsync"></a>
## services\.proxy-suite\.zapret\.zapret-discord-youtube\.hostlistRules\.\*\.enableDirectSync
Include these domains in ` zapret.directSync `\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-configname"></a>
## services\.proxy-suite\.zapret\.zapret-discord-youtube\.hostlistRules\.\*\.configName
Config to copy the strategy from\. Cannot be used with ` nfqwsArgs `\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"general(ALT9)"`
<a id="services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-defaultdomains"></a>
## services\.proxy-suite\.zapret\.zapret-discord-youtube\.hostlistRules\.\*\.defaultDomains
Upstream lists to include (“discord” is “general”, “youtube” is “google”)\. Without
` preset `, use only one, so the strategy can be inferred from it\.
**Type:** list of (one of “general”, “google”, “discord”, “youtube”, “instagram”, “soundcloud”, “twitter”)\
**Default:** `[ ]`\
**Example:** `[ "google" ]`
<a id="services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-defaultips"></a>
## services\.proxy-suite\.zapret\.zapret-discord-youtube\.hostlistRules\.\*\.defaultIps
Upstream IP lists to include\.
**Type:** list of value “all” (singular enum)\
**Default:** `[ ]`\
**Example:** `[ "all" ]`
<a id="services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-domains"></a>
## services\.proxy-suite\.zapret\.zapret-discord-youtube\.hostlistRules\.\*\.domains
Domains in this list\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "example.com" ]`
<a id="services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-ips"></a>
## services\.proxy-suite\.zapret\.zapret-discord-youtube\.hostlistRules\.\*\.ips
IPs or CIDRs in this list\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "203.0.113.0/24" ]`
<a id="services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-name"></a>
## services\.proxy-suite\.zapret\.zapret-discord-youtube\.hostlistRules\.\*\.name
List name\.
**Type:** string matching the pattern ^\[a-z0-9]\[a-z0-9-]\*$\
**Example:** `"cloudflare"`
<a id="services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-nfqwsargs"></a>
## services\.proxy-suite\.zapret\.zapret-discord-youtube\.hostlistRules\.\*\.nfqwsArgs
Raw nfqws arguments; ` --hostlist ` and ` --new ` are added\. Cannot be used with ` configName `\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "--filter-tcp=443 --dpi-desync=fake,multisplit" ]`
<a id="services-proxy-suite-zapret-zapret-discord-youtube-hostlistrules-preset"></a>
## services\.proxy-suite\.zapret\.zapret-discord-youtube\.hostlistRules\.\*\.preset
Strategy to copy, from ` configName ` or the active config\.
**Type:** null or one of “general”, “google”, “instagram”, “soundcloud”, “twitter”\
**Default:** `null`\
**Example:** `"google"`
<a id="services-proxy-suite-zapret-zapret-discord-youtube-includeextraupstreamlists"></a>
## services\.proxy-suite\.zapret\.zapret-discord-youtube\.includeExtraUpstreamLists
Also use the upstream instagram, soundcloud and twitter lists\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-zapret-zapret-discord-youtube-ips"></a>
## services\.proxy-suite\.zapret\.zapret-discord-youtube\.ips
Extra IPs or CIDRs to unblock\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "203.0.113.0/24" ]`
<a id="services-proxy-suite-zapret-zapret2-autohostlist-enable"></a>
## services\.proxy-suite\.zapret\.zapret2\.autoHostlist\.enable
Learn blocked sites: after ` failThreshold ` failed connections, a site is treated as
blocked\. When off, only ` zapret2.domains ` and ` proxy-ctl zapret auto add ` are used:
the sites already learned are kept but ignored, by zapret2 and ` zapret.directSync `
alike, until it is back on\. Each site’s strategy is still remembered\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-zapret-zapret2-autohostlist-extendeddetection"></a>
## services\.proxy-suite\.zapret\.zapret2\.autoHostlist\.extendedDetection
Learn with proxy-suite’s detector instead of nfqws2’s\. It also learns sites blocked
only some of the time (a working connection no longer clears the failures before it),
downloads that stall partway (the 16 KB cutoff), and requests that never get an
answer\. It also follows learned sites past the first 4 KB a strategy is judged on:
one whose downloads keep stalling keeps the proxy’s route (` zapret.directSync `)\.
Learned sites are logged with ` strategyLog `\. Only with the source’s own
` profiles `, and for TLS: nfqws2-keenetic no longer learns plain HTTP sites\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-zapret-zapret2-autohostlist-failthreshold"></a>
## services\.proxy-suite\.zapret\.zapret2\.autoHostlist\.failThreshold
Failures before a site is learned\.
**Type:** positive integer, meaning >0\
**Default:** `3`
<a id="services-proxy-suite-zapret-zapret2-autohostlist-failtime"></a>
## services\.proxy-suite\.zapret\.zapret2\.autoHostlist\.failTime
Seconds without a failure before the count resets\.
**Type:** positive integer, meaning >0\
**Default:** `300`
<a id="services-proxy-suite-zapret-zapret2-autohostlist-incomingmaxseq"></a>
## services\.proxy-suite\.zapret\.zapret2\.autoHostlist\.incomingMaxseq
After this many bytes received, a reset or redirect is not a failure\.
**Type:** positive integer, meaning >0\
**Default:** `4096`
<a id="services-proxy-suite-zapret-zapret2-autohostlist-retransmaxseq"></a>
## services\.proxy-suite\.zapret\.zapret2\.autoHostlist\.retransMaxseq
Stop watching a connection for failures after this many bytes sent\.
**Type:** positive integer, meaning >0\
**Default:** `32768`
<a id="services-proxy-suite-zapret-zapret2-autohostlist-retransreset"></a>
## services\.proxy-suite\.zapret\.zapret2\.autoHostlist\.retransReset
Reset a stalled connection at ` retransThreshold `, so failures are counted faster\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-zapret-zapret2-autohostlist-retransthreshold"></a>
## services\.proxy-suite\.zapret\.zapret2\.autoHostlist\.retransThreshold
Retransmissions of the first request that count as a failure\.
**Type:** positive integer, meaning >0\
**Default:** `3`
<a id="services-proxy-suite-zapret-zapret2-autohostlist-udpin"></a>
## services\.proxy-suite\.zapret\.zapret2\.autoHostlist\.udpIn
Most UDP replies that still count as no answer (see ` udpOut `)\.
**Type:** positive integer, meaning >0\
**Default:** `1`
<a id="services-proxy-suite-zapret-zapret2-autohostlist-udpout"></a>
## services\.proxy-suite\.zapret\.zapret2\.autoHostlist\.udpOut
UDP packets sent, with at most ` udpIn ` replies, that count as a failure\.
**Type:** positive integer, meaning >0\
**Default:** `4`
<a id="services-proxy-suite-zapret-zapret2-blobs"></a>
## services\.proxy-suite\.zapret\.zapret2\.blobs
Extra fake payloads by name (blob=\<name>): a file in zapret2’s files/fake, or an absolute path\.
**Type:** attribute set of string matching the pattern \[^\[:space:]]+\
**Default:** `{ }`\
**Example:** `{ tls_clienthello = "/etc/proxy-suite/my_clienthello.bin"; }`
<a id="services-proxy-suite-zapret-zapret2-cutoff-enable"></a>
## services\.proxy-suite\.zapret\.zapret2\.cutoff\.enable
Work around ISPs that cut TLS to some hosting networks after about 16 KB, which no
strategy fixes\. A daily probe finds the affected networks, and with
` strategySource = "z2k" ` (and its own ` profiles `) a whitelisted name that gets
through for each, which z2k puts into a fake ClientHello\. Otherwise no name is
searched for, and every affected network is left to ` proxyFallback `\. Each run makes
thousands of short direct connections\. ` proxy-ctl zapret cutoff ` shows the results\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-zapret-zapret2-cutoff-proxyfallback"></a>
## services\.proxy-suite\.zapret\.zapret2\.cutoff\.proxyFallback
Send cut-off networks that no name fixes through the proxy\. Needs the sing-box backend,
an outbound, and a route mode other than all-bypass\. Only works for traffic the proxy
sees by IP (TUN, TProxy, per-app routing)\. Explicit direct rules still win\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-zapret-zapret2-domains"></a>
## services\.proxy-suite\.zapret\.zapret2\.domains
Domains always treated as blocked\. At runtime: ` proxy-ctl zapret auto add `\.
**Type:** list of string matching the pattern \[^\[:space:]]+\
**Default:** `[ ]`\
**Example:** `[ "rutracker.org" ]`
<a id="services-proxy-suite-zapret-zapret2-excludedomains"></a>
## services\.proxy-suite\.zapret\.zapret2\.excludeDomains
Domains never touched or learned\. At runtime: ` proxy-ctl zapret auto exclude `\.
**Type:** list of string matching the pattern \[^\[:space:]]+\
**Default:** `[ ]`\
**Example:** `[ "bank.example.com" ]`
<a id="services-proxy-suite-zapret-zapret2-ipv6"></a>
## services\.proxy-suite\.zapret\.zapret2\.ipv6
Handle IPv6 too\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-zapret-zapret2-ports-extratcp"></a>
## services\.proxy-suite\.zapret\.zapret2\.ports\.extraTcp
More TCP ports, handled like the profiles’ own: each profile that recognizes its traffic
(` --filter-l7 `, e\.g\. TLS) gets them too, so TLS to a blocked site on one of these ports
gets the same strategies\. A profile without ` --filter-l7 ` keeps its ports\.
**Type:** list of (16 bit unsigned integer; between 0 and 65535 (both inclusive) or string matching the pattern \[0-9]+(-\[0-9]+)?)\
**Default:** `[ ]`\
**Example:** `[ 8444 "9000-9010" ]`
<a id="services-proxy-suite-zapret-zapret2-ports-extraudp"></a>
## services\.proxy-suite\.zapret\.zapret2\.ports\.extraUdp
More UDP ports, handled like the profiles’ own: each profile that recognizes its traffic
(` --filter-l7 `, e\.g\. STUN, Discord, QUIC) gets them too, so a game’s or call app’s STUN
on these ports gets the same strategies as Discord’s\.
**Type:** list of (16 bit unsigned integer; between 0 and 65535 (both inclusive) or string matching the pattern \[0-9]+(-\[0-9]+)?)\
**Default:** `[ ]`\
**Example:** `[ "27015-27030" ]`
<a id="services-proxy-suite-zapret-zapret2-ports-tcp"></a>
## services\.proxy-suite\.zapret\.zapret2\.ports\.tcp
TCP ports zapret2 handles\. The ports the profiles filter on and ` extraTcp ` are always added\. ` null `: use the ports from ` strategySource `\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"80,443"`
<a id="services-proxy-suite-zapret-zapret2-ports-udp"></a>
## services\.proxy-suite\.zapret\.zapret2\.ports\.udp
UDP ports zapret2 handles\. The ports the profiles filter on and ` extraUdp ` are always added\. ` null `: use the ports from ` strategySource `\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"443"`
<a id="services-proxy-suite-zapret-zapret2-profiles"></a>
## services\.proxy-suite\.zapret\.zapret2\.profiles
Your own nfqws2 profiles, instead of those from ` strategySource `\. The first match wins\.
` <HOSTLIST> ` expands to the site list arguments, ` <HOSTLIST_NOAUTO> ` to the same without
learning\. ` --qnum `, ` --fwmark ` and ` --lua-init ` are added for you\. ` null `: use the profiles from ` strategySource `\.
**Type:** null or (list of string)\
**Default:** `null`\
**Example:**
```nix
[
"--filter-tcp=443 --filter-l7=tls <HOSTLIST> --payload=tls_client_hello --lua-desync=multisplit:pos=1,midsld"
]
```
<a id="services-proxy-suite-zapret-zapret2-proxyfallback"></a>
## services\.proxy-suite\.zapret\.zapret2\.proxyFallback
Send through the proxy what zapret2 cannot fix: a site none of its strategies get
through for (only its QUIC, when that alone fails), and an address that leaves
connections unanswered (blocked by address, as Telegram’s are)\. Learned sites go
direct (` zapret.directSync `) only once a strategy is seen working for them\. Needs an
outbound; works for traffic the proxy sees (TUN, TProxy, per-app routing; by address
only where it sees the address)\. ` proxy-ctl zapret auto retry ` gives one another try\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-zapret-zapret2-strategylog"></a>
## services\.proxy-suite\.zapret\.zapret2\.strategyLog
Log each counted failure and strategy switch to the journal, per site
(` proxy-ctl logs proxy-suite-zapret `)\. Without it nfqws2 logs them only with
` debug.zapret2.packets `\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-zapret-zapret2-strategysource"></a>
## services\.proxy-suite\.zapret\.zapret2\.strategySource
Where the strategies, blobs and ports come from\.
- “nfqws2-keenetic”: its strategies and site lists\.
- “z2k”: z2k’s strategies, which rotate per category (YouTube, Discord, QUIC, …), with
its site lists, including the full RKN list (more memory)\.
Either way, each site’s working strategy is remembered across restarts\.
**Type:** one of “nfqws2-keenetic”, “z2k”\
**Default:** `"nfqws2-keenetic"`\
**Example:** `"z2k"`
+81
View File
@@ -0,0 +1,81 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
backend = "sing-box"; # or "xray", "hybrid"
# `url` ends up in the Nix store; use `urlFile` for secrets.
outbounds = [ { tag = "nl-vps"; url = "hy2://password@example.com:443?sni=example.com"; } ];
subscriptions = [ { tag = "main-sub"; urlFile = "/run/secrets/sub-url"; } ];
selection = "urltest"; # pick the fastest; default "first"
tproxy.enable = true;
tun.enable = true;
};
perAppRouting = {
enable = true;
createDefaultProfiles = true;
proxychains.enable = true;
tun.enable = true;
tproxy.enable = true;
zapret.enable = true;
};
zapret.enable = true;
sshProxy = {
enable = true;
server = {
user = "root";
host = "ssh.example.com";
};
identityFile = "/run/secrets/proxy-suite-ssh-key";
hostKeyFile = "/run/secrets/proxy-suite-ssh-known-hosts";
};
# Only one global tunnel (AWG, TUN or TProxy) runs at a time.
amneziaWg = {
enable = true;
profiles.home.configFile = "/run/secrets/home-amneziawg.conf";
profiles.work.vpnFile = "/run/secrets/work-amnezia.vpn";
# Or use a profile as an outbound, tagged "de":
profiles.de = {
asOutbound = "interface"; # or "userspace" (no root), "singBox" (plain WireGuard)
configFile = "/run/secrets/de-amneziawg.conf";
};
};
warp = {
enable = true;
asOutbound = "singBox"; # outbound tagged "warp"
# asAmneziaWg = true; # or a global profile: proxy-ctl awg on warp
};
# Outbound tagged "tor"; .onion names always go there.
tor = {
enable = true;
asOutbound = true;
# bridges.file = "/run/secrets/tor-bridges";
# upstream = "proxy"; # reach Tor through the proxy
};
tgWsProxy = {
enable = true;
secretFile = "/run/secrets/tg-ws-proxy-secret";
};
# Tunnel through a video call. A creator runs on a free server and logs the call link;
# the joiner here is an outbound tagged "wl".
whitelistBypass = {
enable = true;
creators.phone = { platform = "wbstream"; cookiesFile = "/run/secrets/wb-cookies.json"; };
# joiners.wl = { platform = "wbstream"; linkFile = "/run/secrets/wb-link"; };
};
gui.enable = true;
};
}
+15
View File
@@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
amneziaWg = {
enable = true;
profiles.home.configFile = "/run/secrets/home-awg.conf";
profiles.work = {
vpnFile = "/run/secrets/work-amnezia.vpn";
autostart = true; # at most one profile
};
};
killSwitch.enable = true; # optional: no leaks while the tunnel is down
};
}
+14
View File
@@ -0,0 +1,14 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy.enable = true;
amneziaWg = {
enable = true;
profiles.de = {
configFile = "/run/secrets/de-awg.conf";
asOutbound = "interface";
};
};
};
}
+18
View File
@@ -0,0 +1,18 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy.enable = true;
amneziaWg = {
enable = true;
profiles.de = {
configFile = "/run/secrets/de-awg.conf";
asOutbound = "interface";
};
};
perAppRouting = {
enable = true;
profiles = [ { name = "games"; outbound = "de"; } ];
};
};
}
+11
View File
@@ -0,0 +1,11 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
amneziaWg.enable = true; # no profiles needed
userControl = {
enable = true;
scopes = [ "services" "amneziaWg" "outbounds" ]; # optional: no sudo for these
};
};
}
+14
View File
@@ -0,0 +1,14 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [
{ tag = "hop"; urlFile = "/run/secrets/hop-url"; }
{ tag = "de-vps"; urlFile = "/run/secrets/de-vps-url"; detour = "hop"; }
];
selectionExclude = [ "hop" ]; # never picked as the exit on its own
};
};
}
+35
View File
@@ -0,0 +1,35 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
routing.rules = [
{ domains = [ "chatgpt.com" "openai.com" ]; outbound = "warp"; }
{ domains = [ "check.torproject.org" ]; outbound = "tor"; }
];
};
# Tagged "warp". Registers a free WARP device on first start.
warp = {
enable = true;
asOutbound = "singBox";
};
# Tagged "tor". .onion names always go to it.
tor = {
enable = true;
asOutbound = true;
};
# Tagged "ssh-proxy".
sshProxy = {
enable = true;
asOutbound = true;
server = { user = "me"; host = "ssh.example.com"; };
identityFile = "/run/secrets/ssh-key";
hostKeyFile = "/run/secrets/ssh-known-hosts"; # from ssh-keyscan
};
};
}
+12
View File
@@ -0,0 +1,12 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
subscriptions = [ { tag = "provider"; urlFile = "/run/secrets/provider-sub-url"; } ];
selection = "urltest";
};
};
}
+16
View File
@@ -0,0 +1,16 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
gui.enable = true;
userControl = {
enable = true;
scopes = [ "services" "routing" "outbounds" "perApp" ];
};
};
users.users.alice.extraGroups = [ "proxy-suite" ];
}
+20
View File
@@ -0,0 +1,20 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
userControl = {
enable = true;
scopes = [ "routing" ];
groups = {
proxy-admins.scopes = [ ];
proxy-users.scopes = [ "perApp" "outbounds" ];
};
};
};
users.users.alice.extraGroups = [ "proxy-admins" ];
users.users.bob.extraGroups = [ "proxy-users" ];
}
+15
View File
@@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
debug.connectionLog = {
enable = true;
hosts = [ "x.com" "twimg.com" ]; # leave empty for every site
inbounds = [ "tproxy" ]; # global and per-app TProxy only
};
};
}
+11
View File
@@ -0,0 +1,11 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
debug.logLevel = "info"; # every connection and the rule that routed it
};
}
+15
View File
@@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
perAppRouting = {
enable = true;
tproxy.enable = true;
};
debug.perAppDns = true;
};
}
@@ -0,0 +1,101 @@
{ ... }:
let
# Telegram apps dial their data centres by IP, so names alone do not catch them
# (https://core.telegram.org/resources/cidr.txt).
telegramIps = [
"91.105.192.0/23"
"91.108.4.0/22"
"91.108.8.0/22"
"91.108.12.0/22"
"91.108.16.0/22"
"91.108.20.0/22"
"91.108.56.0/22"
"149.154.160.0/20"
"185.76.151.0/24"
"2001:67c:4e8::/48"
"2001:b28:f23c::/48"
"2001:b28:f23d::/48"
"2001:b28:f23f::/48"
"2a0a:f280::/32"
];
in
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "primary"; urlFile = "/run/secrets/proxy-primary-url"; } ];
routing = {
# Unlisted sites leave directly, where zapret2 unblocks what DPI blocks.
default = "direct";
# Russian sites go to WARP by the last rule below instead.
directRu = false;
# Checked in order, before the lists; the first match wins.
rules = [
{
outbound = "ssh-proxy";
geosites = [ "pixiv" "twitter" ];
}
{
outbound = "warp";
geosites = [ "youtube" ];
}
# Russian services see WARP's address instead of this host's.
{
outbound = "warp";
geosites = [ "category-ru" ];
geoips = [ "ru" ];
}
];
# Through the selected outbound ("primary").
proxy = {
geosites = [ "openai" "anthropic" "telegram" "netflix" ];
ips = telegramIps;
# WARP registers through the proxy: its API is blocked directly in Russia.
domains = [ "api.cloudflareclient.com" ];
};
};
# For blocked sites no list names yet. YouTube already has its rule, so its video
# hosts are not worth probing.
autoProxy = {
enable = true;
exclude = [ "googlevideo.com" "gvt1.com" ];
};
};
warp = {
enable = true;
asOutbound = "singBox";
};
sshProxy = {
enable = true;
asOutbound = true;
server = {
user = "me";
host = "203.0.113.20";
port = 2222;
};
identityFile = "/run/secrets/proxy-ssh-key";
hostKeyFile = "/run/secrets/proxy-ssh-known-hosts";
};
# .onion names go to Tor without a rule. Tor is blocked here, so it connects
# through the proxy.
tor = {
enable = true;
asOutbound = true;
upstream = "proxy";
};
zapret = {
enable = true;
engine = "zapret2";
};
};
}
@@ -0,0 +1,61 @@
{ ... }:
let
interface = "awg0";
serverAddress = "10.77.77.1";
privateDomains = [ "mail.example.com" ];
in
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "primary"; urlFile = "/run/secrets/proxy-primary-url"; } ];
};
inbounds = {
enable = true;
routing.via = "proxy";
# Fixed addresses, so firewall rules and DNS can name each device.
# Keys are generated on first start.
users = {
laptop.address = "10.77.77.2";
phone.address = "10.77.77.3";
};
listeners.vpn = {
type = "amneziawg";
port = 51820;
users = [ "laptop" "phone" ];
amneziaWg = {
# Devices also reach this host, its LAN and each other, directly.
mode = "lan";
interfaceName = interface;
subnet = "10.77.77.0/24";
subnet6 = "fd77:77:77::/64";
mtu = 1400;
dns = [ serverAddress ];
# Optional: a fixed server key, so client configs survive a reinstall.
privateKeyFile = "/run/secrets/awg-server-key";
};
};
};
};
# Private names for VPN clients; everything else is forwarded to 1.1.1.1.
services.dnsmasq = {
enable = true;
resolveLocalQueries = false;
settings = {
bind-dynamic = true;
interface = interface;
listen-address = serverAddress;
no-resolv = true;
server = [ "1.1.1.1" ];
address = map (domain: "/${domain}/${serverAddress}") privateDomains;
};
};
# The interface comes and goes with the listener.
systemd.services.dnsmasq = {
after = [ "proxy-suite-inbounds-awg.service" ];
wants = [ "proxy-suite-inbounds-awg.service" ];
};
}
@@ -0,0 +1,159 @@
{ config, lib, ... }:
let
domain = "vpn.example.com";
certDir = config.security.acme.certs.${domain}.directory;
users = [
"alice"
"bob"
"carol"
];
# The listeners terminate TLS themselves, so share links honestly say security=tls.
tls = {
enable = true;
certificateFile = "${certDir}/fullchain.pem";
keyFile = "${certDir}/key.pem";
serverName = domain;
};
# nginx on 443 hands a path to a loopback listener.
fronted = port: path: extra: {
type = "vless";
inherit port users;
address = "127.0.0.1";
sharePort = 443; # share links name nginx's port, not the listener's
transport = extra // {
inherit path;
# nginx sets this header, so XRay sees each client's real address (for `proxy-ctl inbounds online`). A client cannot forge it: nginx overwrites it.
trustedXForwardedFor = [ "X-Real-IP" ];
};
inherit tls;
};
location = port: extra: {
proxyPass = "https://127.0.0.1:${toString port}";
extraConfig = ''
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_ssl_server_name on;
proxy_ssl_name ${domain};
# Tunnels idle along with their users; the 60s default would cut them.
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
''
+ extra;
};
in
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "primary"; urlFile = "/run/secrets/proxy-primary-url"; } ];
};
inbounds = {
users = lib.genAttrs users (name: { uuidFile = "/run/secrets/proxy-uuid-${name}"; });
enable = true;
serverAddress = domain;
routing.via = "proxy";
listeners = {
# nginx speaks HTTP/1.1 to the listener, which only packet-up mode crosses.
xhttp = fronted 10003 "/media" {
type = "xhttp";
mode = "packet-up";
};
ws = fronted 10002 "/media-ws" { type = "ws"; };
# stream-one needs HTTP/2 all the way: nginx's grpc_pass provides it.
xhttp-stream = lib.recursiveUpdate (fronted 10004 "/media-stream" {
type = "xhttp";
mode = "stream-one";
}) { tls.alpn = [ "h2" ]; };
# HTTP/3 takes UDP 443 only, beside nginx on TCP 443. No trustedXForwardedFor:
# nothing is in front, so it already sees the real client.
xhttp-h3 = {
type = "vless";
port = 443;
inherit users;
transport = { type = "xhttp"; path = "/media-h3"; };
tls = tls // { alpn = [ "h3" ]; };
};
reality = {
type = "vless";
port = 2053;
inherit users;
flow = "xtls-rprx-vision";
reality = {
enable = true;
# Probes without the key land on a real TLS 1.3 + HTTP/2 site.
dest = "www.samsung.com:443";
serverNames = [ "www.samsung.com" ];
privateKeyFile = "/run/secrets/proxy-reality-key";
publicKey = "jNXH…";
shortIds = [ "0123abcd" ];
};
};
};
subscriptions = {
enable = true;
baseUrl = "https://${domain}/sub";
};
};
userControl.enable = true; # passwordless proxy-ctl for the admin, see below
};
users.users.admin.extraGroups = [ "proxy-suite" ];
security.acme = {
acceptTerms = true;
defaults.email = "admin@example.com";
# A renewed certificate restarts the listeners.
certs.${domain}.reloadServices = [ "proxy-suite-inbounds.service" ];
};
systemd.services.proxy-suite-inbounds = {
wants = [ "acme-${domain}.service" ];
after = [ "acme-${domain}.service" ];
};
services.nginx = {
enable = true;
virtualHosts.${domain} = {
forceSSL = true;
enableACME = true;
locations = {
# A prefix match: XHTTP appends /<session>/<seq>.
"/media" = location 10003 ''
proxy_http_version 1.1;
proxy_request_buffering off;
proxy_buffering off;
client_max_body_size 0;
'';
"= /media-ws" = location 10002 "" // { proxyWebsockets = true; };
"/media-stream".extraConfig = ''
grpc_pass grpcs://127.0.0.1:10004;
grpc_set_header X-Forwarded-For $remote_addr;
grpc_set_header X-Real-IP $remote_addr;
grpc_ssl_server_name on;
grpc_ssl_name ${domain};
grpc_read_timeout 3600s;
grpc_send_timeout 3600s;
client_max_body_size 0;
'';
# Subscriptions. Some clients show profile-title and follow profile-update-interval.
"/sub/".extraConfig = ''
alias /run/proxy-suite-inbounds/subscriptions/;
default_type text/plain;
autoindex off;
add_header profile-title "My VPN" always;
add_header profile-update-interval "12" always;
'';
};
};
};
}
@@ -0,0 +1,59 @@
{ config, pkgs, ... }:
let
proxySuite = config.lib.proxy-suite;
in
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
# Support all available protocols by enabling hybrid backend.
backend = "hybrid";
# The server's subscription: every listener, each a separate outbound.
subscriptions = [ { tag = "home"; urlFile = "/run/secrets/proxy-home-sub"; } ];
# The fastest listener that gets through the current network.
selection = "urltest";
urlTest.url = "https://telegram.org"; # blocked here, so a pass means it works
routing.default = "direct";
autoProxy.enable = true;
tun.enable = true; # when everything should go through: `proxy-ctl proxy tun on`
};
zapret = {
enable = true;
engine = "zapret2";
};
# The private VPN: `proxy-ctl awg on home`.
amneziaWg = {
enable = true;
profiles.home.configFile = "/run/secrets/home-vpn.conf";
};
killSwitch.enable = true;
perAppRouting = {
enable = true;
createDefaultProfiles = true;
proxychains.enable = true;
tun.enable = true;
};
gui.enable = true;
userControl.enable = true;
};
users.users.me.extraGroups = [ "proxy-suite" ];
environment.systemPackages = [
# CLIs that only work through the proxy, whatever the routing says.
(proxySuite.wrapEnv { protocol = "all"; } pkgs.codex)
(proxySuite.wrapEnv { } pkgs.claude-code)
# A browser for blocked sites, with its UDP (QUIC) too.
(proxySuite.wrapPerApp { profile = "tun"; } pkgs.chromium)
];
# Nix downloads through the proxy.
systemd.services.nix-daemon.environment = proxySuite.envFor "http";
}
+14
View File
@@ -0,0 +1,14 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [
{ tag = "de-vps"; urlFile = "/run/secrets/de-vps-url"; }
{ tag = "nl-vps"; urlFile = "/run/secrets/nl-vps-url"; }
];
groups.eu.outbounds = [ "de-vps" "nl-vps" ]; # de-vps first, nl-vps when it fails
};
};
}
+12
View File
@@ -0,0 +1,12 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite.proxy = {
enable = true;
subscriptions = [ { tag = "provider"; urlFile = "/run/secrets/provider-sub"; } ];
groups.fast = {
subscriptions = [ "provider" ]; # every entry the subscription holds
match = [ "de-*" ]; # and every outbound whose tag matches
strategy = "urltest";
};
};
}
+8
View File
@@ -0,0 +1,8 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite.proxy = {
enable = true;
selection = "failover";
priority = { eu = 10; warp = 20; };
};
}
+13
View File
@@ -0,0 +1,13 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
amneziaWg.enable = true;
proxy.enable = true;
warp = {
enable = true;
asOutbound = "interface";
instances = 2; # warp-1 (keeps an existing registration) and warp-2
};
};
}
+12
View File
@@ -0,0 +1,12 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite.warp = {
enable = true;
asOutbound = "interface";
devices = {
warp-a = { };
warp-b.endpoint = "162.159.193.10:500";
};
group.strategy = "failover";
};
}
+16
View File
@@ -0,0 +1,16 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
perAppRouting = {
enable = true;
createDefaultProfiles = true; # a profile named after each method below
proxychains.enable = true;
tun.enable = true;
};
};
}
+15
View File
@@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
perAppRouting = {
enable = true;
tun.enable = true;
profiles = [ { name = "browser"; route = "tun"; } ];
};
};
}
+15
View File
@@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "nl"; urlFile = "/run/secrets/nl-url"; } ];
};
perAppRouting = {
enable = true;
tun.enable = true;
profiles = [ { name = "game"; route = "tun"; outbound = "nl"; } ];
};
};
}
+18
View File
@@ -0,0 +1,18 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
perAppRouting = {
enable = true;
createDefaultProfiles = true;
tun = {
enable = true;
keepRunning = true;
};
};
};
}
+22
View File
@@ -0,0 +1,22 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "nl"; urlFile = "/run/secrets/nl-url"; } ];
};
amneziaWg = {
enable = true;
profiles.home.configFile = "/run/secrets/home.conf";
};
perAppRouting = {
enable = true;
tun.enable = true;
profiles = [
{ name = "game"; route = "tun"; outbound = "nl"; keepRunning = true; }
{ name = "home"; outbound = "awg:home"; keepRunning = true; }
];
};
};
}
+17
View File
@@ -0,0 +1,17 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
routing = {
default = "direct";
proxy.domains = [ "youtube.com" "googlevideo.com" ];
proxy.geosites = [ "instagram" ];
};
# Find blocked sites on its own, and route each one through an exit that reaches it.
autoProxy.enable = true;
};
};
}
+18
View File
@@ -0,0 +1,18 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [
{ tag = "nl-vps"; urlFile = "/run/secrets/nl-vps-url"; }
{ tag = "us-vps"; urlFile = "/run/secrets/us-vps-url"; }
];
routing = {
rules = [ { geosites = [ "netflix" ]; outbound = "us-vps"; } ];
direct.domains = [ "bank.example" ];
block.geosites = [ "category-ads-all" ];
};
};
};
}
+15
View File
@@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
routing = {
default = "direct";
ruleSets.blocked.url = "https://example.com/blocked.srs";
proxy.ruleSets = [ "blocked" ];
};
};
};
}
+37
View File
@@ -0,0 +1,37 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
inbounds = {
enable = true;
serverAddress = "vpn.example.com"; # null: this host's public IPv4
routing.via = "direct"; # clients exit straight from this host
# Each user once; listeners name the ones they accept, and take the secret they need.
users = {
phone.uuidFile = "/run/secrets/uuid-phone";
laptop.uuidFile = "/run/secrets/uuid-laptop";
};
listeners = {
vless-reality = {
type = "vless";
port = 443;
flow = "xtls-rprx-vision";
users = [ "phone" "laptop" ];
reality = {
enable = true;
serverNames = [ "www.microsoft.com" ];
privateKeyFile = "/run/secrets/reality-private-key";
publicKey = "jNXH…"; # both keys from `xray x25519`
shortIds = [ "0123abcd" ];
};
};
# Keys for the server and each user are generated on first start.
awg = {
type = "amneziawg";
port = 51820;
users = [ "phone" ];
};
};
};
};
}
+11
View File
@@ -0,0 +1,11 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite.inbounds.subscriptions = {
enable = true;
baseUrl = "https://vpn.example.com/sub";
};
services.nginx.virtualHosts."vpn.example.com".locations."/sub/" = {
alias = "/run/proxy-suite-inbounds/subscriptions/";
extraConfig = "access_log off;"; # the token is the URL's secret
};
}
+12
View File
@@ -0,0 +1,12 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite.inbounds.runtime = {
enable = true;
ports = [ "20000-20099" ]; # runtime listeners bind only here; opened in the firewall
vias = [ "direct" ]; # exits besides routing.via and "block"
tlsCertificates.main = { # named, so a runtime listener never points at a file
certificateFile = "/var/lib/acme/vpn.example.com/fullchain.pem";
keyFile = "/var/lib/acme/vpn.example.com/key.pem";
};
};
}
+17
View File
@@ -0,0 +1,17 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite.inbounds = {
manager = {
enable = true;
speedLimits.enable = true; # nftables, and proxy-suite's XRay patch
};
# Declared users take a policy in the config; runtime ones get theirs from proxy-ctl or the API.
users.phone.policy = {
expiresAt = "2026-12-31";
trafficLimit = "100G";
trafficPeriod = "monthly";
ipLimit = 2;
speedLimit = "50M/10M"; # down/up, bits per second
};
};
}
+13
View File
@@ -0,0 +1,13 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
tun.enable = true;
autostart = "tun"; # or null, to start it by hand
};
killSwitch.enable = true;
};
}
@@ -0,0 +1,13 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
whitelistBypass = {
enable = true;
creators.laptop = {
platform = "wbstream";
cookiesFile = "/run/secrets/wbstream-cookies.json";
};
};
};
}
@@ -0,0 +1,11 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy.enable = true;
whitelistBypass = {
enable = true;
joiners.wl.platform = "wbstream";
};
};
}
+28
View File
@@ -0,0 +1,28 @@
{ config, pkgs, ... }:
let
proxySuite = config.lib.proxy-suite;
in
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
perAppRouting = {
enable = true;
createDefaultProfiles = true;
proxychains.enable = true;
tun.enable = true;
};
};
environment.systemPackages = [
(proxySuite.wrapEnv { } pkgs.yt-dlp)
(proxySuite.wrapProxychains { } pkgs.curl)
(proxySuite.wrapPerApp { profile = "tun"; } pkgs.firefox)
];
# A service: here nix-daemon, so downloads go through the proxy.
systemd.services.nix-daemon.environment = proxySuite.envFor "http";
}
+13
View File
@@ -0,0 +1,13 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
zapret = {
enable = true;
zapret-discord-youtube = {
configName = "general(ALT)"; # the default; try others if it does not work
domains = [ "rutracker.org" ]; # more sites to unblock
};
};
};
}
+11
View File
@@ -0,0 +1,11 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
zapret = {
enable = true;
engine = "zapret2";
zapret2.domains = [ "rutracker.org" ]; # always treated as blocked
};
};
}
+4
View File
@@ -0,0 +1,4 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite.zapret.zapret2.ports.extraUdp = [ "27015-27030" ];
}
+15
View File
@@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
zapret = {
enable = true;
global.enable = false; # no system-wide zapret
};
perAppRouting = {
enable = true;
createDefaultProfiles = true; # adds a profile named "zapret"
zapret.enable = true;
};
};
}
+166
View File
@@ -0,0 +1,166 @@
# Use an AmneziaWG config
Bring the AmneziaWG config from your provider or your own server, either as a `.conf` file or
as an Amnezia app `vpn://` export. AmneziaWG 1.x to 3.x are supported. Each profile can run
in one of two ways:
- **as a global VPN**: all traffic goes through it, like `wg-quick up`;
- **as an outbound**: the proxy sends only what your routing picks through it.
## As a global VPN
```nix
services.proxy-suite = {
enable = true;
amneziaWg = {
enable = true;
profiles.home.configFile = "/run/secrets/home-awg.conf";
profiles.work = {
vpnFile = "/run/secrets/work-amnezia.vpn";
autostart = true; # at most one profile
};
};
killSwitch.enable = true; # optional: no leaks while the tunnel is down
};
```
```sh
proxy-ctl awg # profiles and which one is up
proxy-ctl awg on home # switches from any other global tunnel
proxy-ctl awg off
```
Only one global tunnel runs at a time: an AmneziaWG profile, TUN or TProxy. Starting one
stops the others.
Connections made to this machine from elsewhere (SSH, a web server, inbound listeners) are
still answered the way they came in, not through the tunnel. For UDP that takes knowing the
port: the inbound listeners and, on NixOS, the firewall's open ports are known; add others to
`amneziaWg.serverUdpPorts`.
## As an outbound
```nix
services.proxy-suite = {
enable = true;
proxy.enable = true;
amneziaWg = {
enable = true;
profiles.de = {
configFile = "/run/secrets/de-awg.conf";
asOutbound = "interface";
};
};
};
```
The outbound is tagged with the profile's name (`de` here). It always runs, and leaves the
host's routes and DNS alone. Use it like any other outbound: for selection, in
[routing rules](./routing.md), or as a hop in a [chain](./chains.md).
| `asOutbound` | Obfuscation | Needs root | Notes |
|---|---|---|---|
| `"interface"` | yes | yes | A real AmneziaWG interface with no routes. |
| `"userspace"` | yes | no | Runs in wireproxy. The only mode on home-manager and Nix-on-Droid. |
| `"singBox"` | no | no | Plain WireGuard inside sing-box. For servers without obfuscation, such as WARP. |
## Run single apps through it
With [per-app routing](./per-app.md) on, `--via` sends one app through an outbound:
```sh
proxy-ctl apps run --via de -- steam
```
An `"interface"` outbound takes the app's packets into its interface directly: no proxy in
between, and UDP as it is. The app's DNS goes to the profile's `DNS` servers (or to
`proxy.dns.remote` when it names none), through the tunnel, even when `/etc/resolv.conf`
points at a local resolver. While the interface is down, the app's connections fail instead of
leaving another way. A `"userspace"` or `"singBox"` outbound works like any other outbound
here: through per-app TUN or TProxy.
A global profile works too, declared or added with `awg add`: `--via home` brings up a copy
of it for the apps alone, the same way, and takes it down after the last one exits. The
rest of the system is untouched. A profile cannot be up globally and for apps at once: while
`awg on home` holds it, `--via home` runs the app as it is, and `awg on home` stops the copy.
When a name is both a global profile and an outbound, say which: `--via awg:home` or
`--via outbound:home`.
```nix
services.proxy-suite = {
enable = true;
proxy.enable = true;
amneziaWg = {
enable = true;
profiles.de = {
configFile = "/run/secrets/de-awg.conf";
asOutbound = "interface";
};
};
perAppRouting = {
enable = true;
profiles = [ { name = "games"; outbound = "de"; } ];
};
};
```
## Add one without rebuilding
`amneziaWg.enable` alone is enough: profiles and outbounds can come from `proxy-ctl` instead
of the config.
```nix
services.proxy-suite = {
enable = true;
amneziaWg.enable = true; # no profiles needed
userControl = {
enable = true;
scopes = [ "services" "amneziaWg" "outbounds" ]; # optional: no sudo for these
};
};
```
```sh
proxy-ctl awg add vpn://AAAA… # named after the export, or the server's host
proxy-ctl awg add home ~/home.conf # a name first; a link, a file, or - for stdin
proxy-ctl awg on home
proxy-ctl awg rm home
proxy-ctl proxy outbounds add de ~/de.conf # an outbound instead (needs proxy.enable)
proxy-ctl proxy outbounds add nl ~/nl.conf --interface # on an interface of its own
```
- A global profile works like a declared one: `awg on`, the tray menu, the kill switch. The
ones added this way share one interface, `amneziaWg.runtime.interfaceName`.
- An outbound runs in wireproxy (like `asOutbound = "userspace"`), so the obfuscation stays.
With `--interface` it gets an AmneziaWG interface of its own instead (like
`asOutbound = "interface"`; root hosts only), which apps can run through directly (see
above).
`amneziaWg.runtime.outboundKind` sets which one an outbound gets when the command does not
say. Either way, it cannot chain through another outbound.
- In `proxy-tui` and the desktop app, paste a `vpn://` link or a whole `.conf` onto a tab: on
the Outbounds tab it becomes an outbound, anywhere else a global profile. The Outbounds tab
also adds one on an interface of its own, and the AmneziaWG tab adds a global profile from a
prompt and removes what was added.
- Hooks (`PostUp` and the like) are always refused, whoever adds the config.
`--container <name>` picks one from a `vpn://` export that holds several.
- Adding and removing takes root, or a `userControl` scope: `amneziaWg` for global profiles,
`outbounds` for outbounds. Turning a profile on and off is `services`.
- They are kept across reboots. `amneziaWg.runtime.enable = false` turns all of this off.
## Good to know
- A profile that stops getting handshake replies moves to a new source port on its own.
`settings.listenPort` pins the port and turns this off.
- If the server's address is blocked, `profiles.<name>.endpoint` replaces it without
editing the file.
- Imported configs cannot run `PostUp` and other hooks unless you set `allowConfigHooks`.
- The profile can also be written in Nix instead of a file, with `profiles.<name>.settings`.
- To host an AmneziaWG server, see [Run your own server](./server.md).
## See also
- [`amneziaWg.profiles`](../options/amneziaWg.md#services-proxy-suite-amneziawg-profiles)
- [`amneziaWg.runtime`](../options/amneziaWg.md#services-proxy-suite-amneziawg-runtime-enable)
- [`asOutbound`](../options/amneziaWg.md#services-proxy-suite-amneziawg-profiles-name-asoutbound)
- [Route a single app](./per-app.md)
- [`settings`](../options/amneziaWg.md#services-proxy-suite-amneziawg-profiles-name-settings)
+96
View File
@@ -0,0 +1,96 @@
# Chain proxies and add exits
Two things are covered here: reaching a server through another one (a chain), and adding
built-in exits (WARP, Tor, an SSH tunnel) for your routing to use.
## Chains
Set `detour` to make an outbound connect through another one. This helps when your
network cannot reach a server directly but can reach a hop that can. It also hides the
final server's address from your ISP.
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [
{ tag = "hop"; urlFile = "/run/secrets/hop-url"; }
{ tag = "de-vps"; urlFile = "/run/secrets/de-vps-url"; detour = "hop"; }
];
selectionExclude = [ "hop" ]; # never picked as the exit on its own
};
};
```
Any outbound can be a hop, including subscription entries, WARP, the SSH tunnel and
AmneziaWG outbounds. A subscription's `detour` applies to every entry in it. On the hybrid
backend, an XRay outbound can only chain through another XRay outbound.
At runtime:
```sh
proxy-ctl proxy outbounds chain de-vps hop de-via-hop # a chained copy of de-vps
proxy-ctl proxy outbounds add 'vless://…' --detour hop # a new outbound behind hop
```
## Extra exits
Each of these adds an outbound with a fixed tag. Route sites to it with
[routing rules](./routing.md), or use it as a hop.
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
routing.rules = [
{ domains = [ "chatgpt.com" "openai.com" ]; outbound = "warp"; }
{ domains = [ "check.torproject.org" ]; outbound = "tor"; }
];
};
# Tagged "warp". Registers a free WARP device on first start.
warp = {
enable = true;
asOutbound = "singBox";
};
# Tagged "tor". .onion names always go to it.
tor = {
enable = true;
asOutbound = true;
};
# Tagged "ssh-proxy".
sshProxy = {
enable = true;
asOutbound = true;
server = { user = "me"; host = "ssh.example.com"; };
identityFile = "/run/secrets/ssh-key";
hostKeyFile = "/run/secrets/ssh-known-hosts"; # from ssh-keyscan
};
};
```
| Exit | Good to know |
|---|---|
| WARP | Registering accepts Cloudflare's terms. If the Cloudflare API is blocked, set `warp.generatorUrl`, or `warp.configFile` with a profile made elsewhere. If the endpoint is blocked, try `warp.endpoint`. |
| Tor | Selection and autoProxy skip it unless it is the only outbound. Where Tor is blocked, add `tor.bridges.lines`, or reach Tor through the proxy with `tor.upstream = "proxy"`. |
| SSH | Needs the server's host keys on sing-box (`hostKeyFile` or `hostKey`). Any SSH server that allows TCP forwarding works, with nothing to install on it. |
## Good to know
- `proxy.selectionExclude` keeps hops and special exits out of automatic selection. You can
still pin them.
- autoProxy tries your exits, WARP included, for each blocked site and keeps the first one
that works.
- WARP can also run as a global VPN instead, through AmneziaWG: `warp.asAmneziaWg`, with
`warp.autostart` to bring it up at boot.
## See also
- [`detour`](../options/proxy.md#services-proxy-suite-proxy-outbounds-detour)
- [`proxy.selectionExclude`](../options/proxy.md#services-proxy-suite-proxy-selectionexclude)
- [WARP](../options/warp.md), [Tor](../options/tor.md), [SSH](../options/sshProxy.md)
+71
View File
@@ -0,0 +1,71 @@
# Connect through a proxy
Run a local proxy on `127.0.0.1:1080` that forwards traffic through your server or
subscription.
## Config
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
subscriptions = [ { tag = "provider"; urlFile = "/run/secrets/provider-sub-url"; } ];
selection = "urltest";
};
};
```
- `outbounds` takes proxy links (`vless://`, `hy2://`, `trojan://`, `ss://`, …), one per
entry. Put each link in a file; see [Keep secrets out of the Nix store](./secrets.md).
- `subscriptions` fetches a list of links from a URL and refreshes it daily. Its entries are
tagged with the subscription's tag as a prefix.
- `selection` picks which outbound to use: `"first"` (the default), `"urltest"` (the
fastest) or `"selector"` (you pick).
You only need one outbound or subscription. With neither, the proxy waits until you add one
with `proxy-ctl proxy outbounds add`.
## Use it
Point apps at `127.0.0.1:1080`. The port speaks both SOCKS5 and HTTP. Many apps follow the
usual variables:
```sh
export all_proxy=socks5h://127.0.0.1:1080
export https_proxy=http://127.0.0.1:1080
```
To route apps without setting them up, see [Route the whole machine](./system-wide.md),
[Route a single app](./per-app.md) or [Wrap programs with the proxy](./wrap-apps.md).
## Commands
```sh
proxy-ctl status # what is running
proxy-ctl proxy outbounds # outbounds, and which one is in use
proxy-ctl proxy outbounds test # ping and delay of each one
proxy-ctl proxy pin my-vps # always use this one
proxy-ctl proxy unpin # back to automatic selection
proxy-ctl proxy outbounds add 'vless://…' # add one at runtime, no rebuild
proxy-ctl proxy subs update # refetch subscriptions now
```
## Good to know
- `proxy.backend` picks the engine: sing-box (the default), XRay, or `"hybrid"`, which runs
sing-box and hands XHTTP and ECH links to XRay.
- `urltest` tests each outbound by fetching `proxy.urlTest.url`. Set it to a site that is
blocked where you are, so an outbound only passes if it really gets around the block.
- Set `proxy.listener.auth` before exposing the port with `listener.address = "0.0.0.0"`.
- `outbounds add` also takes one outbound as sing-box or XRay JSON. Such an outbound cannot
name a local file or program (a `tor` outbound, `*_path`, `*File`, `masterKeyLog`): the
backend would open or run it with its own privileges. Declare those in `proxy.outbounds`.
## See also
- [`proxy.outbounds`](../options/proxy.md#services-proxy-suite-proxy-outbounds)
- [`proxy.subscriptions`](../options/proxy.md#services-proxy-suite-proxy-subscriptions)
- [`proxy.selection`](../options/proxy.md#services-proxy-suite-proxy-selection)
- [`proxy.backend`](../options/proxy.md#services-proxy-suite-proxy-backend)
+146
View File
@@ -0,0 +1,146 @@
# Control it day to day
Once the config is built, you rarely need to rebuild: most switches happen at runtime,
through one of three front ends.
- **`proxy-ctl`**: the command line. `proxy-ctl help` lists everything, and shell completion
is included.
- **`proxy-tui`**: a terminal UI with the same controls. It works over SSH too. On by default.
- **The desktop app** (`gui.enable`): the same again, with a tray icon. It starts with your
graphical session.
The TUI and the app run `proxy-ctl` underneath, so they can do exactly what it can.
## Without sudo
Reading status needs no privileges. Changing things does, unless you use `userControl`:
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
gui.enable = true;
userControl = {
enable = true;
scopes = [ "services" "routing" "outbounds" "perApp" ];
};
};
users.users.alice.extraGroups = [ "proxy-suite" ];
```
Members of the group get the listed scopes. An empty `scopes` list grants all of them:
| Scope | Allows |
|---|---|
| `services` | turning services on, off and restarting them |
| `routing` | `proxy pin`, `proxy unpin`, `proxy mode`, `proxy rules` |
| `outbounds` | adding, removing, enabling and disabling outbounds and subscriptions, AmneziaWG outbounds included |
| `amneziaWg` | `awg add` and `awg rm`: global AmneziaWG profiles, which take over the host's routes and DNS |
| `perApp` | `apps run` with `tun`, `tproxy` and `zapret` profiles |
| `secrets` | reading share links, subscription URLs and running configs |
| `inbounds` | adding, removing and binding runtime inbound users and listeners, and their secrets |
| `autoProxy`, `zapret`, `stats`, `whitelistBypass` | the matching `proxy-ctl` groups |
Log out and back in after joining the group. Without `userControl`, a change asks for an
admin password, or you run `proxy-ctl` with sudo.
### Several groups
`userControl.groups` adds more groups, each with scopes of its own. A member gets what all
of their groups allow:
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
userControl = {
enable = true;
scopes = [ "routing" ];
groups = {
proxy-admins.scopes = [ ];
proxy-users.scopes = [ "perApp" "outbounds" ];
};
};
};
users.users.alice.extraGroups = [ "proxy-admins" ];
users.users.bob.extraGroups = [ "proxy-users" ];
```
`userControl.group` still owns proxy-suite's files. The other groups reach them through
POSIX ACLs, so `/var/lib/proxy-suite` and `/run` need a file system that supports ACLs. ext4,
btrfs, xfs and tmpfs all do.
The sing-box Clash API's secret stays readable by root only. Other users reach the API
through `proxy-suite-clash-api`, which decides per request. Any member can read the
outbounds and test them. Switching a selector through the API needs `routing`, and live
connections (`proxy-ctl where`) need `secrets`. Nothing else in the API is open to them.
## Runtime changes and the Nix config
| Change | Lasts |
|---|---|
| `proxy outbounds add`, `proxy subs add`, `awg add` | until removed with `rm`; kept across reboots |
| `proxy outbounds disable` | until `enable`; works on outbounds from Nix too |
| `inbounds users add`, `inbounds add`, `inbounds bind` | until removed; kept across reboots |
| `proxy pin` | until `unpin`; kept across reboots |
| `proxy rules add` | until removed with `rules rm`; kept across reboots |
| `proxy mode` | until the next reboot |
| `… on` / `… off` | until the next reboot; boot state comes from the config |
Outbounds from the Nix config cannot be removed at runtime, only disabled. The same goes for
AmneziaWG profiles: `awg rm` only removes those added with `awg add`.
In the TUI and the app, pasting a link onto a tab adds it there: a share link becomes an
outbound, a subscription URL a subscription. An AmneziaWG `vpn://` link or a whole `.conf`
becomes a global profile, or an outbound when pasted onto the Outbounds tab. See
[Use an AmneziaWG config](./amneziawg.md).
The app also opens `proxy-suite://install-config?url=<subscription URL>` links, which the
subscription page of a proxy-suite server offers on Linux: it shows the `proxy subs add` it
would run and waits for you to confirm it. The link's `name` becomes the subscription's tag
(`VPN alice` as `VPN-alice`, with `-2` after it when taken); without one, it is named after
the URL's host.
Adding a rule, an outbound, a group, a listener or a user opens a form with one field per
parameter. Optional fields are marked, and the values the field knows (outbounds, users,
listeners, strategies) are offered: in the TUI, → completes one, and in the app, a list beside
the field picks one. Less common flags sit under "More options". The command the form will run
shows below it. In the TUI, tab moves between fields and enter or ctrl+s runs; in the app, Run
stays off until nothing is missing.
Fields that take several values (a rule's domains and addresses, a group's members, a
listener's users) are lists: each value sits on its own line, enter adds the one typed, and
pasting several adds each. The same lists edit what is already there: one action opens a
rule's matches, a group's members, a listener's users or a user's listeners as they are now.
You add or take out values in one go, and what changes is marked before you run it. It runs as
one command (`proxy rules matches <name> set`, `proxy groups members <tag> set`,
`inbounds users on <tag>`, `inbounds users listeners <user>`), so the inbounds restart once.
## Commands
```sh
proxy-ctl status # everything at a glance
proxy-ctl status --json # the same, for scripts
proxy-ctl logs # follow the logs of every proxy-suite service, with the last 1000 lines
proxy-ctl restart # restart what is running
```
In a terminal, `proxy-ctl logs` follows in [`lnav`](https://lnav.org): it follows while at
the bottom, scrolling back pauses it, `G` follows again, `e`/`E` jump between errors, `/`
searches, and `q` or Ctrl-C quits. `:enable-word-wrap` wraps long lines, and lnav remembers
it for the next time. Without lnav ([`tools.lnav.enable`](../options/tools.md#services-proxy-suite-tools-lnav-enable),
off on Nix-on-Droid) it follows in `less`. Piped, it is plain `journalctl -f`.
## See also
- [`userControl.scopes`](../options/userControl.md#services-proxy-suite-usercontrol-scopes)
- [`userControl.groups`](../options/userControl.md#services-proxy-suite-usercontrol-groups)
- [`gui.enable`](../options/gui.md#services-proxy-suite-gui-enable)
- [`tui.enable`](../options/tui.md#services-proxy-suite-tui-enable)
- [The full `proxy-ctl help`](../../README.md), at the end of the README
+101
View File
@@ -0,0 +1,101 @@
# Track down a problem
Turn on more logging, and record connections, for a problem that comes and goes. Each of
these logs to the journal; `proxy-ctl logs <unit>` follows it.
## Record connections
Pages that sometimes half load, or images left blank, are hard to catch on demand. Record
the backend's connections and look back at the time it happened:
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
debug.connectionLog = {
enable = true;
hosts = [ "x.com" "twimg.com" ]; # leave empty for every site
inbounds = [ "tproxy" ]; # global and per-app TProxy only
};
};
```
```sh
journalctl -u 'proxy-suite-connection-log*' --since "10 min ago"
```
There is a recorder per backend: `proxy-suite-connection-log` for the local proxy and TProxy,
global or per-app, `proxy-suite-connection-log-tun` for the global TUN and
`proxy-suite-connection-log-per-app-tun` for per-app TUN. Each runs while its backend does.
TUN connections come in on `tun-in`: put that in `inbounds` too, or leave it empty.
Each connection gets a line as it opens, with its listener, site, rule and exit, and one as
it closes, with the bytes each way. One that sent and got nothing back for
`stallAfter` seconds is logged as `stalled`, and as `resumed` if the answer comes. A
connection is looked at every `interval` seconds, so one shorter than that can be missed,
and the byte counts are from the last look.
The same, live and without a rebuild:
```sh
proxy-ctl debug conns --host twimg.com --inbound tproxy
```
It needs root, or the `secrets` scope: connections show every site visited. `--backend tun`
or `--backend per-app-tun` shows a TUN backend's, as root and with `debug.connectionLog` on,
which gives those backends the API it reads.
## More from the backend
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
debug.logLevel = "info"; # every connection and the rule that routed it
};
```
"debug" and "trace" log more than that, including DNS. Follow it with
`proxy-ctl logs proxy-suite-socks`.
## DNS of per-app routes
Apps run through per-app TUN or TProxy have their lookups sent on into the route. To see
each lookup, its answer and how long it took, and the ones that got no answer:
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
perAppRouting = {
enable = true;
tproxy.enable = true;
};
debug.perAppDns = true;
};
```
```sh
proxy-ctl logs proxy-suite-per-app-tproxy-dns
```
## Good to know
- All of these can log every site visited, for anyone who can read the journal. Turn them
off when done.
- zapret2 has its own: `debug.zapret2.packets` logs every packet nfqws2 handles, and
`debug.zapret2.autoHostlist` why sites are or are not learned.
## See also
- [`debug`](../options/debug.md): every option
- [Control it day to day](./control.md): `proxy-ctl logs` and the rest
+160
View File
@@ -0,0 +1,160 @@
# Example: several exits, picked per site
A host in Russia with five ways out: direct (with zapret2 for DPI), a VPS, WARP, an SSH
server and Tor. Each site goes to whichever works best for it, and autoProxy covers the
sites nobody listed. On a [relay server](./relay-server.md), its clients get the same
choice, with a few differences shown below.
| Exit | Tag | Gets |
|---|---|---|
| This host, with zapret2 | `direct` | Everything not listed below |
| The VPS | `primary`, as the selected `proxy` | AI services, Telegram, Netflix, WARP's registration |
| The SSH server | `ssh-proxy` | pixiv, Twitter |
| WARP | `warp` | YouTube, Russian sites |
| Tor | `tor` | `.onion` names |
| Whichever reaches it first | set by autoProxy | Blocked sites no list names |
```nix
{ ... }:
let
# Telegram apps dial their data centres by IP, so names alone do not catch them
# (https://core.telegram.org/resources/cidr.txt).
telegramIps = [
"91.105.192.0/23"
"91.108.4.0/22"
"91.108.8.0/22"
"91.108.12.0/22"
"91.108.16.0/22"
"91.108.20.0/22"
"91.108.56.0/22"
"149.154.160.0/20"
"185.76.151.0/24"
"2001:67c:4e8::/48"
"2001:b28:f23c::/48"
"2001:b28:f23d::/48"
"2001:b28:f23f::/48"
"2a0a:f280::/32"
];
in
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "primary"; urlFile = "/run/secrets/proxy-primary-url"; } ];
routing = {
# Unlisted sites leave directly, where zapret2 unblocks what DPI blocks.
default = "direct";
# Russian sites go to WARP by the last rule below instead.
directRu = false;
# Checked in order, before the lists; the first match wins.
rules = [
{
outbound = "ssh-proxy";
geosites = [ "pixiv" "twitter" ];
}
{
outbound = "warp";
geosites = [ "youtube" ];
}
# Russian services see WARP's address instead of this host's.
{
outbound = "warp";
geosites = [ "category-ru" ];
geoips = [ "ru" ];
}
];
# Through the selected outbound ("primary").
proxy = {
geosites = [ "openai" "anthropic" "telegram" "netflix" ];
ips = telegramIps;
# WARP registers through the proxy: its API is blocked directly in Russia.
domains = [ "api.cloudflareclient.com" ];
};
};
# For blocked sites no list names yet. YouTube already has its rule, so its video
# hosts are not worth probing.
autoProxy = {
enable = true;
exclude = [ "googlevideo.com" "gvt1.com" ];
};
};
warp = {
enable = true;
asOutbound = "singBox";
};
sshProxy = {
enable = true;
asOutbound = true;
server = {
user = "me";
host = "203.0.113.20";
port = 2222;
};
identityFile = "/run/secrets/proxy-ssh-key";
hostKeyFile = "/run/secrets/proxy-ssh-known-hosts";
};
# .onion names go to Tor without a rule. Tor is blocked here, so it connects
# through the proxy.
tor = {
enable = true;
asOutbound = true;
upstream = "proxy";
};
zapret = {
enable = true;
engine = "zapret2";
};
};
}
```
## Checking the result
```sh
proxy-ctl where youtube.com # -> warp, by the rule for youtube
proxy-ctl where pixiv.net # -> ssh-proxy, by the first rule
proxy-ctl where chatgpt.com # -> proxy -> primary, by geosite openai
proxy-ctl proxy auto # what autoProxy routed, and through which exit
proxy-ctl zapret auto # what zapret2 learned
```
## With relay clients
With `inbounds.routing.via = "proxy"`, relay clients go through the routing above. Two
checks come first by default: Russian sites are blocked for them (`blockRu`), and sites on
zapret's list leave directly, so this host's zapret handles them (`zapretDirect`). Sites in
`inbounds.routing.proxy` skip both and reach the rules above:
```nix no-check
services.proxy-suite.inbounds.routing = {
via = "proxy";
blockRu = false; # clients reach Russian sites too, through WARP by the rule above
proxy = {
# YouTube is on zapret's list, but WARP works better for it.
geosites = [ "youtube" "category-ru" ];
geoips = [ "ru" ];
};
};
```
`inbounds.routing.proxy` covers listeners with their own `via` too, `"direct"` ones
included, so their YouTube and Russian sites also go through WARP.
## Notes
- Rules take effect in order. Put narrow ones (a single CDN) before broad ones (a whole
country).
- Rules can name any outbound tag: yours, `warp`, `ssh-proxy`, `tor`, or an AmneziaWG
outbound.
- Selection and autoProxy skip `tor`; it gets only `.onion` names and what rules send to it.
- See [Chain proxies and add exits](../chains.md) for each kind of exit on its own.
+90
View File
@@ -0,0 +1,90 @@
# Example: a private VPN for your own devices
An AmneziaWG server for your laptop and phone. Unlike the proxy listeners, it also reaches
the server itself and its private services, like a home VPN. Internet traffic still follows
the server's routing (`inbounds.routing.via`), so the devices get the same exits and zapret
as the server.
A small DNS server on the tunnel address answers for private names, such as a mail server
that is only reachable over the VPN.
```nix
{ ... }:
let
interface = "awg0";
serverAddress = "10.77.77.1";
privateDomains = [ "mail.example.com" ];
in
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "primary"; urlFile = "/run/secrets/proxy-primary-url"; } ];
};
inbounds = {
enable = true;
routing.via = "proxy";
# Fixed addresses, so firewall rules and DNS can name each device.
# Keys are generated on first start.
users = {
laptop.address = "10.77.77.2";
phone.address = "10.77.77.3";
};
listeners.vpn = {
type = "amneziawg";
port = 51820;
users = [ "laptop" "phone" ];
amneziaWg = {
# Devices also reach this host, its LAN and each other, directly.
mode = "lan";
interfaceName = interface;
subnet = "10.77.77.0/24";
subnet6 = "fd77:77:77::/64";
mtu = 1400;
dns = [ serverAddress ];
# Optional: a fixed server key, so client configs survive a reinstall.
privateKeyFile = "/run/secrets/awg-server-key";
};
};
};
};
# Private names for VPN clients; everything else is forwarded to 1.1.1.1.
services.dnsmasq = {
enable = true;
resolveLocalQueries = false;
settings = {
bind-dynamic = true;
interface = interface;
listen-address = serverAddress;
no-resolv = true;
server = [ "1.1.1.1" ];
address = map (domain: "/${domain}/${serverAddress}") privateDomains;
};
};
# The interface comes and goes with the listener.
systemd.services.dnsmasq = {
after = [ "proxy-suite-inbounds-awg.service" ];
wants = [ "proxy-suite-inbounds-awg.service" ];
};
}
```
## Adding a device
```sh
proxy-ctl inbounds link vpn phone --config --qr # scan in the AmneziaWG app
proxy-ctl inbounds link vpn laptop --config > laptop.conf
proxy-ctl inbounds link vpn phone # a vpn:// link instead
```
On a laptop that also runs proxy-suite, the `.conf` becomes a profile: see
[Use an AmneziaWG config](../amneziawg.md).
## Notes
- `mode = "lan"` turns on IP forwarding. The default, `"proxy"`, gives devices the internet only, like the other listeners.
- Only TCP and UDP reach the internet; ping and other protocols stop at the server.
- A device that keeps its own private key can be added with `users.*.publicKey` instead; it gets no generated config.
+200
View File
@@ -0,0 +1,200 @@
# Example: a relay server behind nginx
A VPS that already runs nginx for websites on port 443 also serves proxy clients: family
and friends, each with their own UUID and subscription. To a censor, the proxy traffic looks
like the site's own HTTPS. Clients get several transports, so each network can use
whichever one gets through.
| Listener | Reached as | Why |
|---|---|---|
| `xhttp` | `https://vpn.example.com/media` through nginx | Looks like ordinary HTTPS to the site |
| `ws` | `/media-ws` through nginx | For clients without XHTTP |
| `xhttp-stream` | `/media-stream` through nginx, over gRPC | HTTP/2 end to end, for stream-one mode |
| `xhttp-h3` | UDP 443, directly | HTTP/3 next to nginx, which holds TCP 443 |
| `reality` | TCP 2053, directly | REALITY with Vision, no HTTP layer to stall |
Client traffic exits through this host's own proxy (`routing.via = "proxy"`): here a single
upstream server, `primary`. With more exits, the server's routing decides where each site
goes; [Several exits, picked per site](./multi-exit.md) shows that.
```nix
{ config, lib, ... }:
let
domain = "vpn.example.com";
certDir = config.security.acme.certs.${domain}.directory;
users = [
"alice"
"bob"
"carol"
];
# The listeners terminate TLS themselves, so share links honestly say security=tls.
tls = {
enable = true;
certificateFile = "${certDir}/fullchain.pem";
keyFile = "${certDir}/key.pem";
serverName = domain;
};
# nginx on 443 hands a path to a loopback listener.
fronted = port: path: extra: {
type = "vless";
inherit port users;
address = "127.0.0.1";
sharePort = 443; # share links name nginx's port, not the listener's
transport = extra // {
inherit path;
# nginx sets this header, so XRay sees each client's real address (for `proxy-ctl inbounds online`). A client cannot forge it: nginx overwrites it.
trustedXForwardedFor = [ "X-Real-IP" ];
};
inherit tls;
};
location = port: extra: {
proxyPass = "https://127.0.0.1:${toString port}";
extraConfig = ''
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_ssl_server_name on;
proxy_ssl_name ${domain};
# Tunnels idle along with their users; the 60s default would cut them.
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
''
+ extra;
};
in
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "primary"; urlFile = "/run/secrets/proxy-primary-url"; } ];
};
inbounds = {
users = lib.genAttrs users (name: { uuidFile = "/run/secrets/proxy-uuid-${name}"; });
enable = true;
serverAddress = domain;
routing.via = "proxy";
listeners = {
# nginx speaks HTTP/1.1 to the listener, which only packet-up mode crosses.
xhttp = fronted 10003 "/media" {
type = "xhttp";
mode = "packet-up";
};
ws = fronted 10002 "/media-ws" { type = "ws"; };
# stream-one needs HTTP/2 all the way: nginx's grpc_pass provides it.
xhttp-stream = lib.recursiveUpdate (fronted 10004 "/media-stream" {
type = "xhttp";
mode = "stream-one";
}) { tls.alpn = [ "h2" ]; };
# HTTP/3 takes UDP 443 only, beside nginx on TCP 443. No trustedXForwardedFor:
# nothing is in front, so it already sees the real client.
xhttp-h3 = {
type = "vless";
port = 443;
inherit users;
transport = { type = "xhttp"; path = "/media-h3"; };
tls = tls // { alpn = [ "h3" ]; };
};
reality = {
type = "vless";
port = 2053;
inherit users;
flow = "xtls-rprx-vision";
reality = {
enable = true;
# Probes without the key land on a real TLS 1.3 + HTTP/2 site.
dest = "www.samsung.com:443";
serverNames = [ "www.samsung.com" ];
privateKeyFile = "/run/secrets/proxy-reality-key";
publicKey = "jNXH…";
shortIds = [ "0123abcd" ];
};
};
};
subscriptions = {
enable = true;
baseUrl = "https://${domain}/sub";
};
};
userControl.enable = true; # passwordless proxy-ctl for the admin, see below
};
users.users.admin.extraGroups = [ "proxy-suite" ];
security.acme = {
acceptTerms = true;
defaults.email = "admin@example.com";
# A renewed certificate restarts the listeners.
certs.${domain}.reloadServices = [ "proxy-suite-inbounds.service" ];
};
systemd.services.proxy-suite-inbounds = {
wants = [ "acme-${domain}.service" ];
after = [ "acme-${domain}.service" ];
};
services.nginx = {
enable = true;
virtualHosts.${domain} = {
forceSSL = true;
enableACME = true;
locations = {
# A prefix match: XHTTP appends /<session>/<seq>.
"/media" = location 10003 ''
proxy_http_version 1.1;
proxy_request_buffering off;
proxy_buffering off;
client_max_body_size 0;
'';
"= /media-ws" = location 10002 "" // { proxyWebsockets = true; };
"/media-stream".extraConfig = ''
grpc_pass grpcs://127.0.0.1:10004;
grpc_set_header X-Forwarded-For $remote_addr;
grpc_set_header X-Real-IP $remote_addr;
grpc_ssl_server_name on;
grpc_ssl_name ${domain};
grpc_read_timeout 3600s;
grpc_send_timeout 3600s;
client_max_body_size 0;
'';
# Subscriptions. Some clients show profile-title and follow profile-update-interval.
"/sub/".extraConfig = ''
alias /run/proxy-suite-inbounds/subscriptions/;
default_type text/plain;
autoindex off;
add_header profile-title "My VPN" always;
add_header profile-update-interval "12" always;
'';
};
};
};
}
```
## Handing out access
```sh
proxy-ctl inbounds sub alice --qr # alice's subscription: every listener, kept current
proxy-ctl inbounds link reality alice --qr
proxy-ctl inbounds online # who is connected, by their real address
proxy-ctl inbounds stats 7 --by user # traffic over the last week
```
To add a user, add a name and a UUID file, and rebuild. Existing links stay valid.
## Notes
- `sharePort = 443` puts nginx's port into share links, while the listener stays on
loopback, closed in the firewall.
- `trustedXForwardedFor` is safe only behind a proxy that overwrites the header, as nginx
does here. On a listener open to the world, clients could set it themselves.
- The certificate belongs to nginx. If the listeners cannot read it, they use a copy, and
`reloadServices` restarts them with the renewed one.
+93
View File
@@ -0,0 +1,93 @@
# Example: a workstation using your own server
The desktop side of the [relay server](./relay-server.md) and the
[private VPN](./private-vpn.md). Most apps go direct, with zapret for DPI. Blocked sites go
through the server. Some programs always use the proxy, and the private VPN is one
command away.
```nix
{ config, pkgs, ... }:
let
proxySuite = config.lib.proxy-suite;
in
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
# Support all available protocols by enabling hybrid backend.
backend = "hybrid";
# The server's subscription: every listener, each a separate outbound.
subscriptions = [ { tag = "home"; urlFile = "/run/secrets/proxy-home-sub"; } ];
# The fastest listener that gets through the current network.
selection = "urltest";
urlTest.url = "https://telegram.org"; # blocked here, so a pass means it works
routing.default = "direct";
autoProxy.enable = true;
tun.enable = true; # when everything should go through: `proxy-ctl proxy tun on`
};
zapret = {
enable = true;
engine = "zapret2";
};
# The private VPN: `proxy-ctl awg on home`.
amneziaWg = {
enable = true;
profiles.home.configFile = "/run/secrets/home-vpn.conf";
};
killSwitch.enable = true;
perAppRouting = {
enable = true;
createDefaultProfiles = true;
proxychains.enable = true;
tun.enable = true;
};
gui.enable = true;
userControl.enable = true;
};
users.users.me.extraGroups = [ "proxy-suite" ];
environment.systemPackages = [
# CLIs that only work through the proxy, whatever the routing says.
(proxySuite.wrapEnv { protocol = "all"; } pkgs.codex)
(proxySuite.wrapEnv { } pkgs.claude-code)
# A browser for blocked sites, with its UDP (QUIC) too.
(proxySuite.wrapPerApp { profile = "tun"; } pkgs.chromium)
];
# Nix downloads through the proxy.
systemd.services.nix-daemon.environment = proxySuite.envFor "http";
}
```
## Day to day
```sh
proxy-ctl status # what runs, and which outbound is picked
proxy-ctl proxy outbounds test # which listeners get through right now
proxy-ctl where some-site.com # direct, zapret or proxy, and why
proxy-ctl proxy tun on # everything through the server for a while
proxy-ctl awg on home # or through the private VPN (stops TUN)
```
The tray app shows the same, and switches with a click.
## Notes
- `wrapEnv` sets the proxy variables for one program only, so the rest of the system keeps
its direct routing. `protocol = "all"` sets both kinds, for a program whose choice you
do not know.
- The kill switch guards whichever global tunnel is on (TUN or the VPN). It is up from boot,
so the internet stays blocked until one of them starts; turning a tunnel off with
`proxy-ctl` lifts it.
- While global TUN is on, per-app `tun` profiles run the app as it is. Everything already goes
through the proxy then.
- See [Wrap programs with the proxy](../wrap-apps.md) for the helpers, and
[Keep secrets out of the Nix store](../secrets.md) for the files under `/run/secrets`.
+133
View File
@@ -0,0 +1,133 @@
# Group outbounds and fail over
A group is one tag standing for several outbounds. Whatever names the group (a routing rule,
a chain, a pin, the top-level pick) uses whichever member the group picks. The usual reason
is failover: when one exit stops carrying traffic, move to the next within seconds instead of
waiting for someone to notice.
## A failover group
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [
{ tag = "de-vps"; urlFile = "/run/secrets/de-vps-url"; }
{ tag = "nl-vps"; urlFile = "/run/secrets/nl-vps-url"; }
];
groups.eu.outbounds = [ "de-vps" "nl-vps" ]; # de-vps first, nl-vps when it fails
};
};
```
The members leave the top level: the top level now picks between `eu` and whatever is in no
group. Members can be any outbound, including subscription entries, WARP, Tor and AmneziaWG,
and other groups.
Each group has a `strategy`:
| Strategy | Picks |
|---|---|
| `failover` (default) | The first member that works, in order. With `failback` (on by default) it goes back to an earlier member once that has worked three checks in a row. |
| `urltest` | The fastest member, switching only when another is faster by `proxy.urlTest.tolerance`. |
| `selector` | The first member, or the one you pick. |
Failover is driven by `proxy-suite-outbound-groups`, which tests the members every `interval`
(30 s by default) and switches through sing-box's Clash API. A member is down after two
failed tests in a row. Watchdogs that already watch a tunnel (the AmneziaWG watchdog, the
sing-box WARP tunnel) tell it at the first sign of trouble, so their outbounds are dropped
within seconds. Connections still open on the dropped member are cut, so clients reconnect
through the next one.
Groups need the sing-box or hybrid backend. The TUN instances of sing-box have no Clash API,
so there a failover group works as `urltest`.
## Members from subscriptions and patterns
```nix
services.proxy-suite.proxy = {
enable = true;
subscriptions = [ { tag = "provider"; urlFile = "/run/secrets/provider-sub"; } ];
groups.fast = {
subscriptions = [ "provider" ]; # every entry the subscription holds
match = [ "de-*" ]; # and every outbound whose tag matches
strategy = "urltest";
};
};
```
Listed `outbounds` come first, in their order; members pulled in by `subscriptions` or `match`
follow, ordered by `proxy.priority`.
## Failover at the top level, and priority
`proxy.selection = "failover"` treats the top level like a failover group. Its order comes
from `proxy.priority`, lower first; anything not listed follows in its usual order:
```nix
services.proxy-suite.proxy = {
enable = true;
selection = "failover";
priority = { eu = 10; warp = 20; };
};
```
## Several WARP devices
One WARP device is one key and one session. With several, `warp` becomes a failover group of
them, so rules and pins that name `warp` keep working and fail over:
```nix
services.proxy-suite = {
enable = true;
amneziaWg.enable = true;
proxy.enable = true;
warp = {
enable = true;
asOutbound = "interface";
instances = 2; # warp-1 (keeps an existing registration) and warp-2
};
};
```
Name them yourself, each with its own endpoint, through `warp.devices`:
```nix
services.proxy-suite.warp = {
enable = true;
asOutbound = "interface";
devices = {
warp-a = { };
warp-b.endpoint = "162.159.193.10:500";
};
group.strategy = "failover";
};
```
Devices whose outages come at the same time (the path to Cloudflare, say) do not help each
other; a different endpoint for each, or a member that is not WARP, does.
## At runtime
```sh
proxy-ctl proxy outbounds # the tree: groups, members, what each uses
proxy-ctl proxy groups add eu de-vps nl-vps # a failover group
proxy-ctl proxy groups add fast --sub provider --strategy urltest
proxy-ctl proxy groups members eu add pl-vps
proxy-ctl proxy pin nl-vps --in eu # hold eu on nl-vps
proxy-ctl proxy unpin --in eu
proxy-ctl proxy priority eu 5 # or: eu up, eu down, eu --clear
proxy-ctl warp restart warp-2
```
Groups added at runtime can be changed and removed there; declared ones change in Nix. In
the TUI and the GUI, the Outbounds tab shows the same tree: `space` folds a group, `p` on a
member pins it inside its group, `g` adds a group, and `+` and `-` move a top-level entry.
## See also
- [`proxy.groups`](../options/proxy.md#services-proxy-suite-proxy-groups)
- [`proxy.priority`](../options/proxy.md#services-proxy-suite-proxy-priority)
- [`warp.devices`](../options/warp.md#services-proxy-suite-warp-devices)
- [Chain proxies and add exits](./chains.md)
+34
View File
@@ -0,0 +1,34 @@
# Usage guides
Short guides for common setups. Each one has a minimal config, the commands you will use,
and links into the [options reference](../options/index.md) for the details. Complete
examples follow below.
| Guide | When to read it |
|---|---|
| [Connect through a proxy](./client-basics.md) | You have a proxy link or a subscription |
| [Route the whole machine](./system-wide.md) | Every app should use the proxy, not only those set to it |
| [Choose what goes through the proxy](./routing.md) | Only blocked sites through the proxy, or everything but some |
| [Route a single app](./per-app.md) | Only some apps should use the proxy |
| [Wrap programs with the proxy](./wrap-apps.md) | A package should always use the proxy, wherever it is started |
| [Unblock sites without a server](./zapret.md) | YouTube, Discord or other sites are slowed or blocked by DPI |
| [Run your own server](./server.md) | You have a VPS and want to connect your devices to it |
| [Keep secrets out of the Nix store](./secrets.md) | Your config holds links, keys or passwords |
| [Control it day to day](./control.md) | Switching things without editing Nix or typing sudo |
| [Use an AmneziaWG config](./amneziawg.md) | You have an AmneziaWG `.conf` or an Amnezia `vpn://` export |
| [Chain proxies and add exits](./chains.md) | WARP, Tor, SSH, or reaching a server through another one |
| [Group outbounds and fail over](./groups.md) | Several exits for one job, moving off one that stops working |
| [Other Linux and Android](./other-hosts.md) | You are not on NixOS |
| [Get past mobile whitelists](./whitelist-bypass.md) | Mobile internet lets only whitelisted services through |
| [Track down a problem](./debug.md) | Something fails now and then, and you want to see why |
## Complete examples
Whole configs that combine the guides, taken from real setups.
| Example | What it shows |
|---|---|
| [A relay server behind nginx](./examples/relay-server.md) | Five transports on one VPS, fronted by nginx, with subscriptions for each user |
| [Several exits, picked per site](./examples/multi-exit.md) | Direct with zapret2, a VPS, WARP, SSH and Tor, each for the sites it suits |
| [A private VPN for your own devices](./examples/private-vpn.md) | An AmneziaWG server with fixed addresses and private DNS names |
| [A workstation using your own server](./examples/workstation.md) | Direct by default, wrapped programs, and TUN or the VPN on demand |
+83
View File
@@ -0,0 +1,83 @@
# Other Linux and Android
The same `services.proxy-suite` options work outside NixOS, through a module for each
kind of host. The other guides apply as they are, within the limits below.
| Host | Module | Runs as |
|---|---|---|
| Any distribution, with [system-manager](https://github.com/numtide/system-manager) | `systemManagerModules.default` | root, in the system's systemd |
| Any distribution, with [home-manager](https://github.com/nix-community/home-manager) | `homeManagerModules.default` | your user, in your systemd user session |
| Android, with [Nix-on-Droid](https://github.com/nix-community/nix-on-droid) | `nixOnDroidModules.default` | the Nix-on-Droid app |
## system-manager
Nearly everything works as on NixOS: TUN, TProxy, zapret, the kill switch and the GUI.
```nix no-check
systemConfigs.default = system-manager.lib.makeSystemConfig {
modules = [
proxy-suite.systemManagerModules.default
{ services.proxy-suite = { enable = true; /* … */ }; }
];
};
```
- Open inbound ports in your distribution's firewall yourself. proxy-suite leaves it alone.
- AmneziaWG runs in userspace, since kernel modules cannot come from Nix here.
## home-manager
Rootless: only what an ordinary user can do.
```nix no-check
homeConfigurations.me = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
proxy-suite.homeManagerModules.default
{ services.proxy-suite = { enable = true; /* … */ }; }
];
};
```
Available: the local proxy with its outbounds, subscriptions and routing, proxychains
per-app routing, AmneziaWG as a `"userspace"` outbound, inbounds on ports 1024 and up, the
GUI and the TUI.
Not available, since they need root: TUN, TProxy, the kill switch, zapret, per-app `tun`,
`tproxy` and `zapret`, and AmneziaWG interfaces. `userControl` has nothing to grant, since
you own the services. The build stops with a message if the config asks for any of these.
## Nix-on-Droid
What home-manager gets, without the GUI. Use `proxy-ctl` or `proxy-tui` in the app's shell.
```nix no-check
nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration {
inherit pkgs;
modules = [
proxy-suite.nixOnDroidModules.default
{ services.proxy-suite = { enable = true; /* … */ }; }
];
};
```
- Android has no boot hook for the app. The services start when a Nix-on-Droid shell opens,
or on `proxy-suitectl boot`.
- Android stops background apps. Keep the app's wake lock on, and turn off battery
optimisation for it.
- Point other apps at `127.0.0.1:1080`, in their own proxy settings or in the Wi-Fi proxy
settings.
- To save space, `proxy-ctl` comes without lnav and curl-impersonate: `proxy-ctl logs`
follows in `less`, and probes use plain curl. Set
[`tools.lnav.enable`](../options/tools.md#services-proxy-suite-tools-lnav-enable) and
[`tools.curlImpersonate.enable`](../options/tools.md#services-proxy-suite-tools-curlimpersonate-enable)
to have them back.
- Every app on the phone can reach `127.0.0.1`, not only the ones you point at the proxy: set
`proxy.listener.auth` so that only those you give the login to can use it. The loopback
hops behind it take a login of their own, drawn per boot, except Tor's SOCKS port and the
OpenSSH tunnel's under XRay, which take none: any app reaches those exits.
## See also
- [Keep secrets out of the Nix store](./secrets.md): secret files must be readable by your
user on home-manager and Nix-on-Droid.
+182
View File
@@ -0,0 +1,182 @@
# Route a single app
Run one program through the proxy, or through zapret, and leave the rest of the system
alone.
## Config
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
perAppRouting = {
enable = true;
createDefaultProfiles = true; # a profile named after each method below
proxychains.enable = true;
tun.enable = true;
};
};
```
## Run an app
```sh
proxy-ctl apps # list profiles
proxy-ctl apps run tun -- firefox
proxy-ctl apps run proxychains -- curl https://example.com
```
Run it as yourself, not with sudo.
## Which method
| Method | Covers | Notes |
|---|---|---|
| `proxychains` | TCP | Preloads a library into the app. Needs no privileges, but does not work with statically linked programs or most Go programs. |
| `tun` | TCP and UDP | Puts the app in its own cgroup and routes it into a separate TUN. Works with any program. |
| `tproxy` | TCP and UDP | Like `tun`, but intercepts with nftables. |
| `zapret` | What zapret handles | No proxy: runs a separate zapret for the app, to get past DPI. Needs `zapret.enable`; see [Unblock sites without a server](./zapret.md). |
`tun` works with any program. `proxychains` is handy for a quick command.
## Your own profiles
Name profiles after what they are for, to keep commands short:
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
perAppRouting = {
enable = true;
tun.enable = true;
profiles = [ { name = "browser"; route = "tun"; } ];
};
};
```
Then run `proxy-ctl apps run browser -- chromium`.
## Through one outbound
Send an app through one outbound you pick, past the [routing rules](./routing.md):
```sh
proxy-ctl apps run --via nl -- firefox
proxy-ctl apps run --via nl --route tproxy -- curl https://example.com
```
Or name it in a profile:
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "nl"; urlFile = "/run/secrets/nl-url"; } ];
};
perAppRouting = {
enable = true;
tun.enable = true;
profiles = [ { name = "game"; route = "tun"; outbound = "nl"; } ];
};
};
```
- An "interface" AmneziaWG outbound, or a global AmneziaWG profile (`--via home`), takes the
app straight into its interface, with no proxy in between, and sends the app's DNS to the
profile's DNS server. See [Use an AmneziaWG config](./amneziawg.md).
- Any other outbound goes through per-app TUN or TProxy (`--route`; TUN when both are
enabled) and needs the sing-box or hybrid backend. Each outbound in use takes one of
`perAppRouting.via.pinSlots`.
- When the outbound is down, the app's connections fail; they never leave another way.
- Add profiles without a rebuild: `proxy-ctl apps add game --via nl`, then
`proxy-ctl apps rm game`. In `proxy-tui` and the desktop app, the Apps tab adds and removes
them, and runs a command via an outbound.
## Keep a route running
`tun`, `tproxy` and `zapret` start their backend with the first app and stop it after the last,
so each first app waits for it to come up. `keepRunning` keeps one running from boot instead:
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
perAppRouting = {
enable = true;
createDefaultProfiles = true;
tun = {
enable = true;
keepRunning = true;
};
};
};
```
The per-app TProxy and zapret step aside under a global TUN or TProxy (zapret under a global
AmneziaWG profile too), as below, and come back once it stops.
A profile through one outbound can be kept running too, with its own `keepRunning`:
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "nl"; urlFile = "/run/secrets/nl-url"; } ];
};
amneziaWg = {
enable = true;
profiles.home.configFile = "/run/secrets/home.conf";
};
perAppRouting = {
enable = true;
tun.enable = true;
profiles = [
{ name = "game"; route = "tun"; outbound = "nl"; keepRunning = true; }
{ name = "home"; outbound = "awg:home"; keepRunning = true; }
];
};
};
```
- An "interface" AmneziaWG outbound keeps its rules and DNS forwarder for apps up.
- A global AmneziaWG profile is kept up for apps alone (as `--via` brings it up), unless the
profile is up globally, which carries the apps already.
- Any other outbound keeps its pin slot: it counts against `perAppRouting.via.pinSlots`
for good, and with it the route's backend stays up.
Only declared profiles: one `proxy-ctl apps add` adds still starts with its first app.
## Good to know
- `tun`, `tproxy` and `zapret` profiles start a system service, so they ask for an admin
password unless `userControl` grants the `perApp` scope (see
[Control it day to day](./control.md)).
- While a global TUN or TProxy is running, these three run the app without their route:
the global mode already carries its traffic. `proxy-ctl` prints a note when it does. So
does `--via`, except that an "interface" AmneziaWG outbound still takes the app under a
global TProxy or AmneziaWG profile.
- With `tun` and `tproxy`, the app's DNS queries go through its route wherever its resolver
is, a local one (such as systemd-resolved on 127.0.0.53) or the LAN router. Lookups glibc
hands to nscd (NixOS's default) do not: nscd resolves them itself, outside the route.
`proxy-ctl` warns when nscd runs. Apps that resolve names themselves are not affected:
programs built with Go, and browsers using their own resolver or DNS-over-HTTPS.
- The app follows your [routing rules](./routing.md) like any other proxied traffic.
## See also
- [Wrap programs with the proxy](./wrap-apps.md): a package that always starts through a profile
- [`perAppRouting.profiles`](../options/perAppRouting.md#services-proxy-suite-perapprouting-profiles)
- [`perAppRouting.createDefaultProfiles`](../options/perAppRouting.md#services-proxy-suite-perapprouting-createdefaultprofiles)
- [`perAppRouting.via`](../options/perAppRouting.md#services-proxy-suite-perapprouting-via-pinslots)
+164
View File
@@ -0,0 +1,164 @@
# Choose what goes through the proxy
Decide per site whether traffic goes through the proxy, goes direct, or is blocked. This
applies to the local proxy, TUN, TProxy and per-app routing alike.
## How a destination is routed
The first match wins, checked in this order. Each step has a priority number, and the
rules you add at runtime (below) go in among them:
| Priority | What is checked |
|---|---|
| 100 | `proxy.routing.rules`, in order, after each outbound's own `routing`. A rule can name a specific outbound. |
| 200 | `proxy.domains` and `proxy.ips` |
| 300 | `block` |
| 400 | `direct`, then private addresses |
| 500 | `proxy.geosites`, `proxy.geoips` and `proxy.ruleSets` |
| after | what autoProxy and zapret2 learned |
| last | `proxy.routing.default`: `"proxy"` (the default) or `"direct"` |
A name in both a block and a direct list (an ad domain under `category-ru`, say) is blocked.
Apps run with `apps run --via` skip all of this.
Russian sites and IPs go direct unless you set `routing.directRu = false`.
Each list and rule matches by `domains` (subdomains included), `ips` (CIDR), `geosites`,
`geoips` and `ruleSets`.
## Only blocked sites through the proxy
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
routing = {
default = "direct";
proxy.domains = [ "youtube.com" "googlevideo.com" ];
proxy.geosites = [ "instagram" ];
};
# Find blocked sites on its own, and route each one through an exit that reaches it.
autoProxy.enable = true;
};
};
```
`autoProxy` saves you from listing every blocked site. It probes new destinations in the
background and routes only those that fail directly. It needs the sing-box backend.
## Everything through the proxy, with exceptions
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [
{ tag = "nl-vps"; urlFile = "/run/secrets/nl-vps-url"; }
{ tag = "us-vps"; urlFile = "/run/secrets/us-vps-url"; }
];
routing = {
rules = [ { geosites = [ "netflix" ]; outbound = "us-vps"; } ];
direct.domains = [ "bank.example" ];
block.geosites = [ "category-ads-all" ];
};
};
};
```
## Rule sets
Rule sets are lists that sing-box downloads and refreshes on its own, so they stay current
without a rebuild. Name them in `routing.ruleSets` and use them in any `ruleSets` list:
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
routing = {
default = "direct";
ruleSets.blocked.url = "https://example.com/blocked.srs";
proxy.ruleSets = [ "blocked" ];
};
};
};
```
They need the sing-box or hybrid backend.
## Add rules at runtime
`proxy-ctl proxy rules` adds rules without a rebuild. They are kept across reboots:
```sh
proxy-ctl proxy rules add direct bank.example 10.0.0.0/8 # these go direct
proxy-ctl proxy rules add proxy geosite:netflix # this through the proxy
proxy-ctl proxy rules add us-vps hulu.com --name streaming # through one outbound or group
proxy-ctl proxy rules add block ads.example --priority 350 # after the config's block list
proxy-ctl proxy rules # every rule, in the order checked
```
A rule matches domains (subdomains included), addresses and CIDRs, `geosite:NAME`,
`geoip:NAME` and `ruleset:NAME` (a rule set from `routing.ruleSets`). It sends them to
`proxy`, `direct`, `block`, or any outbound or group, ones added at runtime included.
Without `--name`, the rule is named after its target, so `rules add direct …` keeps adding to
the same rule. A new rule gets priority 50, ahead of everything in the config. Give it
another number with `--priority`, or move it later:
```sh
proxy-ctl proxy rules priority streaming 450 # after the direct lists
proxy-ctl proxy rules priority streaming up # one row up, past a rule or a config step
proxy-ctl proxy rules matches direct rm 10.0.0.0/8
proxy-ctl proxy rules target streaming de-vps
proxy-ctl proxy rules disable streaming # keep it, but stop applying it
proxy-ctl proxy rules rm streaming
```
On equal priority, a runtime rule goes first. Route modes treat runtime rules like the
config's: `all-proxy` drops the ones that go direct, and `all-bypass` keeps only blocks.
A change applies at once. On sing-box and hybrid, adding or removing a rule's domains and
addresses does not restart anything. Other changes, and every change on XRay, restart the
proxy, which drops open connections. A rule whose outbound is gone is left out until the
outbound is back, and `proxy rules` says why.
The Routing tab in the TUI and the app lists the same rules, the config's included. It adds
(`n`), edits (`a`, `x`, `t`), moves (`+`, `-`, `y`), disables (`e`) and removes (`d`) them. The
route mode is a selector above the table (`m`). Pasting a bare domain onto the tab sends it
through the proxy.
## Commands
```sh
proxy-ctl where youtube.com # how a site is routed right now, and why
proxy-ctl proxy mode whitelist # direct unless a rule says otherwise
proxy-ctl proxy mode blacklist # proxy unless a rule says otherwise
proxy-ctl proxy mode all-proxy # everything through the proxy, except blocks
proxy-ctl proxy mode all-bypass # everything direct, except blocks
proxy-ctl proxy mode default # back to routing.default
proxy-ctl proxy rules # every routing rule, in the order checked
proxy-ctl proxy auto # what autoProxy routed, and where
proxy-ctl proxy rulesets update # refetch rule sets now
```
A route mode set with `proxy-ctl` lasts until the next reboot. Rules added with
`proxy rules` last until removed.
## Good to know
- Geosite and geoip names come from the [geodata](../options/geodata.md) databases.
- With `zapret`, sites that zapret handles are sent direct, so zapret can unblock them. See
[Unblock sites without a server](./zapret.md).
- To send some sites to WARP, Tor or another exit, see [Chain proxies and add exits](./chains.md).
## See also
- [`proxy.routing.rules`](../options/proxy.md#services-proxy-suite-proxy-routing-rules)
- [`proxy.routing.default`](../options/proxy.md#services-proxy-suite-proxy-routing-default)
- [`proxy.routing.ruleSets`](../options/proxy.md#services-proxy-suite-proxy-routing-rulesets)
- [`proxy.autoProxy`](../options/proxy.md#services-proxy-suite-proxy-autoproxy-enable)
+67
View File
@@ -0,0 +1,67 @@
# Keep secrets out of the Nix store
Everything in a Nix config is copied to `/nix/store`, which every user on the machine can
read. That includes proxy links, passwords and keys. So every option that holds a secret has
a `…File` twin, which takes a path that is read when the service starts:
| Inline (ends up in the store) | Use instead |
|---|---|
| `url` | `urlFile` |
| `password` | `passwordFile` |
| `uuid` | `uuidFile` |
| `vpn` | `vpnFile` |
| `privateKey` | `privateKeyFile` |
| `secret` | `secretFile` |
The option reference marks each inline one with "Ends up in the Nix store".
A file can stay owned by root with mode `0400`. The services read it as root when they start.
With home-manager and Nix-on-Droid, your own user must be able to read it.
## With sops-nix
```nix no-check
sops.secrets."proxy/my-vps-url" = { };
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [
{ tag = "my-vps"; urlFile = config.sops.secrets."proxy/my-vps-url".path; }
];
};
};
```
## With agenix
```nix no-check
age.secrets.my-vps-url.file = ./secrets/my-vps-url.age;
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [
{ tag = "my-vps"; urlFile = config.age.secrets.my-vps-url.path; }
];
};
};
```
## Without a secrets tool
Any path outside the store works, such as a root-only file you create by hand:
```sh
sudo install -D -m 0400 /dev/stdin /var/lib/proxy-secrets/my-vps-url <<< 'vless://…'
```
## Good to know
- A secret file that changes takes effect on the next restart: `proxy-ctl restart`.
- Anything added at runtime with `proxy-ctl` (outbounds, subscriptions) is kept outside the
store, readable by root and by the `userControl` group.
- Share links, subscription URLs and running configs contain secrets too. `proxy-ctl` shows
them only to root, and to `userControl` members with the `secrets` scope.
+345
View File
@@ -0,0 +1,345 @@
# Run your own server
Accept proxy clients on a VPS, and hand out share links, QR codes and subscriptions for
them. The listeners run on XRay, and AmneziaWG listeners run on AmneziaWG.
## A fresh VPS: the installer
If your provider lets you boot a custom ISO, build the installer:
```sh
nix build github:FUFSoB/proxy-suite-flake#installer-iso
```
The image is `result/iso/proxy-suite-installer-<build time>-<commit>-<system>.iso`. Boot
the VPS from it. The console installer asks for the public IP, users, an optional
domain, whether to run the QEMU guest agent (so the VPS panel sees the server's state)
and the disk to erase, then installs NixOS with `nixosModules.server`: VLESS
REALITY, TLS and WS listeners, ACME certificates and SSH, with fish as the login shell
and vim (nano stays the default editor), git, htop, tmux, jq, mtr, iftop, dig, ncdu,
iperf3, tcpdump, bandwhich, nload, lsof and nvd (`services.proxy-suite-server.tools`).
It also collects Nix garbage weekly (generations older than 14 days, 10 boot entries at
most), caps the journal at 200M, bans addresses that keep failing SSH logins (fail2ban),
and counts traffic per day and month (`vnstat -m`); each is a NixOS default to override.
It installs the proxy-suite source the ISO carries: `/etc/nixos` follows this repository
on GitHub when the ISO's commit is there, and holds a copy otherwise. The disk is laid out by disko
(`services.proxy-suite-server.disko`): btrfs with `compress=zstd:3`, subvolumes `@` on `/`,
`@nix`, `@varlog` on `/var/log` and `@home`, and a 2G swap file in `@swap`. After the reboot, log in
and run:
```sh
proxy-ctl inbounds link vless-reality --qr
```
## An existing NixOS host
```nix
services.proxy-suite = {
enable = true;
inbounds = {
enable = true;
serverAddress = "vpn.example.com"; # null: this host's public IPv4
routing.via = "direct"; # clients exit straight from this host
# Each user once; listeners name the ones they accept, and take the secret they need.
users = {
phone.uuidFile = "/run/secrets/uuid-phone";
laptop.uuidFile = "/run/secrets/uuid-laptop";
};
listeners = {
vless-reality = {
type = "vless";
port = 443;
flow = "xtls-rprx-vision";
users = [ "phone" "laptop" ];
reality = {
enable = true;
serverNames = [ "www.microsoft.com" ];
privateKeyFile = "/run/secrets/reality-private-key";
publicKey = "jNXH…"; # both keys from `xray x25519`
shortIds = [ "0123abcd" ];
};
};
# Keys for the server and each user are generated on first start.
awg = {
type = "amneziawg";
port = 51820;
users = [ "phone" ];
};
};
};
};
```
Store the secrets with your secrets tool (see [Keep secrets out of the Nix store](./secrets.md)).
To make them:
```sh
uuidgen # one UUID per user
nix run nixpkgs#xray -- x25519 # the private key for the file, the public key for the config
```
The firewall opens the listener ports on its own. Other protocols (trojan, shadowsocks,
hysteria2, vmess, …) and transports (ws, grpc, xhttp) are set per listener; see
[`inbounds.listeners`](../options/inbounds.md#services-proxy-suite-inbounds-listeners).
## Share access
```sh
proxy-ctl inbounds # listeners
proxy-ctl inbounds link vless-reality phone --qr # link as a QR code for the phone
proxy-ctl inbounds link awg phone --config # AmneziaWG .conf
proxy-ctl inbounds users # users: order, address, listeners
proxy-ctl inbounds stats # traffic per user
proxy-ctl inbounds online # who is connected
```
Subscriptions give each user one URL with their links from every listener, so clients pick
up changes on their own. Enable them and serve the directory with a web server:
```nix
services.proxy-suite.inbounds.subscriptions = {
enable = true;
baseUrl = "https://vpn.example.com/sub";
};
services.nginx.virtualHosts."vpn.example.com".locations."/sub/" = {
alias = "/run/proxy-suite-inbounds/subscriptions/";
extraConfig = "access_log off;"; # the token is the URL's secret
};
```
Then `proxy-ctl inbounds sub phone --qr` prints that user's subscription.
The token at the end of the URL is all that guards a subscription. It is an HMAC under a key
generated on first start (/var/lib/proxy-suite/inbounds/subscription-key, carried by
`proxy-ctl inbounds export`), or under `subscriptions.keyFile` when you keep your own. A
server that handed out URLs before there was a key keeps them with
`subscriptions.keyFile = false`: its tokens stay a hash of the user's name and
credentials, which anyone who has one of the user's links can work out, and with it the rest
of their links. Turning the key on later changes every user's URL.
## Add users and listeners at runtime
With `inbounds.runtime`, users and listeners can be added with `proxy-ctl`, the TUI or the app,
without a rebuild. The config says what they may use: ports, exits and certificates.
```nix
services.proxy-suite.inbounds.runtime = {
enable = true;
ports = [ "20000-20099" ]; # runtime listeners bind only here; opened in the firewall
vias = [ "direct" ]; # exits besides routing.via and "block"
tlsCertificates.main = { # named, so a runtime listener never points at a file
certificateFile = "/var/lib/acme/vpn.example.com/fullchain.pem";
keyFile = "/var/lib/acme/vpn.example.com/key.pem";
};
};
```
```sh
proxy-ctl inbounds users add alice --listener vless-reality # secrets are generated
proxy-ctl inbounds add friends vless --port 20001 --reality www.microsoft.com --user alice
proxy-ctl inbounds bind phone friends # a declared user on it too
proxy-ctl inbounds users # order, address, listeners
proxy-ctl inbounds link friends alice --qr
```
A runtime user can join any listener; a declared user only a runtime one (bind two declared
ones in the config). Each user's `order` is its `routing.serverSource` number, as in the
config: given with `--order` or the lowest free one, and kept. A listener takes JSON too,
shaped like an [`inbounds.listeners`](../options/inbounds.md#services-proxy-suite-inbounds-listeners)
entry: `proxy-ctl inbounds add friends listener.json`. It cannot name files, raw XRay JSON,
AmneziaWG or port hopping; REALITY keys and Shadowsocks 2022 server keys are generated.
Every change restarts the inbounds, which drops the connections once. One that does not hold
up is refused, and anything that stops working later (a certificate removed from the config,
say) is left out with a warning in `proxy-ctl logs proxy-suite-inbounds` while the rest runs.
Without root, members of `userControl.group` need the `inbounds` scope.
## Policies: expiry, traffic, devices, speed
`inbounds.manager` runs a daemon that keeps each user's policy and applies it to the running
inbounds without a restart: users switched off, out of time or out of traffic leave XRay
through its API (their open connections are cut), the others keep theirs.
```nix
services.proxy-suite.inbounds = {
manager = {
enable = true;
speedLimits.enable = true; # nftables, and proxy-suite's XRay patch
};
# Declared users take a policy in the config; runtime ones get theirs from proxy-ctl or the API.
users.phone.policy = {
expiresAt = "2026-12-31";
trafficLimit = "100G";
trafficPeriod = "monthly";
ipLimit = 2;
speedLimit = "50M/10M"; # down/up, bits per second
};
};
```
```sh
proxy-ctl inbounds users add alice --listener vless-reality --expires +30d --traffic 50G --period monthly --ips 2
proxy-ctl inbounds users # status, traffic used of the allowance, expiry
proxy-ctl inbounds users show alice
proxy-ctl inbounds users set alice --speed 20M/5M
proxy-ctl inbounds users extend alice 30d # from the expiry, or from now if it passed
proxy-ctl inbounds users extend alice 30d --reset # a renewal: the traffic starts over too
proxy-ctl inbounds users add bob --listener vless-reality --on-hold 30d --traffic 50G
proxy-ctl inbounds users reset alice # start the traffic over
proxy-ctl inbounds users rotate-sub alice # a new subscription URL; the old one stops answering
proxy-ctl inbounds users disable alice
proxy-ctl inbounds bans # addresses past an ipLimit, banned for a while
```
What a policy holds:
- `expiresAt`: past it the user is switched off, and their subscription still says when.
- `expiresAfter` (`--on-hold`): a term that starts with the first connection, for access sold
ahead. Until the user connects they are on hold; then `expiresAt` is set that much later
(event user.activated). `extend` lengthens the term while on hold. An `expiresAt` given wins.
- `trafficLimit`, `trafficPeriod`: up and down together, counted from the day the user came
or was reset; a period renews at local midnight, monthly on that day of the month.
- `ipLimit`: past it, the addresses that came last are banned from the user's ports for
`manager.ipLimit.banTime`. Not on AmneziaWG (a peer has one address anyway), nor behind
a PROXY-protocol front.
- `speedLimit`: XRay marks the sockets its exits dial for the user with their slot, and
nftables polices that mark both ways; AmneziaWG peers by their tunnel address.
- `meta`: strings for a bot of yours, such as a Telegram ID.
Runtime users expired long ago can go by themselves: `manager.deleteExpiredAfter = "30d"`
deletes each that long after its expiry (event user.deleted, with the reason). Declared users
stay.
Subscriptions served by the manager carry the traffic, the allowance and the expiry
(`subscription-userinfo`), which v2rayN, Hiddify, Happ and Streisand show, plus a title and
an update interval. The same URL answers each client in what it reads:
- Clash and mihomo apps (Clash Meta, Clash Verge, FlClash, Stash): a mihomo config, the
user's servers in a group that picks the fastest and one to choose by hand.
- The sing-box apps (SFA, SFI, SFM): a sing-box config with TUN.
- A browser: a page with the state, traffic and expiry, a QR code, buttons that add the
subscription to an app, and each link to copy. In Russian when the browser asks for it.
The buttons for the browser's system come first (Android, iOS, macOS, Windows, Linux), the
rest under "Other apps": Happ, Hiddify, v2rayNG, Streisand, Karing, sing-box, Clash (Clash
Meta, FlClash, Clash Verge Rev, Clash Party, Stash) and, on Linux, proxy-suite's own desktop
app (`gui.enable`), which asks before it adds the subscription.
- Everything else, Hiddify included: base64 of the links, as before.
`?format=base64|links|clash|sing-box|html` picks one by hand. Listeners only XRay dials
(XHTTP, ECH) are left out of the Clash and sing-box configs, and AmneziaWG out of all of them.
The page's QR code, drawn by the browser, is of `inbounds.subscriptions.baseUrl`; without it,
of the address the browser asked for, as the web server passes it on in `Host` and
`X-Forwarded-Proto`. Set `baseUrl`: then no header decides what the page offers. The page
runs nothing but its own script and stylesheet (a CSP with their hashes), and no answer is
cached, sent on as a referrer or indexed.
Point the web server at the manager's socket instead of the static files; the tokens and so
the URLs stay the same. Keep the tokens out of its access log, and slow down whoever guesses:
```nix
services.nginx.appendHttpConfig = "limit_req_zone $binary_remote_addr zone=sub:1m rate=30r/m;";
services.nginx.virtualHosts."vpn.example.com".locations."/sub/" = {
proxyPass = "http://unix:/run/proxy-suite-inbounds-manager/sub.sock:";
recommendedProxySettings = true; # Host, X-Forwarded-Proto, X-Real-IP
extraConfig = ''
access_log off;
limit_req zone=sub burst=20 nodelay;
'';
};
```
A token that is not there gets a 404 and a line in the manager's journal, at most one a minute
per address (X-Real-IP from the web server), with how many came since:
`subscription: unknown token from 203.0.113.7 (12 more since the last line)`. A fail2ban
filter on it bans whoever keeps guessing.
`proxy-ctl inbounds users rotate-sub <name>` gives a user a new URL with their credentials
left as they are, for a URL that got out; their clients need the new one. It stays with the
user through an export and import.
Worth knowing:
- A user switched off by the manager loses their open connections too: TCP ones are closed
(`ss -K`), UDP ones (Hysteria2, XHTTP over HTTP/3) dropped for a while. Others behind the
same address reconnect once. Without the manager, removing a runtime user cuts its TCP
connections only.
- Giving a user a speed limit, or taking it away, changes their XRay level: their
connections drop once.
- An exit whose own JSON or URL sets `sockopt.mark` keeps it, and its users are not
speed-limited there. Socks and http listeners take no speed limit either.
### The API
The manager answers HTTP+JSON on `/run/proxy-suite-inbounds-manager/api.sock` (root, and
`userControl.group` with the "inbounds" scope, or `manager.api.group`), and with
`manager.api.listen` and bearer tokens over TCP, for a bot elsewhere (behind TLS):
```sh
curl --unix-socket /run/proxy-suite-inbounds-manager/api.sock http://x/api/v1/users
curl --unix-socket /run/proxy-suite-inbounds-manager/api.sock http://x/api/v1/users \
-d '{"name": "bob", "listeners": ["vless-reality"], "policy": {"expiresAt": "+30d", "trafficLimit": "50G"}}'
```
| Call | What |
| --- | --- |
| `GET /api/v1/users`, `GET /api/v1/users/<name>` | users: policy, status and why, traffic, online addresses, subscription |
| `POST /api/v1/users` | `{name, listeners, order?, policy?}`: a runtime user, secrets generated |
| `PATCH /api/v1/users/<name>` | policy fields, and `unset: [fields]` to drop runtime ones |
| `DELETE /api/v1/users/<name>` | a runtime user, and their policy |
| `POST /api/v1/users/<name>/enable`, `/disable`, `/reset-traffic` | |
| `POST /api/v1/users/<name>/extend` | `{by: "30d"}` or `{until: "2027-01-31"}`, and `resetTraffic: true` to start the traffic over |
| `POST /api/v1/users/<name>/rotate-subscription` | a new subscription URL; the old one stops answering |
| `PUT /api/v1/users/<name>/listeners` | `{listeners: [...]}` |
| `GET /api/v1/users/<name>/links` | share links and client configs |
| `GET /api/v1/listeners`, `/online`, `/bans`; `DELETE /api/v1/bans/<address>` | |
| `GET /api/v1/export`, `POST /api/v1/import` | see below |
| `GET /api/v1/events` | the latest events |
Sizes take K, M, G, T (binary), speeds k, M, G bits per second, times a date, an ISO time,
a Unix time or `+30d`. Errors come as `{"error": "..."}` with a 4xx status.
`manager.webhooks` POST each event as JSON (`{event, user, at, data}`), signed with
`X-Proxy-Suite-Signature: sha256=<HMAC>` when given a secret: user.created, user.deleted,
user.updated, user.enabled, user.disabled (with the reasons), user.reset, user.activated
(a term on hold started), user.traffic (80 % and 100 % of the allowance), user.expiring
(3 days and 1 day before) and user.ip-limit.
### Moving to another server
```sh
proxy-ctl inbounds export users.json # on the old one: 0600, it holds every secret
proxy-ctl inbounds import users.json # on the new one, with the same listeners
```
The export holds the runtime users and listeners (their UUIDs, passwords and REALITY keys),
the policies and what they are measured against, the AmneziaWG listeners' keys and
addresses, the Salamander passwords proxy-suite generated, and the traffic counted. Secrets
the config names by file (sops and the like) are not in it. Runtime users and listeners
already on the new server are refused and policies already there kept, unless `--replace`;
an AmneziaWG listener that has a key already keeps it unless `--replace`, which its existing
clients need.
## Good to know
- Clients cannot reach this host's LAN or Russian sites by default
(`inbounds.routing.blockPrivate`, `blockRu`).
- Nor, by default, BitTorrent or port 25 (`routing.blockTorrent`, `routing.blockPorts`):
copyright notices and spam are what hosters close servers over. XRay's sniffing catches
the peers' handshake, not trackers, DHT or encrypted connections: torrents get slow, not
impossible. Should a complaint come anyway, `inbounds.accessLog` logs who went where.
- Through "direct", clients reach this host itself only on the listeners' ports and
`inbounds.serverPorts` (80/443 with subscriptions), whatever it listens on. Its addresses
are read when the inbounds start: restart them after the address changes.
- With `routing.via = "proxy"` (the default), client traffic goes through this host's own
proxy instead, following its routing. That needs `proxy.enable`. A listener can also exit
through one outbound with `via = "<tag>"`.
- For clients that cannot reach the server at all, `tor.onionService` serves the
listeners over Tor too.
## See also
- [`inbounds.listeners`](../options/inbounds.md#services-proxy-suite-inbounds-listeners)
- [`inbounds.routing.via`](../options/inbounds.md#services-proxy-suite-inbounds-routing-via)
- [`inbounds.runtime`](../options/inbounds.md#services-proxy-suite-inbounds-runtime-enable)
- [`inbounds.subscriptions`](../options/inbounds.md#services-proxy-suite-inbounds-subscriptions-enable)
- [`tor.onionService`](../options/tor.md#services-proxy-suite-tor-onionservice-enable)
+74
View File
@@ -0,0 +1,74 @@
# Route the whole machine
Send every app's traffic through the proxy, including apps with no proxy settings. There
are two global modes, and either can start at boot.
## Config
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
tun.enable = true;
autostart = "tun"; # or null, to start it by hand
};
killSwitch.enable = true;
};
```
## TUN or TProxy
- **TUN** adds a virtual network interface and routes everything into it. It is the usual
pick.
- **TProxy** intercepts TCP and UDP with nftables instead of adding an interface. Pick it if
this host is a gateway for other devices: list their interfaces in
`proxy.tproxy.lanInterfaces` (NixOS needs `networking.nftables.enable` for that).
You can enable both and switch between them. Starting one global mode stops the other, and
an AmneziaWG profile running as a global VPN counts as one too.
Your [routing rules](./routing.md) still apply in both modes. Sites that the rules send
direct skip the proxy.
## Commands
```sh
proxy-ctl proxy tun on # or: off, toggle, restart
proxy-ctl proxy tproxy on
proxy-ctl status # which mode is running
proxy-ctl killswitch # kill switch state
proxy-ctl killswitch off # lift the kill switch without stopping the tunnel
```
## Good to know
- The kill switch blocks outgoing traffic from boot until the tunnel is up, while it restarts
and after it fails, so nothing leaks. LAN, DHCP and the time daemon's NTP stay open.
Subscriptions are fetched through the tunnel; only if that fails are they fetched
directly, so the proxy can come up from a cold cache. The subscription host then sees
your address. Turning the tunnel off with `proxy-ctl` lifts the kill switch until the
next boot or tunnel start.
- With TUN or a global AmneziaWG profile, the kill switch also holds forwarded traffic
(Docker, libvirt, podman) to the LAN while the tunnel is down. TProxy diverts only
`proxy.tproxy.lanInterfaces`, so in TProxy mode other containers and VMs bypass the proxy
whether the tunnel is up or not. With TProxy alone the kill switch lets them through, and
with TUN or AmneziaWG also configured it cuts them off in TProxy mode.
- Networks the kill switch should leave open besides the private ranges, such as a routed
IPv6 prefix on a VM bridge, go in `killSwitch.allowedSubnets`. It defaults to
`proxy.tproxy.localSubnets`, so what TProxy leaves out stays reachable.
- If the uplink has no IPv6, set `proxy.dns.strategy = "ipv4_only"` (sing-box). Otherwise
direct IPv6 connections hang instead of falling back to IPv4.
- `proxy.tproxy.localSubnets` lists networks that skip TProxy. Add your LAN and VM bridges if
they are not in `192.168.0.0/16`.
- While a global mode is on, per-app `tun`, `tproxy` and `zapret` profiles run the app
without their route, so wrapped programs still start.
## See also
- [`proxy.tun`](../options/proxy.md#services-proxy-suite-proxy-tun-enable)
- [`proxy.tproxy`](../options/proxy.md#services-proxy-suite-proxy-tproxy-enable)
- [`proxy.autostart`](../options/proxy.md#services-proxy-suite-proxy-autostart)
- [`killSwitch.enable`](../options/killSwitch.md#services-proxy-suite-killswitch-enable)
- [`proxy.ipv6`](../options/proxy.md#services-proxy-suite-proxy-ipv6)
+87
View File
@@ -0,0 +1,87 @@
# Get past mobile whitelists
Some mobile networks let through only a whitelist of services, such as video calls, and
block everything else. [whitelist-bypass](https://github.com/kulikov0/whitelist-bypass)
tunnels your traffic through a video call on a whitelisted platform.
It takes two machines:
- a **creator** on a host with normal internet access, such as a VPS or a home machine. It
logs in to the call platform, starts a call and relays traffic to the internet;
- a **joiner** on the censored side, such as a laptop on mobile internet. It joins that call
and becomes an outbound for the proxy.
Supported platforms: `"wbstream"`, `"telemost"`, `"dion"` and `"bitrix"`. Each needs an
account for the creator.
## The creator
One creator per joiner device.
```nix
services.proxy-suite = {
enable = true;
whitelistBypass = {
enable = true;
creators.laptop = {
platform = "wbstream";
cookiesFile = "/run/secrets/wbstream-cookies.json";
};
};
};
```
The cookies come from the upstream desktop Creator app or a browser. They are read on first start, and
the login refreshes itself after that. `proxy-ctl wl auth laptop` replaces them at runtime,
and asks for an email and password instead on DION and Bitrix.
The creator starts a call and keeps reusing it. Get its link with:
```sh
proxy-ctl wl link laptop
```
## The joiner
The joiner is an outbound tagged with its name (`wl` here), so it needs the local proxy.
```nix
services.proxy-suite = {
enable = true;
proxy.enable = true;
whitelistBypass = {
enable = true;
joiners.wl.platform = "wbstream";
};
};
```
Give it the creator's link, then send traffic through it:
```sh
proxy-ctl wl join wl 'https://…' # the link from `proxy-ctl wl link`
proxy-ctl proxy pin wl
```
The link can also come from a file, with `joiners.<name>.linkFile`.
## Commands
```sh
proxy-ctl wl # creators and joiners, and their state
proxy-ctl wl new laptop # start a new call, if the platform closed the old one
proxy-ctl wl restart # restart all of them; or name one
```
## Good to know
- By default, the creator's traffic exits straight from its host. With
`creators.<name>.upstream = "proxy"`, it goes through that host's own proxy and routing.
- Use it when nothing else gets through, and `proxy-ctl proxy unpin` once other outbounds
work again.
- Pair it with [Route the whole machine](./system-wide.md) on the joiner to cover every app.
## See also
- [`whitelistBypass.creators`](../options/whitelistBypass.md#services-proxy-suite-whitelistbypass-creators)
- [`whitelistBypass.joiners`](../options/whitelistBypass.md#services-proxy-suite-whitelistbypass-joiners)
+131
View File
@@ -0,0 +1,131 @@
# Wrap programs with the proxy
Build the proxy into a package, so a program uses it wherever and however it is started,
with no setup in the program. On NixOS and home-manager, the module provides the pieces as
`config.lib.proxy-suite`, built from your listener and per-app routing settings.
| Helper | How the program is routed | Covers |
|---|---|---|
| `wrapEnv` | Proxy variables (`https_proxy`, `all_proxy`, …) | Programs that read them: most CLIs, Go, Python, curl, git |
| `wrapProxychains` | proxychains, for programs that ignore the variables | TCP; not static or Go programs |
| `wrapPerApp` | A [per-app routing](./per-app.md) profile, via `proxy-ctl apps run` | Everything, TCP and UDP (`tun` profile) |
| `env`, `envFor` | Just the variables, for services and shells | Whatever reads them |
## On NixOS
```nix
{ config, pkgs, ... }:
let
proxySuite = config.lib.proxy-suite;
in
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
};
perAppRouting = {
enable = true;
createDefaultProfiles = true;
proxychains.enable = true;
tun.enable = true;
};
};
environment.systemPackages = [
(proxySuite.wrapEnv { } pkgs.yt-dlp)
(proxySuite.wrapProxychains { } pkgs.curl)
(proxySuite.wrapPerApp { profile = "tun"; } pkgs.firefox)
];
# A service: here nix-daemon, so downloads go through the proxy.
systemd.services.nix-daemon.environment = proxySuite.envFor "http";
}
```
The wrapped programs keep their names, and the package's `.desktop` files start them.
## From home-manager
A home-manager config inside NixOS reads the system's helpers through `osConfig`:
```nix no-check
{ osConfig, pkgs, ... }:
let
proxySuite = osConfig.lib.proxy-suite;
in
{
home.packages = [
(proxySuite.wrapEnv { protocol = "all"; } pkgs.codex)
(proxySuite.wrapEnv { } pkgs.claude-code)
];
}
```
When proxy-suite itself runs under home-manager, use `config.lib.proxy-suite`.
## Other hosts, or another host's proxy
system-manager and Nix-on-Droid have no `config.lib`. There, or for a proxy that this config
does not run, the flake builds the URLs, the variables and `wrapEnv` from an address:
```nix no-check
proxySuite = inputs.proxy-suite.lib.proxyHelpers {
inherit pkgs;
address = "192.168.1.10"; # default "127.0.0.1"
port = 1080; # default 1080
# username and password, if the proxy asks for them
};
```
## Reference
- `urls.http`, `urls.socks5h`, `urls.socks5`: the proxy's URLs. A listener on `0.0.0.0` or
`::` is reached on loopback. With `socks5h://` the proxy resolves names; `socks5://`
resolves them locally, for programs that do not accept `socks5h://`, such as Chromium and
Electron apps.
- `urls.socks`: the same as `urls.socks5h`.
- `env`: every proxy variable (`http_proxy`, `https_proxy`, `all_proxy`, their upper-case
forms, and `no_proxy`). `envFor "http"` or `envFor "socks"` gives one kind only.
- `wrapEnv { protocol ? "http"; programs ? null; } package`: the package, with its programs
run with the variables of `protocol`.
- `wrapProxychains { programs ? null; } package`: its programs run under proxychains. Needs
`perAppRouting.proxychains.enable`.
- `wrapPerApp { profile; programs ? null; } package`: its programs run with
`proxy-ctl apps run <profile>`. Needs the profile in `perAppRouting`.
`programs = [ "…" ]` wraps only the named programs of the package; the rest stay as they
are. By default, every program in its `bin/` is wrapped.
## Which variables
`wrapEnv` sets one kind and unsets the other, so proxy variables in your shell cannot
send the program somewhere else:
- `protocol = "http"` (the default): `http_proxy` and `https_proxy`, which nearly
everything reads.
- `protocol = "socks"`: `all_proxy` with `socks5h://`, so the proxy resolves names. For
programs that read only that one, or handle SOCKS better.
- `protocol = "all"`: both, when you are not sure which one a program reads.
Local addresses (`localhost`, `127.0.0.0/8`, `::1`) always stay direct, through `no_proxy`.
## Good to know
- The variables need `proxy.enable`. They cannot hold a password from
`listener.auth.passwordFile`. Use `wrapProxychains` then, since it reads the password
at run time.
- `wrapPerApp` with a `tun`, `tproxy` or `zapret` profile has the same needs as
`proxy-ctl apps run`: an admin password, or the `perApp` scope in `userControl`.
- A helper that cannot work stops the build and says why, for example when a profile does
not exist.
- A wrapper does not inherit the package's license, so wrapping an unfree package needs
nothing beyond what the package itself needs.
- For every program on the machine, see [Route the whole machine](./system-wide.md)
instead.
## See also
- [Route a single app](./per-app.md): the profiles `wrapPerApp` uses
- [`perAppRouting.profiles`](../options/perAppRouting.md#services-proxy-suite-perapprouting-profiles)
+125
View File
@@ -0,0 +1,125 @@
# Unblock sites without a server
zapret gets around DPI blocking by changing how the first packets of a connection look. It
needs no proxy server: the traffic still goes straight to the site. It only helps with
blocks that DPI enforces, and not with sites whose IPs are blocked outright.
## Ready-made presets: zapret-discord-youtube
The default engine. It covers YouTube and Discord out of the box.
```nix
services.proxy-suite = {
enable = true;
zapret = {
enable = true;
zapret-discord-youtube = {
configName = "general(ALT)"; # the default; try others if it does not work
domains = [ "rutracker.org" ]; # more sites to unblock
};
};
};
```
Which preset works depends on your ISP. If sites still do not load, try other presets from
the [zapret-discord-youtube](https://github.com/kartavkun/zapret-discord-youtube) list, such
as `"general (ALT9)"`.
## Blocked sites found automatically: zapret2
zapret2 notices failing connections, marks the site as blocked, and finds a strategy that
works for it. Each site's strategy is remembered. It also learns sites blocked only some of
the time, downloads that stall partway, and requests that never get an answer.
What zapret2 cannot fix goes through your proxy, when you have one: a site none of its
strategies get through for (only its QUIC, when that alone fails), and an address that
never answers at all, as Telegram's are blocked. That works for traffic the proxy sees
(TUN, TProxy, per-app routing). `proxy-ctl zapret auto` names such an address by the sites
looked up to it, when systemd-resolved still had them cached as it was blocked.
```nix
services.proxy-suite = {
enable = true;
zapret = {
enable = true;
engine = "zapret2";
zapret2.domains = [ "rutracker.org" ]; # always treated as blocked
};
};
```
`zapret2.strategySource = "z2k"` switches to z2k's strategies and site lists, which includes
the full RKN list and uses more memory. It also turns on a workaround for ISPs that cut
TLS to some hosting networks after about 16 KB.
Each failure zapret2 counts and each strategy switch is logged, per site:
`proxy-ctl logs proxy-suite-zapret`. A site stays on its first strategy as long as that one
works.
Other ports, such as a game's, take the same strategies with `zapret2.ports.extraUdp` or
`extraTcp`:
```nix
services.proxy-suite.zapret.zapret2.ports.extraUdp = [ "27015-27030" ];
```
## Commands
```sh
proxy-ctl zapret # status
proxy-ctl zapret off # or: on, toggle, restart
proxy-ctl zapret auto # sites zapret2 learned, and what goes to the proxy
proxy-ctl zapret auto add example.com # treat a site as blocked
proxy-ctl zapret auto retry example.com # give zapret2 another try at what it sent the proxy
proxy-ctl zapret auto exclude example.com # never touch or learn a site
proxy-ctl zapret auto forget example.com # forget it and its strategy
proxy-ctl zapret cutoff # networks cut off at 16 KB (z2k)
```
## With a proxy
zapret and the proxy work side by side. By default (`zapret.directSync`), the sites zapret
handles are sent direct, so they skip the proxy and reach zapret. With zapret2 that includes
the ones you pin with `proxy-ctl zapret auto add`, and the sites it learns once one of its
strategies is seen getting through; your own rules and autoProxy still come first.
Everything else follows your [routing rules](./routing.md).
## Only for some apps
To leave the rest of the system alone, turn the system-wide zapret off and run apps through
it one by one:
```nix
services.proxy-suite = {
enable = true;
zapret = {
enable = true;
global.enable = false; # no system-wide zapret
};
perAppRouting = {
enable = true;
createDefaultProfiles = true; # adds a profile named "zapret"
zapret.enable = true;
};
};
```
Then run `proxy-ctl apps run zapret -- firefox`. The app gets zapret's strategy for every
site, not only the listed ones. `directSync`, `cidrExemption` and the sites zapret2 learns
belong to the system-wide zapret, so they do nothing here. See
[Route a single app](./per-app.md) for more.
## Good to know
- zapret needs root, so it is not available with home-manager or Nix-on-Droid.
- If it breaks VMs or containers behind NAT, list their subnets in `zapret.cidrExemption`.
- For games, set `zapret-discord-youtube.gameFilter`.
## See also
- [`zapret.engine`](../options/zapret.md#services-proxy-suite-zapret-engine)
- [`zapret.global.enable`](../options/zapret.md#services-proxy-suite-zapret-global-enable)
- [`zapret-discord-youtube.configName`](../options/zapret.md#services-proxy-suite-zapret-zapret-discord-youtube-configname)
- [`zapret2.strategySource`](../options/zapret.md#services-proxy-suite-zapret-zapret2-strategysource)
- [`zapret2.ports.extraUdp`](../options/zapret.md#services-proxy-suite-zapret-zapret2-ports-extraudp)
- [`zapret.directSync`](../options/zapret.md#services-proxy-suite-zapret-directsync-enable)
Generated
+49 -27
View File
@@ -1,30 +1,48 @@
{
"nodes": {
"flake-utils": {
"disko": {
"inputs": {
"systems": "systems"
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"lastModified": 1789770686,
"narHash": "sha256-uZkBR7yHdIKUFB5SZdfgh1qkGfI3XmYmI/lTiquxbck=",
"owner": "nix-community",
"repo": "disko",
"rev": "725ea35e410ad83be4931d1bff7e090eacaf3563",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"owner": "nix-community",
"repo": "disko",
"type": "github"
}
},
"nfqws2-keenetic": {
"flake": false,
"locked": {
"lastModified": 1789144514,
"narHash": "sha256-G+LvvXDqzYm8SOXNc3N+HIzvD9DR3J+WT+HHDdmjB0Y=",
"owner": "nfqws",
"repo": "nfqws2-keenetic",
"rev": "fa22c177b340e73d8b8a94b295af20e0228c4c22",
"type": "github"
},
"original": {
"owner": "nfqws",
"repo": "nfqws2-keenetic",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1775710090,
"narHash": "sha256-ar3rofg+awPB8QXDaFJhJ2jJhu+KqN/PRCXeyuXR76E=",
"lastModified": 1791594108,
"narHash": "sha256-XK4KceonkwD8LuMAt/vNrz982mXJM5jeHAxMwsUXXAQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "4c1018dae018162ec878d42fec712642d214fdfa",
"rev": "6510408d147d8c5e6d76043e899e9251756f6a75",
"type": "github"
},
"original": {
@@ -36,39 +54,43 @@
},
"root": {
"inputs": {
"disko": "disko",
"nfqws2-keenetic": "nfqws2-keenetic",
"nixpkgs": "nixpkgs",
"z2k": "z2k",
"zapret": "zapret"
}
},
"systems": {
"z2k": {
"flake": false,
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"lastModified": 1789186266,
"narHash": "sha256-d9gg7s66P3pkN7d4l72ryaGC9Ayoqg4tbHaoDNbDTT4=",
"owner": "necronicle",
"repo": "z2k",
"rev": "7beb9754d65a2cafd9c1d26d382bcb61d453d5b3",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"owner": "necronicle",
"ref": "z2k-enhanced",
"repo": "z2k",
"type": "github"
}
},
"zapret": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
],
"zapret-flowseal": "zapret-flowseal"
},
"locked": {
"lastModified": 1775231936,
"narHash": "sha256-jvyi6D2Ps0zicpIcn24tacIymQOyUVY6lr6B5RLQkx8=",
"lastModified": 1790422884,
"narHash": "sha256-va22R1zFF7JmibmFwezLYfRup8PfVO3pV7toQH+cbL0=",
"owner": "kartavkun",
"repo": "zapret-discord-youtube",
"rev": "b3e3f854f8d9cf35ddbcbfa7a03cb0a1334dd7eb",
"rev": "b82f45c363506588afbb45fefe41fe4670ae1480",
"type": "github"
},
"original": {
@@ -80,11 +102,11 @@
"zapret-flowseal": {
"flake": false,
"locked": {
"lastModified": 1775228068,
"narHash": "sha256-LAbCZRwoGxQcgO1nio33NlxBXIdsTQJxHQxu1RWctIA=",
"lastModified": 1790845315,
"narHash": "sha256-zhyCW0LFkWkByHu2Vfgita8Bh3lIexUemGyz9elekUQ=",
"owner": "Flowseal",
"repo": "zapret-discord-youtube",
"rev": "22a9ca3bc067441789c83bd80c00d38e54be51c4",
"rev": "eb16c1419057e36b8a36fbe7c959483450e6ac8b",
"type": "github"
},
"original": {
+105 -24
View File
@@ -1,5 +1,5 @@
{
description = "NixOS proxy suite – sing-box, zapret, tg-ws-proxy";
description = "NixOS proxy suite - SingBox, XRay, AmneziaWG 3.1, zapret, tg-ws-proxy, Tor";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
@@ -7,6 +7,18 @@
url = "github:kartavkun/zapret-discord-youtube";
inputs.nixpkgs.follows = "nixpkgs";
};
nfqws2-keenetic = {
url = "github:nfqws/nfqws2-keenetic";
flake = false;
};
z2k = {
url = "github:necronicle/z2k/z2k-enhanced";
flake = false;
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
@@ -14,6 +26,9 @@
self,
nixpkgs,
zapret,
nfqws2-keenetic,
z2k,
disko,
}:
let
systems = [
@@ -22,7 +37,15 @@
];
forAll = nixpkgs.lib.genAttrs systems;
pkgsFor = system: import nixpkgs { inherit system; };
proxySuiteModule = import ./modules/proxy-suite { inherit zapret; };
proxySuiteModules = import ./modules/proxy-suite {
inherit
zapret
nixpkgs
nfqws2-keenetic
z2k
;
};
proxySuiteModule = proxySuiteModules.nixos;
mkOptionsDoc = import ./nix/options-doc.nix {
inherit nixpkgs pkgsFor proxySuiteModule;
};
@@ -39,19 +62,68 @@
# Main module – bakes in the zapret flake so consumers don't need it as a separate input.
nixosModules.default = proxySuiteModule;
# A single-user VPS: VLESS REALITY, TLS and WS inbounds, ACME and SSH. Includes default.
nixosModules.server = import ./deploy/server-module.nix {
inherit proxySuiteModule;
diskoModule = disko.nixosModules.disko;
};
# Rootless, in the user's systemd manager: the local proxy, inbounds on ports from 1024
# up, and what else needs no root.
homeManagerModules.default = proxySuiteModules.homeManager;
# For numtide/system-manager on other distributions: everything NixOS has, with the
# firewall and kernel modules left to the host.
systemManagerModules.default = proxySuiteModules.systemManager;
# nix-on-droid, where proxy-suitectl supervises the services: what home-manager gets,
# without the GUI.
nixOnDroidModules.default = proxySuiteModules.nixOnDroid;
# Proxy variables and wrapEnv from an address alone: for a proxy this config does not
# run, or on system-manager and nix-on-droid, which have no config.lib.
# `proxy-suite.lib.proxyHelpers { inherit pkgs; port = 1080; }`. On NixOS and
# home-manager the module has the full set as config.lib.proxy-suite.
lib.proxyHelpers =
args:
import ./modules/proxy-suite/helpers.nix (
{
inherit (args.pkgs) lib;
}
// args
);
# Re-export zapret standalone for users who want just that.
nixosModules.zapret = zapret.nixosModules.default;
overlays.default = final: prev: {
# From prev: these override the nixpkgs packages of the same name.
inherit (import ./pkgs/default.nix { pkgs = prev; })
amneziawg-tools
amneziawg-go
;
inherit (import ./pkgs/default.nix { pkgs = final; })
mkProxyCtl
mkProxySuiteTray
mkTgWsProxy
tg-ws-proxy
proxy-suite-tray
whitelist-bypass
wireproxy-awg
zapret2
;
# Replaced by Proxy Suite GUI, which mkProxyCtl builds as `.gui`.
proxy-suite-tray = throw "proxy-suite-tray was replaced by Proxy Suite GUI: set services.proxy-suite.gui.enable";
mkProxySuiteTray = throw "mkProxySuiteTray was replaced by Proxy Suite GUI: set services.proxy-suite.gui.enable";
};
# `nix fmt`; the nix-format check holds the tree to it. The usage snippets are
# generated, and the usage-docs check wants them as their Markdown has them.
formatter = forAll (
system:
(pkgsFor system).nixfmt-tree.override {
settings.global.excludes = [ "docs/usage/.snippets/*" ];
}
);
packages = forAll (
system:
let
@@ -64,33 +136,40 @@
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
options_output_path="$(nix build --no-link --print-out-paths "''${repo_root}#optionsDoc")"
readme_output_path="$(nix build --no-link --print-out-paths "''${repo_root}#readmeDoc")"
install -Dm644 "''${options_output_path}" "''${repo_root}/docs/options.md"
install -Dm644 "''${readme_output_path}" "''${repo_root}/README.md"
echo "updated ''${repo_root}/docs/options.md"
echo "updated ''${repo_root}/README.md"
'';
text = builtins.readFile ./nix/update-docs.sh;
};
in
{
inherit (suitePkgs)
amneziawg-tools
amneziawg-go
tg-ws-proxy
proxy-suite-tray
whitelist-bypass
wireproxy-awg
z2k-detect
zapret2
;
xray = import ./pkgs/xray.nix { inherit pkgs; };
# Console installer for a proxy-suite VPS (deploy/iso.nix).
installer-iso =
(nixpkgs.lib.nixosSystem {
modules = [
(import ./deploy/iso.nix {
inherit self;
serverModule = self.nixosModules.server;
})
{ nixpkgs.hostPlatform = system; }
];
}).config.system.build.installerIso;
optionsDoc = mkOptionsDoc system;
usageSnippets = pkgs.runCommand "proxy-suite-usage-snippets" { } (
''
mkdir "$out"
''
+ pkgs.lib.concatMapStrings (snippet: ''
cp ${pkgs.writeText snippet.file snippet.text} "$out"/${snippet.file}
'') (import ./nix/usage-snippets.nix { inherit (pkgs) lib; }).snippets
);
readmeDoc = mkReadmeDoc system;
update-docs = updateDocs;
update-options-doc = pkgs.writeShellApplication {
@@ -123,8 +202,10 @@
system
nixpkgs
proxySuiteModule
proxySuiteModules
zapret
;
serverModule = self.nixosModules.server;
generatedOptionsDoc = mkOptionsDoc system;
generatedReadmeDoc = mkReadmeDoc system;
}
+243
View File
@@ -0,0 +1,243 @@
# AmneziaWG server listeners of services.proxy-suite.inbounds: one interface per listener,
# whose TCP and UDP is diverted by TProxy to the listener's loopback XRay inbound, so it
# leaves by the same routing as every other inbound. "lan" listeners also reach this host,
# its private networks and each other natively; "proxy" listeners reach nothing but that.
{
lib,
pkgs,
cfg,
derived,
proxyInboundsSpecFile,
reservedIpBlock,
ip,
nft,
}:
let
awgCfg = cfg.amneziaWg;
listeners = derived.proxyInboundsAwg;
inherit (derived.constants) awgInboundFwmark awgInboundRouteTable awgInboundRulePriority;
unitName = "proxy-suite-inbounds-awg";
nftTable = "proxy_suite_awg_inbounds";
ipv6 = lib.any (listener: listener.subnet6 != null) listeners;
lanListeners = builtins.filter (listener: listener.mode == "lan") listeners;
lanIPv6 = lib.any (listener: listener.subnet6 != null) lanListeners;
scriptsDir = import ./lib/scripts-dir.nix { inherit lib; };
python3 = "${pkgs.python3}/bin/python3";
awg = "${awgCfg.toolsPackage}/bin/awg";
awgCommon = import ./awg-common.nix { inherit lib pkgs awgCfg; };
# Diverted packets are delivered locally; only "lan" listeners forward.
sysctl =
lib.optionalAttrs (lanListeners != [ ]) {
"net.ipv4.ip_forward" = 1;
}
// lib.optionalAttrs lanIPv6 {
"net.ipv6.conf.all.forwarding" = 1;
};
quote = value: ''"${value}"'';
# Everything a listener's clients send that is not theirs to reach natively.
mkListenerChain =
index: listener:
let
verdict = if listener.mode == "lan" then "return" else "drop";
port = toString listener.internalPort;
mark = toString awgInboundFwmark;
in
''
chain listener_${toString index} {
# Cloud instance metadata (credentials, IAM tokens): for this host alone, never
# for its clients, "lan" or not.
ip daddr { ${lib.concatStringsSep ", " derived.constants.cloudMetadata.ipv4} } drop
ip6 daddr { ${lib.concatStringsSep ", " derived.constants.cloudMetadata.ipv6} } drop
fib daddr type { local, broadcast, multicast } ${verdict}
ip daddr $RESERVED_IP ${verdict}
# Not in RESERVED_IP, whose other users route it by the local subnets instead.
ip daddr 192.168.0.0/16 ${verdict}
ip6 daddr $RESERVED_IP6 ${verdict}
ip daddr ${listener.subnet} ${verdict}
${lib.optionalString (listener.subnet6 != null) " ip6 daddr ${listener.subnet6} ${verdict}"}
meta l4proto { tcp, udp } tproxy ip to 127.0.0.1:${port} meta mark set ${mark} accept
${lib.optionalString (
listener.subnet6 != null
) " meta l4proto { tcp, udp } tproxy ip6 to [::1]:${port} meta mark set ${mark} accept"}
# Nothing else can follow the listener's routing (ICMP to the internet among it).
drop
}
'';
nftRulesFile = pkgs.writeText "proxy-suite-routing" ''
${reservedIpBlock}
table inet ${nftTable} {
${lib.concatStrings (lib.imap0 mkListenerChain listeners)}
chain prerouting {
# Ahead of TProxy and TUN capture, and of the reverse-path filter.
type filter hook prerouting priority mangle - 5; policy accept;
# The XRay inbounds only take what is diverted to them.
iifname != "lo" meta l4proto { tcp, udp } th dport { ${
lib.concatMapStringsSep ", " (listener: toString listener.internalPort) listeners
} } fib daddr type local drop
${lib.concatStrings (
lib.imap0 (index: listener: ''
iifname ${quote listener.interface} jump listener_${toString index}
'') listeners
)}
}
${lib.optionalString (lanListeners != [ ]) ''
# Private networks need no route back to the clients.
chain postrouting {
type nat hook postrouting priority srcnat; policy accept;
${lib.concatMapStrings (listener: ''
ip saddr ${listener.subnet} oifname != ${quote listener.interface} masquerade
${lib.optionalString (
listener.subnet6 != null
) "ip6 saddr ${listener.subnet6} oifname != ${quote listener.interface} masquerade"}
'') lanListeners}
}
''}
}
'';
# The table swapped in whole, in one transaction, also after a firewall reload flushed it.
nftReplaceFile = pkgs.writeText "proxy-suite-routing" ''
table inet ${nftTable}
delete table inet ${nftTable}
include "${nftRulesFile}"
'';
routingDown =
lib.concatMapStrings
(family: ''
while ${ip} ${family} rule del pref ${toString awgInboundRulePriority} 2>/dev/null; do :; done
${ip} ${family} route flush table ${toString awgInboundRouteTable} 2>/dev/null || true
'')
[
"-4"
"-6"
];
# The interfaces run with Table=off and no DNS, so deleting them undoes awg-quick.
interfacesDown = lib.concatMapStrings (listener: ''
${ip} link del dev ${lib.escapeShellArg listener.interface} 2>/dev/null || true
'') listeners;
stop = pkgs.writeShellScript unitName ''
set +e
${nft} delete table inet ${nftTable} 2>/dev/null
${routingDown}
${interfacesDown}
true
'';
start = pkgs.writeShellScript unitName ''
set -Eeuo pipefail
trap ${stop} ERR
${awgCommon.modprobe}
${stop}
# Before any interface is up: its iifname matches already, so no client packet comes
# in ahead of the confinement.
${nft} -f ${nftRulesFile}
PYTHONPATH=${scriptsDir} ${python3} ${scriptsDir}/awg_inbound.py prepare \
--spec ${proxyInboundsSpecFile} --awg ${awg} --runtime-dir "$RUNTIME_DIRECTORY" \
> "$RUNTIME_DIRECTORY/interfaces"
while read -r _interface implementation config; do
${awgCommon.awgQuickUp "$implementation" "\"$config\""}
done < "$RUNTIME_DIRECTORY/interfaces"
${lib.concatStrings (
lib.mapAttrsToList (name: value: ''
${pkgs.procps}/bin/sysctl -q -w ${name}=${toString value}
'') sysctl
)}
# Diverted packets are for the local XRay sockets, whatever their destination. Only as
# they come in: with src_valid_mark on (awg-quick turns it on for a global profile and
# leaves it), the kernel checks a packet's source by its mark too, and the local route
# here would make every client's IPv4 address a martian.
${lib.concatMapStrings (family: ''
${ip} ${family} route replace local default dev lo table ${toString awgInboundRouteTable}
${lib.concatMapStrings (listener: ''
${ip} ${family} rule add pref ${toString awgInboundRulePriority} iif ${lib.escapeShellArg listener.interface} fwmark ${toString awgInboundFwmark} table ${toString awgInboundRouteTable}
'') listeners}
'') ([ "-4" ] ++ lib.optional ipv6 "-6")}
'';
in
{
services.proxy-suite.internal = {
nftables = true;
packages = [
awgCfg.toolsPackage
awgCfg.userspacePackage
];
kernelModulePackages = lib.optionals (awgCfg.kernelModulePackage != null) [
awgCfg.kernelModulePackage
];
inherit sysctl;
firewall = {
# Past the host firewall: diverted packets reach input with their original destination,
# and "proxy" listeners already drop the rest in prerouting.
trustedInterfaces = map (listener: listener.interface) listeners;
# Diverted packets carry a mark whose table has no route back.
extraReversePathFilterRules = lib.concatMapStrings (listener: ''
iifname "${listener.interface}" accept
'') listeners;
};
services.${unitName} = {
description = "proxy-suite AmneziaWG inbound interfaces";
# After nftables, whose start flushes what came before it on flushRuleset hosts.
after = [
"network-online.target"
"nftables.service"
];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
# Put back after a firewall reload that flushed the ruleset, and restarted along with a
# restart of nftables, which a reload hook never hears of.
unitConfig = {
ReloadPropagatedFrom = [ "nftables.service" ];
PartOf = [ "nftables.service" ];
};
path = [
awgCfg.toolsPackage
awgCfg.userspacePackage
pkgs.coreutils
pkgs.iproute2
pkgs.kmod
pkgs.nftables
];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
RuntimeDirectory = unitName;
RuntimeDirectoryMode = "0700";
StateDirectory = "proxy-suite";
UMask = "0077";
ExecStart = start;
ExecReload = "${nft} -f ${nftReplaceFile}";
ExecStop = stop;
LockPersonality = true;
ProtectClock = true;
ProtectControlGroups = true;
ProtectHostname = true;
ProtectKernelLogs = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
};
};
# Client configs and links are rendered from the state this unit keeps.
services.proxy-suite-inbounds = {
after = [ "${unitName}.service" ];
wants = [ "${unitName}.service" ];
};
};
}
File diff suppressed because it is too large. Load diff
+63
View File
@@ -0,0 +1,63 @@
# Routing rules → generated configs → nftables rule files → service context: the wiring the
# host-neutral module does at evaluation time, in one place so the docs generator and the
# checks assemble it exactly as the running system does.
{
lib,
pkgs,
cfg,
packages,
zapret,
}:
let
rules = import ./rules.nix {
inherit
lib
pkgs
cfg
zapret
;
};
configs = import ./config.nix {
inherit
lib
pkgs
cfg
rules
;
};
nftr = import ./nftables.nix { inherit lib pkgs cfg; };
context = import ./service/context.nix {
inherit
lib
pkgs
packages
cfg
;
inherit (configs)
tproxyFile
tunFile
perAppTunFile
routeModeRulesFile
proxyInboundsFile
proxyInboundsSpecFile
;
inherit (nftr)
perAppTunChainFile
perAppTproxyRulesFile
perAppZapretRulesFile
nftablesRulesFile
killSwitchRulesFile
ip
nft
;
};
in
{
inherit
rules
configs
nftr
context
;
inherit (context) derived;
}
Loaded 100 of 579 files, more files were not shown because too many files have changed in this diff. Show more