Repository navigation
xray: let the last entry for a user win within one user batch - #134
Open
Free-Guy-IR wants to merge 2 commits into
Open
Free-Guy-IR wants to merge 2 commits into
Free-Guy-IR wants to merge 2 commits into
Conversation
UpdateUsers compared every entry with the state before the batch and applied all removals before any add, so when one batch carried the same email twice the outcome did not follow the last entry. The full sync that rebuilds the config also kept a user an earlier entry added even when a later entry dropped them. Both now keep only the last entry for each email.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
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.
Fixes #129
Found by code review; never seen in production. A robustness fix: the upstream panel and bridge do not send a batch with a repeated email today (node_bridge_py
c5632b65a10akeeps one queued entry per email,storage.py:159-166). Headd41c6fd0dd44, based on main v0.5.7739eab94a934;git merge-tree --write-treeonto dev9ccd2638c7feis clean. No code change since the PR was opened.What
UpdateUsers(viabuildInboundUpdates) andConfig.syncUsersnow keep only the last entry per email, at the position of its first entry, before they build the per-inbound updates or rebuild an inbound's clients.Config.updateUsersgets the same input, although no RPC reaches it today (its only caller isUpdateUsersAndRestart).Real node, real Xray
Node built from dev
9ccd2638and from this PR merged onto dev, REST, real Xray 26.3.27, macOS arm64, onetrojaninbound, core read withxray api inbounduser. OnePUT /users/sync/chunkedper step:1.alice[on trojan, no inbounds](added then removed)[no inbounds, on trojan](removed then kept)Tests
backend/xray/user_sync_batch_test.go:TestUpdateUsersLetsTheLastEntryForAUserWinandTestUpdateUsersAndSyncUsersLetTheLastEntryForAUserWinInTheConfig.backend/xray/user_sync_interleave_test.go:TestConcurrentSyncUserAndUpdateUsersKeepCoreAndConfigInAgreement. This is an ordering test, not a race test:syncMuserializesSyncUserandUpdateUsers, and the test checks that core and config agree whichever runs first, and that a lone batch ends as its last entry says.go1.27.3,
-race -count=3, macOS arm64. On dev9ccd2638with the two test files (production code unchanged), all three tests fail in all three runs:The round at which the interleave test fails varies between runs (0, 1 and 2 in the run above). On this PR merged onto dev all three pass in all three runs (
ok backend/xray 6.973s).Behaviour change
An email listed more than once is applied once, at the position of its first entry, with the content of its last entry. When two different users in one batch share a credential, this can change the order in which they are added to the core. Batches without a repeated email are applied as before (read from the code).