ws client: ignore offers/answers from self

This commit is contained in:
Feross Aboukhadijeh 2015-05-20 06:40:25 -07:00
parent a80f2559e7
commit bb145cce14
2 changed files with 7 additions and 0 deletions

View File

@ -38,6 +38,8 @@ function Client (peerId, port, torrent, opts) {
? peerId
: new Buffer(peerId, 'hex')
self._port = port
self._peerIdHex = self._peerId.toString('hex')
self._infoHash = Buffer.isBuffer(torrent.infoHash)
? torrent.infoHash
: new Buffer(torrent.infoHash, 'hex')

View File

@ -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
if (data.offer) {
peer = new Peer({