uTorrent 自动屏蔽迅雷脚本(uTorrent block xunlei/thunder)

2018-11-19 17:10:27 +08:00
 SHF

uTorrent 自动屏蔽迅雷脚本

GitHub: https://github.com/ShenHongFei/utorrent-block-xunlei

方法

  1. 根据 uTorrent 的 WebUI API 发送 http request 获取到所有种子的 peers 信息
  2. 按照 client name 筛选出使用迅雷的 peer IP,写入 ipfilter.dat 文件
  3. 发送 http request 让 uTorrent 重新加载 ipfilter.dat

屏蔽列表

-XL0012-***

Xunlei/***

7.x.x.x

Xfplay

效果

每隔一段时间,已连接用户中使用迅雷客户端的 IP 将会被封锁

脚本

utorrent=
    init: ->
        @root_url= 'http://127.0.0.1:10000/gui/'
        @cookies= request.jar()
        token_html = await request
            uri: @root_url + 'token.html'
            auth:
                user: 'admin'
                pass: 'xxxxxx'
            jar: @cookies
        $ = cheerio.load token_html
        @token = $('div').text()
        await @get_torrents()
        
    call: ({api='', params, method='GET'}={})->
        JSON.parse await request
            uri: @root_url + api
            method: method
            qs:{
                token: @token
                params...
            }
            auth:
                user: 'admin'
                pass: 'xxxxxx'
            jar: @cookies
    
    get_torrents: -> 
        @torrents = (await @call params: list: 1).torrents
        @hashes = @torrents.map (x)-> x[0]
        
    get_peers: (hash)->
        resp = await @call params:
            action: 'getpeers'
            hash: hash
        resp.peers
    
    get_all_peers: ->
        peers = []
        for hash in @hashes
            peers.append((await @get_peers hash)[1])
        for peer in peers
            ip: peer[1]
            client: peer[5]
        
    block_xunlei: ->
        peers = await @get_all_peers()
        blocks = peers.filter (x)-> x.client.match /(-XL0012-)|(Xunlei)|(^7\.)|(Xfplay)/i
        if blocks.isEmpty()
            log 'no xunlei clients detected'
            log peers
            return
        else
            log blocks
        ipfilter = new File 'C:/Users/shf/AppData/Roaming/uTorrent/ipfilter.dat'
        ipfilter.data += (x.ip for x in blocks).join('\n') + '\n'
        ipfilter.save()
        log 'ipfilter.dat updated'
        await @call params:
            action: 'setsetting'
            s: 'ipfilter.enable'
            v: '1'
        log 'ipfilter.dat reloaded'

    run: ->
        await @init()
        await @block_xunlei()
        @task = setInterval => 
            await @block_xunlei()
        , 3*60*1000

        
    stop: ->
        @task.clearInterval()

日志

未检测到迅雷时

no xunlei clients detected
当前已连接 peers
[ { ip: '180.94.154.163', client: 'µTorrent/3.5.4.0' },
  { ip: '223.140.248.38', client: 'BitComet 1.53' },
  { ip: '101.88.108.19', client: 'µTorrent/2.2.1.0' },
  { ip: '39.161.242.50', client: 'Unknown FD/5.1.0.0' },
  { ip: '171.88.70.72', client: 'Transmission 2.94' },
  { ip: '218.79.69.196', client: '[FAKE] µTorrent/3.0.0.0' },
  { ip: '123.204.251.13', client: 'BitComet 1.51' },
  { ip: '118.150.188.121', client: 'μTorrent 3.5.3' },
  { ip: '118.150.188.121', client: 'μTorrent 3.5.3' },
  { ip: '118.150.188.121', client: 'μTorrent 3.5.3' } ]
[ { ip: '222.164.100.163', client: '7.9.34.4908' } ]

检测到迅雷时

使用迅雷的 peers
[ { ip: '183.25.54.216', client: '-XL0012-溶 S 鑋亾#+4 厓' } ]
reading C:/Users/shf/AppData/Roaming/uTorrent/ipfilter.dat
wrote C:/Users/shf/AppData/Roaming/uTorrent/ipfilter.dat
ipfilter.dat updated
ipfilter.dat reloaded

uTorrent Log

[2018-11-19 16:50:25] Loaded ipfilter.dat (51 entries)

14517 次点击
所在节点    分享发现
38 条回复
zmj1316
2018-11-19 17:32:28 +08:00
这个好,可惜 utorrent 的 web API 上次爆出漏洞,不太敢开了......
SHF
2018-11-19 17:51:59 +08:00
@zmj1316 怕危险的话限制来源 IP 为 本机 IP 127.0.0.1 就可以仅本机访问了,uTorrent 设置 > 高级 > 只允许下列 IP 地址 访问。
kslr
2018-11-19 19:07:35 +08:00
目前有数据分析吗?迅雷比例是多少
Vanctol
2018-11-19 19:58:13 +08:00
Nice. 其他下载软件有这个功能吗? 比如 fdm
SHF
2018-11-19 20:10:59 +08:00
@kslr 不同的种子迅雷的比例不太一样,国外的种子比较少,国内的 60% 都是吸血雷。你可以随便找个种子下载,看看用户列表就有直观感受了。
xxhjkl
2018-11-19 20:16:04 +08:00
这么使用啊 这个脚本
SHF
2018-11-19 20:18:07 +08:00
@Vanctol FDM 是基于 Aria2 的,我看了看 Aria2 的 repo 里有人体力这个 issue 但是没解决,估计没有这个功能。https://github.com/aria2/aria2/issues/1146
qBittorrent 有一个 Enhanced Edition 也可以自动屏蔽迅雷,但是试了很多次 qBittorrent 比 uTorrent 慢太多了,跑不满带宽。
SHF
2018-11-19 20:19:10 +08:00
@xxhjkl 需要一些编程基础,暂时没有那种一键就能用的。
yanghong502
2018-11-19 22:02:57 +08:00
……之前在 pt 站的客户端列表看到一个迅雷。
Wenpo
2018-11-20 01:30:51 +08:00
屏蔽了又怎样呢
lovestudykid
2018-11-20 02:03:39 +08:00
迅雷客户端不给 bt 网络上传吗?
MayKiller
2018-11-20 02:18:32 +08:00
另外还有一个 qBittorrent 的也挺好用
https://github.com/c0re100/qBittorrent-Enhanced-Edition/releases
xmtudgzy
2018-11-20 06:53:50 +08:00
就是因为 uTorrent 2.2.1 不能屏蔽渣雷为首的吸血鬼,所以在公网 BT 上不敢用这个客户端 。
大声的问一句:老师,你这个脚本该怎么用?
chih758
2018-11-20 09:18:09 +08:00
chih758
2018-11-20 09:19:27 +08:00
好东西,我研究下看能不能移植到 qBittorrent 的 webUI
Removable
2018-11-20 09:30:16 +08:00
@yanghong502 #9 啊?是怎么通过验证的?
SHF
2018-11-20 10:24:18 +08:00
@lovestudykid 是的,吸血雷只从 BT 网络下载资源,然后只在迅雷用户之间内部分享(也许先分享给开了会员的人),破坏了 P2P 网络的公平性。
SHF
2018-11-20 10:25:57 +08:00
@MayKiller qBittorrent 比 uTorrent 慢太多了,跑不满带宽,你可以用一个热门的种子比如 ubuntu 镜像的种子试试,我这 qBittorrent 最快只有带宽的 30%,而 utorrent 能到带宽的 80% 以上。
edsheeran
2018-11-20 10:37:04 +08:00
@SHF tracker 問題?
SHF
2018-11-20 10:40:45 +08:00
@edsheeran 应该是 tracker 没有把迅雷的 client id 检测出来然后屏蔽掉,反而正常把其它做种的 peers 的 IP 给返回了。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/509327

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX