diff --git a/index.js b/index.js index b44892d..d769d42 100644 --- a/index.js +++ b/index.js @@ -39,7 +39,7 @@ module.exports = function (metadata) { // TODO: throw or disregard invalid metadata? //throw new Error('ut_metadata constructed with invalid metadata') } - + if (info) this._gotMetadata(info) } @@ -50,7 +50,7 @@ module.exports = function (metadata) { } ut_metadata.prototype.onExtendedHandshake = function (handshake) { - if (!handshake.m.ut_metadata) { + if (!handshake.m || !handshake.m.ut_metadata) { return this.emit('warning', new Error('Peer does not support ut_metadata')) } if (!handshake.metadata_size) {