def announce():
'''/announce.php?info_hash=&peer_id=&ip=&port=&uploaded=&downloaded=&left=&numwant=&key=&compact=1'''
ip = request.args.get('ip')
port = request.args.get('port')
if not ip or not port:
return abort(404)
address = (ip, int(port))
binhash = urlparse.parse_qs(request.query_string)['info_hash'][0]
country = geoip.country_code_by_addr(ip)
if country not in ('CN','TW','JP','HK', 'KR'):
return abort(404)
rpc.announce(binhash.encode('hex'), address)
return bencode({'peers': '', 'interval': 86400})
评论列表
文章目录