diff --git a/src/listener.js b/src/listener.js index f04b6e5..839f9d1 100644 --- a/src/listener.js +++ b/src/listener.js @@ -24,6 +24,12 @@ module.exports = (handler) => { // Avoid uncaught errors cause by unstable connections socket.on('error', noop) + if (socket.remoteAddress === undefined || + socket.remotePort === undefined) { + log('connection closed before p2p connection made') + return + } + const addr = getMultiaddr(socket) log('new connection', addr.toString())