Skip to content

Quota Management For Server

Hirbod Behnam edited this page Aug 9, 2019 · 1 revision

You may want to limit the amount of data users can download or upload. Here is a small guide to setup this small program to limit the users.

Getting started

At first install mtproto proxy on your server. Then head to here and download one of the executables suitable for your system.

After you downloaded it, install tmux. Then download this file in the directory you downloaded the executable.

Edit the rules.json file. How?

  1. All Listen values are the ports that will be share with users. None of the listen values must be same.
  2. All Forward values must be 127.0.0.1: + the port that you defined your proxy to run on. For example if your proxy is running on port 8024, forward must be 127.0.0.1:8024
  3. Quota is the number of bytes that a user can download or upload. For example if you want to limit the user with 200MB, you must calculate 1024 * 1024 * 2000. (For unlimited quota use 9223372036854775807)

Here is an example file:

{
  "SaveDuration": 600,
  "Rules": [
    {
      "Listen": 5362,
      "Forward": "127.0.0.1:8024",
      "Quota": 1073741824
    },
    {
      "Listen": 5363,
      "Forward": "127.0.0.1:8024",
      "Quota": 104857600
    },
    {
      "Listen": 5364,
      "Forward": "127.0.0.1:8024",
      "Quota":9223372036854775807
    }
  ]
}

In tmux, just type ./pf-xxx (depending on your system) to run the forwarder. Open the ports on your firewall and you are good to go.

Sharing links

For example your default proxy link is like this:

https://t.me/proxy?server=1.1.1.1&port=8024&secret=dd00000000000000000000000000000000

When you want to share it with your clients, just change the port number to the one you like. For example if I change the link to https://t.me/proxy?server=1.1.1.1&port=5363&secret=dd00000000000000000000000000000000, client have a 100MB quota.