Skip to content

refactor: online map broken logic & fix race conditions#5732

Open
kastov wants to merge 2 commits intoXTLS:mainfrom
kastov:fix/online-map
Open

refactor: online map broken logic & fix race conditions#5732
kastov wants to merge 2 commits intoXTLS:mainfrom
kastov:fix/online-map

Conversation

@kastov
Copy link
Contributor

@kastov kastov commented Feb 26, 2026

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.

@kastov kastov changed the title refactor: online map broken logic && fix race conditions refactor: online map broken logic & fix race conditions Feb 26, 2026
@kastov
Copy link
Contributor Author

kastov commented Feb 26, 2026

also, there were issues in the current implementation: several data races in the internal map, last cleanup occurring outside the mutex, and a lock that was blocking all Manager operations.

@Fangliding
Copy link
Member

@hossinasaadi

Copy link
Contributor

@hossinasaadi hossinasaadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. This is cleaner and more effective, thanks for the improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants