Add alternative method to fetch user

This commit is contained in:
Cadence Fish
2020-02-03 02:24:14 +13:00
parent 96fa4758c0
commit 272f4b6e3b
10 changed files with 191 additions and 65 deletions

View File

@@ -44,12 +44,12 @@ 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) {
// @ts-ignore
tor = new granax()
} else {
tor = new granax.TorController(connect(9051), {authOnConnect: false})
tor.authenticate(`"${constants.tor_password}"`, err => {
tor.authenticate(`"${constants.tor.password}"`, err => {
if (err) console.log("Tor auth error:", err)
})
}

View File

@@ -21,8 +21,8 @@ class TorSwitcher {
* @returns {Promise<T>}
* @template T the return value of the test function
*/
request(url, test) {
if (this.torManager) {
request(type, url, test) {
if (this.torManager && constants.tor.for[type]) {
return this.torManager.request(url, test)
} else {
return request(url).then(res => test(res))
@@ -32,7 +32,7 @@ class TorSwitcher {
const switcher = new TorSwitcher()
if (constants.use_tor) {
if (constants.tor.enabled) {
require("./tor").then(torManager => {
if (torManager) switcher.setManager(torManager)
})