feat: runtime users and inbounds

This commit is contained in:
fufsob committed 2026-09-29 08:11:29 +00:00
1 parent a4752049ef
commit 9bbffe24b4
36 files changed
+2932 -83

No files matched your search

+98 -1
View File
@@ -115,6 +115,16 @@ Part of the [proxy-suite options reference](./index.md).
- [ipv6](#services-proxy-suite-inbounds-routing-serversource-ipv6)
- [via](#services-proxy-suite-inbounds-routing-via)
- [zapretDirect](#services-proxy-suite-inbounds-routing-zapretdirect)
- runtime
- [enable](#services-proxy-suite-inbounds-runtime-enable)
- [fallbackDests](#services-proxy-suite-inbounds-runtime-fallbackdests)
- [ports](#services-proxy-suite-inbounds-runtime-ports)
- [tlsCertificates](#services-proxy-suite-inbounds-runtime-tlscertificates)
- `<name>`
- [certificateFile](#services-proxy-suite-inbounds-runtime-tlscertificates-name-certificatefile)
- [keyFile](#services-proxy-suite-inbounds-runtime-tlscertificates-name-keyfile)
- [serverName](#services-proxy-suite-inbounds-runtime-tlscertificates-name-servername)
- [vias](#services-proxy-suite-inbounds-runtime-vias)
- [serverAddress](#services-proxy-suite-inbounds-serveraddress)
- [serverAliases](#services-proxy-suite-inbounds-serveraliases)
- [serverPorts](#services-proxy-suite-inbounds-serverports)
@@ -1086,6 +1096,93 @@ Send zapret hostlist sites direct, so this host’s zapret unblocks them\. Only
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-inbounds-runtime-enable"></a>
## services\.proxy-suite\.inbounds\.runtime\.enable
Users and listeners added at runtime with ` proxy-ctl inbounds users add ` and
` inbounds add `, kept in ` inbounds.d ` in the state directory\. Runtime users can be
bound to any listener; declared users to runtime listeners only\. A change restarts
the inbounds, which drops every connection once\. Anything a runtime listener could
reach beyond its port is declared here: its ports, certificates, exits and
fallbacks\. Members of ` userControl.group ` need the “inbounds” scope\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-inbounds-runtime-fallbackdests"></a>
## services\.proxy-suite\.inbounds\.runtime\.fallbackDests
` dest ` values a runtime listener’s fallbacks may use, such as a decoy site\. A
fallback to a ` listener ` must name another runtime listener\.
**Type:** list of (16 bit unsigned integer; between 0 and 65535 (both inclusive) or string)\
**Default:** `[ ]`\
**Example:** `[ "127.0.0.1:8080" ]`
<a id="services-proxy-suite-inbounds-runtime-ports"></a>
## services\.proxy-suite\.inbounds\.runtime\.ports
Ports runtime listeners may use, on any address: single ports and “from-to” ranges\.
Opened in the firewall (TCP and UDP) with ` openFirewall `, and reachable through the
tunnel like the listeners’ own\. Keep them clear of the declared listeners and of
other services here\.
**Type:** list of (16 bit unsigned integer; between 0 and 65535 (both inclusive) or string matching the pattern \[0-9]±\[0-9]+)\
**Default:** `[ ]`\
**Example:** `[ 8443 "20000-20099" ]`
<a id="services-proxy-suite-inbounds-runtime-tlscertificates"></a>
## services\.proxy-suite\.inbounds\.runtime\.tlsCertificates
Certificates a runtime listener with TLS (trojan, hysteria2, ` tls.enable `) may use,
by name: it names one in ` tls.certificate ` (` --tls <name> `), never a file\.
**Type:** attribute set of (submodule)\
**Default:** `{ }`\
**Example:**
```nix
{
main = {
certificateFile = "/var/lib/acme/vpn.example.com/fullchain.pem";
keyFile = "/var/lib/acme/vpn.example.com/key.pem";
};
}
```
<a id="services-proxy-suite-inbounds-runtime-tlscertificates-name-certificatefile"></a>
## services\.proxy-suite\.inbounds\.runtime\.tlsCertificates\.\<name>\.certificateFile
File with the PEM certificate chain\.
**Type:** string
<a id="services-proxy-suite-inbounds-runtime-tlscertificates-name-keyfile"></a>
## services\.proxy-suite\.inbounds\.runtime\.tlsCertificates\.\<name>\.keyFile
File with the PEM private key\.
**Type:** string
<a id="services-proxy-suite-inbounds-runtime-tlscertificates-name-servername"></a>
## services\.proxy-suite\.inbounds\.runtime\.tlsCertificates\.\<name>\.serverName
SNI in share links\. ` null `: ` serverAddress `\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-inbounds-runtime-vias"></a>
## services\.proxy-suite\.inbounds\.runtime\.vias
Exits a runtime listener may pick with ` via `, besides ` routing.via ` and “block”:
“proxy”, “direct” or a ` proxy.outbounds ` tag, as in ` routing.via `\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "direct" ]`
<a id="services-proxy-suite-inbounds-serveraddress"></a>
## services\.proxy-suite\.inbounds\.serverAddress
@@ -1204,7 +1301,7 @@ kept for as long as the user exists\.
The user’s number, for good: their ` inbounds.routing.serverSource ` addresses are
that many past the start of each range (5: 10\.78\.0\.5 in 10\.78\.0\.0/24)\. Users
without one follow the highest number given, by name, and move when users are
added before them\. Unique\.
added before them\. Unique\. Runtime users (` inbounds.runtime `) go around these numbers\.
**Type:** null or (positive integer, meaning >0)\
**Default:** `null`\
+7
View File
@@ -89,6 +89,13 @@ services.proxy-suite = {
via = "proxy";
zapretDirect = true;
};
runtime = {
enable = false;
fallbackDests = [ ];
ports = [ ];
tlsCertificates = { };
vias = [ ];
};
serverAddress = null;
serverAliases = [ ];
serverPorts = [ ];
+3 -1
View File
@@ -40,11 +40,13 @@ What the group may do\. Empty allows everything\.
- “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”, “whitelistBypass”, “amneziaWg”)\
**Type:** list of (one of “services”, “perApp”, “routing”, “outbounds”, “secrets”, “autoProxy”, “zapret”, “stats”, “inbounds”, “whitelistBypass”, “amneziaWg”)\
**Default:** `[ ]`\
**Example:** `[ "services" "routing" ]`
+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";
};
};
}
+2
View File
@@ -41,6 +41,7 @@ Members of the group get the listed scopes. An empty `scopes` list grants all of
| `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
@@ -52,6 +53,7 @@ admin password, or you run `proxy-ctl` with sudo.
|---|---|
| `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 mode` | until the next reboot |
| `… on` / `… off` | until the next reboot; boot state comes from the config |
+39
View File
@@ -88,6 +88,7 @@ hysteria2, vmess, …) and transports (ws, grpc, xhttp) are set per listener; se
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
```
@@ -106,6 +107,43 @@ services.nginx.virtualHosts."vpn.example.com".locations."/sub/".alias =
Then `proxy-ctl inbounds sub phone --qr` prints that user's subscription.
## 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.
## Good to know
- Clients cannot reach this host's LAN or Russian sites by default
@@ -120,5 +158,6 @@ Then `proxy-ctl inbounds sub phone --qr` prints that user's subscription.
- [`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)