From: tobtoht Date: Fri, 21 Feb 2025 07:56:52 +0000 (+0100) Subject: macos: fix Tor startup X-Git-Url: https://git.nutra.tk/v1?a=commitdiff_plain;h=7992d7be9bdba1b4f95353134ca9d654e593945a;p=gamesguru%2Ffeather.git macos: fix Tor startup --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 623184f4..8d1150d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,9 @@ option(DONATE_BEG "Prompt donation window every once in a while" OFF) option(WITH_SCANNER "Enable webcam QR scanner" ON) option(STACK_TRACE "Dump stack trace on crash (Linux only)" OFF) +# internal configuration options +option(TOR_INSTALLED "Is Tor installed on the filesystem?" OFF) + # Plugins option(WITH_PLUGIN_HOME "Include Home tab plugin" ON) option(WITH_PLUGIN_TICKERS "Include Tickers Home plugin" ON) diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh index 9b9060d1..8f33fb32 100755 --- a/contrib/guix/libexec/build.sh +++ b/contrib/guix/libexec/build.sh @@ -298,7 +298,7 @@ export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}" *mingw32) case "$OPTIONS" in installer) - CMAKEVARS+=" -DPLATFORM_INSTALLER=On -DTOR_DIR=Off -DTOR_VERSION=Off" + CMAKEVARS+=" -DPLATFORM_INSTALLER=On -DTOR_INSTALLED=On -DTOR_DIR=Off -DTOR_VERSION=Off" ;; esac ;; @@ -318,7 +318,7 @@ export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}" CMAKEVARS+=" -DNO_AES=On" # Raspberry Pi ;; *darwin*) - CMAKEVARS+=" -DTOR_DIR=Off -DTOR_VERSION=Off" + CMAKEVARS+=" -DTOR_DIR=Off -DTOR_VERSION=Off -DTOR_INSTALLED=On" ;; esac @@ -410,6 +410,7 @@ export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}" mkdir -p Feather.app/Contents/bin cp -a /feather/contrib/depends/${HOST}/Tor/libevent-2.1.7.dylib Feather.app/Contents/bin cp -a /feather/contrib/depends/${HOST}/Tor/tor Feather.app/Contents/bin + chmod +x Feather.app/Contents/bin/tor ;; esac diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 67b6670e..e3f48b78 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -217,6 +217,10 @@ if(PLATFORM_INSTALLER) target_compile_definitions(feather PRIVATE PLATFORM_INSTALLER=1) endif() +if(TOR_INSTALLED) + target_compile_definitions(feather PRIVATE TOR_INSTALLED=1) +endif() + if(STACK_TRACE) target_compile_definitions(feather PRIVATE STACK_TRACE=1) endif() diff --git a/src/utils/TorManager.cpp b/src/utils/TorManager.cpp index 37a40b4f..e9db83cc 100644 --- a/src/utils/TorManager.cpp +++ b/src/utils/TorManager.cpp @@ -20,10 +20,16 @@ TorManager::TorManager(QObject *parent) connect(m_checkConnectionTimer, &QTimer::timeout, this, &TorManager::checkConnection); this->torDir = Config::defaultConfigDir().filePath("tor"); -#if defined(PLATFORM_INSTALLER) +#if defined(TOR_INSTALLED) // When installed, use directory relative to application path. this->torDir = QDir(Utils::applicationPath()).filePath("tor"); #endif + if (QString(FEATHER_TARGET_TRIPLET) == "arm64-apple-darwin" || QString(FEATHER_TARGET_TRIPLET) == "x86_64-apple-darwin") { + QString featherBinaryPath = QCoreApplication::applicationDirPath(); + QDir appBinaryDir(featherBinaryPath); + appBinaryDir.cd(".."); + this->torDir = appBinaryDir.filePath("bin"); + } this->torDataPath = Config::defaultConfigDir().filePath("tor/data"); @@ -187,11 +193,15 @@ bool TorManager::unpackBins() { this->torPath = QDir(this->torDir).filePath(torBin); -#if defined(PLATFORM_INSTALLER) +#if defined(TOR_INSTALLED) // We don't need to unpack if Tor was installed using the installer return true; #endif + if (QString(FEATHER_TARGET_TRIPLET) == "arm64-apple-darwin" || QString(FEATHER_TARGET_TRIPLET) == "x86_64-apple-darwin") { + return true; + } + SemanticVersion embeddedVersion = SemanticVersion::fromString(QString(TOR_VERSION)); SemanticVersion filesystemVersion = this->getVersion(torPath); qDebug() << QString("Tor versions: embedded %1, filesystem %2").arg(embeddedVersion.toString(), filesystemVersion.toString()); @@ -256,7 +266,7 @@ bool TorManager::shouldStartTorDaemon() { } // Don't start a Tor daemon if we don't have one -#if !defined(HAS_TOR_BIN) && !defined(PLATFORM_INSTALLER) +#if !defined(HAS_TOR_BIN) && !defined(TOR_INSTALLED) qWarning() << "Feather built without embedded Tor. Assuming --use-local-tor"; return false; #endif diff --git a/src/widgets/NetworkProxyWidget.cpp b/src/widgets/NetworkProxyWidget.cpp index 832d7351..d307b3dd 100644 --- a/src/widgets/NetworkProxyWidget.cpp +++ b/src/widgets/NetworkProxyWidget.cpp @@ -44,7 +44,7 @@ NetworkProxyWidget::NetworkProxyWidget(QWidget *parent) // [Tor settings] // [Let Feather start and manage a Tor daemon] -#if !defined(HAS_TOR_BIN) && !defined(PLATFORM_INSTALLER) +#if !defined(HAS_TOR_BIN) && !defined(TOR_INSTALLED) ui->checkBox_torManaged->setChecked(false); ui->checkBox_torManaged->setEnabled(false); ui->checkBox_torManaged->setToolTip("Feather was bundled without Tor"); @@ -69,7 +69,7 @@ NetworkProxyWidget::NetworkProxyWidget(QWidget *parent) // [Show Tor logs] ui->frame_torShowLogs->setVisible(!conf()->get(Config::useLocalTor).toBool()); -#if !defined(HAS_TOR_BIN) && !defined(PLATFORM_INSTALLER) +#if !defined(HAS_TOR_BIN) && !defined(TOR_INSTALLED) ui->frame_torShowLogs->setVisible(false); #endif connect(ui->btn_torShowLogs, &QPushButton::clicked, [this]{