From 1968e8ac104b1c0fbf87c825cf4d233ea24bdaed Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sun, 11 May 2014 14:21:47 -0700 Subject: [PATCH 1/4] 2.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7ada3a6..02ce643 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ut_metadata", "description": "Extension for Peers to Send Metadata Files (BEP 9)", - "version": "1.4.0", + "version": "2.0.0", "author": { "name": "Feross Aboukhadijeh", "email": "feross@feross.org", From 82a02fd81a711fa6fe833b20c39d7edd53197556 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sun, 11 May 2014 14:23:19 -0700 Subject: [PATCH 2/4] throw exception when metadata is bad --- index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index b44892d..42ec93c 100644 --- a/index.js +++ b/index.js @@ -36,10 +36,9 @@ module.exports = function (metadata) { // if buffer fails to decode or there is no info key, then metadata is corrupt info = bncode.encode(bncode.decode(metadata).info) } catch (err) { - // TODO: throw or disregard invalid metadata? - //throw new Error('ut_metadata constructed with invalid metadata') + throw new Error('`ut_metadata` constructed with corrupt/invalid metadata') } - + if (info) this._gotMetadata(info) } From c998828d7260bf8b2ccd3d6454fb87f423eb3f0b Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sun, 11 May 2014 14:32:49 -0700 Subject: [PATCH 3/4] improve invalid metadata test --- test/fetch.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/fetch.js b/test/fetch.js index 2070239..019ca3d 100644 --- a/test/fetch.js +++ b/test/fetch.js @@ -122,7 +122,7 @@ test('fetch() large torrent', function (t) { } else if (ext === 'ut_metadata') { // note: this should get called twice, once for each block of the ubuntu metadata t.pass('got extended ut_metadata message') - + // this is emitted for consistency's sake, but it's ignored // by the user since the ut_metadata package handles the // complexities internally @@ -142,7 +142,7 @@ test('discard invalid metadata', function (t) { wire1.pipe(wire2).pipe(wire1) var invalidMetadata = metadata.slice(0) - invalidMetadata[0] = 99 // mess up the first byte of the metadata + invalidMetadata[55] = 65 // mess up a byte in the info block wire1.use(ut_metadata(invalidMetadata)) wire2.use(ut_metadata()) @@ -163,4 +163,3 @@ test('discard invalid metadata', function (t) { wire1.handshake(parsedTorrent.infoHash, id1) }) - From 1e19a567ff926f5f8992db18ac776852a9fb7b3e Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sun, 11 May 2014 14:33:03 -0700 Subject: [PATCH 4/4] 2.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 02ce643..b136975 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ut_metadata", "description": "Extension for Peers to Send Metadata Files (BEP 9)", - "version": "2.0.0", + "version": "2.0.1", "author": { "name": "Feross Aboukhadijeh", "email": "feross@feross.org",