mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-03-01 11:21:25 -05:00
fixed compilation. Qt is completely gone
This commit is contained in:
parent
7dc5c90d63
commit
b323a1635e
@ -9,9 +9,6 @@ libretroshare_shared {
|
|||||||
} else {
|
} else {
|
||||||
CONFIG += staticlib
|
CONFIG += staticlib
|
||||||
}
|
}
|
||||||
CONFIG += qt
|
|
||||||
|
|
||||||
QT += network
|
|
||||||
|
|
||||||
TARGET = retroshare
|
TARGET = retroshare
|
||||||
TARGET_PRL = libretroshare
|
TARGET_PRL = libretroshare
|
||||||
@ -732,7 +729,6 @@ HEADERS += tor/AddOnionCommand.h \
|
|||||||
tor/HiddenService.h \
|
tor/HiddenService.h \
|
||||||
tor/PendingOperation.h \
|
tor/PendingOperation.h \
|
||||||
tor/ProtocolInfoCommand.h \
|
tor/ProtocolInfoCommand.h \
|
||||||
tor/SecureRNG.h \
|
|
||||||
tor/TorTypes.h \
|
tor/TorTypes.h \
|
||||||
tor/SetConfCommand.h \
|
tor/SetConfCommand.h \
|
||||||
tor/StrUtil.h \
|
tor/StrUtil.h \
|
||||||
@ -757,7 +753,6 @@ SOURCES += tor/AddOnionCommand.cpp \
|
|||||||
tor/TorProcess.cpp \
|
tor/TorProcess.cpp \
|
||||||
tor/CryptoKey.cpp \
|
tor/CryptoKey.cpp \
|
||||||
tor/PendingOperation.cpp \
|
tor/PendingOperation.cpp \
|
||||||
tor/SecureRNG.cpp \
|
|
||||||
tor/StrUtil.cpp
|
tor/StrUtil.cpp
|
||||||
|
|
||||||
# gxs tunnels
|
# gxs tunnels
|
||||||
|
@ -7,7 +7,7 @@ class RsTcpSocket: public RsFdBinInterface
|
|||||||
public:
|
public:
|
||||||
RsTcpSocket(const std::string& tcp_address,uint16_t tcp_port);
|
RsTcpSocket(const std::string& tcp_address,uint16_t tcp_port);
|
||||||
RsTcpSocket();
|
RsTcpSocket();
|
||||||
virtual ~RsTcpSocket();
|
virtual ~RsTcpSocket()=default;
|
||||||
|
|
||||||
enum State: uint8_t {
|
enum State: uint8_t {
|
||||||
UNKNOWN = 0x00,
|
UNKNOWN = 0x00,
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "CryptoKey.h"
|
#include "CryptoKey.h"
|
||||||
#include "SecureRNG.h"
|
|
||||||
#include "Useful.h"
|
#include "Useful.h"
|
||||||
|
|
||||||
#include <openssl/bn.h>
|
#include <openssl/bn.h>
|
||||||
@ -134,7 +133,7 @@ ByteArray torControlHashedPassword(const ByteArray &password)
|
|||||||
ByteArray salt(8);
|
ByteArray salt(8);
|
||||||
RsRandom::random_bytes(&salt[0],8);
|
RsRandom::random_bytes(&salt[0],8);
|
||||||
|
|
||||||
uint32_t count = ((quint32)16 + (96 & 15)) << ((96 >> 4) + 6);
|
uint32_t count = ((uint32_t)16 + (96 & 15)) << ((96 >> 4) + 6);
|
||||||
|
|
||||||
Sha1CheckSum md = RsDirUtil::sha1sum((salt+password).data(),count);
|
Sha1CheckSum md = RsDirUtil::sha1sum((salt+password).data(),count);
|
||||||
|
|
||||||
|
@ -30,8 +30,7 @@
|
|||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef HIDDENSERVICE_H
|
#pragma once
|
||||||
#define HIDDENSERVICE_H
|
|
||||||
|
|
||||||
#include "CryptoKey.h"
|
#include "CryptoKey.h"
|
||||||
#include "bytearray.h"
|
#include "bytearray.h"
|
||||||
@ -109,5 +108,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HIDDENSERVICE_H
|
|
||||||
|
@ -1,147 +0,0 @@
|
|||||||
/* Ricochet - https://ricochet.im/
|
|
||||||
* Copyright (C) 2014, John Brooks <john.brooks@dereferenced.net>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
*
|
|
||||||
* * Neither the names of the copyright owners nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "SecureRNG.h"
|
|
||||||
#include <QtDebug>
|
|
||||||
#include <openssl/rand.h>
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
#include <wtypes.h>
|
|
||||||
#include <wincrypt.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if QT_VERSION >= 0x040700
|
|
||||||
#include <QElapsedTimer>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool SecureRNG::seed()
|
|
||||||
{
|
|
||||||
#if QT_VERSION >= 0x040700
|
|
||||||
QElapsedTimer timer;
|
|
||||||
timer.start();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
/* RAND_poll is very unreliable on windows; with older versions of OpenSSL,
|
|
||||||
* it can take up to several minutes to run and has been known to crash.
|
|
||||||
* Even newer versions seem to take around 400ms, which is far too long for
|
|
||||||
* interactive startup. Random data from the windows CSP is used as a seed
|
|
||||||
* instead, as it should be very high quality random and fast. */
|
|
||||||
HCRYPTPROV provider = 0;
|
|
||||||
if (!CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
|
|
||||||
{
|
|
||||||
qWarning() << "Failed to acquire CSP context for RNG seed:" << hex << GetLastError();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Same amount of entropy OpenSSL uses, apparently. */
|
|
||||||
char buf[32];
|
|
||||||
|
|
||||||
if (!CryptGenRandom(provider, sizeof(buf), reinterpret_cast<BYTE*>(buf)))
|
|
||||||
{
|
|
||||||
qWarning() << "Failed to get entropy from CSP for RNG seed: " << hex << GetLastError();
|
|
||||||
CryptReleaseContext(provider, 0);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CryptReleaseContext(provider, 0);
|
|
||||||
|
|
||||||
RAND_seed(buf, sizeof(buf));
|
|
||||||
memset(buf, 0, sizeof(buf));
|
|
||||||
#else
|
|
||||||
if (!RAND_poll())
|
|
||||||
{
|
|
||||||
qWarning() << "OpenSSL RNG seed failed:" << ERR_get_error();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if QT_VERSION >= 0x040700
|
|
||||||
qDebug() << "RNG seed took" << timer.elapsed() << "ms";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SecureRNG::random(char *buf, int size)
|
|
||||||
{
|
|
||||||
int r = RAND_bytes(reinterpret_cast<unsigned char*>(buf), size);
|
|
||||||
if (r <= 0)
|
|
||||||
qFatal("RNG failed: %lu", ERR_get_error());
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray SecureRNG::random(int size)
|
|
||||||
{
|
|
||||||
QByteArray re(size, 0);
|
|
||||||
random(re.data(), size);
|
|
||||||
return re;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray SecureRNG::randomPrintable(int length)
|
|
||||||
{
|
|
||||||
QByteArray re(length, 0);
|
|
||||||
for (int i = 0; i < re.size(); i++)
|
|
||||||
re[i] = randomInt(95) + 32;
|
|
||||||
return re;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned SecureRNG::randomInt(unsigned max)
|
|
||||||
{
|
|
||||||
unsigned cutoff = UINT_MAX - (UINT_MAX % max);
|
|
||||||
unsigned value = 0;
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
random(reinterpret_cast<char*>(&value), sizeof(value));
|
|
||||||
if (value < cutoff)
|
|
||||||
return value % max;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef UINT64_MAX
|
|
||||||
#define UINT64_MAX ((quint64)-1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
quint64 SecureRNG::randomInt64(quint64 max)
|
|
||||||
{
|
|
||||||
quint64 cutoff = UINT64_MAX - (UINT64_MAX % max);
|
|
||||||
quint64 value = 0;
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
random(reinterpret_cast<char*>(value), sizeof(value));
|
|
||||||
if (value < cutoff)
|
|
||||||
return value % max;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
/* Ricochet - https://ricochet.im/
|
|
||||||
* Copyright (C) 2014, John Brooks <john.brooks@dereferenced.net>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following disclaimer
|
|
||||||
* in the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
*
|
|
||||||
* * Neither the names of the copyright owners nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SECURERNG_H
|
|
||||||
#define SECURERNG_H
|
|
||||||
|
|
||||||
#include <QByteArray>
|
|
||||||
|
|
||||||
class SecureRNG
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static bool seed();
|
|
||||||
|
|
||||||
static void random(char *buf, int size);
|
|
||||||
static QByteArray random(int size);
|
|
||||||
|
|
||||||
static QByteArray randomPrintable(int length);
|
|
||||||
static unsigned randomInt(unsigned max);
|
|
||||||
static quint64 randomInt64(quint64 max);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SECURERNG_H
|
|
@ -874,5 +874,4 @@ bool TorControl::torVersionAsNewAs(const std::string& match) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "TorControl.moc"
|
|
||||||
|
|
||||||
|
@ -30,8 +30,7 @@
|
|||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TORCONTROL_H
|
#pragma once
|
||||||
#define TORCONTROL_H
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -171,5 +170,3 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern Tor::TorControl *torControl;
|
extern Tor::TorControl *torControl;
|
||||||
|
|
||||||
#endif // TORCONTROLMANAGER_H
|
|
||||||
|
@ -49,6 +49,10 @@ TorControlSocket::~TorControlSocket()
|
|||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TorControlSocket::connectToHost(const std::string& tcp_address,uint16_t tcp_port)
|
||||||
|
{
|
||||||
|
RsTcpSocket::connect(tcp_address,tcp_port);
|
||||||
|
}
|
||||||
std::string TorControlSocket::peerAddress() const
|
std::string TorControlSocket::peerAddress() const
|
||||||
{
|
{
|
||||||
if(connectionState() == State::CONNECTED)
|
if(connectionState() == State::CONNECTED)
|
||||||
|
@ -52,8 +52,6 @@ public:
|
|||||||
explicit TorControlSocket(TorControlSocketClient *client);
|
explicit TorControlSocket(TorControlSocketClient *client);
|
||||||
virtual ~TorControlSocket();
|
virtual ~TorControlSocket();
|
||||||
|
|
||||||
void connect(const std::string& tcp_address,uint16_t tcp_port);
|
|
||||||
|
|
||||||
std::string errorMessage() const { return m_errorMessage; }
|
std::string errorMessage() const { return m_errorMessage; }
|
||||||
|
|
||||||
void connectToHost(const std::string& tcp_address,uint16_t tcp_port);
|
void connectToHost(const std::string& tcp_address,uint16_t tcp_port);
|
||||||
|
@ -580,8 +580,6 @@ void TorManagerPrivate::setError(const std::string &message)
|
|||||||
//emit q->errorChanged();
|
//emit q->errorChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "TorManager.moc"
|
|
||||||
|
|
||||||
bool RsTor::isTorAvailable()
|
bool RsTor::isTorAvailable()
|
||||||
{
|
{
|
||||||
return !instance()->d->torExecutablePath().empty();
|
return !instance()->d->torExecutablePath().empty();
|
||||||
|
@ -32,8 +32,7 @@
|
|||||||
|
|
||||||
// This code has been further modified to fit Retroshare context.
|
// This code has been further modified to fit Retroshare context.
|
||||||
|
|
||||||
#ifndef TORMANAGER_H
|
#pragma once
|
||||||
#define TORMANAGER_H
|
|
||||||
|
|
||||||
#include "retroshare/rstor.h"
|
#include "retroshare/rstor.h"
|
||||||
#include "HiddenService.h"
|
#include "HiddenService.h"
|
||||||
@ -107,6 +106,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
#
|
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
|
|
||||||
#include "TorProcess.h"
|
#include "TorProcess.h"
|
||||||
#include "CryptoKey.h"
|
#include "CryptoKey.h"
|
||||||
#include "SecureRNG.h"
|
|
||||||
|
|
||||||
using namespace Tor;
|
using namespace Tor;
|
||||||
|
|
||||||
|
@ -30,11 +30,9 @@
|
|||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef UTILS_USEFUL_H
|
#pragma once
|
||||||
#define UTILS_USEFUL_H
|
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "util/rsdebug.h"
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
/* Print a warning for bug conditions, and assert on a debug build.
|
/* Print a warning for bug conditions, and assert on a debug build.
|
||||||
*
|
*
|
||||||
@ -50,7 +48,7 @@
|
|||||||
* triggered unless the code or logic is wrong.
|
* triggered unless the code or logic is wrong.
|
||||||
*/
|
*/
|
||||||
#if !defined(QT_NO_DEBUG) || defined(QT_FORCE_ASSERTS)
|
#if !defined(QT_NO_DEBUG) || defined(QT_FORCE_ASSERTS)
|
||||||
# define BUG() Explode(__FILE__,__LINE__), qWarning() << "BUG:"
|
# define BUG() Explode(__FILE__,__LINE__), RsWarn() << "BUG:"
|
||||||
namespace {
|
namespace {
|
||||||
class Explode
|
class Explode
|
||||||
{
|
{
|
||||||
@ -59,13 +57,10 @@ public:
|
|||||||
int line;
|
int line;
|
||||||
Explode(const char *file, int line) : file(file), line(line) { }
|
Explode(const char *file, int line) : file(file), line(line) { }
|
||||||
~Explode() {
|
~Explode() {
|
||||||
qt_assert("something broke!", file, line);
|
RsErr() << "something broke! in file " << file << line;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define BUG() qWarning() << "BUG:"
|
# define BUG() qWarning() << "BUG:"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user