refactor: users single-point

This commit is contained in:
fufsob committed 2026-09-29 05:39:33 +00:00
1 parent c8b9b3de46
commit a4752049ef
35 files changed
+1009 -381

No files matched your search

+163 -99
View File
@@ -98,16 +98,6 @@ Part of the [proxy-suite options reference](./index.md).
- [type](#services-proxy-suite-inbounds-listeners-name-transport-type)
- [type](#services-proxy-suite-inbounds-listeners-name-type)
- [users](#services-proxy-suite-inbounds-listeners-name-users)
- item
- [address](#services-proxy-suite-inbounds-listeners-name-users-address)
- [name](#services-proxy-suite-inbounds-listeners-name-users-name)
- [password](#services-proxy-suite-inbounds-listeners-name-users-password)
- [passwordFile](#services-proxy-suite-inbounds-listeners-name-users-passwordfile)
- [presharedKeyFile](#services-proxy-suite-inbounds-listeners-name-users-presharedkeyfile)
- [privateKeyFile](#services-proxy-suite-inbounds-listeners-name-users-privatekeyfile)
- [publicKey](#services-proxy-suite-inbounds-listeners-name-users-publickey)
- [uuid](#services-proxy-suite-inbounds-listeners-name-users-uuid)
- [uuidFile](#services-proxy-suite-inbounds-listeners-name-users-uuidfile)
- [via](#services-proxy-suite-inbounds-listeners-name-via)
- [xrayJson](#services-proxy-suite-inbounds-listeners-name-xrayjson)
- [openFirewall](#services-proxy-suite-inbounds-openfirewall)
@@ -119,6 +109,10 @@ Part of the [proxy-suite options reference](./index.md).
- [geoips](#services-proxy-suite-inbounds-routing-proxy-geoips)
- [geosites](#services-proxy-suite-inbounds-routing-proxy-geosites)
- [ips](#services-proxy-suite-inbounds-routing-proxy-ips)
- serverSource
- [interface](#services-proxy-suite-inbounds-routing-serversource-interface)
- [ipv4](#services-proxy-suite-inbounds-routing-serversource-ipv4)
- [ipv6](#services-proxy-suite-inbounds-routing-serversource-ipv6)
- [via](#services-proxy-suite-inbounds-routing-via)
- [zapretDirect](#services-proxy-suite-inbounds-routing-zapretdirect)
- [serverAddress](#services-proxy-suite-inbounds-serveraddress)
@@ -129,6 +123,17 @@ 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)
- [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)
- [presharedKeyFile](#services-proxy-suite-inbounds-users-name-presharedkeyfile)
- [privateKeyFile](#services-proxy-suite-inbounds-users-name-privatekeyfile)
- [publicKey](#services-proxy-suite-inbounds-users-name-publickey)
- [uuid](#services-proxy-suite-inbounds-users-name-uuid)
- [uuidFile](#services-proxy-suite-inbounds-users-name-uuidfile)
<a id="services-proxy-suite-inbounds-enable"></a>
## services\.proxy-suite\.inbounds\.enable
@@ -161,7 +166,7 @@ Server listeners, by tag\.
vless-reality = {
type = "vless";
port = 443;
users = [ { uuidFile = "/run/secrets/proxy-inbound-uuid"; } ];
users = [ "phone" ];
flow = "xtls-rprx-vision";
reality = {
enable = true;
@@ -175,7 +180,7 @@ Server listeners, by tag\.
home = {
type = "amneziawg";
port = 51820;
users = [ { name = "phone"; } { name = "laptop"; } ];
users = [ "phone" "laptop" ];
amneziaWg.mode = "lan";
};
}
@@ -941,94 +946,11 @@ Protocol\. Set exactly one of ` type `, ` xrayJson ` or ` jsonFile `\.
<a id="services-proxy-suite-inbounds-listeners-name-users"></a>
## services\.proxy-suite\.inbounds\.listeners\.\<name>\.users
Accepted users\.
Accepted users, by their names in ` inbounds.users `\.
**Type:** list of (submodule)\
**Type:** list of string matching the pattern \[^\[:space:]]+\
**Default:** `[ ]`\
**Example:** `[ { uuidFile = "/run/secrets/proxy-inbound-uuid"; } ]`
<a id="services-proxy-suite-inbounds-listeners-name-users-address"></a>
## services\.proxy-suite\.inbounds\.listeners\.\<name>\.users\.\*\.address
AmneziaWG tunnel IPv4 address, inside ` amneziaWg.subnet `\. ` null `: the lowest free one,
kept for as long as the user exists\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"10.66.0.10"`
<a id="services-proxy-suite-inbounds-listeners-name-users-name"></a>
## services\.proxy-suite\.inbounds\.listeners\.\<name>\.users\.\*\.name
User name, shown in share links, subscriptions and stats\.
**Type:** string\
**Default:** `""`\
**Example:** `"phone"`
<a id="services-proxy-suite-inbounds-listeners-name-users-password"></a>
## services\.proxy-suite\.inbounds\.listeners\.\<name>\.users\.\*\.password
Password (trojan, shadowsocks, socks, http)\. Ends up in the Nix store; prefer ` passwordFile `\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"hunter2"`
<a id="services-proxy-suite-inbounds-listeners-name-users-passwordfile"></a>
## services\.proxy-suite\.inbounds\.listeners\.\<name>\.users\.\*\.passwordFile
File with the password\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/proxy-inbound-password"`
<a id="services-proxy-suite-inbounds-listeners-name-users-presharedkeyfile"></a>
## services\.proxy-suite\.inbounds\.listeners\.\<name>\.users\.\*\.presharedKeyFile
File with the AmneziaWG preshared key, instead of a generated one\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/awg-phone-psk"`
<a id="services-proxy-suite-inbounds-listeners-name-users-privatekeyfile"></a>
## services\.proxy-suite\.inbounds\.listeners\.\<name>\.users\.\*\.privateKeyFile
File with the AmneziaWG client private key, instead of a generated one\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/awg-phone-key"`
<a id="services-proxy-suite-inbounds-listeners-name-users-publickey"></a>
## services\.proxy-suite\.inbounds\.listeners\.\<name>\.users\.\*\.publicKey
AmneziaWG public key, for a client that keeps its own private key (no config or link is
generated for it)\. ` null `: generate a key pair\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"jNXH..."`
<a id="services-proxy-suite-inbounds-listeners-name-users-uuid"></a>
## services\.proxy-suite\.inbounds\.listeners\.\<name>\.users\.\*\.uuid
UUID (vless, vmess)\. Ends up in the Nix store; prefer ` uuidFile `\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"b831381d-6324-4d53-ad4f-8cda48b30811"`
<a id="services-proxy-suite-inbounds-listeners-name-users-uuidfile"></a>
## services\.proxy-suite\.inbounds\.listeners\.\<name>\.users\.\*\.uuidFile
File with the UUID\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/proxy-inbound-uuid"`
**Example:** `[ "phone" "laptop" ]`
<a id="services-proxy-suite-inbounds-listeners-name-via"></a>
## services\.proxy-suite\.inbounds\.listeners\.\<name>\.via
@@ -1108,6 +1030,40 @@ IP ranges (CIDR) that clients always reach through the local proxy, whatever the
**Default:** `[ ]`\
**Example:** `[ "1.1.1.0/24" ]`
<a id="services-proxy-suite-inbounds-routing-serversource-interface"></a>
## services\.proxy-suite\.inbounds\.routing\.serverSource\.interface
Dummy interface the ` serverSource ` addresses are put on\.
**Type:** string matching the pattern \[a-zA-Z0-9_-]{1,15}\
**Default:** `"ps-self"`
<a id="services-proxy-suite-inbounds-routing-serversource-ipv4"></a>
## services\.proxy-suite\.inbounds\.routing\.serverSource\.ipv4
Range each inbound user gets an address from, for the connections they make to this
host itself (` serverAddress `, ` serverAliases `, ` serverPorts `)\. Otherwise those come
from this host’s own address, and its services (mail, the web server, their rate
limits and bans) see every user as one\. They see neither the users’ real addresses\.
The addresses sit on a dummy interface and reach nothing but this host\. Pick a range
nothing here routes or trusts\. Users are numbered by their ` order `, then name, from
the range’s second address: set ` order ` to keep each user’s address as users come
and go\.
**Type:** null or string matching the pattern (\[0-9]{1,3}\\\.){3}\[0-9]{1,3}/\[0-9]{1,2}\
**Default:** `null`\
**Example:** `"10.78.0.0/24"`
<a id="services-proxy-suite-inbounds-routing-serversource-ipv6"></a>
## services\.proxy-suite\.inbounds\.routing\.serverSource\.ipv6
The same for IPv6: a prefix written with “::”, such as a ULA /64\. Needed as well when
` serverAliases ` lists an IPv6 address, which is otherwise dialed from this host’s own\.
**Type:** null or string matching the pattern \[0-9a-fA-F:]\*::/\[0-9]{1,3}\
**Default:** `null`\
**Example:** `"fd78:78:78::/64"`
<a id="services-proxy-suite-inbounds-routing-via"></a>
## services\.proxy-suite\.inbounds\.routing\.via
@@ -1125,7 +1081,7 @@ Where client traffic exits by default\. Each listener can override it\.
<a id="services-proxy-suite-inbounds-routing-zapretdirect"></a>
## services\.proxy-suite\.inbounds\.routing\.zapretDirect
Send zapret hostlist sites direct, so this host’s zapret unblocks them\. Only for the default ` via `\.
Send zapret hostlist sites direct, so this host’s zapret unblocks them\. Only for the default ` via `\. With a direct listener or the XRay backend, only by IP: XRay matches names by what a client puts in its handshake, whatever address it connects to\.
**Type:** boolean\
**Default:** `true`
@@ -1209,3 +1165,111 @@ Group of the web server that serves the subscription files\.
**Type:** string\
**Default:** `"nginx"`\
**Example:** `"caddy"`
<a id="services-proxy-suite-inbounds-users"></a>
## services\.proxy-suite\.inbounds\.users
Inbound users, by name, which listeners accept by naming them in their ` users `\. Each
listener takes the secret its protocol wants: ` uuid `/` uuidFile ` for vless and vmess,
` password `/` passwordFile ` for the others, the keys for AmneziaWG\.
**Type:** attribute set of (submodule)\
**Default:** `{ }`\
**Example:**
```nix
{
phone = {
order = 1;
uuidFile = "/run/secrets/proxy-inbound-uuid";
};
laptop.order = 2;
}
```
<a id="services-proxy-suite-inbounds-users-name-address"></a>
## services\.proxy-suite\.inbounds\.users\.\<name>\.address
AmneziaWG tunnel IPv4 address, inside ` amneziaWg.subnet `\. ` null `: the lowest free one,
kept for as long as the user exists\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"10.66.0.10"`
<a id="services-proxy-suite-inbounds-users-name-order"></a>
## services\.proxy-suite\.inbounds\.users\.\<name>\.order
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\.
**Type:** null or (positive integer, meaning >0)\
**Default:** `null`\
**Example:** `1`
<a id="services-proxy-suite-inbounds-users-name-password"></a>
## services\.proxy-suite\.inbounds\.users\.\<name>\.password
Password (trojan, shadowsocks, socks, http)\. Ends up in the Nix store; prefer ` passwordFile `\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"hunter2"`
<a id="services-proxy-suite-inbounds-users-name-passwordfile"></a>
## services\.proxy-suite\.inbounds\.users\.\<name>\.passwordFile
File with the password\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/proxy-inbound-password"`
<a id="services-proxy-suite-inbounds-users-name-presharedkeyfile"></a>
## services\.proxy-suite\.inbounds\.users\.\<name>\.presharedKeyFile
File with the AmneziaWG preshared key, instead of a generated one\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/awg-phone-psk"`
<a id="services-proxy-suite-inbounds-users-name-privatekeyfile"></a>
## services\.proxy-suite\.inbounds\.users\.\<name>\.privateKeyFile
File with the AmneziaWG client private key, instead of a generated one\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/awg-phone-key"`
<a id="services-proxy-suite-inbounds-users-name-publickey"></a>
## services\.proxy-suite\.inbounds\.users\.\<name>\.publicKey
AmneziaWG public key, for a client that keeps its own private key (no config or link is
generated for it)\. ` null `: generate a key pair\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"jNXH..."`
<a id="services-proxy-suite-inbounds-users-name-uuid"></a>
## services\.proxy-suite\.inbounds\.users\.\<name>\.uuid
UUID (vless, vmess)\. Ends up in the Nix store; prefer ` uuidFile `\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"b831381d-6324-4d53-ad4f-8cda48b30811"`
<a id="services-proxy-suite-inbounds-users-name-uuidfile"></a>
## services\.proxy-suite\.inbounds\.users\.\<name>\.uuidFile
File with the UUID\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/proxy-inbound-uuid"`
+6
View File
@@ -81,6 +81,11 @@ services.proxy-suite = {
geosites = [ ];
ips = [ ];
};
serverSource = {
interface = "ps-self";
ipv4 = null;
ipv6 = null;
};
via = "proxy";
zapretDirect = true;
};
@@ -93,6 +98,7 @@ services.proxy-suite = {
enable = false;
group = "nginx";
};
users = { };
};
killSwitch = {
enable = false;
+1 -1
View File
@@ -34,7 +34,7 @@ host serves one joiner on a censored one\.
<a id="services-proxy-suite-whitelistbypass-package"></a>
## services\.proxy-suite\.whitelistBypass\.package
whitelist-bypass 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 `)
@@ -15,15 +15,16 @@ in
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;
# Fixed addresses, so firewall rules and DNS can name each device.
# Keys are generated on first start.
users = [
{ name = "laptop"; address = "10.77.77.2"; }
{ name = "phone"; address = "10.77.77.3"; }
];
users = [ "laptop" "phone" ];
amneziaWg = {
# Devices also reach this host, its LAN and each other, directly.
mode = "lan";
@@ -3,7 +3,7 @@ let
domain = "vpn.example.com";
certDir = config.security.acme.certs.${domain}.directory;
users = map (name: { inherit name; uuidFile = "/run/secrets/proxy-uuid-${name}"; }) [
users = [
"alice"
"bob"
"carol"
@@ -54,6 +54,7 @@ in
};
inbounds = {
users = lib.genAttrs users (name: { uuidFile = "/run/secrets/proxy-uuid-${name}"; });
enable = true;
serverAddress = domain;
routing.via = "proxy";
+7 -5
View File
@@ -6,15 +6,17 @@
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 = [
{ name = "phone"; uuidFile = "/run/secrets/uuid-phone"; }
{ name = "laptop"; uuidFile = "/run/secrets/uuid-laptop"; }
];
users = [ "phone" "laptop" ];
reality = {
enable = true;
serverNames = [ "www.microsoft.com" ];
@@ -27,7 +29,7 @@
awg = {
type = "amneziawg";
port = 51820;
users = [ { name = "phone"; } ];
users = [ "phone" ];
};
};
};
+7 -6
View File
@@ -26,15 +26,16 @@ in
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;
# Fixed addresses, so firewall rules and DNS can name each device.
# Keys are generated on first start.
users = [
{ name = "laptop"; address = "10.77.77.2"; }
{ name = "phone"; address = "10.77.77.3"; }
];
users = [ "laptop" "phone" ];
amneziaWg = {
# Devices also reach this host, its LAN and each other, directly.
mode = "lan";
+2 -1
View File
@@ -23,7 +23,7 @@ let
domain = "vpn.example.com";
certDir = config.security.acme.certs.${domain}.directory;
users = map (name: { inherit name; uuidFile = "/run/secrets/proxy-uuid-${name}"; }) [
users = [
"alice"
"bob"
"carol"
@@ -74,6 +74,7 @@ in
};
inbounds = {
users = lib.genAttrs users (name: { uuidFile = "/run/secrets/proxy-uuid-${name}"; });
enable = true;
serverAddress = domain;
routing.via = "proxy";
+7 -5
View File
@@ -40,15 +40,17 @@ services.proxy-suite = {
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 = [
{ name = "phone"; uuidFile = "/run/secrets/uuid-phone"; }
{ name = "laptop"; uuidFile = "/run/secrets/uuid-laptop"; }
];
users = [ "phone" "laptop" ];
reality = {
enable = true;
serverNames = [ "www.microsoft.com" ];
@@ -61,7 +63,7 @@ services.proxy-suite = {
awg = {
type = "amneziawg";
port = 51820;
users = [ { name = "phone"; } ];
users = [ "phone" ];
};
};
};