A small script for uTorrent that blocks Xunlei(Thunder) clients automatically. uTorrent 自动屏蔽迅雷脚本
10 KB/s
的非法客户端,将带宽留给合法客户端10 × 累计上传量 + 5MB
的非法客户端理由:
-XL0012-***
Xunlei/***
7.x.x.x
Xfplay
FDM
dandanplay
Mozilla
go.torrent
aria2
this.should_block = (() => {
if (!/-XL0012-|Xunlei|^7\.|aria2|Xfplay|dandanplay|FDM|go\.torrent|Mozilla/i.test(this.client)) return false
const [state] = this.torrent.state
if (state === '做种')
return this.upload_speed > 10 * 2 ** 10 // 我方上传速度大于 10 KB/s
if (state === '下载')
return this.uploaded > this.downloaded * 10 + 5 * 2**20 // 累计吸血量大于 `10 × 累计上传量 + 5MB`
return false
})()
支持 IP 定位,显示地理位置
批量可编程式修改 uTorrent 的 resume.dat 内保存的任务信息,从而:
命令行监控,实时查看 peers 情况
--username
和 --password
参数的值--port
参数的值C:/Users/<用户名>/AppData/Roaming/uTorrent/ipfilter.dat
,该目录下应该有 resume.dat 文件存在)保证 ipfilter.dat 文件存在(若不存在则新建空白 ipfilter.dat 文件),脚本会在原有 ipfilter.dat 文件内容之后添加被屏蔽的 IP,不影响已有内容及其功能utorrent-block-xunlei.exe
, 下载地址: https://github.com/ShenHongFei/utorrent-block-xunlei/releases
utorrent-block-xunlei.exe --help
Usage: utorrent-block-xunlei --port 50050 --username tom --password 123456 --ipfilter "C:/Users/tom/AppData/Roaming/uTorrent/ipfilter.dat"
Xunlei Blocker of uTorrent
Options:
-V, --version output the version number
--hostname <hostname> 可选参数, uTorrent WebUI 主机的 hostname, 默认为本机 127.0.0.1, 也可设置远程主机 IP 或域名 (default: "127.0.0.1")
--port <port> 必传参数, "uTorrent 设置 > 连接 > 监听端口 > 传入连接所使用的端口" 中设置的端口号
--username <username> 必传参数, "uTorrent 设置 > 高级 > 网页界面 > 身份验证 > 用户" 中设置的用户名
--password <password> 必传参数, "uTorrent 设置 > 高级 > 网页界面 > 身份验证 > 密码" 中设置的密码
--ipfilter <ipfilter> 必传参数, uTorrent 数据目录中 ipfilter.dat 文件的完整路径,如: C:/Users/tom/AppData/Roaming/uTorrent/ipfilter.dat
--interval <interval> 可选参数, 检测 peers 的间隔(秒), 默认每隔 20 秒检测并屏蔽一次 (default: "20")
--interval-reset <interval> 可选参数, 间隔 interval 秒自动重置当前时间间隔内被动态屏蔽的 IP,默认间隔 2 小时 (default: "7200")
-h, --help display help for command
启动 blocker (修改下参数的值): utorrent-block-xunlei --port 50050 --username shf --password 123456 --ipfilter "C:/Users/shf/AppData/Roaming/uTorrent/ipfilter.dat"
(可选,不影响屏蔽功能) 在 uTorrent 中开启屏蔽日志,查看被屏蔽的连接请求
4.1 在 uTorrent 下方的日志面板中点击右键
4.2 勾选 记录用户通讯信息 > 记录拦截连接
4.3 有被屏蔽的用户连接时可以在 uTorrent 日志面板中看到类似下面的日志
[2018-11-22 19:03:43] Loaded ipfilter.dat (51 entries)
[2018-11-22 19:03:46] IpFilter blocked peer 223.81.192.235
[2018-11-22 19:03:49] IpFilter blocked peer 223.81.192.235
[2018-11-22 19:04:06] IpFilter blocked peer 223.81.192.235
[2018-11-22 19:04:21] IpFilter blocked peer 183.25.54.216
[2018-11-22 19:04:46] IpFilter blocked peer 223.81.192.235
...
实时控制,查看状态,REPL
在 utorrent-block-xunlei
命令行窗口中输入 utorrent
可通过 REPL 查看其属性,调用其方法
如输入 utorrent.print_blockeds()
可查看被动态屏蔽的 IP
退出 utorrent-block-xunlei 时需在命令行窗口中输入 exit()
, 以保证 ipfilter.dat
恢复到运行前的状态,不残留动态屏蔽的 IP
npm i utorrent-block-xunlei
import { UTorrent, Torrent, Peer, TorrentData, TorrentFile, ResumeData } from 'utorrent-block-xunlei'
let utorrent = await UTorrent.connect({
root_url: 'http://127.0.0.1:50050/gui/',
username: 'xxx',
password: 'xxxxxxxx',
ipfilter_dat: 'C:/Users/xxx/AppData/Roaming/uTorrent/ipfilter.dat',
interval: 20 * 1000,
print: {
torrents: '所有',
peers: true
}
})
utorrent.start_blocking()
utorrent.hide_display()
utorrent.show_display()
utorrent.stop_blocking()
utorrent.reset_ipfilter()
utorrent.block_peers()
utorrent.print_blockeds()
utorrent.state