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