alireza0 / s-ui

An advanced Web Panel • Built for SagerNet/Sing-Box
https://t.me/XrayUI
GNU General Public License v3.0
2.11k stars 304 forks source link

Usage of users #146

Closed mortag closed 5 days ago

mortag commented 1 month ago

Dear Developer Team,

Thank you for releasing your app. I have a question and I would appreciate if you could help me.

Due to a lack of resources, I don't want to install the full app. Instead, I only want to install sing-box from the source code. I'm specifically interested in using the Hysteria2 protocol. However, I'm not sure how to monitor the traffic of each individual user.

Is it possible for you to provide any hints or guidance about this? For example, is there an option to enable debug logging or any other features that could help me track the traffic usage per user?

I'd be grateful for any assistance you can provide. Please let me know if you need any clarification or have additional questions.

Best regards,

alireza0 commented 1 month ago

Dear @mortag ,

First you should run your sing-box core with v2ray_api enabled with listenning port. Then you can get traffic usage information by GRPC call to this port. You can follow traffic job and v2rayApi.go in backend\singbox.

Good luck

mortag commented 1 month ago

Daer Alireza,

I greatly appreciate your assistance.

Could you please explain how to use Sing-Box with the v2ray_api? I have installed the Sing-Box service and created the client configuration, but I need guidance on how to proceed.

Thank you for your help.

alireza0 commented 1 month ago

To build sing-box with v2rayApi module, you need to mention the tag on build process:

go build -tags with_v2ray_api -o sing-box ./cmd/sing-box

In order to enable it in configuration, you should configure your config.json like this:

{
  "inbounds": [ ...inbounds ],
  "outbounds": [ ...outbounds ],
  "route": {
    "rules": [ ...rules ]
  },
...Other Parts
  "experimental": {
    "v2ray_api": {
      "listen": "127.0.0.1:1080",
      "stats": {
        "enabled": true,
        "inbounds": [ <INBOUND TAGS> ],
        "outbounds": [ <OUTBOUND TAGS> ],
        "users": [ <USER NAMES> ]
      }
    }
  }
}

In this configuration, your v2ray_api will listen to 127.0.0.1:1080 and send you statistics of mentioned inbounds,outbounds,users which you enter the TAG/Name in stats object. Reference

GRPC call to this port, uses this proto: code

Results are key-value type which value is a number and key will be like this ( reference ): user>>>[email]>>>traffic>>>uplink

mortag commented 4 weeks ago

Dear Alireza,

Thank you for your assistance. I apologize for contacting you again.

I have successfully rebuilt the core with new modules and added an experimental section to the config.json file. However, I have been unsuccessful in retrieving user traffic using the curl command for the past few days.

My question is, in order to retrieve traffic data, do I need to set up an API with a database, or can I only obtain the data using curl?

Thanks,

alireza0 commented 4 weeks ago

It is not as easy as curl. As I mentioned, you should use GRPC to call this api.

mortag commented 3 weeks ago

Dear Alireza, As I am not a programmer, it is challenging for me to create a new API to calculate data usage. Therefore, I have decided to use your Prefect project.

I would like to use it as a VPN specifically for gaming. To achieve this, I need it to filter all websites, except for the game sites.

Is this possible? If so, could you please guide me on how to implement it?

Thank you.

alireza0 commented 3 weeks ago

I don't know which IP/Domain list you want to use. But it is possible to define routing rules to avoid/accept traffic to a list of IPs or Domains.

mortag commented 5 days ago

I am wanting gratitude for the assistance you provided me. Your support was invaluable, and I genuinely appreciate the time and effort you dedicated to helping me and I am truly grateful for your kindness and generosity.

Thank you once again for your support. Warmest regards,