Unverified Commit c96b4ecc authored by jeff's avatar jeff
Browse files

mac changes

parent 4cfdea07
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
......@@ -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";
......
......@@ -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();
......
......@@ -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);
......
......@@ -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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment