summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Becker <jeff@i2p.rocks>2020-02-08 11:12:21 -0500
committerJeff Becker <jeff@i2p.rocks>2020-02-19 10:38:43 -0500
commitc96b4ecc5da3dbea4bd9c272ba5b5ac598e8efc2 (patch)
treee0dd77ae98d809b449c71a186baacf5ec6663a08
parent4cfdea07c0587b16467a9e91dcaa1522da7dd961 (diff)
mac changes
-rwxr-xr-xCMakeLists.txt27
-rwxr-xr-xsrc/main.cpp2
-rwxr-xr-xsrc/protocol/AuthHiddenServiceChannel.cpp4
-rwxr-xr-xsrc/tor/TorManager.cpp27
-rwxr-xr-xsrc/tor/TorProcess.cpp2
5 files changed, 43 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 65da1ed..c91fb3d 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.1.0)
-if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+if (APPLE)
set(MACOSX TRUE)
endif()
project(ricochet-refresh)
@@ -12,27 +12,28 @@ set(CMAKE_AUTOUIC ON)
if(CMAKE_VERSION VERSION_LESS "3.7.0")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()
-if (MACOSX)
- set(QT5_DIR /usr/local/opt/qt/include)
- set(Protobuf_INCLUDE_DIRS /usr/local/opt/protobuf/include)
- set(OPENSSL_INCLUDE_DIR /usr/local/opt/openssl/include)
+if (APPLE)
+ set(Qt5_DIR /usr/local/opt/qt5/lib/cmake/Qt5)
+ set(Protobuf_ROOT_DIR /usr/local/opt/protobuf)
+ #set(OPENSSL_ROOT_DIR /usr/local/opt/openssl)
+ set(Protobuf_INCLUDE_DIR ${Protobuf_ROOT_DIR}/include)
+ #set(OPENSSL_INCLUDE_DIR ${OPENSSL_ROOT_DIR}/include)
endif()
-find_package(Qt5Widgets REQUIRED)
find_package(Protobuf REQUIRED)
-find_package(Qt5Network REQUIRED)
find_package(OpenSSL REQUIRED)
# qt5 modules
-set(MODULES Core Widgets Network Quick)
+set(MODULES Core Widgets Network Quick QuickCompiler)
+if(APPLE)
+set(MODULES ${MODULES} MacExtras)
+endif()
foreach(mod IN ITEMS ${MODULES})
find_package(Qt5 REQUIRED ${mod} REQUIRED)
endforeach(mod IN ITEMS ${MODULES})
-find_package(Qt5QuickCompiler REQUIRED)
-
qtquick_compiler_add_resources(UI_RESOURCES src/ui/qml/qml.qrc)
@@ -151,8 +152,12 @@ set(HEADERS src/protocol/Channel.h
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src ${Protobuf_INCLUDE_DIRS} ${QT5_DIR})
add_executable(ricochet-refresh ${SOURCES} ${HEADERS} ${UI_RESOURCES})
-target_link_libraries(ricochet-refresh protobuf)
+target_link_libraries(ricochet-refresh ${PROTOBUF_LIBRARIES})
target_link_libraries(ricochet-refresh Qt5::Widgets Qt5::Network OpenSSL::Crypto)
target_link_libraries(ricochet-refresh Qt5::Widgets Qt5::Network Qt5::Quick Qt5::Core OpenSSL::Crypto)
+if(APPLE)
+ target_include_directories(ricochet-refresh PUBLIC Qt5:MacExtras)
+ target_link_libraries(ricochet-refresh Qt5::MacExtras)
+endif()
qt5_use_modules(ricochet-refresh ${MODULES}) \ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index 6875200..f1388e7 100755
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -111,7 +111,9 @@ int main(int argc, char *argv[])
/* Tor control manager */
Tor::TorManager *torManager = Tor::TorManager::instance();
+
torManager->setDataDirectory(QFileInfo(settings->filePath()).path() + QStringLiteral("/tor/"));
+
torControl = torManager->control();
torManager->start();
qCDebug(ricochet_main) << "started tor manager";
diff --git a/src/protocol/AuthHiddenServiceChannel.cpp b/src/protocol/AuthHiddenServiceChannel.cpp
index df49af9..388c777 100755
--- a/src/protocol/AuthHiddenServiceChannel.cpp
+++ b/src/protocol/AuthHiddenServiceChannel.cpp
@@ -245,14 +245,12 @@ void AuthHiddenServiceChannel::sendAuthMessage()
qCDebug(hs_auth) << "digest=" << digest;
signature = d->privateKey.signSHA256(digest);
-
if (signature.isEmpty()) {
BUG() << "Creating proof on AuthHiddenServiceChannel failed";
closeChannel();
return;
}
-
// put signature & public key in a Proof class, to be sent as auth message
// Proof is a subclass of google::protobuf::Message
// Proof is used as a storage to contain public key and signature for verification
@@ -275,8 +273,6 @@ void AuthHiddenServiceChannel::sendAuthMessage()
QByteArray AuthHiddenServiceChannelPrivate::getProofData(const QString &client)
{
// FIXME: Currently, clientHostname is empty string, client didn't get passed correctly from parameters.
- if(!client.endsWith(QLatin1String(".onion")));
- return QByteArray();
QByteArray serverHostname = connection->serverHostname().replace(QLatin1String(".onion"), QLatin1String("")).toLatin1();
QByteArray clientHostname = client.toLatin1();
diff --git a/src/tor/TorManager.cpp b/src/tor/TorManager.cpp
index 70ca9e8..43ab0e4 100755
--- a/src/tor/TorManager.cpp
+++ b/src/tor/TorManager.cpp
@@ -39,6 +39,11 @@
#include <QDir>
#include <QCoreApplication>
+
+#ifdef Q_OS_OSX
+#include <CoreFoundation/CoreFoundation.h>
+#endif
+
using namespace Tor;
Q_LOGGING_CATEGORY(tor_manager, "ricochet.tor");
@@ -152,8 +157,13 @@ void TorManager::start()
SettingsObject settings(QStringLiteral("tor"));
// If a control port is defined by config or environment, skip launching tor
- if (!settings.read("controlPort").isUndefined() ||
- !qEnvironmentVariableIsEmpty("TOR_CONTROL_PORT"))
+ #ifdef Q_OS_MACOS
+ const bool noEmbedded = false;
+ #else
+ const bool noEmbedded = true;
+ #endif
+ if (noEmbedded && (!settings.read("controlPort").isUndefined() ||
+ !qEnvironmentVariableIsEmpty("TOR_CONTROL_PORT")))
{
QHostAddress address(settings.read("controlAddress").toString());
quint16 port = (quint16)settings.read("controlPort").toInt();
@@ -185,6 +195,7 @@ void TorManager::start()
} else {
// Launch a bundled Tor instance
QString executable = d->torExecutablePath();
+ qCWarning(tor_manager) << "launch " << executable;
if (executable.isEmpty()) {
d->setError(QStringLiteral("Cannot find tor executable"));
return;
@@ -275,6 +286,16 @@ void TorManagerPrivate::getConfFinished()
QString TorManagerPrivate::torExecutablePath() const
{
+#ifdef Q_OS_OSX
+ CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
+ CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle);
+ const char *pathPtr = CFStringGetCStringPtr(macPath,kCFStringEncodingUTF8);
+ std::string path(pathPtr);
+ CFRelease(appUrlRef);
+ CFRelease(macPath);
+ return QString::fromStdString(path) + QStringLiteral("/Contents/MacOS/tor/tor");
+#else
+
SettingsObject settings(QStringLiteral("tor"));
QString path = settings.read("executablePath").toString();
if (!path.isEmpty())
@@ -298,6 +319,7 @@ QString TorManagerPrivate::torExecutablePath() const
// Try $PATH
return filename.mid(1);
+#endif
}
bool TorManagerPrivate::createDataDir(const QString &path)
@@ -311,7 +333,6 @@ bool TorManagerPrivate::createDefaultTorrc(const QString &path)
static const char defaultTorrcContent[] =
"SocksPort auto\n"
"AvoidDiskWrites 1\n"
- "DisableNetwork 1\n"
"__ReloadTorrcOnSIGHUP 0\n";
QFile file(path);
diff --git a/src/tor/TorProcess.cpp b/src/tor/TorProcess.cpp
index f8f9809..2aaddd3 100755
--- a/src/tor/TorProcess.cpp
+++ b/src/tor/TorProcess.cpp
@@ -166,7 +166,7 @@ void TorProcess::start()
QFile::remove(d->controlPortFilePath());
d->controlPort = 0;
d->controlHost.clear();
-
+ qWarning() << "launch " << d->executable;
d->process.setProcessChannelMode(QProcess::MergedChannels);
d->process.start(d->executable, args, QIODevice::ReadOnly);
}