Marzban Torrent Blocker is an application designed to block torrent usage by users of the Marzban panel. The application analyzes logs, detects torrent activity, and temporarily blocks the user, sending notifications to the administrator via Telegram, and optionally to the user. It can also work with other panels and directly with Xray.
Enable logging. Section log
"log": {
"access": "/var/lib/marzban-node/access.log",
"error": "/var/lib/marzban-node/error.log",
"loglevel": "error",
"dnsLog": false
},
Configure bittorrent traffic tagging. Section routing
. Add the rule:
{
"protocol": [
"bittorrent"
],
"outboundTag": "TORRENT",
"type": "field"
},
Here, TORRENT
is the tag that the application will use to filter logs.
Configure bittorrent traffic blocking. Section outbounds
. Send all traffic to blackhole:
{
"protocol": "blackhole",
"tag": "TORRENT"
},
Unfortunately, this blocking only effectively handles about 20% of bittorrent traffic.
On the server where the panel is hosted, create the folder /var/lib/marzban-node
:
mkdir -p /var/lib/marzban-node
Add a new volume to the /opt/marzban/docker-compose.yml
file:
volumes:
- /var/lib/marzban:/var/lib/marzban
- /var/lib/marzban-node:/var/lib/marzban-node #новый volume
Restart the panel with the following command:
docker compose down --remove-orphans; docker compose up -d
Ensure that the volume is correctly mounted in docker-compose.yml
:
volumes:
- /var/lib/marzban-node:/var/lib/marzban-node
By default, this volume is present, ensuring logs are accessible on the host.
To automatically install the application, follow these steps:
bash <(curl -fsSL git.new/install)
Token
and Chat ID
, and start the service.systemctl start/status/stop torrent-blocker
After installation, you can configure the application's behavior via the configuration file located at: /opt/torrent-blocker/config.yaml
.
Key configuration parameters:
/var/lib/marzban-node/access.log
10
TORRENT
true
false
CHAT_ID
from the log entry. Optional.An example configuration file with detailed comments is available at /opt/torrent-blocker/config.yaml
.
If the user's CHAT_ID
is included in their login on the Marzban panel, you can configure the application to send notifications directly to the user.
For example, if the user's login in Marzban looks like this: kutovoys_tgid-1234111
, you can set up the following in config.yaml
:
tgid-(\\d+)
email: \\d+\\.(\\w+)_tgid-
In this case, the administrator will receive notifications with the username kutovoys
, and the user will also be notified directly via Telegram when they are blocked.
We welcome contributions from the community! If you have ideas for improvements or have found a bug, please create an issue or submit a pull request on GitHub.