Browse Source

Upgrade to onionoo v1

pm2
Luke Childs 8 years ago
parent
commit
bd56da71bc
  1. 12
      lib/tor.js
  2. 2
      package.json

12
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)

2
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": {

Loading…
Cancel
Save