mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-22 19:49:28 +00:00
proxy: fix only allow onion services with feather managed daemon
This commit is contained in:
parent
199e085709
commit
c11ca77599
3 changed files with 15 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ private:
|
|||
bool m_stopRetries = false;
|
||||
bool m_localTor;
|
||||
bool m_started = false;
|
||||
bool m_unpacked = false;
|
||||
QTimer *m_checkConnectionTimer;
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue