uTorrent 自动屏蔽迅雷脚本
GitHub: https://github.com/ShenHongFei/utorrent-block-xunlei
方法
屏蔽列表
-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)
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.