alanyang / dhtspider Goto Github PK
View Code? Open in Web Editor NEWBittorrent dht network spider
Bittorrent dht network spider
Hey,作者你好,我这段时间在研究dht爬虫,自己也写了一个,效果不是很好,就准备down下来大神的源码看一看,运行的过程中出了一些问题,不知道是不是我的环境不对?请教
-------------------- 分割线 上面是废话---------------------
问题:拿到代码跑了一晚上之后,发现输出的全部都是unensure的infohash,即get_peers 返回的infohash,announce_peer 一次也没有,所以很纳闷。这是我的问题,希望作者可以解答一下
如题,有什么特殊的原因吗?
根据bep_0005规定,响应findNode的res中r的id应为
{"id" : "<queried nodes id>", "nodes" : "<compact node info>"}
而在你的源码中在响应其他的节点的findNode请求时,返回的不是自己节点的id
onFindNodeRequest(message, address) {
const {t: tid, a: {id: nid, target: infohash}} = message
if (tid === undefined || target.length != 20 || nid.length != 20) {
return
}
this.send({
t: tid,
y: 'r',
r: {
id: Node.neighbor(nid, this.table.id),// 这里穿的参数为何不是this.table.id
nodes: Node.encodeNodes(this.table.first())
}
}, address)
}
根据你源码中的实现,this.table.id为你这个节点的id,Node.neighbor方法传入2个参数,取第一个参数的前6个,和第2个参数的后14位,将id重组。
源码中类似的实现也很多,请问为何这样实现,要变化返回的id?
虽然说重点信息应该是nodes字段中前8个‘有用’的node信息(ip和port),节点的id本身并不重要。
另外想延伸的讨论一下node的id在dht中扮演的角色,node的id是不是并没有太大的用处,因为重要的是节点中维护的table中的其他可用的node的ip和port。
如果有说错的地方请指出,谢谢回复
报错内容
const {Table, Node} = require('./table')
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/Users/long/gopath/src/github.com/alanyang/dhtspider/sample/index.js:3:21)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
执行命令 :node index.js
node版本
node --version
v5.9.1
Hi,
Is there possible to make a complete guide about how to make it working like on your sample website?
I mean, I did make it running and listening on port 6339, then i see scrolling hashes like this: https://vgy.me/AsjRDT.jpg , then what im supposed to do after?
I hope to get an answer, thank you!
static neighbor(target, id) { return Buffer.concat([target.slice(0, 6), id.slice(6)]) }
if I start the sample I get:
lib/spider.js:6
const {Table, Node} = require('./table')
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object. (/home/zibri/dhtspider/sample/index.js:3:21)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
http://engiy.com/ is good bt search. go language version of the open source?
看见Node模块里有一个neighbor的方法, 不知该方法的作用是什么, 并且为什么要进行slice的操作?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.