mirror of
https://github.com/feather-wallet/feather.git
synced 2024-11-17 01:37:53 +00:00
TorManager: fix tor connection issue after crash
This commit is contained in:
parent
a09b15f79e
commit
b75ec4381a
4 changed files with 12 additions and 6 deletions
|
@ -638,7 +638,7 @@ void WindowManager::onProxySettingsChanged() {
|
|||
QString host = conf()->get(Config::socks5Host).toString();
|
||||
quint16 port = conf()->get(Config::socks5Port).toString().toUShort();
|
||||
|
||||
if (conf()->get(Config::proxy).toInt() == Config::Proxy::Tor && !torManager()->isLocalTor()) {
|
||||
if (conf()->get(Config::proxy).toInt() == Config::Proxy::Tor && (!torManager()->isLocalTor() || torManager()->isAlreadyRunning())) {
|
||||
host = torManager()->featherTorHost;
|
||||
port = torManager()->featherTorPort;
|
||||
}
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
|
||||
#include "utils/TorManager.h"
|
||||
|
||||
#include <QScreen>
|
||||
#include <QDesktopServices>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include "utils/config.h"
|
||||
#include "utils/Utils.h"
|
||||
|
@ -122,7 +120,7 @@ void TorManager::checkConnection() {
|
|||
this->setConnectionState(false);
|
||||
}
|
||||
|
||||
else if (m_localTor) {
|
||||
else if (m_localTor && !m_alreadyRunning) {
|
||||
QString host = conf()->get(Config::socks5Host).toString();
|
||||
quint16 port = conf()->get(Config::socks5Port).toString().toUShort();
|
||||
this->setConnectionState(Utils::portOpen(host, port));
|
||||
|
@ -236,10 +234,15 @@ bool TorManager::isStarted() {
|
|||
return m_started;
|
||||
}
|
||||
|
||||
bool TorManager::isAlreadyRunning() {
|
||||
return m_alreadyRunning;
|
||||
}
|
||||
|
||||
bool TorManager::shouldStartTorDaemon() {
|
||||
QString torHost = conf()->get(Config::socks5Host).toString();
|
||||
quint16 torPort = conf()->get(Config::socks5Port).toString().toUShort();
|
||||
QString torHostPort = QString("%1:%2").arg(torHost, QString::number(torPort));
|
||||
m_alreadyRunning = false;
|
||||
|
||||
// Don't start a Tor daemon if Feather is run with Torsocks
|
||||
if (Utils::isTorsocks()) {
|
||||
|
@ -287,6 +290,7 @@ bool TorManager::shouldStartTorDaemon() {
|
|||
// Tor daemon (or other service) is already running on our port (19450)
|
||||
|
||||
if (Utils::portOpen(featherTorHost, featherTorPort)) {
|
||||
m_alreadyRunning = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
bool unpackBins();
|
||||
bool isLocalTor();
|
||||
bool isStarted();
|
||||
bool isAlreadyRunning();
|
||||
SemanticVersion getVersion(const QString &fileName);
|
||||
|
||||
static TorManager* instance();
|
||||
|
@ -62,9 +63,10 @@ private:
|
|||
QProcess *m_process;
|
||||
int m_restarts = 0;
|
||||
bool m_stopRetries = false;
|
||||
bool m_localTor;
|
||||
bool m_localTor = false;
|
||||
bool m_started = false;
|
||||
bool m_unpacked = false;
|
||||
bool m_alreadyRunning = false;
|
||||
QTimer *m_checkConnectionTimer;
|
||||
};
|
||||
|
||||
|
|
|
@ -230,7 +230,7 @@ void Nodes::connectToNode(const FeatherNode &node) {
|
|||
|
||||
QString proxyAddress;
|
||||
if (useSocks5Proxy(node)) {
|
||||
if (conf()->get(Config::proxy).toInt() == Config::Proxy::Tor && !torManager()->isLocalTor()) {
|
||||
if (conf()->get(Config::proxy).toInt() == Config::Proxy::Tor && (!torManager()->isLocalTor() || torManager()->isAlreadyRunning())) {
|
||||
proxyAddress = QString("%1:%2").arg(torManager()->featherTorHost, QString::number(torManager()->featherTorPort));
|
||||
} else {
|
||||
proxyAddress = QString("%1:%2").arg(conf()->get(Config::socks5Host).toString(),
|
||||
|
|
Loading…
Reference in a new issue