refactor: online map broken logic & fix race conditions#5732
Open
refactor: online map broken logic & fix race conditions#5732
Conversation
Contributor
Author
|
|
Member
hossinasaadi
approved these changes
Feb 26, 2026
Contributor
hossinasaadi
left a comment
There was a problem hiding this comment.
Looks good to me. This is cleaner and more effective, thanks for the improvement.
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.
After this functionality was introduced last year, there were some doubts about its usefulness. Unfortunately, after it began to be actively used, those concerns were confirmed. In its current state (without these fixes), Online Map is practically unusable and largely pointless.
The logic based on the last 20 seconds simply does not work. Due to the specific nature of how Xray operates, many connections live much longer than 20 seconds, and even if this time could be adjusted, it would not fix the underlying problem.
A fairly common situation was the following: no IP addresses are shown, yet traffic is actively flowing (being recorded in statistics), which indicates that a connection is active. However, it is impossible to determine which IP address it originates from — even though that is precisely what the Online Map feature is supposed to provide.
This PR fixes the incorrect Online Map logic: an IP address is now retained for as long as the connection remains active. Once the connection is closed, the IP address is removed. This is the correct behavior.