Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
Add configuration file and other tweaks
Browse files Browse the repository at this point in the history
--save-config [CONFIG-FILE]

--load-config [CONFIG-FILE]
  • Loading branch information
SeaHOH committed Oct 11, 2020
1 parent 79a89ac commit 00db9dd
Show file tree
Hide file tree
Showing 14 changed files with 1,153 additions and 234 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ coverage.xml

# Translations
*.mo
*.po~

# Django stuff:
*.log
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
include LICENSE
include README_zh.md
recursive-include src *LICENSE*
recursive-include src *README*
76 changes: 49 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ work, please recommend it to your friends, Thanks.
- Does not work in old versions of μTorrent which did not provided API `getpeers`.
- **Please use this script in local network**, μTorrent Web API does not
support HTTPS connections, it is not safe.
- If you can not accept read/write the ipfilter.dat file frequently, it can be
soft/symbolic link to a RAM disk.
- I took preventive measures, if you stiil found a normal peer has been banned,
please tell us via [issues board](https://github.com/SeaHOH/ban-peers/issues).

Expand Down Expand Up @@ -88,19 +90,21 @@ Network File:

```
$ ban_peers -h
Welcome using Ban-Peers 0.9.1
Welcome using Ban-Peers 0.9.2
Usage: ban_peers [-H IP|DOMAIN] [-p PORT] [-a USERNAME:PASSWORD] [-e HOURS]
[-t MINUTES] [-f FORMAT] [-C] [-X] [-P] [-L] [-N] [-R] [-U]
[-A] [-O] [-h] [-v]
[IPFILTER-PATH]
usage: ban_peers.pyz [-H IP|DOMAIN] [-p PORT] [-a USERNAME:PASSWORD] [-e HOURS]
[-t MINUTES] [-f FORMAT] [-C] [-X] [-P] [-L] [-N] [-R]
[-U] [-A] [-O] [-s [CONFIG-FILE] | -l [CONFIG-FILE]] [-h]
[-v]
[IPFILTER-PATH]
Checking & banning BitTorrent leech peers via Web API, remove ads, working for
uTorrent.
Positional Arguments:
IPFILTER-PATH Path of ipfilter dir/file, wait input if empty. IMPORTANT
NOTICE: must be the uTorrent settings path!
IPFILTER-PATH Path of ipfilter dir/file, will try load from config file
or wait input if empty. IMPORTANT NOTICE: must be the
uTorrent settings path!
Optional Arguments:
-H IP|DOMAIN, --host IP|DOMAIN
Expand All @@ -110,11 +114,11 @@ Optional Arguments:
-a USERNAME:PASSWORD, --authorization USERNAME:PASSWORD
WebUI authorization, wait input if required
-e HOURS, --expire HOURS
Ban expire time for peers, default 12 HOURS
Ban expire time for peers, default 12 hours
-t MINUTES, --time-allowed-refuse MINUTES
How much time to keep connecting before temporary banned
refused upload peers, at least 5 MINUTES, default 10
MINUTES
refused upload peers, at least 5 minutes, default 10
minutes
-f FORMAT, --log-header FORMAT
Format of log header, see time.strftime, default %H:%M:%S
-C, --resolve-country
Expand All @@ -136,28 +140,25 @@ Optional Arguments:
Remove ads via set Advanced Settings, only working for
localhost, and to fail in older uTorrent
-O, --no-close-pairing
Don't turn off Web Pairing setting after remove ads
Don't turn off Web Pairing setting after
-s [CONFIG-FILE], --save-config [CONFIG-FILE]
Save current arguments to a config file except "--remove-
ads", "--help" and "--version". Save to default location
"<YOUR CONFIG DIR>/BanPeers/ban_peers.conf" if empty input
-l [CONFIG-FILE], --load-config [CONFIG-FILE]
Load arguments from a config file, will not overlaid the
inputted arguments. Load from current directory (use
conf/ini/cfg as extension name) or default location if
empty input
-h, --help Show this help message and exit
-v, --version Show version and exit
```

```markdown
$ ban_peers -p 12345 -a username:password /var/lib/utserver
Welcome using Ban-Peers 0.9.1
19:44:33 Set uTorrent setting 'webui.allow_pairing' to True
19:44:35 Set uTorrent setting 'gui.show_plus_upsell_nodes' to False **_Remove upsell tip in the sidebar_**
19:44:35 Set uTorrent setting 'webui.allow_pairing' to False **_disallow pairing_**
19:44:35 Set uTorrent setting 'bt.use_rangeblock' to False **_Won't restore after quit_**
19:44:35 Set uTorrent setting 'ipfilter.enable' to True
19:44:35 uTorrent auto-banning script start running
Choose your operation: (Q)uit, (S)top, (R)estart, (P)ause/Proceed
```

or

```markdown
$ ban-peers
Welcome using Ban-Peers 0.9.1
Welcome using Ban-Peers 0.9.2
No ipfilter has be inputted, try load from config file
Load ipfilter from config file fail, found nothing
Please input uTorrent settings folder path or ipfilter file path:
/var/lib/utserver
Please input WebUI username: username
Expand All @@ -167,8 +168,29 @@ Please input WebUI password: password **_No cover_**
19:44:35 Set uTorrent setting 'webui.allow_pairing' to False **_disallow pairing_**
19:44:35 Set uTorrent setting 'bt.use_rangeblock' to False **_Won't restore after quit_**
19:44:35 Set uTorrent setting 'ipfilter.enable' to True
19:44:35 uTorrent auto-banning script start running
19:44:35 Auto-banning script start running
Choose your operation: (Q)uit, (S)top, (R)estart, (P)ause/Proceed
19:44:36 Auto-banning script quit running
...

...
$ ban_peers -p 12345 -a username:password /var/lib/utserver --save-config
Welcome using Ban-Peers 0.9.2
Start saving config file "<YOUR CONFIG DIR>/BanPeers/ban_peers.conf"
Save argument "ipfilter = /var/lib/utserver"
Save argument "port = 12345"
Save argument "authorization = username:password"
...

...
$ ban-peers -p 54321
Welcome using Ban-Peers 0.9.2
No ipfilter has be inputted, try load from config file
Start loading config file "<YOUR CONFIG DIR>/BanPeers/ban_peers.conf"
Load argument "ipfilter = /var/lib/utserver"
**_Doesn't load inputted argument port_**
Load argument "authorization = username:password"
...
```

- Quit: exit the script.
Expand Down
62 changes: 40 additions & 22 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# 注意事项
- 无法在未提供 `getpeers` API 的旧版本 μTorrent 中正常工作。
- **请在本地网络内使用此脚本**,μTorrent 网页 API 不支持 HTTPS 连接,它并不安全。
- 如果无法接受频繁读写 ipfilter.dat 文件,可以将它软链接到内存盘。
- 虽然已采取一些预防措施,如果你仍然发现有正常的对端被错误屏蔽,
请反馈到 [issues 板块](https://github.com/SeaHOH/ban-peers/issues)

Expand Down Expand Up @@ -78,18 +79,18 @@ Android:

```
ban_peers -h
欢迎使用 Ban-Peers 0.9.1
欢迎使用 Ban-Peers 0.9.2
用 法: ban_peers [-H IP|域名] [-p 端口] [-a 用户名:密码] [-e 小时] [-t 分钟]
[-f 格式] [-C] [-X] [-P] [-L] [-N] [-R] [-U] [-A] [-O] [-h]
[-v]
[IP屏蔽配置路径]
用 法: ban_peers.pyz [-H IP|域名] [-p 端口] [-a 用户名:密码] [-e 小时]
[-t 分钟] [-f 格式] [-C] [-X] [-P] [-L] [-N] [-R] [-U]
[-A] [-O] [-s [配置文件] | -l [配置文件]] [-h] [-v]
[IP屏蔽配置路径]
通过网页 API 检查并屏蔽 BitTorrent 吸血对端,移除广告,工作于 uTorrent。
位置参数:
IP屏蔽配置路径 ipfilter 目录或文件路径,留空将等待输入。重要提示: 必须是
uTorrent 配置使用的路径!
IP屏蔽配置路径 ipfilter 目录或文件路径,留空将尝试从配置文件加载,或等待输
入。重要提示: 必须是 uTorrent 配置使用的路径!
可选参数:
-H IP|域名, --host IP|域名
Expand Down Expand Up @@ -124,27 +125,23 @@ ban_peers -h
本的 uTorrent
-O, --no-close-pairing
移除广告后,不关闭网络配对配置项
-s [配置文件], --save-config [配置文件]
保存当前参数到一个配置文件,不包括 "--remove-ads"、"--help"
和 "--version",如果输入留空则保存到默认位置 "<你的配置目录>
\BanPeers\ban_peers.conf"
-l [配置文件], --load-config [配置文件]
从一个配置文件加载参数,不会覆盖已输入的参数,如果输入留空
则尝试从当前目录 (使用 conf/ini/cfg 作为扩展名) 或默认位置
加载
-h, --help 显示此帮助信息并退出
-v, --version 显示版本信息并退出
```

```markdown
C:\Users\username>ban_peers -p 12345 -a username:password X:\uTorrent
欢迎使用 Ban-Peers 0.9.1
19:44:33 设定 uTorrent 配置 'webui.allow_pairing' 到 True **_允许配对_**
19:44:35 设定 uTorrent 配置 'gui.show_plus_upsell_nodes' 到 False **_移除侧栏付费版升级提示_**
19:44:35 设定 uTorrent 配置 'webui.allow_pairing' 到 False **_禁止配对_**
19:44:35 设定 uTorrent 配置 'bt.use_rangeblock' 到 False **_脚本退出后不会自动恢复_**
19:44:35 设定 uTorrent 配置 'ipfilter.enable' 到 True
19:44:35 uTorrent 自动屏蔽脚本开始运行
请选择你要执行的操作: (Q)退出,(S)停止,(R)重新开始,(P)暂停/恢复
```

或者

```markdown
C:\Users\username>ban_peers
欢迎使用 Ban-Peers 0.9.1
欢迎使用 Ban-Peers 0.9.2
没有输入 ipfilter,尝试从配置文件加载
从配置文件加载 ipfilter 失败,什么都没有找到
请输入 uTorrent 配置文件夹路径,或者 ipfilter 文件路径:
X:\uTorrent
请输入 WebUI 用户名: username
Expand All @@ -156,6 +153,27 @@ X:\uTorrent
19:44:35 设定 uTorrent 配置 'ipfilter.enable' 到 True
19:44:35 uTorrent 自动屏蔽脚本开始运行
请选择你要执行的操作: (Q)退出,(S)停止,(R)重新开始,(P)暂停/恢复
19:44:36 自动屏蔽脚本退出运行
...

...
C:\Users\username>ban_peers -p 12345 -a username:password X:\uTorrent --save-config
欢迎使用 Ban-Peers 0.9.2
开始保存配置文件 "<你的配置目录>\BanPeers\ban_peers.conf"
保存参数 "ipfilter = X:\uTorrent"
保存参数 "port = 12345"
保存参数 "authorization = username:password"
...

...
C:\Users\username>ban_peers -p 54321
欢迎使用 Ban-Peers 0.9.2
没有输入 ipfilter,尝试从配置文件加载
开始保存配置文件 "<YOUR CONFIG DIR>\BanPeers\ban_peers.conf"
加载参数 "ipfilter = X:\uTorrent"
**_没有加载已输入的 port 参数_**
加载参数 "authorization = username:password"
...
```

- 退出:退出此脚本。
Expand Down
Loading

0 comments on commit 00db9dd

Please sign in to comment.