You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
678 B
24 lines
678 B
9 years ago
|
const onionoo = require('onionoo');
|
||
|
|
||
|
module.exports = {
|
||
|
listNodes: query => {
|
||
|
return onionoo
|
||
|
.summary(query)
|
||
|
.then(summary => {
|
||
|
const nodes = summary.relays.concat(summary.bridges);
|
||
|
return Promise.all(nodes.map(node => onionoo.details({ lookup: node.f || node.h })));
|
||
|
})
|
||
|
.then(summaryDetails => {
|
||
|
return summaryDetails.map(details => {
|
||
|
if(details.relays[0]) {
|
||
|
details.relays[0].type = 'relay';
|
||
|
return details.relays[0];
|
||
|
} else if(details.bridges[0]) {
|
||
|
details.bridges[0].type = 'bridge';
|
||
|
return details.bridges[0];
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
};
|