diff --git a/src/utils/TorManager.cpp b/src/utils/TorManager.cpp index 830dbd6..a445654 100644 --- a/src/utils/TorManager.cpp +++ b/src/utils/TorManager.cpp @@ -41,6 +41,7 @@ void TorManager::init() { auto state = m_process.state(); if (m_localTor && (state == QProcess::ProcessState::Running || state == QProcess::ProcessState::Starting)) { m_process.kill(); + m_started = false; } featherTorPort = config()->get(Config::torManagedPort).toString().toUShort(); @@ -48,6 +49,7 @@ void TorManager::init() { void TorManager::stop() { m_process.kill(); + m_started = false; } void TorManager::start() { @@ -168,6 +170,10 @@ void TorManager::handleProcessError(QProcess::ProcessError error) { } bool TorManager::unpackBins() { + if (m_unpacked) { + return true; + } + QString torBin = "tor"; #if defined(Q_OS_WIN) torBin += ".exe"; @@ -211,6 +217,7 @@ bool TorManager::unpackBins() { | QFile::ReadOwner | QFile::ReadGroup | QFile::ReadOther); #endif + m_unpacked = true; return true; } @@ -253,6 +260,10 @@ bool TorManager::shouldStartTorDaemon() { return false; } + if (m_started) { + return true; + } + // Don't start a Tor daemon if one is already running if (Utils::portOpen(torHost, torPort)) { return false; @@ -267,10 +278,8 @@ bool TorManager::shouldStartTorDaemon() { } // Tor daemon (or other service) is already running on our port (19450) + if (Utils::portOpen(featherTorHost, featherTorPort)) { - // TODO: this is a hack, fix it later - config()->set(Config::socks5Host, featherTorHost); - config()->set(Config::socks5Port, featherTorPort); return false; } diff --git a/src/utils/TorManager.h b/src/utils/TorManager.h index 16bf76c..a09b710 100644 --- a/src/utils/TorManager.h +++ b/src/utils/TorManager.h @@ -64,6 +64,7 @@ private: bool m_stopRetries = false; bool m_localTor; bool m_started = false; + bool m_unpacked = false; QTimer *m_checkConnectionTimer; }; diff --git a/src/utils/nodes.cpp b/src/utils/nodes.cpp index bcbd26e..6ff97cd 100644 --- a/src/utils/nodes.cpp +++ b/src/utils/nodes.cpp @@ -208,7 +208,8 @@ void Nodes::connectToNode(const FeatherNode &node) { } if (config()->get(Config::proxy).toInt() == Config::Proxy::Tor && config()->get(Config::torOnlyAllowOnion).toBool()) { - if (!node.isOnion()) { + if (!node.isOnion() && !node.isLocal()) { + // We only want to connect to .onion nodes, but local nodes get an exception. return; } }