From bd56da71bcaa9b76d4d11bc1eccbb7226c2e6af9 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Mon, 26 Dec 2016 17:20:57 +0700 Subject: [PATCH] Upgrade to onionoo v1 --- lib/tor.js | 12 ++++++++---- package.json | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/tor.js b/lib/tor.js index d976322..30c0b93 100644 --- a/lib/tor.js +++ b/lib/tor.js @@ -1,10 +1,12 @@ -const onionoo = require('onionoo'); +const Onionoo = require('onionoo'); +const onionoo = new Onionoo(); module.exports = { listNodes: query => { return onionoo .summary(query) - .then(summary => { + .then(response => { + const summary = response.body; const nodes = summary.relays.concat(summary.bridges); return Promise.all(nodes.map(node => module.exports.node(node.f || node.h))); }); @@ -12,7 +14,8 @@ module.exports = { node: id => { return onionoo .details({ lookup: id }) - .then(details => { + .then(response => { + const details = response.body; if(details.relays[0]) { details.relays[0].type = 'relay'; return details.relays[0]; @@ -25,7 +28,8 @@ module.exports = { bandwidth: id => { return onionoo .bandwidth({ lookup: id }) - .then(bandwidth => { + .then(response => { + const bandwidth = response.body; try { const lastMonth = bandwidth.relays[0].write_history['1_month']; return lastMonth.values.map(value => value * lastMonth.factor) diff --git a/package.json b/package.json index 8c7a9da..e36f31f 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "express-minify-html": "^0.6.0", "moment": "^2.14.1", "nunjucks": "^2.5.0", - "onionoo": "^0.5.1", + "onionoo": "^1.0.0", "pretty-bytes": "^4.0.2" }, "devDependencies": {