bittorrent

How to convert torrent info hash for scrape?

ぃ、小莉子 提交于 2019-12-30 07:13:04
问题 I have a torrent hash from the magnet link. For example: fda164e7af470f83ea699a529845a9353cc26576 When I try to get information about leechers and peers I should request: http://tracker.publicbt.com/scrape?info_hash=??? How should I convert info hash for this request? Is it url encoding or becoding? how? In PHP. 回答1: It's a raw hexadecimal representation. Use pack() with H to convert it. Then URL encode it. 回答2: Got this python snippet from a colleague, r = '' s =

Given a .torrent file how do I generate a magnet link in python? [closed]

旧时模样 提交于 2019-12-28 05:10:52
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I need a way to convert .torrents into magnet links. Would like a way to do so in python. Are there any libraries that already do this? 回答1: You can do this with the bencode module, extracted from BitTorrent. To

How to UrlEncode a Sha1 string for a torrent tracker

做~自己de王妃 提交于 2019-12-25 08:29:52
问题 I try to send an HTTP request to a Torrent Tracker that must be with this form: bt1.archive.org GET /announce?info_hash=ACC3B2E433D7C7475ABB5941B5681CB7A1EA26E2 HTTP/1.1 Host: bt1.archive.org Connection: keep-alive Accept: text/html User-Agent: CSharp But the info_hash parameter must be UrlEncoded and it must look like: %AC%C3%B2%E4%33%D7%C7%47%5A%BB%59%41%B5%68%1C%B7%A1%EA%26%E2 , So I use System.Net.WebUtility.UrlEncode(info_hash) And the output is the same as the input. I think the answer

How to interpret 'nodes' in a DHT response?

南楼画角 提交于 2019-12-25 07:46:32
问题 I'm reading through BEP-0005 and I don't really understand how the node IDs translate to (IP, port) pairs. Consider the following code: import bencode import random import socket import pprint # Generate a 160-bit (20-byte) random node ID. rand = lambda: ''.join([chr(random.randint(0, 255)) for _ in range(20)]) my_id = rand() get_peers = {"t": '0f', "y": "q", "q": "get_peers", "a": {"id": my_id, "info_hash": '\xd9\x9d\x14\x8c\xf7\xb5\xee' '\x84</\x806\xd6d\x13\xb3\xe3\x0f\x1b\xe7'} } get

Mainline DHT unspecified entry in bencoded dictionary

微笑、不失礼 提交于 2019-12-24 10:36:56
问题 I have found an entry in a bencoded dictionary in DHT traffic, generated by BitTorrent, which I do not understand, nor can find anything about in the DHT specification at http://bittorrent.org/beps/bep_0005.html. Example of packet query and response with wireshark: query = {"a":{"id":".=...4...R..%..s~..;"}, "q":"ping", "t":"..oo", "v":"UThK", "y":"q"} response = {"r":{"id":"..=..x......o....w/%"}, "t":"..oo", "v":"UT..", "y":"r"} full hex dump can be found here: http://pastebin.com/SMB4f8LR.

Python3.6 how to install libtorrent?

偶尔善良 提交于 2019-12-24 09:58:36
问题 Does libtorrent support python3 now? if supported how to install it . I want to code a DHT Crawler with python3 , i don't know why my code alaways got Connection reset by peer error , so i want to use libtorrent , if there are another lib , i'm happy to use it . My biggest problem is , conversing the infohash to torrent file . Could it be a code problem? class Crawler(Maga): async def handler(self, infohash, addr): fetchMetadata(infohash, addr) def fetchMetadata(infohash, addr, timeout=5):

Can somebody shed a light what this strange DHT response means?

本秂侑毒 提交于 2019-12-24 03:58:31
问题 Sometimes I receive this strange responses from other nodes. Transaction id match to my request transaction id as well as the remote IP so I tend to believe that node responded with this but it looks like sort of a mix of response and request d1:q9:find_node1:rd2:id20:.éV0özý.?tj­N.?.!2:ip4:DÄ.^7:nodes.v26:.ï?M.:iSµLW.Ðä¸úzDÄ.^æCe1:t2:..1:y1:re Worst of all is that it is malformed. Look at 7:nodes.v it means that I add nodes.v to the dictionary. It is supposed to be 5:nodes. So, I'm lost.

How to parse Ip and port from http tracker response

家住魔仙堡 提交于 2019-12-24 03:07:25
问题 I am sending a request to a tracker and get a response d8:completei2e10:downloadedi1e10:incompletei1e8:intervali1971e12:min intervali985e5:peers18:\235'\027\253\000\000\331e57\374-\033"\022,\270\302e How to get Peers list or peer IP and port from this response 回答1: The response from the tracker is bencoded . Adding some whitespace for clarity: d 8:complete i2e 10:downloaded i1e 10:incomplete i1e 8:interval i1971e 12:min interval i985e 5:peers 18:\235'\027\253\000\000\331e57\374-\033"\022,\270

Why is hashing the info dict turning out wrong?

百般思念 提交于 2019-12-24 00:46:38
问题 I have been trying for ages to get this hashing thing for BitTorrent to work in Java but it always becomes wrong. I have narrowed it down to a few lines of code where I'm 99% sure the problem is: Bencode bencode = new Bencode(Charset.forName("UTF-8")); byte[] fileBytes = new byte[33237]; Map<String, Object> dict = bencode.decode(fileBytes, Type.DICTIONARY); Map infoMap = (Map) object.get("info"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); BencodeOutputStream bos = new

bittorrent DHT detailed specification

人走茶凉 提交于 2019-12-24 00:42:44
问题 In my new weekend project I decided to write an bittorrent client from scratch, no ready to use libraries at all. After two days looking for documentation I'm already about to give up :smile:. I know there are the BEPs, but they are far from enough to understand all the specification. After reading a lot more I think the tracker and peer protocols seems to be old and easy to understand/implement (yes, I know, to write a good code with balance, peer selection, optimizations, this is not easy