From 214f33fd05458f7f148f85cf2080c41a56ab73b9 Mon Sep 17 00:00:00 2001 From: Nekun Date: Sun, 4 Apr 2021 22:46:48 +0000 Subject: [PATCH] Add tor-host option --- src/main.cpp | 3 +++ src/utils/tor.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1df7390..97dc191 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -48,6 +48,9 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) { QCommandLineOption useLocalTorOption(QStringList() << "use-local-tor", "Use system wide installed Tor instead of the bundled."); parser.addOption(useLocalTorOption); + QCommandLineOption torHostOption(QStringList() << "tor-host", "Address of running Tor instance.", "torHost"); + parser.addOption(torHostOption); + QCommandLineOption torPortOption(QStringList() << "tor-port", "Port of running Tor instance.", "torPort"); parser.addOption(torPortOption); diff --git a/src/utils/tor.cpp b/src/utils/tor.cpp index 1f6d186..3d1a0f4 100644 --- a/src/utils/tor.cpp +++ b/src/utils/tor.cpp @@ -23,11 +23,14 @@ Tor::Tor(AppContext *ctx, QObject *parent) this->torDir = Config::defaultConfigDir().filePath("tor"); this->torDataPath = QDir(this->torDir).filePath("data"); - if (m_ctx->cmdargs->isSet("tor-port")) { - Tor::torPort = m_ctx->cmdargs->value("tor-port").toUShort(); + if (m_ctx->cmdargs->isSet("tor-port") || m_ctx->cmdargs->isSet("tor-host")) { + if (m_ctx->cmdargs->isSet("tor-host")) + Tor::torHost = m_ctx->cmdargs->value("tor-host"); + if (m_ctx->cmdargs->isSet("tor-port")) + Tor::torPort = m_ctx->cmdargs->value("tor-port").toUShort(); this->localTor = true; if (!Utils::portOpen(Tor::torHost, Tor::torPort)) { - this->errorMsg = QString("--tor-port was specified but no running Tor instance was found on port %1.").arg(QString::number(Tor::torPort)); + this->errorMsg = QString("--tor-host || --tor-port were specified but no running Tor instance was found on %1:%2.").arg(Tor::torHost,QString::number(Tor::torPort)); } return; }