Compare commits
3 Commits
19ad44b066
...
4d6497c196
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d6497c196 | |||
| f83ae80b1f | |||
| cf7f63b496 |
3496
package-lock.json
generated
3496
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
65
src/get-exit-nodes.js
Normal file
65
src/get-exit-nodes.js
Normal file
@@ -0,0 +1,65 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const util = require('util');
|
||||
const Consensus = require('./tor/Consensus');
|
||||
const OR = require('./tor/OnionRouter');
|
||||
|
||||
const LogLevels = {
|
||||
off: 0,
|
||||
error: 1,
|
||||
warn: 2,
|
||||
info: 3,
|
||||
debug: 4
|
||||
}
|
||||
let logLevel = LogLevels.error;
|
||||
function timestamp() {
|
||||
const d = new Date().toISOString();
|
||||
return [d.slice(5, 5), d.slice(11, 8)].join(' ')
|
||||
}
|
||||
class Logger {
|
||||
debug(...args) {
|
||||
if (LogLevels.debug > logLevel) return;
|
||||
const [format, ...rest] = args;
|
||||
console.error(timestamp(), "D", util.format(format, ...rest));
|
||||
}
|
||||
info(...args) {
|
||||
if (LogLevels.info > logLevel) return;
|
||||
const [format, ...rest] = args;
|
||||
console.error(timestamp(), "I", util.format(format, ...rest));
|
||||
}
|
||||
warn(...args) {
|
||||
if (LogLevels.warn > logLevel) return;
|
||||
const [format, ...rest] = args;
|
||||
console.error(timestamp(), "W", util.format(format, ...rest));
|
||||
}
|
||||
error(...args) {
|
||||
if (LogLevels.error > logLevel) return;
|
||||
const [format, ...rest] = args;
|
||||
console.error(timestamp(), "E", util.format(format, ...rest));
|
||||
}
|
||||
}
|
||||
|
||||
(async function main(args) {
|
||||
try {
|
||||
const ip_only = args[0] === '--ip-only';
|
||||
const logger = new Logger();
|
||||
const home = process.env.HOME || process.env.USERPROFILE;
|
||||
const app_cache_path = path.join(home, '.cache', 'mini-tor-js');
|
||||
const cached_consensus_path = path.join(app_cache_path, 'cached-consensus')
|
||||
fs.mkdirSync(app_cache_path, {recursive: true});
|
||||
// Load consensus
|
||||
const consensus = new Consensus(logger);
|
||||
await consensus.fetch(cached_consensus_path);
|
||||
consensus.set_allowed_dir_ports(80, 443);
|
||||
|
||||
const routers = consensus.get_onion_routers_by_criteria({
|
||||
flags: OR.valid | OR.exit
|
||||
});
|
||||
for (const router of routers) {
|
||||
if (ip_only) console.log(router.ip);
|
||||
else console.log(router.name, router.ip, router.dir_port, router.or_port);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
})(process.argv.slice(2))
|
||||
@@ -13,16 +13,15 @@ function authority_onion_router(name, ip, or_port, dir_port) {
|
||||
}
|
||||
}
|
||||
const authorities = [
|
||||
//authority_onion_router("dizum", "194.109.206.212", 443, 80),
|
||||
authority_onion_router("Serge", "66.111.2.131", 9001, 9030),
|
||||
authority_onion_router("moria1", "128.31.0.34", 9101, 9131),
|
||||
//authority_onion_router("tor26", "86.59.21.38", 443, 80},
|
||||
authority_onion_router("bastet", "204.13.164.118", 443, 80),
|
||||
//authority_onion_router("maatuska", "171.25.193.9", 80, 443),
|
||||
authority_onion_router("dannenberg", "193.23.244.244", 443, 80),
|
||||
authority_onion_router("Faravahar", "154.35.175.225", 443, 80),
|
||||
authority_onion_router("gabelmoo", "131.188.40.189", 443, 80),
|
||||
authority_onion_router("longclaw", "199.58.81.140", 443, 80),
|
||||
authority_onion_router("dizum", "45.66.35.11", 443, 80), //OK
|
||||
authority_onion_router("moria1", "128.31.0.39", 9101, 9131),//OK
|
||||
authority_onion_router("tor26", "217.196.147.77", 443, 80), //OK
|
||||
authority_onion_router("bastet", "204.13.164.118", 443, 80), //OK
|
||||
authority_onion_router("maatuska", "171.25.193.9", 80, 443), //OK
|
||||
authority_onion_router("dannenberg", "193.23.244.244", 443, 80), //OK
|
||||
authority_onion_router("Faravahar", "216.218.219.41", 443, 80), //OK
|
||||
authority_onion_router("gabelmoo", "131.188.40.189", 443, 80), //OK
|
||||
authority_onion_router("longclaw", "199.58.81.140", 443, 80), //OK
|
||||
]
|
||||
const router_status_flags = [
|
||||
"Authority",
|
||||
|
||||
Reference in New Issue
Block a user