x-ui icon indicating copy to clipboard operation
x-ui copied to clipboard

Chaining (using as middle/bridge server) and traffic calculation

Open ghost opened this issue 2 years ago • 1 comments

Welcome

  • [X] Yes, I'm using the latest major release. Only such installations are supported.
  • [X] Yes, I'm using the supported system. Only such systems are supported.
  • [X] Yes, I have read all WIKI document,nothing can help me in my problem.
  • [X] Yes, I've searched similar issues on GitHub and didn't find any.
  • [X] Yes, I've included all information below (version, config, log, etc).

Description of the problem,screencshot would be good

I am using x-ui in a chained setup as bridge server ( (Client) <-> [ Bridge Server(with x-ui) ] <-> [ Upstream Server ] <-> (Internet) ) upstream has a ws inbound (proivided here) and on bridge i modify xray config and add another outbound

{
  "api": {
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ],
    "tag": "api"
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 62789,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1"
      },
      "tag": "api"
    }
  ],
  "outbounds": [
    {
      "tag": "proxy",
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "<upstream-ip>",
            "port": <upstream-port>,
            "users": [
              {
                "id": "<upstream-uuid>",
                "alterId": <upstream-alterid>,
                "security": "none"
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "ws"
      },
      "mux": {
        "enabled": true
      }
    },
    {
      "protocol": "freedom",
      "settings": {}
    },
    {
      "protocol": "blackhole",
      "settings": {},
      "tag": "blocked"
    }
  ],
  "policy": {
    "levels": {
      "0": {
        "handshake": 10,
        "connIdle": 100,
        "uplinkOnly": 2,
        "downlinkOnly": 3,
        "statsUserUplink": true,
        "statsUserDownlink": true,
        "bufferSize": 10240
      }
    },
    "system": {
      "statsInboundDownlink": true,
      "statsInboundUplink": true
    }
  },
  "routing": {
    "rules": [
      {
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api",
        "type": "field"
      },
      {
        "ip": [
          "geoip:private"
        ],
        "outboundTag": "blocked",
        "type": "field"
      },
      {
        "outboundTag": "blocked",
        "protocol": [
          "bittorrent"
        ],
        "type": "field"
      }
    ]
  },
  "stats": {}
}

this setup works fine, but the problem is traffic calculation, I'm not sure if this is accurate but for example if total traffic for all inbounds in bridge is 10 GB total downlink would be around 40 GB

Version of x-ui

0.3.4.0

x-ui log or xray log

log is this on repeat (theres only one inbound with a single connected device at the time of log)

Feb 12 12:34:23 ubuntu22 x-ui[116739]: 2023/02/12 12:34:23 WARNING - failed to update traffic for client:[email protected],inboundId:0
Feb 12 12:34:23 ubuntu22 x-ui[116739]: 2023/02/12 12:34:23 WARNING - AddClientTraffic update data error: UNIQUE constraint failed: client_infos.email
Feb 12 12:34:33 ubuntu22 x-ui[116739]: 2023/02/12 12:34:33 WARNING - failed to update traffic for client:[email protected],inboundId:0
Feb 12 12:34:33 ubuntu22 x-ui[116739]: 2023/02/12 12:34:33 WARNING - AddClientTraffic update data error: UNIQUE constraint failed: client_infos.email

ghost avatar Feb 12 '23 09:02 ghost

I have the same problem. When I download a 200Mb file , it will be calculated 2Gb on my ISP.

hamed121221 avatar Mar 22 '23 11:03 hamed121221