From 829a12be35c82c6586a2315c955037aa5895146b Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Wed, 3 Apr 2019 00:27:37 +0100 Subject: [PATCH] fix(p2p): additional myself check --- src/background/p2p.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/background/p2p.js b/src/background/p2p.js index 5b1d422..a5e9f53 100644 --- a/src/background/p2p.js +++ b/src/background/p2p.js @@ -116,6 +116,11 @@ class p2p { return; } + if(data.peerId === this.peerId) { + logT('p2p', 'try connection to myself, ignore', this.peerId) + return; + } + for(const peer of this.clients) { if(peer.peerId === data.peerId) { // already connected from different interface @@ -544,6 +549,13 @@ class p2p { return; } + // ignore myself check + if(data.peerId === this.peerId) { + logT('p2p', 'try connection to myself, ignore', this.peerId) + rawSocket.destroy() + return; + } + for(let peer of this.peers) { if(peer.peerId === data.peerId) { // already connected from different interface