feat: better inbounds user management

This commit is contained in:
FUFSoB committed 2026-10-14 21:41:49 +05:00
1 parent 2f8414455d
commit 9f7ad91f39
47 files changed
+6767 -78

No files matched your search

+366
View File
@@ -113,10 +113,41 @@ Part of the [proxy-suite options reference](./index.md).
- [users](#services-proxy-suite-inbounds-listeners-name-users)
- [via](#services-proxy-suite-inbounds-listeners-name-via)
- [xrayJson](#services-proxy-suite-inbounds-listeners-name-xrayjson)
- manager
- [enable](#services-proxy-suite-inbounds-manager-enable)
- api
- [group](#services-proxy-suite-inbounds-manager-api-group)
- [listen](#services-proxy-suite-inbounds-manager-api-listen)
- [tokensFile](#services-proxy-suite-inbounds-manager-api-tokensfile)
- [deleteExpiredAfter](#services-proxy-suite-inbounds-manager-deleteexpiredafter)
- [interval](#services-proxy-suite-inbounds-manager-interval)
- ipLimit
- [banTime](#services-proxy-suite-inbounds-manager-iplimit-bantime)
- notify
- [expiryDays](#services-proxy-suite-inbounds-manager-notify-expirydays)
- [trafficPercent](#services-proxy-suite-inbounds-manager-notify-trafficpercent)
- speedLimits
- [enable](#services-proxy-suite-inbounds-manager-speedlimits-enable)
- [slots](#services-proxy-suite-inbounds-manager-speedlimits-slots)
- subscriptions
- [enable](#services-proxy-suite-inbounds-manager-subscriptions-enable)
- [group](#services-proxy-suite-inbounds-manager-subscriptions-group)
- [listen](#services-proxy-suite-inbounds-manager-subscriptions-listen)
- [profileTitle](#services-proxy-suite-inbounds-manager-subscriptions-profiletitle)
- [supportUrl](#services-proxy-suite-inbounds-manager-subscriptions-supporturl)
- [updateInterval](#services-proxy-suite-inbounds-manager-subscriptions-updateinterval)
- [webPageUrl](#services-proxy-suite-inbounds-manager-subscriptions-webpageurl)
- [webhooks](#services-proxy-suite-inbounds-manager-webhooks)
- item
- [events](#services-proxy-suite-inbounds-manager-webhooks-events)
- [secretFile](#services-proxy-suite-inbounds-manager-webhooks-secretfile)
- [url](#services-proxy-suite-inbounds-manager-webhooks-url)
- [openFirewall](#services-proxy-suite-inbounds-openfirewall)
- routing
- [blockPorts](#services-proxy-suite-inbounds-routing-blockports)
- [blockPrivate](#services-proxy-suite-inbounds-routing-blockprivate)
- [blockRu](#services-proxy-suite-inbounds-routing-blockru)
- [blockTorrent](#services-proxy-suite-inbounds-routing-blocktorrent)
- proxy
- [domains](#services-proxy-suite-inbounds-routing-proxy-domains)
- [geoips](#services-proxy-suite-inbounds-routing-proxy-geoips)
@@ -146,12 +177,21 @@ Part of the [proxy-suite options reference](./index.md).
- [enable](#services-proxy-suite-inbounds-subscriptions-enable)
- [baseUrl](#services-proxy-suite-inbounds-subscriptions-baseurl)
- [group](#services-proxy-suite-inbounds-subscriptions-group)
- [keyFile](#services-proxy-suite-inbounds-subscriptions-keyfile)
- [users](#services-proxy-suite-inbounds-users)
- `<name>`
- [address](#services-proxy-suite-inbounds-users-name-address)
- [order](#services-proxy-suite-inbounds-users-name-order)
- [password](#services-proxy-suite-inbounds-users-name-password)
- [passwordFile](#services-proxy-suite-inbounds-users-name-passwordfile)
- policy
- [enabled](#services-proxy-suite-inbounds-users-name-policy-enabled)
- [expiresAfter](#services-proxy-suite-inbounds-users-name-policy-expiresafter)
- [expiresAt](#services-proxy-suite-inbounds-users-name-policy-expiresat)
- [ipLimit](#services-proxy-suite-inbounds-users-name-policy-iplimit)
- [speedLimit](#services-proxy-suite-inbounds-users-name-policy-speedlimit)
- [trafficLimit](#services-proxy-suite-inbounds-users-name-policy-trafficlimit)
- [trafficPeriod](#services-proxy-suite-inbounds-users-name-policy-trafficperiod)
- [presharedKeyFile](#services-proxy-suite-inbounds-users-name-presharedkeyfile)
- [privateKeyFile](#services-proxy-suite-inbounds-users-name-privatekeyfile)
- [publicKey](#services-proxy-suite-inbounds-users-name-publickey)
@@ -1132,6 +1172,219 @@ Raw XRay inbound JSON (ends up in the Nix store)\. Its tag is replaced; a missin
**Default:** `null`\
**Example:** `{ protocol = "dokodemo-door"; settings = { port = 8080; }; }`
<a id="services-proxy-suite-inbounds-manager-enable"></a>
## services\.proxy-suite\.inbounds\.manager\.enable
The inbound manager, a daemon that keeps the users’ policies (` inbounds.users.<name>.policy `,
and what it is told at runtime): who is switched off, whose time ran out, who used up
their traffic, how many addresses and how much speed each may have\. It applies them to
the running inbounds without a restart, answers an HTTP+JSON API for proxy-ctl and bots,
serves subscriptions with the traffic and expiry clients show, and calls webhooks\.
Users and listeners added through it need ` inbounds.runtime `\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-inbounds-manager-api-group"></a>
## services\.proxy-suite\.inbounds\.manager\.api\.group
Group that may use the API socket, /run/proxy-suite-inbounds-manager/api\.sock: all of
it, every user’s secrets included\. ` null `: ` userControl.group ` when it has the
“inbounds” scope, root only otherwise\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"vpn-admins"`
<a id="services-proxy-suite-inbounds-manager-api-listen"></a>
## services\.proxy-suite\.inbounds\.manager\.api\.listen
Address and port the API also listens on over TCP, for a bot on another host\. Plain
HTTP: put it on loopback behind a TLS proxy\. Needs ` tokensFile `; the firewall is not
opened for it\.
**Type:** null or string matching the pattern (\[\[]\[0-9A-Fa-f:\.]+\[]]|\[0-9\.]+|localhost):\[0-9]{1,5}\
**Default:** `null`\
**Example:** `"127.0.0.1:9180"`
<a id="services-proxy-suite-inbounds-manager-api-tokensfile"></a>
## services\.proxy-suite\.inbounds\.manager\.api\.tokensFile
File with the bearer tokens the TCP API takes, one per line, “name:token” or the token
alone\. Read at start\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/inbounds-manager-tokens"`
<a id="services-proxy-suite-inbounds-manager-deleteexpiredafter"></a>
## services\.proxy-suite\.inbounds\.manager\.deleteExpiredAfter
Delete runtime users this long after their ` expiresAt `, as ` proxy-ctl inbounds users rm `
would: their secrets, policy and subscription go\. A number with m, h, d or w\. Users
declared in the config stay\. ` null `: never\.
**Type:** null or string matching the pattern \[0-9]+\[mhdw]\
**Default:** `null`\
**Example:** `"30d"`
<a id="services-proxy-suite-inbounds-manager-interval"></a>
## services\.proxy-suite\.inbounds\.manager\.interval
Seconds between two rounds of counting traffic and checking the policies\.
**Type:** integer between 5 and 3600 (both inclusive)\
**Default:** `30`
<a id="services-proxy-suite-inbounds-manager-iplimit-bantime"></a>
## services\.proxy-suite\.inbounds\.manager\.ipLimit\.banTime
Seconds an address past a user’s ` ipLimit ` is banned for\.
**Type:** positive integer, meaning >0\
**Default:** `600`
<a id="services-proxy-suite-inbounds-manager-notify-expirydays"></a>
## services\.proxy-suite\.inbounds\.manager\.notify\.expiryDays
Days before the expiry that send a user\.expiring event\.
**Type:** list of (positive integer, meaning >0)\
**Default:** `[ 3 1 ]`
<a id="services-proxy-suite-inbounds-manager-notify-trafficpercent"></a>
## services\.proxy-suite\.inbounds\.manager\.notify\.trafficPercent
Shares of the traffic allowance used that send a user\.traffic event, once per period\.
**Type:** list of integer between 1 and 100 (both inclusive)\
**Default:** `[ 80 100 ]`
<a id="services-proxy-suite-inbounds-manager-speedlimits-enable"></a>
## services\.proxy-suite\.inbounds\.manager\.speedLimits\.enable
Speed limits (` policy.speedLimit `)\. XRay marks the sockets its exits dial for a limited
user with the user’s slot, which proxy-suite’s XRay build carries a patch for
(pkgs/patches/xray-user-level-mark\.patch), and nftables polices each mark’s
traffic both ways\. AmneziaWG peers are policed by their tunnel address\. Needs root\.
**Type:** boolean\
**Default:** `false`
<a id="services-proxy-suite-inbounds-manager-speedlimits-slots"></a>
## services\.proxy-suite\.inbounds\.manager\.speedLimits\.slots
How many users may have a speed limit at once: an XRay user level each\.
**Type:** integer between 1 and 65535 (both inclusive)\
**Default:** `512`
<a id="services-proxy-suite-inbounds-manager-subscriptions-enable"></a>
## services\.proxy-suite\.inbounds\.manager\.subscriptions\.enable
Serve each user’s subscription from /run/proxy-suite-inbounds-manager/sub\.sock, with the
headers clients read their traffic, allowance and expiry from (subscription-userinfo),
a title and an update interval\. The token is the last part of the path, the same
as the static files’ (` inbounds.subscriptions `), so their URLs keep working:
```nix
services.nginx.virtualHosts."vpn.example.com".locations."/sub/".proxyPass =
"http://unix:/run/proxy-suite-inbounds-manager/sub.sock:";
```
**Type:** boolean\
**Default:** `config.services.proxy-suite.inbounds.shareLinks`
<a id="services-proxy-suite-inbounds-manager-subscriptions-group"></a>
## services\.proxy-suite\.inbounds\.manager\.subscriptions\.group
Group of the web server that connects to the subscription socket\.
**Type:** string\
**Default:** `config.services.proxy-suite.inbounds.subscriptions.group`
<a id="services-proxy-suite-inbounds-manager-subscriptions-listen"></a>
## services\.proxy-suite\.inbounds\.manager\.subscriptions\.listen
Address and port the subscriptions are also served on over TCP, for a web server that cannot reach the socket\.
**Type:** null or string matching the pattern (\[\[]\[0-9A-Fa-f:\.]+\[]]|\[0-9\.]+|localhost):\[0-9]{1,5}\
**Default:** `null`\
**Example:** `"127.0.0.1:9181"`
<a id="services-proxy-suite-inbounds-manager-subscriptions-profiletitle"></a>
## services\.proxy-suite\.inbounds\.manager\.subscriptions\.profileTitle
The profile’s name in clients; {user} is the user’s\.
**Type:** string\
**Default:** `"{user}"`\
**Example:** `"My VPN ({user})"`
<a id="services-proxy-suite-inbounds-manager-subscriptions-supporturl"></a>
## services\.proxy-suite\.inbounds\.manager\.subscriptions\.supportUrl
Where clients send users for help (support-url), such as a Telegram link\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"https://t.me/my_vpn_support"`
<a id="services-proxy-suite-inbounds-manager-subscriptions-updateinterval"></a>
## services\.proxy-suite\.inbounds\.manager\.subscriptions\.updateInterval
Hours between clients’ updates of the subscription (profile-update-interval)\.
**Type:** null or (positive integer, meaning >0)\
**Default:** `12`
<a id="services-proxy-suite-inbounds-manager-subscriptions-webpageurl"></a>
## services\.proxy-suite\.inbounds\.manager\.subscriptions\.webPageUrl
The service’s page (profile-web-page-url)\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-inbounds-manager-webhooks"></a>
## services\.proxy-suite\.inbounds\.manager\.webhooks
Where to tell about users created, deleted, updated, switched off (with why) and back
on, their traffic reset, their term started on their first connection (user\.activated), thresholds of their allowance, coming expiries and addresses
banned past their ipLimit\. Retried a few times; a hook that stays down misses them\.
**Type:** list of (submodule)\
**Default:** `[ ]`\
**Example:**
```nix
[ { url = "http://127.0.0.1:8088/proxy-suite"; secretFile = "/run/secrets/hook"; } ]
```
<a id="services-proxy-suite-inbounds-manager-webhooks-events"></a>
## services\.proxy-suite\.inbounds\.manager\.webhooks\.\*\.events
Events to send\. Empty: all of them\.
**Type:** list of (one of “user\.created”, “user\.deleted”, “user\.updated”, “user\.enabled”, “user\.disabled”, “user\.reset”, “user\.activated”, “user\.traffic”, “user\.expiring”, “user\.ip-limit”)\
**Default:** `[ ]`
<a id="services-proxy-suite-inbounds-manager-webhooks-secretfile"></a>
## services\.proxy-suite\.inbounds\.manager\.webhooks\.\*\.secretFile
File with a secret: each body is signed, X-Proxy-Suite-Signature: sha256=\<HMAC-SHA256 hex>\.
**Type:** null or string\
**Default:** `null`
<a id="services-proxy-suite-inbounds-manager-webhooks-url"></a>
## services\.proxy-suite\.inbounds\.manager\.webhooks\.\*\.url
URL the events are POSTed to as JSON: {event, user, at, data}\.
**Type:** string
<a id="services-proxy-suite-inbounds-openfirewall"></a>
## services\.proxy-suite\.inbounds\.openFirewall
@@ -1140,6 +1393,17 @@ Open the firewall for every listener not on loopback\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-inbounds-routing-blockports"></a>
## services\.proxy-suite\.inbounds\.routing\.blockPorts
Destination ports clients may not reach, TCP and UDP: single ports and “from-to”
ranges\. Port 25 by default: mail sent straight to other servers, which spam goes
out by and hosters close\. Mail clients’ own ports (465, 587) stay open\.
**Type:** list of (16 bit unsigned integer; between 0 and 65535 (both inclusive) or string matching the pattern \[0-9]±\[0-9]+)\
**Default:** `[ 25 ]`\
**Example:** `[ 25 "6881-6889" ]`
<a id="services-proxy-suite-inbounds-routing-blockprivate"></a>
## services\.proxy-suite\.inbounds\.routing\.blockPrivate
@@ -1159,6 +1423,17 @@ Block Russian destinations (geosite “category-ru”, geoip “ru”)\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-inbounds-routing-blocktorrent"></a>
## services\.proxy-suite\.inbounds\.routing\.blockTorrent
Block BitTorrent: connections XRay’s sniffing recognizes by the peers’ handshake, and µTP\.
Not trackers or DHT, nor what a client encrypts (MSE): it makes downloading slow, not
impossible\. Hosters act on the copyright notices torrents bring\. Listeners given as raw
XRay JSON need sniffing on for it\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-inbounds-routing-proxy-domains"></a>
## services\.proxy-suite\.inbounds\.routing\.proxy\.domains
@@ -1427,6 +1702,25 @@ Group of the web server that serves the subscription files\.
**Default:** `"nginx"`\
**Example:** `"caddy"`
<a id="services-proxy-suite-inbounds-subscriptions-keyfile"></a>
## services\.proxy-suite\.inbounds\.subscriptions\.keyFile
The key the subscription tokens are an HMAC under\. Changing it changes every user’s
URL\.
- ` null `: generated on first start and kept in the state directory
(inbounds/subscription-key), where ` proxy-ctl inbounds export ` takes it from\.
- a file with a secret, such as ` openssl rand -hex 32 `: that one, read at start and
at each runtime change\.
- ` false `: no key\. A token is a hash of the user’s name and credentials alone, as
before there was a key: whoever learns one of a user’s links can work out their
subscription URL, and from it every other link of theirs\. For a server that gave
URLs out before\.
**Type:** null or value false (singular enum) or string\
**Default:** `null`\
**Example:** `"/run/secrets/inbounds-subscription-key"`
<a id="services-proxy-suite-inbounds-users"></a>
## services\.proxy-suite\.inbounds\.users
@@ -1489,6 +1783,78 @@ File with the password\.
**Default:** `null`\
**Example:** `"/run/secrets/proxy-inbound-password"`
<a id="services-proxy-suite-inbounds-users-name-policy-enabled"></a>
## services\.proxy-suite\.inbounds\.users\.\<name>\.policy\.enabled
Whether the user may connect\. Needs ` inbounds.manager `, as every ` policy ` field does\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-inbounds-users-name-policy-expiresafter"></a>
## services\.proxy-suite\.inbounds\.users\.\<name>\.policy\.expiresAfter
A term that starts with the user’s first connection, for access sold ahead: seconds,
or a number with m, h, d or w\. Until they connect the user is on hold, and when
they do ` expiresAt ` is set to that much later\. An ` expiresAt ` given wins\.
**Type:** null or positive integer, meaning >0, or string matching the pattern \[0-9]+\[mhdw]\
**Default:** `null`\
**Example:** `"30d"`
<a id="services-proxy-suite-inbounds-users-name-policy-expiresat"></a>
## services\.proxy-suite\.inbounds\.users\.\<name>\.policy\.expiresAt
When the user’s access ends: a date (the end of that day, local time), an ISO time,
or a Unix time\. Their connections are cut then, and their subscription still says
when it ended\.
**Type:** null or unsigned integer, meaning >=0, or string matching the pattern \[0-9]{4}-\[0-9]{2}-\[0-9]{2}(\[T ]\[0-9:\.]+(\[±]\[0-9:]+|Z)?)?\
**Default:** `null`\
**Example:** `"2026-12-31"`
<a id="services-proxy-suite-inbounds-users-name-policy-iplimit"></a>
## services\.proxy-suite\.inbounds\.users\.\<name>\.policy\.ipLimit
How many addresses may use the user at once\. The ones past it that came last are
banned for ` inbounds.manager.ipLimit.banTime ` from the user’s ports\. Not on
AmneziaWG, whose peer has one address anyway, nor behind a PROXY-protocol front\.
**Type:** null or (positive integer, meaning >0)\
**Default:** `null`\
**Example:** `2`
<a id="services-proxy-suite-inbounds-users-name-policy-speedlimit"></a>
## services\.proxy-suite\.inbounds\.users\.\<name>\.policy\.speedLimit
Speed limit in bits per second, decimal (k, M, G): one rate for both ways, or
“down/up”\. Needs ` inbounds.manager.speedLimits.enable `\. On socks and http listeners
it does not apply\.
**Type:** null or string matching the pattern \[0-9]+(\\\.\[0-9]+)?\[kKMG]?(/\[0-9]+(\\\.\[0-9]+)?\[kKMG]?)?\
**Default:** `null`\
**Example:** `"20M/5M"`
<a id="services-proxy-suite-inbounds-users-name-policy-trafficlimit"></a>
## services\.proxy-suite\.inbounds\.users\.\<name>\.policy\.trafficLimit
Traffic allowance, up and down together: bytes, or with K, M, G, T (binary units, as
clients show them)\. Past it the user is switched off until the period renews or the
traffic is reset\.
**Type:** null or unsigned integer, meaning >=0, or string matching the pattern \[0-9]+(\\\.\[0-9]+)?\[KMGTP]?(i?B)?\
**Default:** `null`\
**Example:** `"50G"`
<a id="services-proxy-suite-inbounds-users-name-policy-trafficperiod"></a>
## services\.proxy-suite\.inbounds\.users\.\<name>\.policy\.trafficPeriod
How often the allowance renews, at local midnight: daily, weekly, or monthly on the
day the count began\. ` null `: never; only a reset starts it over\.
**Type:** null or one of “daily”, “weekly”, “monthly”\
**Default:** `null`
<a id="services-proxy-suite-inbounds-users-name-presharedkeyfile"></a>
## services\.proxy-suite\.inbounds\.users\.\<name>\.presharedKeyFile
+42
View File
@@ -91,11 +91,52 @@ services.proxy-suite = {
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 = [ ];
@@ -125,6 +166,7 @@ services.proxy-suite = {
baseUrl = null;
enable = false;
group = "nginx";
keyFile = null;
};
users = { };
};
+4 -2
View File
@@ -4,6 +4,8 @@
enable = true;
baseUrl = "https://vpn.example.com/sub";
};
services.nginx.virtualHosts."vpn.example.com".locations."/sub/".alias =
"/run/proxy-suite-inbounds/subscriptions/";
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
};
}
+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
};
};
}
+6
View File
@@ -101,6 +101,12 @@ outbound, a subscription URL a subscription. An AmneziaWG `vpn://` link or a who
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
+181 -2
View File
@@ -101,12 +101,22 @@ 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/";
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,
@@ -144,10 +154,179 @@ up is refused, and anything that stops working later (a certificate removed from
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.