Skip to content

Commit bb145cc

Browse files
committed
ws client: ignore offers/answers from self
1 parent a80f255 commit bb145cc

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

client.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ function Client (peerId, port, torrent, opts) {
3838
? peerId
3939
: new Buffer(peerId, 'hex')
4040
self._port = port
41+
self._peerIdHex = self._peerId.toString('hex')
42+
4143
self._infoHash = Buffer.isBuffer(torrent.infoHash)
4244
? torrent.infoHash
4345
: new Buffer(torrent.infoHash, 'hex')

lib/websocket-tracker.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ WebSocketTracker.prototype._onSocketData = function (data) {
145145
})
146146
}
147147

148+
if (self.client._peerIdHex === common.binaryToHex(data.peer_id)) {
149+
// ignore offers/answers from this client
150+
return
151+
}
152+
148153
var peer
149154
if (data.offer) {
150155
peer = new Peer({

0 commit comments

Comments
 (0)