Replies: 1 comment
|
TL;DR: this is (very likely) not a bug in your config – Xray deliberately
https://github.com/XTLS/Xray-core/blob/v26.6.27/app/stats/online_map.go#L36-L39 func (om *OnlineMap) AddIP(ip string) {
if ip == localhostIPv4 || ip == localhostIPv6 { // "127.0.0.1", "[::1]"
return
}(same check in the original implementation: Traffic counters are not filtered this way – hence the confusing Verified empirically on v26.6.27 (VLESS+REALITY,
So protocol-side tracking works fine (both dispatcher paths call Workarounds if Xray sits behind a same-host proxy:
Probably explains the same symptom in #4496 and #3983. Note #5868 @hossinasaadi @kastov It would be great to at least document the loopback exclusion next to |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Xray version: 25.12.8 (from xray --version)
Environment: Docker container (teddysun/xray:latest) with host networking
API port: 10085 (dokodemo-door inbound)
Here is config:
{
"log": {
"loglevel": "info",
"access": "/var/log/xray/access.log",
"error": "/var/log/xray/error.log"
},
"api": {
"tag": "api",
"services": [
"HandlerService",
"StatsService"
]
},
"stats": {},
"policy": {
"levels": {
"0": {
"statsUserUplink": true,
"statsUserDownlink": true,
"statsUserOnline": true
}
},
"system": {
"statsInboundUplink": true,
"statsInboundDownlink": true
}
},
"inbounds": [
{
"port": 443,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "permanent_test_user",
"email": "permanent_test_user@example.com",
"flow": ""
},
{
"id": "a9e7f88c-f6f1-44bd-905a-64879ab84cbc",
"email": "user",
"flow": ""
},
{
"id": "86a82955-8657-43c6-ae74-af724bb06299",
"email": "user1@example.com",
"flow": ""
}
],
"decryption": "none"
},
"streamSettings": {
"network": "tcp",
"security": "reality",
"realitySettings": {
"show": false,
"dest": "www.google.com:443",
"serverNames": ["www.google.com"],
"privateKey": "private-key",
"shortIds": [
"525ec83f86",
"64061320d2",
"04f8996da7",
"0a041b9462"
]
}
}
},
{
"listen": "127.0.0.1",
"port": 10085,
"protocol": "dokodemo-door",
"settings": { "address": "127.0.0.1" },
"tag": "api"
}
],
"outbounds": [
{ "protocol": "freedom", "tag": "direct" },
{ "protocol": "blackhole", "tag": "blocked" }
],
"routing": {
"rules": [
{
"inboundTag": ["api"],
"outboundTag": "api",
"type": "field"
}
]
}
}
What I did:
Enabled statsUserOnline in policy level 0 (the default level for all clients, as none have explicit level set).
Restarted Xray.
Connected two clients(same phone, btw) (using VLESS+REALITY) and generated some traffic.
Queried statistics using:
docker exec -it xray bash -c "xray api statsquery --server=127.0.0.1:10085"
Got result:
{
"stat": [
{
"name": "user>>>user1@example.com>>>traffic>>>downlink",
"value": 14722
},
{
"name": "inbound>>>api>>>traffic>>>uplink",
"value": 170
},
{
"name": "inbound>>>api>>>traffic>>>downlink",
"value": 24
},
{
"name": "user>>>permanent_test_user@example.com>>>traffic>>>uplink",
"value": 26272
},
{
"name": "user>>>permanent_test_user@example.com>>>traffic>>>downlink",
"value": 63520
},
{
"name": "user>>>user1@example.com>>>traffic>>>uplink",
"value": 6863
}
]
}
Why are online user statistics not appearing despite statsUserOnline: true in policy level 0? Is there any additional configuration required? Or is this a known limitation/ bug?
All reactions