FranzKafkaYu / x-ui

Lightweight Xray panel with multi-protocol and multi-user on the same port,supports English language and Telegram bot. Easy to use and easy to manage.
GNU General Public License v3.0
8.03k stars 1.64k forks source link

为什么单端口多用户情况下,流量统计都是0? #478

Closed shyboy0415 closed 1 year ago

shyboy0415 commented 1 year ago

Welcome

Description of the problem,screencshot would be good

为什么单端口多用户情况下,流量统计都是0?有什么限制吗? image 端口下的统计是正常的 image

Version of x-ui

[INF] 当前面板信息[current panel info]: 面板版本[version]: 0.3.4.4:20230717

x-ui log or xray log

-- Logs begin at Wed 2023-08-02 12:36:44 EDT. -- Aug 02 20:43:31 racknerd-6567e1 x-ui[30352]: ClearTrafficByPort,port id 2 Aug 02 20:43:34 racknerd-6567e1 x-ui[30352]: 2023/08/02 20:43:34 INFO - We got 2 members in client Aug 02 20:43:34 racknerd-6567e1 x-ui[30352]: 2023/08/02 20:43:34 INFO - We got 1 members in client Aug 02 20:43:34 racknerd-6567e1 x-ui[30352]: 2023/08/02 20:43:34 INFO - We got 1 members in client Aug 02 20:43:34 racknerd-6567e1 x-ui[30352]: ClearTrafficByPort,port id 3 Aug 02 20:43:44 racknerd-6567e1 x-ui[30352]: 2023/08/02 20:43:44 INFO - We got 2 members in client Aug 02 20:43:44 racknerd-6567e1 x-ui[30352]: 2023/08/02 20:43:44 INFO - We got 1 members in client Aug 02 20:50:54 racknerd-6567e1 x-ui[30352]: 2023/08/02 20:50:54 INFO - We got 2 members in client Aug 02 20:50:54 racknerd-6567e1 x-ui[30352]: 2023/08/02 20:50:54 INFO - We got 1 members in client Aug 02 20:50:54 racknerd-6567e1 x-ui[30352]: 2023/08/02 20:50:54 INFO - We got 1 members in client Aug 02 20:51:24 racknerd-6567e1 x-ui[30352]: 2023/08/02 20:51:24 INFO - We got 2 members in client Aug 02 20:51:24 racknerd-6567e1 x-ui[30352]: 2023/08/02 20:51:24 INFO - We got 1 members in client Aug 02 20:51:32 racknerd-6567e1 x-ui[30352]: ClearTrafficByPort,port id 3 Aug 02 20:51:34 racknerd-6567e1 x-ui[30352]: 2023/08/02 20:51:34 INFO - We got 2 members in client Aug 02 20:51:34 racknerd-6567e1 x-ui[30352]: 2023/08/02 20:51:34 INFO - We got 1 members in client Aug 02 20:51:34 racknerd-6567e1 x-ui[30352]: 2023/08/02 20:51:34 INFO - We got 1 members in client Aug 02 20:51:49 racknerd-6567e1 x-ui[30352]: ClearTrafficByPort,port id 2 Aug 02 20:51:54 racknerd-6567e1 x-ui[30352]: 2023/08/02 20:51:54 INFO - We got 2 members in client Aug 02 20:51:54 racknerd-6567e1 x-ui[30352]: 2023/08/02 20:51:54 INFO - We got 1 members in client Aug 02 20:51:54 racknerd-6567e1 x-ui[30352]: 2023/08/02 20:51:54 INFO - We got 1 members in client Aug 02 21:07:24 racknerd-6567e1 x-ui[30352]: 2023/08/02 21:07:24 INFO - We got 1 members in client Aug 02 21:07:24 racknerd-6567e1 x-ui[30352]: 2023/08/02 21:07:24 INFO - We got 1 members in client Aug 02 21:07:24 racknerd-6567e1 x-ui[30352]: 2023/08/02 21:07:24 INFO - We got 1 members in client
FranzKafkaYu commented 1 year ago

请检查配置模板的设置,开启单个用户的流量统计需要配置policy,如下所示:

 "policy": {
    "levels": {
      "0": {
        "handshake": 10,
        "connIdle": 100,
        "uplinkOnly": 2,
        "downlinkOnly": 3,
        "statsUserUplink": true,
        "statsUserDownlink": true,
        "bufferSize": 10240
      }
    },
    "system": {
      "statsInboundDownlink": true,
      "statsInboundUplink": true
    }
  },  

完整配置参考:

{
"log": {
    "access": "/usr/local/x-ui/bin/access.log",
    "error": "/usr/local/x-ui/bin/error.log",
    "loglevel": " debug",
    "dnsLog": true
 },
  "api": {
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ],
    "tag": "api"
  },
 "dns": {
      "servers": [
      "127.0.0.1"
    ]
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 62789,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1"
      },
      "tag": "api"
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blocked"
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blockedByIp"
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blockedByDomain"
    }
  ],
  "policy": {
    "levels": {
      "0": {
        "handshake": 10,
        "connIdle": 100,
        "uplinkOnly": 2,
        "downlinkOnly": 3,
        "statsUserUplink": true,
        "statsUserDownlink": true,
        "bufferSize": 10240
      }
    },
    "system": {
      "statsInboundDownlink": true,
      "statsInboundUplink": true
    }
  },
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "domainMatcher": "hybrid",
    "rules": [
      {
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api",
        "type": "field"
      },
      {
        "ip": [
          "geoip:cn"
        ],
        "outboundTag": "blockedByIp",
        "type": "field"
      },
      {
        "type": "field",
        "domain": [
          "geosite:category-ads-all",
          "geosite:cn",
          "geosite:tld-cn",
          "geosite:private",
          "geosite:category-games@cn"
        ],
        "outboundTag": "blockedByDomain"
      },
      {
        "outboundTag": "blocked",
        "protocol": [
          "bittorrent"
        ],
        "type": "field"
      }
    ]
  },
  "stats": {}
}  
shyboy0415 commented 1 year ago

谢谢