From a807acc296ff931cfcba8516d50a0a701e46df3d Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Tue, 28 Sep 2021 16:23:52 +1300 Subject: [PATCH] Allow customisation of tor port --- src/lib/constants.js | 1 + src/lib/utils/tor.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/constants.js b/src/lib/constants.js index 473ee54..ef6fde4 100644 --- a/src/lib/constants.js +++ b/src/lib/constants.js @@ -28,6 +28,7 @@ let constants = { tor: { enabled: true, // If false, everything else in this block has no effect. password: null, // If `null`, Bibliogram will run its own Tor process instead. + port: 9051, // If a password is provided, Bibliogram will connect to Tor on this port. (This is ignored when running its own Tor process.) for: { user_html: true, timeline_graphql: false, diff --git a/src/lib/utils/tor.js b/src/lib/utils/tor.js index 456af26..517697f 100644 --- a/src/lib/utils/tor.js +++ b/src/lib/utils/tor.js @@ -51,11 +51,11 @@ module.exports = new Promise(resolve => { /** @type {import("@deadcanaries/granax/lib/controller")} */ // @ts-ignore let tor - if (constants.tor.password == null) { + if (constants.tor.password == null || constants.tor.port == null) { // @ts-ignore tor = new granax() } else { - tor = new granax.TorController(connect(9051), {authOnConnect: false}) + tor = new granax.TorController(connect(constants.tor.port), {authOnConnect: false}) tor.authenticate(`"${constants.tor.password}"`, err => { if (err) console.log("Tor auth error:", err) })