Unverified Commit 9b7e2322 authored by jeff's avatar jeff
Browse files

initial sweep of "making it compile"

CMakeLists:
* make cmake build system build on linux (ubuntu 19.10)

src/main.cpp:
* add logging category for ricochet

src/utils/CryptoKey.cpp:
* throw exception so that a fixme gets fixed

src/tor/TorManager.h:
* logging category for tor manager

src/tor/TorManager.cpp:
* make default config use relative path for hidden service dir
parent 1587796b
......@@ -23,7 +23,37 @@ find_package(Qt5Widgets REQUIRED)
find_package(Protobuf REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(Qt5 REQUIRED Core REQUIRED Widgets REQUIRED Network REQUIRED Quick REQUIRED)
# qt5 modules
set(MODULES Core Widgets Network Quick)
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)
# protocol buffer definitions
set(PROTO_DEFS
src/protocol/ControlChannel.proto
src/protocol/AuthHiddenService.proto
src/protocol/ChatChannel.proto
src/protocol/ContactRequestChannel.proto
)
# generate protocol buffer source files
PROTOBUF_GENERATE_CPP(PROTO_SRC PROTO_HDR ${PROTO_DEFS})
# exclude generated protobuf files from automoc
foreach(f IN ITEMS ${PROTO_HDR} ${PROTO_SRC})
set_property(SOURCE ${f} PROPERTY SKIP_AUTOGEN ON)
endforeach()
# source file
set(SOURCES src/main.cpp
......@@ -64,6 +94,7 @@ set(SOURCES src/main.cpp
src/protocol/ChatChannel.cpp
src/protocol/ContactRequestChannel.cpp
lib/onion_ed25519_signature/ed25519.c
${PROTO_SRC}
)
set(HEADERS src/protocol/Channel.h
src/protocol/Channel_p.h
......@@ -116,8 +147,12 @@ set(HEADERS src/protocol/Channel.h
lib/onion_ed25519_signature/ed25519-hash.h
lib/onion_ed25519_signature/modm-donna-64bit.h
lib/onion_ed25519_signature/orconfig.h
${PROTO_HDR}
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src ${Protobuf_INCLUDE_DIRS} ${QT5_DIR})
add_executable(ricochet-refresh ${SOURCES} ${HEADERS})
add_executable(ricochet-refresh ${SOURCES} ${HEADERS} ${UI_RESOURCES})
target_link_libraries(ricochet-refresh protobuf)
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)
\ No newline at end of file
target_link_libraries(ricochet-refresh Qt5::Widgets Qt5::Network Qt5::Quick Qt5::Core OpenSSL::Crypto)
qt5_use_modules(ricochet-refresh ${MODULES})
\ No newline at end of file
......@@ -51,6 +51,14 @@
#include <QStandardPaths>
#include <openssl/crypto.h>
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(ricochet_main);
Q_LOGGING_CATEGORY(ricochet_main, "ricochet.main");
static bool initSettings(SettingsFile *settings, QLockFile **lockFile, QString &errorMessage);
static bool importLegacySettings(SettingsFile *settings, const QString &oldPath);
static void initTranslation();
......@@ -72,13 +80,16 @@ int main(int argc, char *argv[])
#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC)
a.setWindowIcon(QIcon(QStringLiteral(":/icons/ricochet_refresh.svg")));
#endif
qCDebug(ricochet_main) << "start app" ;
QScopedPointer<SettingsFile> settings(new SettingsFile);
SettingsObject::setDefaultFile(settings.data());
QString error;
QLockFile *lock = 0;
qCDebug(ricochet_main) << "init settings" ;
if (!initSettings(settings.data(), &lock, error)) {
qCCritical(ricochet_main) << "init settings failed" ;
QMessageBox::critical(0, qApp->translate("Main", "Ricochet Error"), error);
return 1;
}
......@@ -103,7 +114,7 @@ int main(int argc, char *argv[])
torManager->setDataDirectory(QFileInfo(settings->filePath()).path() + QStringLiteral("/tor/"));
torControl = torManager->control();
torManager->start();
qCDebug(ricochet_main) << "started tor manager";
/* Identities */
identityManager = new IdentityManager;
QScopedPointer<IdentityManager> scopedIdentityManager(identityManager);
......
......@@ -41,6 +41,8 @@
using namespace Tor;
Q_LOGGING_CATEGORY(tor_manager, "ricochet.tor");
namespace Tor
{
......@@ -222,7 +224,7 @@ void TorManager::start()
void TorManagerPrivate::processStateChanged(int state)
{
qDebug() << Q_FUNC_INFO << state << TorProcess::Ready << process->controlPassword() << process->controlHost() << process->controlPort();
qCDebug(tor_manager) << Q_FUNC_INFO << state << TorProcess::Ready << process->controlPassword() << process->controlHost() << process->controlPort();
if (state == TorProcess::Ready) {
control->setAuthPassword(process->controlPassword());
control->connect(process->controlHost(), process->controlPort());
......@@ -231,13 +233,13 @@ void TorManagerPrivate::processStateChanged(int state)
void TorManagerPrivate::processErrorChanged(const QString &errorMessage)
{
qDebug() << "tor error:" << errorMessage;
qCWarning(tor_manager)<< errorMessage;
setError(errorMessage);
}
void TorManagerPrivate::processLogMessage(const QString &message)
{
qDebug() << "tor:" << message;
qCDebug(tor_manager) << message;
if (logMessages.size() >= 50)
logMessages.takeFirst();
logMessages.append(message);
......@@ -310,7 +312,7 @@ bool TorManagerPrivate::createDefaultTorrc(const QString &path)
"SocksPort auto\n"
"AvoidDiskWrites 1\n"
"DisableNetwork 1\n"
"HiddenServiceDir /var/lib/tor/hidden_service\n"
"HiddenServiceDir ./tor/hidden_service\n"
"HiddenServicePort 45678\n"
"HiddenServiceVersion 3\n"
"__ReloadTorrcOnSIGHUP 0\n";
......
......@@ -36,6 +36,10 @@
#include <QObject>
#include <QStringList>
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(tor_manager);
namespace Tor
{
......
......@@ -39,6 +39,7 @@
#include <openssl/bio.h>
#include <openssl/pem.h>
#include <QMessageBox>
#include <memory>
extern "C" {
#include "../lib/onion_ed25519_signature/sign.h"
}
......@@ -197,6 +198,7 @@ bool CryptoKey::loadFromFile(const QString &path, KeyType type, KeyFormat format
//todo no V3 implementation for this, since it's not really used
return true;
}
return false;
}
/**
......@@ -800,6 +802,31 @@ bool base32_decode(char *dest, unsigned int destlen, const char *src, unsigned i
return true;
}
std::string decode_base32(std::string encoded){
}
\ No newline at end of file
template < int a, int b >
static size_t
DecodeSize(size_t sz)
{
auto d = div(sz, a);
if(d.rem)
d.quot++;
return b * d.quot;
}
/// get base32 binary size of encoded input of size sz bytes
static size_t
Base32DecodeSize(size_t sz)
{
return DecodeSize< 5, 8 >(sz);
}
// std::string version of base32_decode
std::string decode_base32(std::string encoded)
{
const size_t decode_len = Base32DecodeSize(encoded.size());
std::shared_ptr<char[]> decoded = std::make_shared<char[]>(decode_len);
if(base32_decode(decoded.get(), decode_len, encoded.c_str(), encoded.size()))
{
return decoded.get();
}
return "";
}
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