mirror of
https://github.com/logos-storage/bittorrent-tracker.git
synced 2026-01-09 16:33:06 +00:00
ws client: ignore offers/answers from self
This commit is contained in:
parent
a80f2559e7
commit
bb145cce14
@ -38,6 +38,8 @@ function Client (peerId, port, torrent, opts) {
|
|||||||
? peerId
|
? peerId
|
||||||
: new Buffer(peerId, 'hex')
|
: new Buffer(peerId, 'hex')
|
||||||
self._port = port
|
self._port = port
|
||||||
|
self._peerIdHex = self._peerId.toString('hex')
|
||||||
|
|
||||||
self._infoHash = Buffer.isBuffer(torrent.infoHash)
|
self._infoHash = Buffer.isBuffer(torrent.infoHash)
|
||||||
? torrent.infoHash
|
? torrent.infoHash
|
||||||
: new Buffer(torrent.infoHash, 'hex')
|
: new Buffer(torrent.infoHash, 'hex')
|
||||||
|
|||||||
@ -145,6 +145,11 @@ WebSocketTracker.prototype._onSocketData = function (data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self.client._peerIdHex === common.binaryToHex(data.peer_id)) {
|
||||||
|
// ignore offers/answers from this client
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var peer
|
var peer
|
||||||
if (data.offer) {
|
if (data.offer) {
|
||||||
peer = new Peer({
|
peer = new Peer({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user