qBittorrent-ClientBlocker,某些不友好的IP和客户端,保护 BT 网络,保护宽带

简介

为了防止被恶意 客户端/IP 吸血,封禁某些不友好的 IP/客户端,保护 BT 网络,保护宽带。

源码:https://github.com/Simple-Tracker/qBittorrent-ClientBlocker

安装

二进制

以 Linux 为例:

创建文件夹

1
mkdir -p /opt/qbittorrent-clientblocker

解压文件

1
tar -zxvf qBittorrent-ClientBlocker-3.6-linux-armv7.tar.gz -C /opt/qbittorrent-clientblocker

Docker

docker compose

1
2
3
4
5
6
7
mkdir qbittorrent-clientblocker
cd qbittorrent-clientblocker


mkdir qbittorrent-clientblocker_data
cd qbittorrent-clientblocker_data
vim config.json
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{
        "checkUpdate": true,
        "debug": false,
        "interval": 6,
        "cleanInterval": 3600,
        "banTime": 86400,
        "timeout": 6,
        "logToFile": true,
        "clientType": "",
        "clientURL": "",
        "clientUsername": "",
        "clientPassword": "",
        "useBasicAuth": false,
        "useShadowBan": true,
        "skipCertVerification": false,
        "blockList": [],
        "blockListFile": [
                "blockList.json",
                //"blockList-Optional.json"
        ],
        "blockListURL": [
                "https://bta.iaalai.cn/qBittorrent-ClientBlocker/blockList.json",
                "https://cdn.jsdelivr.net/gh/Simple-Tracker/qBittorrent-ClientBlocker@dev/blockList.json"
        ],
        "portBlockList": [],
        "ipBlockList": [],
        "ipBlockListFile": [
                "ipBlockList.txt"
        ],
        "ipBlockListURL": [
                "https://bta.iaalai.cn/BTN-Collected-Rules/combine/all.txt",
                "https://cdn.jsdelivr.net/gh/PBH-BTN/BTN-Collected-Rules@main/combine/all.txt",
                //"https://bta.iaalai.cn/BTN-Collected-Rules/qBittorrent-ClientBlocker/ipBlockList.txt",
                "https://cdn.jsdelivr.net/gh/Simple-Tracker/qBittorrent-ClientBlocker@dev/ipBlockList.txt"
        ]
        /*
        "debug_CheckTorrent": false,
        "debug_CheckPeer": false,
        "updateInterval": 86400,
        "restartInterval": 6,
        "torrentMapCleanInterval": 60,
        "banAllPort": true,
        "banIPCIDR": "/32",
        "banIP6CIDR": "/128",
        "ignoreEmptyPeer": true,
        "ignoreNoLeechersTorrent": true,
        "ignorePTTorrent": true,
        "ignoreAuthFailed": false,
        "sleepTime": 20,
        "proxy": "Auto",
        "longConnection": true,
        "logPath": "logs",
        "logDebug": false,
        "listen": "127.0.0.1:26262",
        "fetchFailedThreshold": 0,
        "execCommand_FetchFailed": "",
        "execCommand_Run": "",
        "execCommand_Ban": "",
        "execCommand_Unban": "",
        "syncServerURL": "",
        "syncServerToken": "",
        "genIPDat": 0,
        "ipUploadedCheck": false,
        "ipUpCheckInterval": 300,
        "ipUpCheckIncrementMB": 38000,
        "ipUpCheckPerTorrentRatio": 3.0,
        "maxIPPortCount": 0,
        "banByProgressUploaded": false,
        "banByPUStartMB": 20,
        "banByPUStartPrecent": 2.0,
        "banByPUAntiErrorRatio": 3.0,
        "banByRelativeProgressUploaded": false,
        "banByRelativePUStartMB": 20,
        "banByRelativePUStartPrecent": 2.0,
        "banByRelativePUAntiErrorRatio": 3.0,
        "ignoreByDownloaded": 100,
        */
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
version: '3.9'
services:
  qbittorrent-clientblocker:
    image: 'simpletracker/qbittorrent-clientblocker:latest'
    container_name: qbittorrent-clientblocker
    environment:
      - useENV=true
      - debug=false
      - logPath=logs
      - clientURL=http://qbittorrent:8080
      - clientUsername=username
      - clientPassword=password
    volumes:
      - './qbittorrent-clientblocker_data/config.json:/app/config.json'
    restart: unless-stopped
    networks:
      - bt-network

networks:
  bt-network:
    external: true
1
docker compose up -d

配置

修改 config.json

1
2
cd /opt/qbittorrent-clientblocker
vim config.json

"clientURL": "", 修改为自己的 qbittorrent 所在 ip 端口,比如

1
"clientURL": "http://localhost:8020",

启动

1
./qBittorrent-ClientBlocker

系统服务

1
vim /etc/systemd/system/qbittorrent-clientblocker.service

填入以下内容

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[Unit]
Description=qBittorrent-ClientBlocker service
Wants=network-online.target
After=qbittorrent-nox.service

[Service]
Type=simple
Restart=always
ExecStart=/bin/sh -c "cd /opt/qBittorrent-ClientBlocker && /opt/qBittorrent-ClientBlocker/qBittorrent-ClientBlocker --nochdir"

[Install]
WantedBy=default.target

启动服务

1
systemctl start qbittorrent-clientblocker.service

查看服务

1
systemctl status qbittorrent-clientblocker.service

关闭服务

1
systemctl stop qbittorrent-clientblocker.service

开机自启

1
systemctl enable qbittorrent-clientblocker.service

winodws 快捷方式启动

winodws 每次启动 qBittorrent 和 qbittorrent-clientblocker,有点繁琐,可以新建快捷方式启动,点击之后可以同时启动。

桌面右键 -> 新建快捷方式,“请键入对象的位置”填写为以下指示的内容:(先不要急着 copy)

1
C:\Windows\System32\cmd.exe /c "(tasklist | findstr qBittorrent-ClientBlocker || start D:\download_tool\qBittorrent-ClientBlocker-3.6-windows-amd64\qBittorrent-ClientBlocker.exe --hidewindow) && start D:\download_tool\qBittorrent\qbittorrent.exe"

copy之前需要将其中软件的路径修改为自己机器所在的路径

需要修改的地方:

  • D:\download_tool\qBittorrent-ClientBlocker-3.6-windows-amd64\qBittorrent-ClientBlocker.exe

  • D:\download_tool\qBittorrent\qbittorrent.exe

修改并填入后,点击下一步,填入快捷方式的名称,比如

1
qBittorrent and qBittorrent-ClientBlocker 快捷方式

下一步完成即可。

如果不喜欢默认的图标,可以 鼠标移动到 快捷方式上,右键 -> 属性,找到 更改图标,设置 qBittorrent 所在的图标,比如

1
D:\download_tool\qBittorrent\qbittorrent.exe
网站总访客数:Loading
网站总访问量:Loading
使用 Hugo 构建
主题 StackJimmy 设计
-->