diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index b132d6d..a83252d 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -46,7 +46,7 @@ add_library(${LIBNAME} ${SOURCE}) target_link_libraries(${LIBNAME} PUBLIC Qt5::Core PUBLIC Qt5::Network - PUBLIC ${BOTAN_LIBRARIES}) + PRIVATE ${BOTAN_LIBRARIES}) target_include_directories(${LIBNAME} PRIVATE ${BOTAN_INCLUDE_DIRS}) foreach(LIB Qt5Network Qt5Core ${BOTAN_LIBRARIES}) diff --git a/lib/address.h b/lib/address.h index 51f4311..e0e1f5d 100644 --- a/lib/address.h +++ b/lib/address.h @@ -43,8 +43,8 @@ class QSS_EXPORT Address : public QObject QObject *parent = 0); Address(const QHostAddress &ip, - const quint16 &p, - QObject *parent = 0); + const quint16 &p, + QObject *parent = 0); Address(const Address &o); //force the generation of default move constructor diff --git a/lib/addresstester.h b/lib/addresstester.h index 1a186d2..adfe231 100644 --- a/lib/addresstester.h +++ b/lib/addresstester.h @@ -39,8 +39,8 @@ class QSS_EXPORT AddressTester : public QObject Q_OBJECT public: AddressTester(const QHostAddress &server_address, - const quint16 &server_port, - QObject *parent = 0); + const quint16 &server_port, + QObject *parent = 0); static const int LAG_TIMEOUT = -1; static const int LAG_ERROR = -2; diff --git a/lib/chacha.h b/lib/chacha.h index 1b97da4..ac4e2f0 100644 --- a/lib/chacha.h +++ b/lib/chacha.h @@ -39,8 +39,8 @@ class ChaCha : public QObject * IV length must be 8 or 12 */ ChaCha(const QByteArray &_key, - const QByteArray &_iv, - QObject *parent = 0); + const QByteArray &_iv, + QObject *parent = 0); public slots: //encrypt (or decrypt, same process for ChaCha algorithm) a byte array. diff --git a/lib/cipher.cpp b/lib/cipher.cpp index ec7871b..4cd40e6 100644 --- a/lib/cipher.cpp +++ b/lib/cipher.cpp @@ -24,12 +24,24 @@ #include #include #include -#include +#include +#include #include #include +#include using namespace QSS; +#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,10,0) +#error "Botan library is too old." +#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2,0,0) +typedef Botan::SecureVector SecureByteArray; +#define DataOfSecureByteArray(sba) sba.begin() +#else +typedef Botan::secure_vector SecureByteArray; +#define DataOfSecureByteArray(sba) sba.data() +#endif + Cipher::Cipher(const QByteArray &method, const QByteArray &key, const QByteArray &iv, diff --git a/lib/cipher.h b/lib/cipher.h index 4f08740..ba2c04f 100644 --- a/lib/cipher.h +++ b/lib/cipher.h @@ -32,23 +32,15 @@ #include #include #include -#include -#include #include "rc4.h" #include "chacha.h" #include "export.h" -namespace QSS { +namespace Botan { +class Pipe; +} -#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,10,0) -#error "Botan library is too old." -#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2,0,0) -typedef Botan::SecureVector SecureByteArray; -#define DataOfSecureByteArray(sba) sba.begin() -#else -typedef Botan::secure_vector SecureByteArray; -#define DataOfSecureByteArray(sba) sba.data() -#endif +namespace QSS { class QSS_EXPORT Cipher : public QObject { diff --git a/lib/encryptorprivate.h b/lib/encryptorprivate.h index 1e7d371..6f5a65e 100644 --- a/lib/encryptorprivate.h +++ b/lib/encryptorprivate.h @@ -41,8 +41,8 @@ class QSS_EXPORT EncryptorPrivate : public QObject * If the initialisation doesn't succeed, isValid() function return false */ EncryptorPrivate(const QString &method, - const QString &password, - QObject *parent = 0); + const QString &password, + QObject *parent = 0); //construct an invalid/null instance explicit EncryptorPrivate(QObject *parent = 0); diff --git a/lib/rc4.h b/lib/rc4.h index d4c86f4..2636e45 100644 --- a/lib/rc4.h +++ b/lib/rc4.h @@ -40,8 +40,8 @@ class RC4 : public QObject // This class implements so-called RC4-MD5 cipher instead of original RC4 // _iv is not allowed to be empty! RC4(const QByteArray &_key, - const QByteArray &_iv, - QObject *parent = 0); + const QByteArray &_iv, + QObject *parent = 0); public slots: QByteArray update(const QByteArray &input); diff --git a/lib/socketstream.h b/lib/socketstream.h index 424c645..5c068f5 100644 --- a/lib/socketstream.h +++ b/lib/socketstream.h @@ -39,8 +39,8 @@ class QSS_EXPORT SocketStream : public QObject * vice versa */ SocketStream(QAbstractSocket *a, - QAbstractSocket *b, - QObject *parent = 0); + QAbstractSocket *b, + QObject *parent = 0); signals: void info(const QString &); diff --git a/lib/tcprelay.h b/lib/tcprelay.h index af1ded4..0d0f9d8 100644 --- a/lib/tcprelay.h +++ b/lib/tcprelay.h @@ -37,13 +37,13 @@ class QSS_EXPORT TcpRelay : public QObject Q_OBJECT public: TcpRelay(QTcpSocket *localSocket, - int timeout, - const Address &server_addr, - const EncryptorPrivate &ep, - const bool &is_local, - const bool &autoBan, - const bool &auth, - QObject *parent = 0); + int timeout, + const Address &server_addr, + const EncryptorPrivate &ep, + const bool &is_local, + const bool &autoBan, + const bool &auth, + QObject *parent = 0); enum STAGE { INIT, ADDR, UDP_ASSOC, DNS, CONNECTING, STREAM, DESTROYED }; diff --git a/lib/tcpserver.h b/lib/tcpserver.h index 78787f3..bc58a23 100644 --- a/lib/tcpserver.h +++ b/lib/tcpserver.h @@ -36,12 +36,12 @@ class QSS_EXPORT TcpServer : public QTcpServer Q_OBJECT public: TcpServer(const EncryptorPrivate &ep, - const int &timeout, - const bool &is_local, - const bool &auto_ban, - const bool &auth, - const Address &serverAddress, - QObject *parent = nullptr); + const int &timeout, + const bool &is_local, + const bool &auto_ban, + const bool &auth, + const Address &serverAddress, + QObject *parent = nullptr); ~TcpServer(); bool listen(const QHostAddress &address, quint16 port); diff --git a/lib/udprelay.h b/lib/udprelay.h index f0fc26d..b5a4850 100644 --- a/lib/udprelay.h +++ b/lib/udprelay.h @@ -37,11 +37,11 @@ class QSS_EXPORT UdpRelay : public QObject Q_OBJECT public: UdpRelay(const EncryptorPrivate &ep, - const bool &is_local, - const bool &auto_ban, - const bool &auth, - const Address &serverAddress, - QObject *parent = 0); + const bool &is_local, + const bool &auto_ban, + const bool &auth, + const Address &serverAddress, + QObject *parent = 0); void setup(const QHostAddress &localAddr, const quint16 &localPort);