]> Nutra Git (v2) - gamesguru/feather.git/commitdiff
macos: fix Tor startup
authortobtoht <tob@featherwallet.org>
Fri, 21 Feb 2025 07:56:52 +0000 (08:56 +0100)
committertobtoht <tob@featherwallet.org>
Fri, 21 Feb 2025 07:57:11 +0000 (08:57 +0100)
CMakeLists.txt
contrib/guix/libexec/build.sh
src/CMakeLists.txt
src/utils/TorManager.cpp
src/widgets/NetworkProxyWidget.cpp

index 623184f443462141b38f5be18c12ab82195e742d..8d1150d0551ae8b0621d3bd35cc156c0f5d55342 100644 (file)
@@ -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)
index 9b9060d195b833ae804b6afb13e255ffe9b01e29..8f33fb32f17942bc4c52676d65e909aeff9bbd90 100755 (executable)
@@ -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
 
index 67b6670e7c8d331e3539604eaf1efc352c7a9d50..e3f48b78aba7f90dd949ec654728d0ac084794c0 100644 (file)
@@ -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()
index 37a40b4f4d6eb8eb2ac1a6a16065f23ed419c521..e9db83cc854b53a4c6be9e83e6cc9fea3f4de443 100644 (file)
@@ -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
index 832d7351236029659c29f4cb776fa33c614a06b9..d307b3dd10e0320d4beee1bd74f1f12ed4f22f9e 100644 (file)
@@ -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]{