|
|
|
@ -50,6 +50,13 @@ Tor::Tor(AppContext *ctx, QObject *parent)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Don't spawn Tor on default port to avoid conflicts
|
|
|
|
|
Tor::torPort = 19450;
|
|
|
|
|
if (Utils::portOpen(Tor::torHost, Tor::torPort)) {
|
|
|
|
|
this->localTor = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qDebug() << "Using embedded tor instance";
|
|
|
|
|
m_process.setProcessChannelMode(QProcess::MergedChannels);
|
|
|
|
|
|
|
|
|
@ -58,6 +65,10 @@ Tor::Tor(AppContext *ctx, QObject *parent)
|
|
|
|
|
connect(&m_process, &QProcess::stateChanged, this, &Tor::stateChanged);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Tor::stop() {
|
|
|
|
|
m_process.kill();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Tor::start() {
|
|
|
|
|
if (this->localTor) {
|
|
|
|
|
this->checkConnection();
|
|
|
|
@ -65,9 +76,6 @@ void Tor::start() {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Don't spawn Tor on default port to avoid conflicts
|
|
|
|
|
Tor::torPort = 19450;
|
|
|
|
|
|
|
|
|
|
auto state = m_process.state();
|
|
|
|
|
if (state == QProcess::ProcessState::Running || state == QProcess::ProcessState::Starting) {
|
|
|
|
|
this->errorMsg = "Can't start Tor, already running or starting";
|
|
|
|
@ -101,10 +109,6 @@ void Tor::start() {
|
|
|
|
|
m_process.start(this->torPath, arguments);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Tor::stop() {
|
|
|
|
|
m_process.terminate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Tor::checkConnection() {
|
|
|
|
|
// We might not be able to connect to localhost if torsocks is used to start feather
|
|
|
|
|
if (m_ctx->isTorSocks)
|
|
|
|
|