diff --git a/client.js b/client.js index 4730fac..daf3224 100644 --- a/client.js +++ b/client.js @@ -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') diff --git a/lib/websocket-tracker.js b/lib/websocket-tracker.js index e9e7388..f2d98aa 100644 --- a/lib/websocket-tracker.js +++ b/lib/websocket-tracker.js @@ -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({