From 9f7ad91f39eeb26da3913ada9010b47f5e5b9196 Mon Sep 17 00:00:00 2001 From: FUFSoB Date: Wed, 14 Oct 2026 21:41:49 +0500 Subject: [PATCH] feat: better inbounds user management --- README.md | 25 +- docs/options/inbounds.md | 366 +++++ docs/options/index.md | 42 + docs/usage/.snippets/server-2.nix | 6 +- docs/usage/.snippets/server-4.nix | 17 + docs/usage/control.md | 6 + docs/usage/server.md | 183 ++- .../config-templates/proxy-inbounds.nix | 25 +- modules/proxy-suite/config.nix | 24 + modules/proxy-suite/derived.nix | 17 + modules/proxy-suite/options/default.nix | 1 + .../proxy-suite/options/inbounds-manager.nix | 215 +++ modules/proxy-suite/options/inbounds.nix | 37 + .../proxy-suite/options/types/inbounds.nix | 80 + modules/proxy-suite/rules/proxy-inbounds.nix | 17 + modules/proxy-suite/service-assertions.nix | 51 + modules/proxy-suite/service/control.nix | 3 + .../service/proxy-inbounds-scripts.nix | 129 +- modules/proxy-suite/service/scripts.nix | 2 + modules/proxy-suite/service/units.nix | 30 +- nix/checks/amnezia-wg-inbound-runtime.nix | 4 +- nix/checks/backend-config-validation.nix | 5 + nix/checks/proxy-inbounds-runtime.nix | 13 +- nix/checks/proxy-inbounds.nix | 133 +- nix/checks/python-tests.nix | 29 + pkgs/patches/xray-user-level-mark.patch | 47 + pkgs/proxy-ctl.nix | 3 +- pkgs/proxy-ctl/proxy_ctl.py | 388 ++++- pkgs/proxy-ctl/proxy_gui.py | 15 +- pkgs/proxy-ctl/proxy_model.py | 23 + pkgs/proxy-ctl/test_proxy_ctl.py | 135 ++ pkgs/proxy-ctl/test_proxy_model.py | 30 + pkgs/xray.nix | 48 +- scripts/awg_inbound.py | 3 + scripts/build-inbound.py | 12 +- scripts/inbound_apply.py | 473 ++++++ scripts/inbound_manager.py | 1404 +++++++++++++++++ scripts/inbound_netfilter.py | 194 +++ scripts/inbound_policy.py | 538 +++++++ scripts/inbound_runtime.py | 67 +- scripts/inbound_subscription.py | 543 +++++++ scripts/proxy_inbound.py | 54 +- scripts/test-build-inbound.py | 41 + scripts/test-inbound-apply.py | 223 +++ scripts/test-inbound-manager.py | 628 ++++++++ scripts/test-inbound-policy.py | 244 +++ scripts/test-inbound-subscription.py | 272 ++++ 47 files changed, 6767 insertions(+), 78 deletions(-) create mode 100644 docs/usage/.snippets/server-4.nix create mode 100644 modules/proxy-suite/options/inbounds-manager.nix create mode 100644 pkgs/patches/xray-user-level-mark.patch create mode 100644 scripts/inbound_apply.py create mode 100644 scripts/inbound_manager.py create mode 100644 scripts/inbound_netfilter.py create mode 100644 scripts/inbound_policy.py create mode 100644 scripts/inbound_subscription.py create mode 100644 scripts/test-inbound-apply.py create mode 100644 scripts/test-inbound-manager.py create mode 100644 scripts/test-inbound-policy.py create mode 100644 scripts/test-inbound-subscription.py diff --git a/README.md b/README.md index 1640e33..cd9d4e7 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Bundles [sing-box](https://github.com/SagerNet/sing-box), [XRay](https://github. - 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 and traffic stats +- 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 @@ -279,5 +279,28 @@ Changes and secrets need root or the userControl group. inbounds rm remove a runtime listener inbounds show 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 [--json] one user: policy, traffic, online, subscription + inbounds users add [...] [policy flags] + add a runtime user with a policy + inbounds users set [--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 ... + back to the config's value, or none + inbounds users enable|disable switch a user on or off + inbounds users reset start their traffic over + inbounds users extend 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 --until