BitTorrent的追踪宣布问题 [英] BitTorrent tracker announce problem

查看:253
本文介绍了BitTorrent的追踪宣布问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在写一个BitTorrent客户端,主要是出于好奇,但部分出于改善我的C#技能的愿望抛业余时间一点点。



我一直在使用理论维基作为我的指导。我已经建立了类处理BEncoding,这我是非常有信心的库;主要是因为该完整性检查是分析后,立即重新从我的内部表示原来的.torrent文件,然后凑和比较。



接下来就是把跟踪宣布合作。在这里,我打了一个绊脚石,因为跟踪不拒绝非常有用的错误信息我的要求



举个例子,在最新堆栈溢出数据库转储。我的代码生成以下宣布的URI:

 
http://208.106.250.207:8192/announce?info_hash=-%CA8%C1% C9rDb%ADL%ED%B4%2A%15I%80Z%B8%F%C的peer_id = 01234567890123456789和端口= 6881&上传= 0&下载= 0左= 0&紧凑= 0&no_peer_id = 0&事件=启动

跟踪器对我的代码响应:

 
D14:失败reason32:无效的信息哈希和/或对IDE

跟踪器的该字符串响应投进Chrome的地址栏:

 
D8:completei2e11:外部IP13:168.7.249.11110:incompletei0e8:intervali600e5:peerslee



的peer_id是(有效)垃圾,但它改变的东西明智的(冒充广泛使用的客户端)不会改变任何东西。



就像我说的,我敢肯定,我拉资讯正确解释了和散列(SHA1)像我应该和对等ID完全形成了。



我的猜测是,我做了一些次要的事情愚蠢错误,并会欣赏察觉其所以然任何帮助。



它一种很难猜测什么代码将是相关的(而且也远得多,只是后)。不过,我会尽力和张贴任何要求。



修改

我是不是十六进制编码的。info_hash,哪种类型的帮助



这是取生成URI,并尝试对获取的响应代码:

  // URI是上面
的WebRequest REQ = WebRequest.Create(URI);
WebResponse的RESP = req.GetResponse();
流流= resp.GetResponseStream();


解决方案

MonoTorrent 是自带的单BitTorrent的实现。
在的 HTTPTracker类有一个 CreateAnnounceString 方法。
也许你可以比较怎么说方法做你的实现?
(你可能需要创建 AnnounceParameters 实例,其中追捕。)


I've been throwing a little bit of spare time at writing a BitTorrent client, mostly out of curiosity but partly out of a desire to improve my c# skills.

I've been using the theory wiki as my guide. I've built up a library of classes for handling BEncoding, which I'm quite confident in; basically because the sanity check is to regenerate the original .torrent file from my internal representation immediately after parsing, then hash and compare.

The next stage is to get tracker announces working. Here I hit a stumbling block, because trackers reject my requests without terribly useful error messages.

Take, for instance, the latest stack overflow database dump. My code generates the following announce URI:

http://208.106.250.207:8192/announce?info_hash=-%CA8%C1%C9rDb%ADL%ED%B4%2A%15i%80Z%B8%F%C&peer_id=01234567890123456789&port=6881&uploaded=0&downloaded=0&left=0&compact=0&no_peer_id=0&event=started

The tracker's response to my code:

d14:failure reason32:invalid info hash and/or peer ide

The tracker's response to that string dropped into Chrome's address bar:

d8:completei2e11:external ip13:168.7.249.11110:incompletei0e8:intervali600e5:peerslee

The peer_id is (valid) garbage, but changing it to something sensible (impersonating a widely used client) doesn't change anything.

Like I said, I'm pretty sure I'm pulling the info dictionary out properly and hashing (SHA1) like I should, and the peer id is well formed.

My guess is I'm doing some minor thing stupidly wrong, and would appreciate any help in spotting what it is exactly.

Its kind of hard to guess what code would be pertinent (and there's far to much to just post). However, I'll try and post anything asked for.

EDIT
I wasn't hex encoding the info_hash, which sort of helps.

This is the code that takes the generates URI and try's to fetch a response:

//uri is the above
WebRequest req = WebRequest.Create(uri);
WebResponse resp = req.GetResponse();
Stream stream = resp.GetResponseStream();

解决方案

MonoTorrent is a BitTorrent implementation that comes with Mono. In the HTTPTracker class there is a CreateAnnounceString method. Maybe you can compare your implementation with how that method is doing it? (You probably need to hunt down where the AnnounceParameters instance is created.)

这篇关于BitTorrent的追踪宣布问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆