-
Notifications
You must be signed in to change notification settings - Fork 4
/
ip.js
33 lines (24 loc) · 1.2 KB
/
ip.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var DHT = require('bittorrent-dht')
var magnet = require('magnet-uri')
var uri = 'magnet:?xt=urn:btih:4a7b842632ca42cdd3c8d54017a8da756839b84d&dn=D0112-Chacha.Choudhary.Sabu.Kaale.Tapu.Mein.pdf&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com'
var parsed = magnet(uri)
//console.log(parsed.infoHash) // 'e3811b9539cacff680e418124272177c47477157'
var dht = new DHT()
dht.listen(20000, function () {
console.log('now listening')
//console.log(dht.address());
})
dht.on('peer', function (peer, infoHash, from) {
//console.log(peer);
console.log(from);
console.log('found potential peer ' + peer.host + ':' + peer.port + ' through ' + from.address + ':' + from.port)
})
//find peers for the given torrent info hash
dht.lookup(parsed.infoHash)
// dht.on('node', function (node) {
// console.log(node);
// })
// dht.on('announce', function (peer, infoHash) {
// console.log(peer);
// console.log(infoHash)
// })