Repository navigation
Manage VLESS client UUIDs from the dashboard, applied to xray live - #10
Merged
Merged
Conversation
Until now the REALITY client list was a comma-joined config value, so revoking a UUID meant editing configuration and restarting the service. A management screen that only takes effect on restart is a trap, so this makes the change real. The list lives in a vless_clients table, one row per client. Precedence is unchanged in spirit: REALITY_CLIENT_IDS still pins the list from configuration and now says so, because accepting edits that quietly do nothing is worse than refusing them. An id left behind by the old comma-joined value is adopted into the table on first run rather than dropped -- otherwise the first dashboard change would revoke a client that is still in the field. Making it live meant teaching the xray supervisor to re-point itself. The reload carries a config that has already passed `xray run --test`, so an invalid change is refused and the running front door keeps serving; the supervisor is the only thing that stops and starts the child, and it answers once the new child is actually accepting connections. Measured live: an add applies in 0.08s. Two refusals worth having. Removing the last client is rejected, because xray with no clients is a front door that rejects everyone and an operator should have to mean it. And a refused change restores the row rather than dropping it, so the database never claims something xray does not do. Verified live against xray on a real port: a UUID added through the API served traffic immediately, the same client failed the moment it was revoked, the untouched client kept working, and xray's own log named the refusal (proxy/vless/encoding: rejected). Covered end to end in tests too, including the case the race detector caught on the way: s.cfg is written under configMu while being read here.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 19 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Until now the REALITY client list was one comma-joined config value. Revoking a UUID meant editing configuration and restarting the service — so there was no way to remove a lost phone without taking the front door down for everyone. Management that only takes effect on restart is a trap, so this makes the change real: an added UUID serves traffic in 0.08s, and a revoked one stops working immediately.
What changed
Storage. A
vless_clientstable, one row per client (uuid,label,enabled). Precedence keeps its existing shape:REALITY_CLIENT_IDS— pins the list from configurationPoint 3 is the upgrade safety net: without it, the first dashboard change would silently revoke a client that is still in the field, because the table would then shadow the config. My own test asserted the opposite at first — adopting means "keeps working", not "goes away".
Live application. The supervisor loop now owns reloads. The new config is rendered and put through
xray run --testbefore anything is touched, so an invalid change is refused and the running front door keeps serving. The supervisor is the only code that stops and starts the child, and it answers the request once the new child is actually accepting connections — not when it was asked to.API (
/api/vless-clients, same shape as/api/users): list, create, relabel, enable/disable, delete. Dashboard: a "REALITY Clients" panel with add/copy/disable/delete, reusing the existing badge and button styles. Rows are built withtextContent, so a label containing markup cannot inject anything into the admin page.Refusals, on purpose
REALITY_CLIENT_IDSset → 409 naming the variable, rather than accepting edits that quietly do nothing.Verification
go vetandgofmtclean; full suite green with and without Xray;-raceclean over the REALITY and VLESS tests.200, real source IP) → revoked it → the same client failed at once → the untouched client kept working → xray's own log named the refusal (proxy/vless/encoding: rejected).vless_test.goasserts the same three things deterministically, with two independent client xray processes: revoked fails, non-revoked keeps working, no restart anywhere.GET /api/vless-clientsserialises[]rather thannull, so the panel can loop over it.Not in this PR
VLESS clients are not linked to SOCKS5 users, so tier limits apply to SOCKS5 sessions only — REALITY sessions arrive through the socks outbound with the service's own credentials. Linking them would mean per-user routing in the xray config and is its own piece of work. Backup needs no change: the table is inside the SQLite file that
VACUUM INTOalready snapshots.