Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upget connected peer list and their progress #1095
Comments
This comment has been minimized.
This comment has been minimized.
|
You'd be best scraping a tracker or creating a backend where you send that information. The wire API can be found here: https://github.com/feross/bittorrent-protocol, but you can only query the stats between you as a peer and that peer. If the peers are TCP/UDP (Won't work on browser), you can get the IP using |
This comment has been minimized.
This comment has been minimized.
|
Btw, You might be able to get the info you need by listening to the torrent.on('wire', function (wire) {
var downloaded = 0
for (var index = 0, len = torrent.pieces.length; index < len; ++index) {
if (wire.peerPieces.get(index)) {
downloaded += (index === len - 1) ? torrent.lastPieceLength : torrent.pieceLength
}
}
var percentComplete = (downloaded / torrent.length) * 100
console.log('Peer ' + wire.addr + ' connected with ' + percentComplete + '% complete')
})(Untested, but something like that should work) |
This comment has been minimized.
This comment has been minimized.
|
@feross Thank you for your help. I will test the code later. just for information, is this okay to post such questions asking for help here? After all, the section is named as 'issues'. Or, should I post this to some place else, like StackOverflow? I would prefer to post here if this is not much a problem. |
This comment has been minimized.
This comment has been minimized.
|
Posting questions is fine, but ideally you would chat with others on https://gitter.im/feross/webtorrent first |

I want to use webtorrent in the browser. I need to get the list of connected peers and their progress. eg: 13.234.5.156, 95% ; 134.67.54.3, 100% etc.
I have looked into API section and found out
torrent.numPeersandtorrent.on('wire', function (wire) {}). but didn't find any specific tutorial/help for my requirement.torrent.numPeersreturns the total number of peers but I need connected peers. Also, it is mentionedtorrent.on('wire', function (wire) {})is emitted whenever a new peer is connected for this torrent. but how to get the IP of the peer?Is this feature available? If yes, can you please point me towards the right direction?