diff --git a/package.json b/package.json index fa78c37..caf17fa 100644 --- a/package.json +++ b/package.json @@ -52,10 +52,9 @@ "interface-connection": "^0.3.2", "lodash": "^4.17.5", "mafmt": "^6.0.0", - "multiaddr": "^4.0.0", + "multiaddr": "^5.0.0", "multistream-select": "^0.14.1", - "peer-id": "^0.10.7", - "peer-info": "^0.14.0", + "peer-info": "~0.14.1", "protons": "^1.0.1", "pull-abortable": "^4.1.1", "pull-handshake": "^1.1.4", diff --git a/src/circuit/hop.js b/src/circuit/hop.js index 2216915..017f35e 100644 --- a/src/circuit/hop.js +++ b/src/circuit/hop.js @@ -56,24 +56,27 @@ class Hop extends EE { */ handle (message, sh) { if (!this.config.enabled) { - return this.utils.writeResponse( + this.utils.writeResponse( sh, proto.CircuitRelay.Status.HOP_CANT_SPEAK_RELAY) + return sh.close() } // check if message is `CAN_HOP` if (message.type === proto.CircuitRelay.Type.CAN_HOP) { - return this.utils.writeResponse( + this.utils.writeResponse( sh, proto.CircuitRelay.Status.SUCCESS) + return sh.close() } // This is a relay request - validate and create a circuit const srcPeerId = PeerId.createFromBytes(message.dstPeer.id) if (srcPeerId.toB58String() === this.peerInfo.id.toB58String()) { - return this.utils.writeResponse( + this.utils.writeResponse( sh, proto.CircuitRelay.Status.HOP_CANT_RELAY_TO_SELF) + return sh.close() } const dstPeerId = PeerId.createFromBytes(message.dstPeer.id).toB58String() @@ -95,9 +98,10 @@ class Hop extends EE { const noPeer = (err) => { log.err(err) setImmediate(() => this.emit('circuit:error', err)) - return this.utils.writeResponse( + this.utils.writeResponse( sh, proto.CircuitRelay.Status.HOP_NO_CONN_TO_DST) + return sh.close() } let dstPeer diff --git a/src/listener.js b/src/listener.js index 3f7e98e..38c1501 100644 --- a/src/listener.js +++ b/src/listener.js @@ -35,7 +35,7 @@ module.exports = (swarm, options, connHandler) => { listener.listen = (ma, callback) => { callback = callback || (() => {}) - swarm.handle(multicodec.relay, (relayProto, conn) => { + swarm.handle(multicodec.relay, (_, conn) => { const sh = new StreamHandler(conn) sh.read((err, msg) => {