Skip to content

API: Fix Online Map#5732

Merged
RPRX merged 2 commits intoXTLS:mainfrom
kastov:fix/online-map
Mar 7, 2026
Merged

API: Fix Online Map#5732
RPRX merged 2 commits intoXTLS:mainfrom
kastov:fix/online-map

Conversation

@kastov
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

@hossinasaadi

Copy link
Copy Markdown
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.

@RPRX RPRX changed the title refactor: online map broken logic & fix race conditions API: Fix Online Map Mar 7, 2026
@RPRX RPRX merged commit eec2802 into XTLS:main Mar 7, 2026
39 checks passed
drovosek229 pushed a commit to drovosek229/Xray-core that referenced this pull request Mar 16, 2026
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.

4 participants