mirror of
https://github.com/QuasarApp/Heart.git
synced 2025-05-16 19:39:41 +00:00
dev 1
This commit is contained in:
parent
1443999e32
commit
98404f52dc
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "QuasarAppLib"]
|
||||||
|
path = QuasarAppLib
|
||||||
|
url = https://github.com/QuasarApp/QuasarAppLib.git
|
14
BaseServer.pro
Normal file
14
BaseServer.pro
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
TEMPLATE = subdirs
|
||||||
|
CONFIG += ordered
|
||||||
|
|
||||||
|
SUBDIRS += \
|
||||||
|
QuasarAppLib \
|
||||||
|
ServerProtocol \
|
||||||
|
ClientProtocol \
|
||||||
|
Terminal \
|
||||||
|
Server \
|
||||||
|
Daemon \
|
||||||
|
serverProtocolTests \
|
||||||
|
|
||||||
|
QuasarAppLib.file = $$PWD/QuasarAppLib/QuasarApp.pro
|
@ -38,54 +38,23 @@ CONFIG(release, debug|release): {
|
|||||||
DESTDIR = $$PWD/build/debug
|
DESTDIR = $$PWD/build/debug
|
||||||
}
|
}
|
||||||
|
|
||||||
#include($$PWD/../../QuasarAppLib/QuasarLib.pri)
|
include($$PWD/../QuasarAppLib/QuasarLib.pri)
|
||||||
include($$PWD/../../SnakeUtils/SnakeUtils.pri)
|
|
||||||
include($$PWD/../Qt-Secret/src/Qt-Secret.pri)
|
include($$PWD/../Qt-Secret/src/Qt-Secret.pri)
|
||||||
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
Objects/basenetworkobject.cpp \
|
baseclient.cpp \
|
||||||
Objects/map.cpp \
|
baseserver.cpp \
|
||||||
Objects/objdata.cpp \
|
|
||||||
Objects/pubkey.cpp \
|
|
||||||
Objects/snake.cpp \
|
|
||||||
Objects/websocket.cpp \
|
|
||||||
clientprotocol.cpp \
|
clientprotocol.cpp \
|
||||||
client.cpp \
|
connectioninfo.cpp
|
||||||
Objects/gamedata.cpp \
|
|
||||||
Objects/getitem.cpp \
|
|
||||||
Objects/login.cpp \
|
|
||||||
networkclasssize.cpp \
|
|
||||||
Objects/player.cpp \
|
|
||||||
rsakeyspool.cpp \
|
|
||||||
server.cpp \
|
|
||||||
factorynetobjects.cpp \
|
|
||||||
connectioninfo.cpp \
|
|
||||||
Objects/updateplayerdata.cpp
|
|
||||||
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
Objects/basenetworkobject.h \
|
baseclient.h \
|
||||||
Objects/map.h \
|
baseserver.h \
|
||||||
Objects/objdata.h \
|
|
||||||
Objects/pubkey.h \
|
|
||||||
Objects/snake.h \
|
|
||||||
Objects/websocket.h \
|
|
||||||
clientprotocol.h \
|
clientprotocol.h \
|
||||||
clientprotocol_global.h \
|
clientprotocol_global.h \
|
||||||
Objects/gamedata.h \
|
|
||||||
Objects/getitem.h \
|
|
||||||
Objects/login.h \
|
|
||||||
networkclasssize.h \
|
|
||||||
client.h \
|
|
||||||
Objects/player.h \
|
|
||||||
rsakeyspool.h \
|
|
||||||
server.h \
|
|
||||||
cp.h \
|
|
||||||
config.h \
|
config.h \
|
||||||
factorynetobjects.h \
|
connectioninfo.h
|
||||||
connectioninfo.h \
|
|
||||||
cpserver.h \
|
|
||||||
Objects/updateplayerdata.h
|
|
||||||
|
|
||||||
include($$PWD/ClientProtocolIncludes.pri)
|
include($$PWD/ClientProtocolIncludes.pri)
|
||||||
|
@ -1,98 +0,0 @@
|
|||||||
#include "basenetworkobject.h"
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int BaseNetworkObject::id() const {
|
|
||||||
return _id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseNetworkObject::setId(int id) {
|
|
||||||
_id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
quint8 BaseNetworkObject::getClass() const {
|
|
||||||
return _class;
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseNetworkObject::BaseNetworkObject() {
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseNetworkObject *BaseNetworkObject::create() const {
|
|
||||||
return new BaseNetworkObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseNetworkObject::~BaseNetworkObject() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClassSize BaseNetworkObject::classSize() const {
|
|
||||||
return getTypeSize(_id) + getTypeSize(_class);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &BaseNetworkObject::writeToStream(QDataStream &stream) const {
|
|
||||||
stream << _class;
|
|
||||||
stream << _id;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &BaseNetworkObject::readFromStream(QDataStream &stream) {
|
|
||||||
stream >> _class;
|
|
||||||
stream >> _id;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BaseNetworkObject::isValid() const {
|
|
||||||
return _id >= 0 && _class > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseNetworkObject::toBytes(QByteArray &array) const {
|
|
||||||
QDataStream stream(&array, QIODevice::WriteOnly);
|
|
||||||
|
|
||||||
writeToStream(stream);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseNetworkObject::fromBytes(const QByteArray &array) {
|
|
||||||
QDataStream stream(array);
|
|
||||||
|
|
||||||
readFromStream(stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClassSize getTypeSize(const EncryptionParams ¶ms) {
|
|
||||||
bool isKey = params.alg & Key;
|
|
||||||
|
|
||||||
switch (params.alg & ~Key) {
|
|
||||||
case RSA: {
|
|
||||||
|
|
||||||
if (isKey) {
|
|
||||||
|
|
||||||
return {
|
|
||||||
static_cast<unsigned int>(sizeof (int) +
|
|
||||||
QRSAEncryption::getKeyBytesSize(static_cast<QRSAEncryption::Rsa>(params.baseBits)))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
auto baseSize =
|
|
||||||
static_cast<unsigned int>(sizeof (int) +
|
|
||||||
QRSAEncryption::getKeyBytesSize(static_cast<QRSAEncryption::Rsa>(params.encryptBits))) / 2;
|
|
||||||
|
|
||||||
return {baseSize, baseSize * params.baseBytes()};
|
|
||||||
}
|
|
||||||
|
|
||||||
case SHA: {
|
|
||||||
return {static_cast<unsigned int>(sizeof (int) + params.baseBytes())};
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return sizeof (int) + 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int EncryptionParams::baseBytes() const {
|
|
||||||
return baseBits / 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,89 +0,0 @@
|
|||||||
#ifndef BASENETWORKOBJECT_H
|
|
||||||
#define BASENETWORKOBJECT_H
|
|
||||||
|
|
||||||
#include "networkclasssize.h"
|
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <QDataStream>
|
|
||||||
#include <QVector>
|
|
||||||
#include <typeinfo>
|
|
||||||
#include "config.h"
|
|
||||||
#include <type_traits>
|
|
||||||
#include "clientprotocol_global.h"
|
|
||||||
#include <qrsaencryption.h>
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
enum cryptoAlghoritms: unsigned int {
|
|
||||||
RSA = 0x0,
|
|
||||||
SHA = 0x2,
|
|
||||||
|
|
||||||
Key = 0x100
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EncryptionParams {
|
|
||||||
unsigned int alg = SHA;
|
|
||||||
unsigned int baseBits = QRSAEncryption::RSA_256;
|
|
||||||
unsigned int encryptBits = QRSAEncryption::RSA_256;
|
|
||||||
|
|
||||||
unsigned int baseBytes() const;
|
|
||||||
};
|
|
||||||
NetworkClassSize getTypeSize(const EncryptionParams ¶ms);
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
NetworkClassSize getTypeSize(const T& type = {}) {
|
|
||||||
|
|
||||||
auto hash = typeid(type).hash_code();
|
|
||||||
|
|
||||||
if (hash == typeid(QString).hash_code()) {
|
|
||||||
|
|
||||||
return { sizeof (int), sizeof (QChar) * MAX_SIZE};
|
|
||||||
|
|
||||||
} else if (hash == typeid(QList<int>).hash_code()) {
|
|
||||||
|
|
||||||
return { sizeof (int), sizeof (int) * MAX_SIZE};
|
|
||||||
|
|
||||||
} else if (hash == typeid(QList<float>).hash_code()) {
|
|
||||||
|
|
||||||
return { sizeof (float), sizeof (float) * MAX_SIZE};
|
|
||||||
|
|
||||||
} else if (hash == typeid(QStringList).hash_code()) {
|
|
||||||
|
|
||||||
auto size = getTypeSize<QString>();
|
|
||||||
return {sizeof (int) , size.max + static_cast<int>(sizeof (int) * MAX_SIZE)};
|
|
||||||
|
|
||||||
}
|
|
||||||
return sizeof (type);
|
|
||||||
}
|
|
||||||
|
|
||||||
class CLIENTPROTOCOLSHARED_EXPORT BaseNetworkObject
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
int _id = -1;
|
|
||||||
protected:
|
|
||||||
quint8 _class = 0;
|
|
||||||
|
|
||||||
public:
|
|
||||||
BaseNetworkObject();
|
|
||||||
virtual BaseNetworkObject* create() const;
|
|
||||||
virtual ~BaseNetworkObject();
|
|
||||||
|
|
||||||
virtual NetworkClassSize classSize() const;
|
|
||||||
virtual QDataStream& writeToStream(QDataStream& stream) const;
|
|
||||||
virtual QDataStream& readFromStream(QDataStream& stream);
|
|
||||||
virtual bool isValid() const;
|
|
||||||
void toBytes(QByteArray& array) const;
|
|
||||||
void fromBytes(const QByteArray& array);
|
|
||||||
int id() const;
|
|
||||||
void setId(int id);
|
|
||||||
quint8 getClass() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
auto cast(const BaseNetworkObject* obj) {
|
|
||||||
static_assert (!std::is_pointer<T>(), "Cast working only with pointers!");
|
|
||||||
return static_cast<T>(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif // BASENETWORKOBJECT_H
|
|
@ -1,50 +0,0 @@
|
|||||||
#include "gamedata.h"
|
|
||||||
#include "config.h"
|
|
||||||
#include "clientprotocol.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
GameData::GameData()
|
|
||||||
{
|
|
||||||
_class = static_cast<quint8>(Command::GameData);
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<int> GameData::getTimeClick() const {
|
|
||||||
return timeClick;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameData::setTimeClick(const QList<int> &value) {
|
|
||||||
timeClick = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
int& GameData::operator[](int index) {
|
|
||||||
return timeClick[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseNetworkObject *GameData::create() const {
|
|
||||||
return new GameData();
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClassSize GameData::classSize() const {
|
|
||||||
return UpdatePlayerData::classSize() +
|
|
||||||
getTypeSize(timeClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &GameData::writeToStream(QDataStream &stream) const {
|
|
||||||
UpdatePlayerData::writeToStream(stream);
|
|
||||||
stream << timeClick;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &GameData::readFromStream(QDataStream &stream) {
|
|
||||||
UpdatePlayerData::readFromStream(stream);
|
|
||||||
stream >> timeClick;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GameData::isValid() const {
|
|
||||||
return timeClick.size() > 0 && UpdatePlayerData::isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
#ifndef GAMEDATA_H
|
|
||||||
#define GAMEDATA_H
|
|
||||||
|
|
||||||
#include <updateplayerdata.h>
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
|
|
||||||
class CLIENTPROTOCOLSHARED_EXPORT GameData: public UpdatePlayerData
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
QList<int> timeClick;
|
|
||||||
public:
|
|
||||||
GameData();
|
|
||||||
QList<int> getTimeClick() const;
|
|
||||||
void setTimeClick(const QList<int> &value);
|
|
||||||
int& operator[](int index);
|
|
||||||
|
|
||||||
BaseNetworkObject *create() const override;
|
|
||||||
NetworkClassSize classSize() const override;
|
|
||||||
QDataStream &writeToStream(QDataStream &stream) const override;
|
|
||||||
QDataStream &readFromStream(QDataStream &stream) override;
|
|
||||||
bool isValid() const override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif // GAMEDATA_H
|
|
@ -1,10 +0,0 @@
|
|||||||
#include "getitem.h"
|
|
||||||
#include "clientprotocol.h"
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
GetItem::GetItem()
|
|
||||||
{
|
|
||||||
_class = static_cast<quint8>(Command::GetItem);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
#ifndef GETITEM_H
|
|
||||||
#define GETITEM_H
|
|
||||||
|
|
||||||
#include <updateplayerdata.h>
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
|
|
||||||
class CLIENTPROTOCOLSHARED_EXPORT GetItem : public UpdatePlayerData
|
|
||||||
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
GetItem();
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif // GETITEM_H
|
|
@ -1,71 +0,0 @@
|
|||||||
#include "login.h"
|
|
||||||
#include "config.h"
|
|
||||||
#include "clientprotocol.h"
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
bool Login::getRegisterNewUser() const {
|
|
||||||
return registerNewUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Login::setRegisterNewUser(bool value) {
|
|
||||||
registerNewUser = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
Login::Login() {
|
|
||||||
_class = static_cast<quint8>(Command::Login);
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseNetworkObject *Login::create() const {
|
|
||||||
return new Login();
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClassSize Login::classSize() const {
|
|
||||||
auto size = BaseNetworkObject::classSize();
|
|
||||||
EncryptionParams param = {
|
|
||||||
cryptoAlghoritms::RSA | cryptoAlghoritms::Key,
|
|
||||||
BASE_HASH_BITS,
|
|
||||||
BASE_ENCRYPTION_BITS
|
|
||||||
};
|
|
||||||
return size + getTypeSize(param) + getTypeSize(gmail) + getTypeSize(registerNewUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &Login::writeToStream(QDataStream &stream) const {
|
|
||||||
BaseNetworkObject::writeToStream(stream);
|
|
||||||
stream << gmail;
|
|
||||||
stream << hashRsaPass;
|
|
||||||
stream << registerNewUser;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &Login::readFromStream(QDataStream &stream) {
|
|
||||||
BaseNetworkObject::readFromStream(stream);
|
|
||||||
stream >> gmail;
|
|
||||||
stream >> hashRsaPass;
|
|
||||||
stream >> registerNewUser;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Login::isValid() const {
|
|
||||||
return gmail.size() > 5 &&
|
|
||||||
hashRsaPass.size() >= 32 &&
|
|
||||||
hashRsaPass.size() <= 64 &&
|
|
||||||
BaseNetworkObject::isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Login::getGmail() const {
|
|
||||||
return gmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Login::setGmail(const QString &value) {
|
|
||||||
gmail = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray Login::getHashPass() const {
|
|
||||||
return hashRsaPass;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Login::setHashPass(const QByteArray &value) {
|
|
||||||
hashRsaPass = value;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
#ifndef LOGIN_H
|
|
||||||
#define LOGIN_H
|
|
||||||
|
|
||||||
#include "basenetworkobject.h"
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
class CLIENTPROTOCOLSHARED_EXPORT Login : public BaseNetworkObject
|
|
||||||
{
|
|
||||||
|
|
||||||
private:
|
|
||||||
QByteArray hashRsaPass;
|
|
||||||
QString gmail;
|
|
||||||
bool registerNewUser = false;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Login();
|
|
||||||
|
|
||||||
BaseNetworkObject *create() const override;
|
|
||||||
NetworkClassSize classSize() const override;
|
|
||||||
QDataStream &writeToStream(QDataStream &stream) const override;
|
|
||||||
QDataStream &readFromStream(QDataStream &stream) override;
|
|
||||||
bool isValid() const override;
|
|
||||||
QString getGmail() const;
|
|
||||||
void setGmail(const QString &value);
|
|
||||||
QByteArray getHashPass() const;
|
|
||||||
void setHashPass(const QByteArray &value);
|
|
||||||
bool getRegisterNewUser() const;
|
|
||||||
void setRegisterNewUser(bool value);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif // LOGIN_H
|
|
@ -1,45 +0,0 @@
|
|||||||
#include "map.h"
|
|
||||||
#include <clientprotocol.h>
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
Map::Map()
|
|
||||||
{
|
|
||||||
_class = static_cast<quint8>(Command::Map);
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseNetworkObject *Map::create() const {
|
|
||||||
return new Map();
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClassSize Map::classSize() const {
|
|
||||||
|
|
||||||
return BaseNetworkObject::classSize()
|
|
||||||
+ getTypeSize(lvl)
|
|
||||||
+ getTypeSize(lenght)
|
|
||||||
+ getTypeSize(objects);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &Map::writeToStream(QDataStream &stream) const {
|
|
||||||
BaseNetworkObject::writeToStream(stream);
|
|
||||||
stream << lvl;
|
|
||||||
stream << lenght;
|
|
||||||
stream << objects;
|
|
||||||
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &Map::readFromStream(QDataStream &stream) {
|
|
||||||
BaseNetworkObject::readFromStream(stream);
|
|
||||||
stream >> lvl;
|
|
||||||
stream >> lenght;
|
|
||||||
stream >> objects;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Map::isValid() const {
|
|
||||||
return lenght > 1 && objects.size() > 1 &&
|
|
||||||
BaseNetworkObject::isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
#ifndef MAP_H
|
|
||||||
#define MAP_H
|
|
||||||
#include "basenetworkobject.h"
|
|
||||||
#include "objdata.h"
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
class CLIENTPROTOCOLSHARED_EXPORT Map : public BaseNetworkObject
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
quint8 lvl;
|
|
||||||
quint16 lenght;
|
|
||||||
QList<ObjData> objects;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Map();
|
|
||||||
|
|
||||||
BaseNetworkObject *create() const override;
|
|
||||||
NetworkClassSize classSize() const override;
|
|
||||||
QDataStream &writeToStream(QDataStream &stream) const override;
|
|
||||||
QDataStream &readFromStream(QDataStream &stream) override;
|
|
||||||
bool isValid() const override;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif // MAP_H
|
|
@ -1,24 +0,0 @@
|
|||||||
#include "objdata.h"
|
|
||||||
#include <QDataStream>
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
QDataStream& operator <<(QDataStream &stream, const ObjData &obj) {
|
|
||||||
stream << obj.id;
|
|
||||||
stream << obj.x;
|
|
||||||
stream << obj.y;
|
|
||||||
stream << obj.rat;
|
|
||||||
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream& operator >>(QDataStream &stream, ObjData &obj) {
|
|
||||||
stream >> obj.id;
|
|
||||||
stream >> obj.x;
|
|
||||||
stream >> obj.y;
|
|
||||||
stream >> obj.rat;
|
|
||||||
|
|
||||||
return stream;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
#ifndef OBJDATA_H
|
|
||||||
#define OBJDATA_H
|
|
||||||
#include "clientprotocol_global.h"
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
struct CLIENTPROTOCOLSHARED_EXPORT ObjData {
|
|
||||||
int id;
|
|
||||||
unsigned short x;
|
|
||||||
unsigned short y;
|
|
||||||
unsigned short rat;
|
|
||||||
|
|
||||||
friend QDataStream& operator << (QDataStream& stream, const ObjData& obj);
|
|
||||||
friend QDataStream& operator >> (QDataStream& stream, ObjData& obj);
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif // OBJDATA_H
|
|
@ -1,116 +0,0 @@
|
|||||||
#include "player.h"
|
|
||||||
#include "config.h"
|
|
||||||
#include <clientprotocol.h>
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
|
|
||||||
QString Player::getName() const {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::setName(const QString &value) {
|
|
||||||
name = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Player::getGmail() const {
|
|
||||||
return gmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::setGmail(const QString &value) {
|
|
||||||
gmail = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int Player::getMany() const
|
|
||||||
{
|
|
||||||
return money;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::setMany(unsigned int value) {
|
|
||||||
money = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int Player::getRecord() const {
|
|
||||||
return record;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::setRecord(unsigned int value) {
|
|
||||||
record = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<int> Player::getItems() const {
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::setItems(const QList<int> &value) {
|
|
||||||
items = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Player::getCureentSnake() const {
|
|
||||||
return cureentSnake;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::setCureentSnake(int value) {
|
|
||||||
cureentSnake = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
unsigned int Player::getAvgRecord() const {
|
|
||||||
return avgRecord;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::setAvgRecord(unsigned int value) {
|
|
||||||
avgRecord = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player::Player() {
|
|
||||||
_class = static_cast<quint8>(Command::Player);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseNetworkObject *Player::create() const {
|
|
||||||
return new Player();
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClassSize Player::classSize() const {
|
|
||||||
|
|
||||||
return UpdatePlayerData::classSize()
|
|
||||||
+ getTypeSize(name)
|
|
||||||
+ getTypeSize(gmail)
|
|
||||||
+ getTypeSize(money)
|
|
||||||
+ getTypeSize(record)
|
|
||||||
+ getTypeSize(avgRecord)
|
|
||||||
+ getTypeSize(items)
|
|
||||||
+ getTypeSize(cureentSnake);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &Player::writeToStream(QDataStream &stream) const {
|
|
||||||
UpdatePlayerData::writeToStream(stream);
|
|
||||||
stream << name;
|
|
||||||
stream << gmail;
|
|
||||||
stream << money;
|
|
||||||
stream << record;
|
|
||||||
stream << avgRecord;
|
|
||||||
stream << items;
|
|
||||||
stream << cureentSnake;
|
|
||||||
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &Player::readFromStream(QDataStream &stream) {
|
|
||||||
UpdatePlayerData::readFromStream(stream);
|
|
||||||
stream >> name;
|
|
||||||
stream >> gmail;
|
|
||||||
stream >> money;
|
|
||||||
stream >> record;
|
|
||||||
stream >> avgRecord;
|
|
||||||
stream >> items;
|
|
||||||
stream >> cureentSnake;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Player::isValid() const {
|
|
||||||
return !name.isNull() && gmail.size() > 5 &&
|
|
||||||
BaseNetworkObject::isValid();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
#ifndef PLAYER_H
|
|
||||||
#define PLAYER_H
|
|
||||||
|
|
||||||
#include "updateplayerdata.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
|
|
||||||
class CLIENTPROTOCOLSHARED_EXPORT Player: public UpdatePlayerData
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
QString name = "user";
|
|
||||||
QString gmail = "";
|
|
||||||
|
|
||||||
unsigned int money = 0;
|
|
||||||
unsigned int record = 0;
|
|
||||||
unsigned int avgRecord = 0;
|
|
||||||
QList<int> items;
|
|
||||||
int cureentSnake = -1;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Player();
|
|
||||||
|
|
||||||
BaseNetworkObject *create() const override;
|
|
||||||
NetworkClassSize classSize() const override;
|
|
||||||
QDataStream &writeToStream(QDataStream &stream) const override;
|
|
||||||
QDataStream &readFromStream(QDataStream &stream) override;
|
|
||||||
bool isValid() const override;
|
|
||||||
QString getName() const;
|
|
||||||
void setName(const QString &value);
|
|
||||||
QString getGmail() const;
|
|
||||||
void setGmail(const QString &value);
|
|
||||||
unsigned int getMany() const;
|
|
||||||
void setMany(unsigned int value);
|
|
||||||
unsigned int getRecord() const;
|
|
||||||
void setRecord(unsigned int value);
|
|
||||||
QList<int> getItems() const;
|
|
||||||
void setItems(const QList<int> &value);
|
|
||||||
int getCureentSnake() const;
|
|
||||||
void setCureentSnake(int value);
|
|
||||||
unsigned int getAvgRecord() const;
|
|
||||||
void setAvgRecord(unsigned int value);
|
|
||||||
// QString getHexPass() const;
|
|
||||||
// void fromHexPass(const QString& passHex);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif // PLAYER_H
|
|
@ -1,62 +0,0 @@
|
|||||||
#include "pubkey.h"
|
|
||||||
#include "clientprotocol.h"
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
PubKey::PubKey():
|
|
||||||
BaseNetworkObject() {
|
|
||||||
_class = static_cast<quint8>(Command::PubKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
QRSAEncryption::Rsa PubKey::getTypeKey() const {
|
|
||||||
return typeKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PubKey::setTypeKey(const QRSAEncryption::Rsa &value) {
|
|
||||||
typeKey = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray PubKey::getKey() const {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PubKey::setKey(const QByteArray &value) {
|
|
||||||
key = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseNetworkObject *PubKey::create() const {
|
|
||||||
return new PubKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClassSize PubKey::classSize() const {
|
|
||||||
EncryptionParams param = {
|
|
||||||
cryptoAlghoritms::RSA | cryptoAlghoritms::Key,
|
|
||||||
BASE_ENCRYPTION_BITS
|
|
||||||
};
|
|
||||||
return BaseNetworkObject::classSize() +
|
|
||||||
getTypeSize(param) +
|
|
||||||
getTypeSize(int(typeKey));
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &PubKey::writeToStream(QDataStream &stream) const {
|
|
||||||
BaseNetworkObject::writeToStream(stream);
|
|
||||||
stream << int(typeKey);
|
|
||||||
stream << key;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &PubKey::readFromStream(QDataStream &stream) {
|
|
||||||
BaseNetworkObject::readFromStream(stream);
|
|
||||||
int _typeKey;
|
|
||||||
stream >> _typeKey;
|
|
||||||
typeKey = static_cast<QRSAEncryption::Rsa>(_typeKey);
|
|
||||||
stream >> key;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PubKey::isValid() const {
|
|
||||||
return static_cast<quint32>(key.size()) == QRSAEncryption::getKeyBytesSize(typeKey)
|
|
||||||
&& BaseNetworkObject::isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
#ifndef PUBKEY_H
|
|
||||||
#define PUBKEY_H
|
|
||||||
#include <qrsaencryption.h>
|
|
||||||
|
|
||||||
#include "basenetworkobject.h"
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
class CLIENTPROTOCOLSHARED_EXPORT PubKey: public BaseNetworkObject
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
QRSAEncryption::Rsa typeKey;
|
|
||||||
QByteArray key;
|
|
||||||
|
|
||||||
public:
|
|
||||||
PubKey();
|
|
||||||
|
|
||||||
BaseNetworkObject *create() const override;
|
|
||||||
NetworkClassSize classSize() const override;
|
|
||||||
QDataStream &writeToStream(QDataStream &stream) const override;
|
|
||||||
QDataStream &readFromStream(QDataStream &stream) override;
|
|
||||||
bool isValid() const override;
|
|
||||||
|
|
||||||
QRSAEncryption::Rsa getTypeKey() const;
|
|
||||||
void setTypeKey(const QRSAEncryption::Rsa &value);
|
|
||||||
QByteArray getKey() const;
|
|
||||||
void setKey(const QByteArray &value);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif // PUBKEY_H
|
|
@ -1,68 +0,0 @@
|
|||||||
#include "snake.h"
|
|
||||||
#include "clientprotocol.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
quint8 Snake::getSpeed() const {
|
|
||||||
return speed;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Snake::setSpeed(const quint8 &value) {
|
|
||||||
speed = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
quint8 Snake::getSnakeClass() const {
|
|
||||||
return snakeClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Snake::setSnakeClass(const quint8 &value) {
|
|
||||||
snakeClass = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<float> Snake::getSkillet() const {
|
|
||||||
return skillet;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Snake::setSkillet(const QList<float> &value) {
|
|
||||||
skillet = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseNetworkObject *Snake::create() const {
|
|
||||||
return new Snake();
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClassSize Snake::classSize() const {
|
|
||||||
return BaseNetworkObject::classSize() +
|
|
||||||
getTypeSize(speed) +
|
|
||||||
getTypeSize(snakeClass) +
|
|
||||||
getTypeSize(skillet);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &Snake::writeToStream(QDataStream &stream) const {
|
|
||||||
BaseNetworkObject::writeToStream(stream);
|
|
||||||
stream << speed;
|
|
||||||
stream << snakeClass;
|
|
||||||
stream << skillet;
|
|
||||||
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &Snake::readFromStream(QDataStream &stream) {
|
|
||||||
BaseNetworkObject::readFromStream(stream);
|
|
||||||
stream >> speed;
|
|
||||||
stream >> snakeClass;
|
|
||||||
stream >> skillet;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Snake::isValid() const {
|
|
||||||
return (speed > 0) && skillet.size() && BaseNetworkObject::isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
Snake::Snake() {
|
|
||||||
_class = static_cast<quint8>(Command::Snake);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
#ifndef SNAKE_H
|
|
||||||
#define SNAKE_H
|
|
||||||
|
|
||||||
#include "basenetworkobject.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
class CLIENTPROTOCOLSHARED_EXPORT Snake: public BaseNetworkObject
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
quint8 speed;
|
|
||||||
quint8 snakeClass;
|
|
||||||
QList<float> skillet;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Snake();
|
|
||||||
quint8 getSpeed() const;
|
|
||||||
void setSpeed(const quint8 &value);
|
|
||||||
quint8 getSnakeClass() const;
|
|
||||||
void setSnakeClass(const quint8 &value);
|
|
||||||
QList<float> getSkillet() const;
|
|
||||||
void setSkillet(const QList<float> &value);
|
|
||||||
|
|
||||||
BaseNetworkObject *create() const override;
|
|
||||||
NetworkClassSize classSize() const override;
|
|
||||||
QDataStream &writeToStream(QDataStream &stream) const override;
|
|
||||||
QDataStream &readFromStream(QDataStream &stream) override;
|
|
||||||
bool isValid() const override;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif // SNAKE_H
|
|
@ -1,49 +0,0 @@
|
|||||||
#include "updateplayerdata.h"
|
|
||||||
#include "config.h"
|
|
||||||
#include "clientprotocol.h"
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
UpdatePlayerData::UpdatePlayerData() {
|
|
||||||
_class = static_cast<quint8>(Command::UpdatePlayerData);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray UpdatePlayerData::getToken() const {
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdatePlayerData::setToken(const QByteArray &value) {
|
|
||||||
token = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseNetworkObject *UpdatePlayerData::create() const {
|
|
||||||
return new UpdatePlayerData();
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClassSize UpdatePlayerData::classSize() const {
|
|
||||||
EncryptionParams param = {
|
|
||||||
cryptoAlghoritms::SHA,
|
|
||||||
BASE_HASH_BITS
|
|
||||||
};
|
|
||||||
|
|
||||||
return BaseNetworkObject::classSize() + getTypeSize(param);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &UpdatePlayerData::writeToStream(QDataStream &stream) const {
|
|
||||||
BaseNetworkObject::writeToStream(stream);
|
|
||||||
stream << token;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &UpdatePlayerData::readFromStream(QDataStream &stream) {
|
|
||||||
BaseNetworkObject::readFromStream(stream);
|
|
||||||
stream >> token;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UpdatePlayerData::isValid() const {
|
|
||||||
return token.size() == 32 && BaseNetworkObject::isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
#ifndef UPDATEPLAYERDATA_H
|
|
||||||
#define UPDATEPLAYERDATA_H
|
|
||||||
|
|
||||||
#include "basenetworkobject.h"
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
|
|
||||||
class CLIENTPROTOCOLSHARED_EXPORT UpdatePlayerData : public BaseNetworkObject
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
QByteArray token;
|
|
||||||
|
|
||||||
public:
|
|
||||||
UpdatePlayerData();
|
|
||||||
QByteArray getToken() const;
|
|
||||||
void setToken(const QByteArray &value);
|
|
||||||
|
|
||||||
BaseNetworkObject *create() const override;
|
|
||||||
NetworkClassSize classSize() const override;
|
|
||||||
QDataStream &writeToStream(QDataStream &stream) const override;
|
|
||||||
QDataStream &readFromStream(QDataStream &stream) override;
|
|
||||||
bool isValid() const override;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif // UPDATEPLAYERDATA_H
|
|
@ -1,71 +0,0 @@
|
|||||||
#include "websocket.h"
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
WebSocket::WebSocket() {
|
|
||||||
_class = static_cast<quint8>(Command::WebSocket);
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseNetworkObject *ClientProtocol::WebSocket::create() const {
|
|
||||||
return new WebSocket();
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClassSize WebSocket::classSize() const {
|
|
||||||
return UpdatePlayerData::classSize() + getTypeSize(_data);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &WebSocket::writeToStream(QDataStream &stream) const {
|
|
||||||
UpdatePlayerData::writeToStream(stream);
|
|
||||||
stream << _data;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &WebSocket::readFromStream(QDataStream &stream) {
|
|
||||||
UpdatePlayerData::readFromStream(stream);
|
|
||||||
stream >> _data;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WebSocket::isValid() const {
|
|
||||||
return static_cast<Command>(_data.cmd) != Command::Undefined &&
|
|
||||||
UpdatePlayerData::isValid();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WebSocket::isSubscribe() const {
|
|
||||||
return _data.subscribe;
|
|
||||||
}
|
|
||||||
|
|
||||||
Command WebSocket::getCommand() const {
|
|
||||||
return static_cast<Command>(_data.cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
int WebSocket::getObjectId() const {
|
|
||||||
return _data.objectId;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebSocket::setSubscribe(bool subscribe){
|
|
||||||
_data.subscribe = subscribe;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebSocket::setCommand(Command cmd) {
|
|
||||||
_data.cmd = static_cast<unsigned char>(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebSocket::setObjectId(int value) {
|
|
||||||
_data.objectId = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &operator<<(QDataStream &stream, WebSocketData data) {
|
|
||||||
stream.writeRawData(reinterpret_cast<char*>(&data), sizeof (data));
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &operator>>(QDataStream &stream, WebSocketData &data) {
|
|
||||||
stream.readRawData(reinterpret_cast<char*>(&data), sizeof (data));
|
|
||||||
return stream;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
#ifndef WEBSOCKET_H
|
|
||||||
#define WEBSOCKET_H
|
|
||||||
#include "updateplayerdata.h"
|
|
||||||
#include "clientprotocol.h"
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
|
||||||
struct WebSocketData {
|
|
||||||
unsigned char cmd : 5;
|
|
||||||
unsigned subscribe : 1;
|
|
||||||
int objectId : 26; // -1 is all ovjects, or other bumber is number of object
|
|
||||||
|
|
||||||
friend QDataStream& operator<< (QDataStream& stream, WebSocketData data);
|
|
||||||
friend QDataStream& operator>> (QDataStream& stream, WebSocketData& data);
|
|
||||||
};
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
class CLIENTPROTOCOLSHARED_EXPORT WebSocket : public UpdatePlayerData
|
|
||||||
{
|
|
||||||
WebSocketData _data;
|
|
||||||
public:
|
|
||||||
WebSocket();
|
|
||||||
|
|
||||||
BaseNetworkObject *create() const override;
|
|
||||||
NetworkClassSize classSize() const override;
|
|
||||||
QDataStream &writeToStream(QDataStream &stream) const override;
|
|
||||||
QDataStream &readFromStream(QDataStream &stream) override;
|
|
||||||
bool isValid() const override;
|
|
||||||
|
|
||||||
bool isSubscribe() const;
|
|
||||||
Command getCommand() const;
|
|
||||||
int getObjectId() const;
|
|
||||||
|
|
||||||
void setSubscribe(bool subscribe);
|
|
||||||
void setCommand(Command cmd) ;
|
|
||||||
void setObjectId(int value);
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif // WEBSOCKET_H
|
|
@ -1,4 +1,4 @@
|
|||||||
#include "client.h"
|
#include "baseclient.h"
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
#define SOLT "SNAKE"
|
#define SOLT "SNAKE"
|
||||||
namespace ClientProtocol {
|
namespace ClientProtocol {
|
||||||
|
|
||||||
Command Client::checkCommand(int sig, Command reqCmd, Type type) {
|
Command BaseClient::checkCommand(int sig, Command reqCmd, Type type) {
|
||||||
|
|
||||||
#define idx static_cast<quint8>(sig)
|
#define idx static_cast<quint8>(sig)
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ Command Client::checkCommand(int sig, Command reqCmd, Type type) {
|
|||||||
return expCmd;
|
return expCmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::updateStatuses(Command extCmd, Command cmd, Type type, const QByteArray& obj)
|
void BaseClient::updateStatuses(Command extCmd, Command cmd, Type type, const QByteArray& obj)
|
||||||
{
|
{
|
||||||
setOnlineStatus(extCmd != Command::Undefined && type == Type::Responke);
|
setOnlineStatus(extCmd != Command::Undefined && type == Type::Responke);
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ void Client::updateStatuses(Command extCmd, Command cmd, Type type, const QByteA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::receiveData(const QByteArray &obj, Header hdr) {
|
bool BaseClient::receiveData(const QByteArray &obj, Header hdr) {
|
||||||
|
|
||||||
auto command = static_cast<Command>(hdr.command);
|
auto command = static_cast<Command>(hdr.command);
|
||||||
auto requesCommand = static_cast<Command>(hdr.requestCommand);
|
auto requesCommand = static_cast<Command>(hdr.requestCommand);
|
||||||
@ -91,7 +91,7 @@ bool Client::receiveData(const QByteArray &obj, Header hdr) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::setRSAKey(const QByteArray& key) {
|
bool BaseClient::setRSAKey(const QByteArray& key) {
|
||||||
bool newStatus = QRSAEncryption::isValidRsaKey(key);
|
bool newStatus = QRSAEncryption::isValidRsaKey(key);
|
||||||
setOnlineStatus(newStatus);
|
setOnlineStatus(newStatus);
|
||||||
|
|
||||||
@ -102,14 +102,14 @@ bool Client::setRSAKey(const QByteArray& key) {
|
|||||||
return newStatus;
|
return newStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::setLoginStatus(bool newStatus) {
|
void BaseClient::setLoginStatus(bool newStatus) {
|
||||||
if (newStatus != _logined) {
|
if (newStatus != _logined) {
|
||||||
_logined = newStatus;
|
_logined = newStatus;
|
||||||
emit loginChanged(_logined);
|
emit loginChanged(_logined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::setOnlineStatus(bool newOnline) {
|
void BaseClient::setOnlineStatus(bool newOnline) {
|
||||||
if (newOnline != _online) {
|
if (newOnline != _online) {
|
||||||
_online = newOnline;
|
_online = newOnline;
|
||||||
emit onlineChanged(_online);
|
emit onlineChanged(_online);
|
||||||
@ -120,7 +120,7 @@ void Client::setOnlineStatus(bool newOnline) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::incommingData() {
|
void BaseClient::incommingData() {
|
||||||
auto array = _destination->readAll();
|
auto array = _destination->readAll();
|
||||||
|
|
||||||
if (_downloadPackage.hdr.isValid()) {
|
if (_downloadPackage.hdr.isValid()) {
|
||||||
@ -142,24 +142,24 @@ void Client::incommingData() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::handleDisconnected() {
|
void BaseClient::handleDisconnected() {
|
||||||
setOnlineStatus(false);
|
setOnlineStatus(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Client::Client(const QString &addrress, unsigned short port, QObject *ptr):
|
BaseClient::BaseClient(const QString &addrress, unsigned short port, QObject *ptr):
|
||||||
QObject (ptr) {
|
QObject (ptr) {
|
||||||
|
|
||||||
_destination = new QTcpSocket(this);
|
_destination = new QTcpSocket(this);
|
||||||
connectToHost(addrress, port);
|
connectToHost(addrress, port);
|
||||||
|
|
||||||
connect(_destination, &QTcpSocket::readyRead,
|
connect(_destination, &QTcpSocket::readyRead,
|
||||||
this, &Client::incommingData);
|
this, &BaseClient::incommingData);
|
||||||
|
|
||||||
connect(_destination, &QTcpSocket::disconnected,
|
connect(_destination, &QTcpSocket::disconnected,
|
||||||
this, &Client::handleDisconnected);
|
this, &BaseClient::handleDisconnected);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::sendPackage(Package &pkg) {
|
bool BaseClient::sendPackage(Package &pkg) {
|
||||||
if (!pkg.isValid()) {
|
if (!pkg.isValid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -184,11 +184,11 @@ bool Client::sendPackage(Package &pkg) {
|
|||||||
return sendet;
|
return sendet;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char Client::nextIndex() {
|
unsigned char BaseClient::nextIndex() {
|
||||||
return static_cast<unsigned char>((currentIndex++) % 256);
|
return static_cast<unsigned char>((currentIndex++) % 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::ping() {
|
bool BaseClient::ping() {
|
||||||
|
|
||||||
Package pcg;
|
Package pcg;
|
||||||
|
|
||||||
@ -206,12 +206,12 @@ bool Client::ping() {
|
|||||||
|
|
||||||
/// Do not change the order of this function,
|
/// Do not change the order of this function,
|
||||||
/// as this may lead to the loss of user accounts.
|
/// as this may lead to the loss of user accounts.
|
||||||
QByteArray Client::generateHash(const QByteArray& pass) const {
|
QByteArray BaseClient::generateHash(const QByteArray& pass) const {
|
||||||
auto passHash = QCryptographicHash::hash(pass, QCryptographicHash::Sha256);
|
auto passHash = QCryptographicHash::hash(pass, QCryptographicHash::Sha256);
|
||||||
return QCryptographicHash::hash(SOLT + passHash, QCryptographicHash::Sha256);
|
return QCryptographicHash::hash(SOLT + passHash, QCryptographicHash::Sha256);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::login(const QString &gmail, const QByteArray &pass, bool newUser) {
|
bool BaseClient::login(const QString &gmail, const QByteArray &pass, bool newUser) {
|
||||||
if (!pass.size()) {
|
if (!pass.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -249,30 +249,30 @@ bool Client::login(const QString &gmail, const QByteArray &pass, bool newUser) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::registration(const QString &gmail,
|
bool BaseClient::registration(const QString &gmail,
|
||||||
const QByteArray &pass) {
|
const QByteArray &pass) {
|
||||||
return login(gmail, pass, true);
|
return login(gmail, pass, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::loginOut() {
|
void BaseClient::loginOut() {
|
||||||
_token = "";
|
_token = "";
|
||||||
setLoginStatus(false);
|
setLoginStatus(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::dissconnectFromHost() {
|
void BaseClient::dissconnectFromHost() {
|
||||||
loginOut();
|
loginOut();
|
||||||
_destination->disconnectFromHost();
|
_destination->disconnectFromHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::connectToHost(const QString &address, unsigned short port) {
|
void BaseClient::connectToHost(const QString &address, unsigned short port) {
|
||||||
_destination->connectToHost(_address = address, _port = port);
|
_destination->connectToHost(_address = address, _port = port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::reconnectToHost() {
|
void BaseClient::reconnectToHost() {
|
||||||
_destination->connectToHost(_address, _port);
|
_destination->connectToHost(_address, _port);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::updateData() {
|
bool BaseClient::updateData() {
|
||||||
|
|
||||||
if (!isLogin()) {
|
if (!isLogin()) {
|
||||||
return false;
|
return false;
|
||||||
@ -299,7 +299,7 @@ bool Client::updateData() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::savaData(const QList<int>& gameData) {
|
bool BaseClient::savaData(const QList<int>& gameData) {
|
||||||
if (!isLogin()) {
|
if (!isLogin()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ bool Client::savaData(const QList<int>& gameData) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::getItem(int id) {
|
bool BaseClient::getItem(int id) {
|
||||||
|
|
||||||
if (!isLogin()) {
|
if (!isLogin()) {
|
||||||
return false;
|
return false;
|
||||||
@ -357,7 +357,7 @@ bool Client::getItem(int id) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::getPlayer(int id){
|
bool BaseClient::getPlayer(int id){
|
||||||
if (!isLogin()) {
|
if (!isLogin()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -387,15 +387,15 @@ bool Client::getPlayer(int id){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool& Client::isOnline() const {
|
const bool& BaseClient::isOnline() const {
|
||||||
return _online;
|
return _online;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool& Client::isLogin() const {
|
const bool& BaseClient::isLogin() const {
|
||||||
return _logined;
|
return _logined;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::setSubscribe(Command cmd, bool subscribe, int id) {
|
bool BaseClient::setSubscribe(Command cmd, bool subscribe, int id) {
|
||||||
if (!isLogin()) {
|
if (!isLogin()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -430,7 +430,7 @@ bool Client::setSubscribe(Command cmd, bool subscribe, int id) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<quint8, bool> Client::getSubscribe() const {
|
QHash<quint8, bool> BaseClient::getSubscribe() const {
|
||||||
return _subscribe;
|
return _subscribe;
|
||||||
}
|
}
|
||||||
|
|
@ -14,32 +14,20 @@ class testSankeServer;
|
|||||||
namespace ClientProtocol {
|
namespace ClientProtocol {
|
||||||
|
|
||||||
|
|
||||||
class CLIENTPROTOCOLSHARED_EXPORT Client: public QObject
|
class CLIENTPROTOCOLSHARED_EXPORT BaseClient: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
QTcpSocket *_destination;
|
QTcpSocket *_destination;
|
||||||
Package _downloadPackage;
|
Package _downloadPackage;
|
||||||
bool _online = false;
|
|
||||||
bool _logined = false;
|
|
||||||
QByteArray _token;
|
QByteArray _token;
|
||||||
QByteArray _rsaKey;
|
|
||||||
int currentIndex = 0;
|
int currentIndex = 0;
|
||||||
QHash<unsigned char, QVariantMap> _requestsMap;
|
QHash<unsigned char, QVariantMap> _requestsMap;
|
||||||
QHash<quint8, bool> _subscribe; // command and data confirmation
|
QHash<quint8, bool> _subscribe; // command and data confirmation
|
||||||
QString _address = LOCAL_SNAKE_SERVER;
|
QString _address = LOCAL_SNAKE_SERVER;
|
||||||
unsigned short _port = DEFAULT_SNAKE_PORT;
|
unsigned short _port = DEFAULT_SNAKE_PORT;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief checkCommand - return old sendet command if commnad not valid return undefined command
|
|
||||||
* @param sig - sig package
|
|
||||||
* @param reqCmd - reqCmd of package
|
|
||||||
* @param type - type of package
|
|
||||||
* @return if commnad not valid return undefined command
|
|
||||||
*/
|
|
||||||
Command checkCommand(int sig, Command reqCmd, Type type);
|
|
||||||
bool receiveData(const QByteArray &obj, Header hdr);
|
bool receiveData(const QByteArray &obj, Header hdr);
|
||||||
bool setRSAKey(const QByteArray &key);
|
|
||||||
void setLoginStatus(bool newStatus);
|
void setLoginStatus(bool newStatus);
|
||||||
void setOnlineStatus(bool newStatus);
|
void setOnlineStatus(bool newStatus);
|
||||||
bool sendPackage(Package &pkg);
|
bool sendPackage(Package &pkg);
|
||||||
@ -48,8 +36,6 @@ private:
|
|||||||
|
|
||||||
QByteArray generateHash(const QByteArray &pass) const;
|
QByteArray generateHash(const QByteArray &pass) const;
|
||||||
|
|
||||||
void updateStatuses(Command extCmd, Command cmd, Type type, const QByteArray &obj);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void incommingData();
|
void incommingData();
|
||||||
void handleDisconnected();
|
void handleDisconnected();
|
||||||
@ -59,7 +45,7 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Client(const QString& addrress = LOCAL_SNAKE_SERVER,
|
explicit BaseClient(const QString& addrress = LOCAL_SNAKE_SERVER,
|
||||||
unsigned short port = DEFAULT_SNAKE_PORT,
|
unsigned short port = DEFAULT_SNAKE_PORT,
|
||||||
QObject * ptr = nullptr);
|
QObject * ptr = nullptr);
|
||||||
|
|
@ -1,13 +1,11 @@
|
|||||||
#include "server.h"
|
#include "baseserver.h"
|
||||||
#include "quasarapp.h"
|
#include "quasarapp.h"
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
#include <factorynetobjects.h>
|
|
||||||
#include <pubkey.h>
|
|
||||||
#include "clientprotocol.h"
|
#include "clientprotocol.h"
|
||||||
|
|
||||||
namespace ClientProtocol {
|
namespace ClientProtocol {
|
||||||
|
|
||||||
bool Server::parsePackage(const Package &pkg, QTcpSocket* sender) {
|
bool BaseServer::parsePackage(const Package &pkg, QAbstractSocket* sender) {
|
||||||
if (!pkg.isValid()) {
|
if (!pkg.isValid()) {
|
||||||
QuasarAppUtils::Params::verboseLog("incomming package is not valid!");
|
QuasarAppUtils::Params::verboseLog("incomming package is not valid!");
|
||||||
changeKarma(sender->peerAddress().toIPv4Address(), CRITICAL_ERROOR);
|
changeKarma(sender->peerAddress().toIPv4Address(), CRITICAL_ERROOR);
|
||||||
@ -31,7 +29,7 @@ bool Server::parsePackage(const Package &pkg, QTcpSocket* sender) {
|
|||||||
|
|
||||||
if (!(pcg.create(Command::Ping, Type::Responke, &pkg.hdr))) {
|
if (!(pcg.create(Command::Ping, Type::Responke, &pkg.hdr))) {
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
|
|
||||||
if (!sendPackage(pcg, sender)) {
|
if (!sendPackage(pcg, sender)) {
|
||||||
QuasarAppUtils::Params::verboseLog("!responce not sendet!");
|
QuasarAppUtils::Params::verboseLog("!responce not sendet!");
|
||||||
@ -49,7 +47,7 @@ bool Server::parsePackage(const Package &pkg, QTcpSocket* sender) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::sendPackage(const Package &pkg, QTcpSocket * target) {
|
bool BaseServer::sendPackage(const Package &pkg, QAbstractSocket * target) {
|
||||||
if (!pkg.isValid()) {
|
if (!pkg.isValid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -70,7 +68,7 @@ bool Server::sendPackage(const Package &pkg, QTcpSocket * target) {
|
|||||||
return sendet;
|
return sendet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::ban(quint32 target) {
|
void BaseServer::ban(quint32 target) {
|
||||||
if (!_connections[target]) {
|
if (!_connections[target]) {
|
||||||
_connections[target] = new Connectioninfo();
|
_connections[target] = new Connectioninfo();
|
||||||
}
|
}
|
||||||
@ -78,7 +76,7 @@ void Server::ban(quint32 target) {
|
|||||||
_connections[target]->ban();
|
_connections[target]->ban();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::unBan(quint32 target) {
|
void BaseServer::unBan(quint32 target) {
|
||||||
if (!_connections.contains(target)) {
|
if (!_connections.contains(target)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -86,37 +84,19 @@ void Server::unBan(quint32 target) {
|
|||||||
_connections[target]->unBan();
|
_connections[target]->unBan();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::registerSocket(QTcpSocket *socket) {
|
bool BaseServer::registerSocket(QAbstractSocket *socket) {
|
||||||
auto address = socket->peerAddress().toIPv4Address();
|
auto address = socket->peerAddress().toIPv4Address();
|
||||||
|
|
||||||
if (!_pool) {
|
|
||||||
QuasarAppUtils::Params::verboseLog("key pool is not inited", QuasarAppUtils::Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
RSAKeyPair pair;
|
_connections[address] = new Connectioninfo(socket, DEFAULT_KARMA);
|
||||||
|
|
||||||
if (!_pool->take(BASE_RSA_BITS, pair)) {
|
connect(socket, &QTcpSocket::readyRead, this, &BaseServer::avelableBytes);
|
||||||
QuasarAppUtils::Params::verboseLog("key pool is empty", QuasarAppUtils::Error);
|
connect(socket, &QTcpSocket::disconnected, this, &BaseServer::handleDisconected);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_connections[address] = new Connectioninfo(socket, DEFAULT_KARMA,
|
|
||||||
pair);
|
|
||||||
|
|
||||||
connect(socket, &QTcpSocket::readyRead, this, &Server::avelableBytes);
|
|
||||||
connect(socket, &QTcpSocket::disconnected, this, &Server::handleDisconected);
|
|
||||||
|
|
||||||
if (!sendPubKey(socket, pair.pub)) {
|
|
||||||
QuasarAppUtils::Params::verboseLog("not sendet pub key to client"
|
|
||||||
"generate new key!", QuasarAppUtils::Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::changeKarma(quint32 addresss, int diff) {
|
bool BaseServer::changeKarma(quint32 addresss, int diff) {
|
||||||
auto ptr = _connections.value(addresss);
|
auto ptr = _connections.value(addresss);
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
return false;
|
return false;
|
||||||
@ -136,7 +116,7 @@ bool Server::changeKarma(quint32 addresss, int diff) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::isBaned(const QTcpSocket * adr) const {
|
bool BaseServer::isBaned(const QTcpSocket * adr) const {
|
||||||
auto ptr = _connections.value(adr->peerAddress().toIPv4Address());
|
auto ptr = _connections.value(adr->peerAddress().toIPv4Address());
|
||||||
|
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
@ -146,7 +126,7 @@ bool Server::isBaned(const QTcpSocket * adr) const {
|
|||||||
return ptr->isBaned();
|
return ptr->isBaned();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Server::connectionsCount() const {
|
int BaseServer::connectionsCount() const {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (auto i : _connections) {
|
for (auto i : _connections) {
|
||||||
if (i->getSct()) {
|
if (i->getSct()) {
|
||||||
@ -161,29 +141,7 @@ int Server::connectionsCount() const {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::sendPubKey(QTcpSocket * target, const QByteArray &pubKey) {
|
void BaseServer::avelableBytes() {
|
||||||
|
|
||||||
Package pcg;
|
|
||||||
|
|
||||||
PubKey pubkey;
|
|
||||||
|
|
||||||
pubkey.setKey(pubKey);
|
|
||||||
pubkey.setTypeKey(BASE_RSA_BITS);
|
|
||||||
pubkey.setId(0);
|
|
||||||
|
|
||||||
if (!pubkey.isValid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(pcg.create(&pubkey, Type::Request))) {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
return sendPackage(pcg, target);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Server::avelableBytes() {
|
|
||||||
auto client = dynamic_cast<QTcpSocket*>(sender());
|
auto client = dynamic_cast<QTcpSocket*>(sender());
|
||||||
|
|
||||||
if (!client) {
|
if (!client) {
|
||||||
@ -213,7 +171,7 @@ void Server::avelableBytes() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::handleDisconected() {
|
void BaseServer::handleDisconected() {
|
||||||
auto _sender = dynamic_cast<QTcpSocket*>(sender());
|
auto _sender = dynamic_cast<QTcpSocket*>(sender());
|
||||||
|
|
||||||
if (_sender) {
|
if (_sender) {
|
||||||
@ -236,7 +194,7 @@ void Server::handleDisconected() {
|
|||||||
QuasarAppUtils::Error);
|
QuasarAppUtils::Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::handleIncommingConnection() {
|
void BaseServer::handleIncommingConnection() {
|
||||||
while (hasPendingConnections()) {
|
while (hasPendingConnections()) {
|
||||||
auto socket = nextPendingConnection();
|
auto socket = nextPendingConnection();
|
||||||
|
|
||||||
@ -249,18 +207,17 @@ void Server::handleIncommingConnection() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Server::Server(RSAKeysPool *pool, QObject *ptr) :
|
BaseServer::BaseServer(QObject *ptr) :
|
||||||
QTcpServer (ptr) {
|
QTcpServer (ptr) {
|
||||||
|
|
||||||
_pool = pool;
|
connect(this, &BaseServer::newConnection, this, &BaseServer::handleIncommingConnection);
|
||||||
connect(this, &Server::newConnection, this, &Server::handleIncommingConnection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Server::~Server() {
|
BaseServer::~BaseServer() {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::run(const QString &ip, unsigned short port) {
|
bool BaseServer::run(const QString &ip, unsigned short port) {
|
||||||
|
|
||||||
if (!listen(QHostAddress(ip), port)) {
|
if (!listen(QHostAddress(ip), port)) {
|
||||||
QuasarAppUtils::Params::verboseLog("listing fail " + this->errorString(),
|
QuasarAppUtils::Params::verboseLog("listing fail " + this->errorString(),
|
||||||
@ -271,7 +228,7 @@ bool Server::run(const QString &ip, unsigned short port) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::stop(bool reset) {
|
void BaseServer::stop(bool reset) {
|
||||||
close();
|
close();
|
||||||
|
|
||||||
if (reset) {
|
if (reset) {
|
||||||
@ -284,7 +241,7 @@ void Server::stop(bool reset) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::badRequest(quint32 address, const Header &req) {
|
void BaseServer::badRequest(quint32 address, const Header &req) {
|
||||||
auto client = _connections.value(address);
|
auto client = _connections.value(address);
|
||||||
|
|
||||||
if (!client) {
|
if (!client) {
|
||||||
@ -309,7 +266,7 @@ void Server::badRequest(quint32 address, const Header &req) {
|
|||||||
QuasarAppUtils::Params::verboseLog("Bad request detected, bud responce command not sendet!"
|
QuasarAppUtils::Params::verboseLog("Bad request detected, bud responce command not sendet!"
|
||||||
" because package not created",
|
" because package not created",
|
||||||
QuasarAppUtils::Error);
|
QuasarAppUtils::Error);
|
||||||
};
|
}
|
||||||
|
|
||||||
if (!sendPackage(pcg, client->getSct())) {
|
if (!sendPackage(pcg, client->getSct())) {
|
||||||
|
|
||||||
@ -324,7 +281,7 @@ void Server::badRequest(quint32 address, const Header &req) {
|
|||||||
QuasarAppUtils::Info);
|
QuasarAppUtils::Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::sendResponse(const BaseNetworkObject *resp, quint32 address, const Header *req) {
|
bool BaseServer::sendResponse(const BaseNetworkObject *resp, quint32 address, const Header *req) {
|
||||||
|
|
||||||
Package pcg;
|
Package pcg;
|
||||||
|
|
||||||
@ -336,12 +293,12 @@ bool Server::sendResponse(const BaseNetworkObject *resp, quint32 address, const
|
|||||||
return sendResponse(&pcg, address, req);
|
return sendResponse(&pcg, address, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::sendResponse(Package *pcg, quint32 address, const Header *req) {
|
bool BaseServer::sendResponse(Package *pcg, quint32 address, const Header *req) {
|
||||||
pcg->signPackage(req);
|
pcg->signPackage(req);
|
||||||
return sendResponse(*pcg, address);
|
return sendResponse(*pcg, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::sendResponse(const Package &pcg, quint32 address)
|
bool BaseServer::sendResponse(const Package &pcg, quint32 address)
|
||||||
{
|
{
|
||||||
auto client = _connections.value(address);
|
auto client = _connections.value(address);
|
||||||
|
|
||||||
@ -361,7 +318,7 @@ bool Server::sendResponse(const Package &pcg, quint32 address)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Server::getWorkState() const {
|
QString BaseServer::getWorkState() const {
|
||||||
if (isListening()) {
|
if (isListening()) {
|
||||||
if (hasPendingConnections())
|
if (hasPendingConnections())
|
||||||
return "overload";
|
return "overload";
|
||||||
@ -373,11 +330,11 @@ QString Server::getWorkState() const {
|
|||||||
return "Not running";
|
return "Not running";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Server::connectionState() const {
|
QString BaseServer::connectionState() const {
|
||||||
return QString("%0 / %1").arg(connectionsCount()).arg(maxPendingConnections());
|
return QString("%0 / %1").arg(connectionsCount()).arg(maxPendingConnections());
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Server::baned() const {
|
QStringList BaseServer::baned() const {
|
||||||
QStringList list = {};
|
QStringList list = {};
|
||||||
for (auto i = _connections.begin(); i != _connections.end(); ++i) {
|
for (auto i = _connections.begin(); i != _connections.end(); ++i) {
|
||||||
if (i.value()->isBaned()) {
|
if (i.value()->isBaned()) {
|
||||||
@ -388,21 +345,11 @@ QStringList Server::baned() const {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::getRSA(quint32 key, RSAKeyPair& res) const {
|
QByteArray BaseServer::getToken(quint32 address) const {
|
||||||
auto sct = _connections.value(key);
|
|
||||||
if (sct) {
|
|
||||||
res = sct->getRSAKey();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray Server::getToken(quint32 address) const {
|
|
||||||
return _connections.value(address)->getToken();
|
return _connections.value(address)->getToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::setToken(quint32 address, const QByteArray &token) {
|
bool BaseServer::setToken(quint32 address, const QByteArray &token) {
|
||||||
if (_connections.contains(address)) {
|
if (_connections.contains(address)) {
|
||||||
_connections[address]->setToken(token);
|
_connections[address]->setToken(token);
|
||||||
return true;
|
return true;
|
@ -4,7 +4,6 @@
|
|||||||
#include "clientprotocol.h"
|
#include "clientprotocol.h"
|
||||||
|
|
||||||
#include <QTcpServer>
|
#include <QTcpServer>
|
||||||
#include "rsakeyspool.h"
|
|
||||||
#include "connectioninfo.h"
|
#include "connectioninfo.h"
|
||||||
|
|
||||||
namespace ClientProtocol {
|
namespace ClientProtocol {
|
||||||
@ -14,22 +13,20 @@ namespace ClientProtocol {
|
|||||||
#define REQUEST_ERROR -5
|
#define REQUEST_ERROR -5
|
||||||
|
|
||||||
|
|
||||||
class CLIENTPROTOCOLSHARED_EXPORT Server : public QTcpServer
|
class CLIENTPROTOCOLSHARED_EXPORT BaseServer : public QTcpServer
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
Package _downloadPackage;
|
Package _downloadPackage;
|
||||||
QHash<quint32, Connectioninfo*> _connections;
|
QHash<quint32, Connectioninfo*> _connections;
|
||||||
|
|
||||||
RSAKeysPool * _pool = nullptr;
|
bool parsePackage(const Package &pkg, QAbstractSocket * sender);
|
||||||
bool parsePackage(const Package &pkg, QTcpSocket * sender);
|
bool sendPackage(const Package &pkg, QAbstractSocket *target);
|
||||||
bool sendPackage(const Package &pkg, QTcpSocket * target);
|
bool registerSocket(QAbstractSocket *socket);
|
||||||
bool registerSocket(QTcpSocket *socket);
|
|
||||||
bool changeKarma(quint32 addresss, int diff);
|
bool changeKarma(quint32 addresss, int diff);
|
||||||
inline bool isBaned(const QTcpSocket *) const;
|
inline bool isBaned(const QTcpSocket *) const;
|
||||||
|
|
||||||
int connectionsCount() const;
|
int connectionsCount() const;
|
||||||
bool sendPubKey(QTcpSocket *target, const QByteArray &pubKey);
|
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -39,8 +36,8 @@ private slots:
|
|||||||
void handleIncommingConnection();
|
void handleIncommingConnection();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Server(RSAKeysPool * pool, QObject * ptr = nullptr);
|
explicit BaseServer(QObject * ptr = nullptr);
|
||||||
~Server() override;
|
~BaseServer() override;
|
||||||
bool run(const QString& ip, unsigned short port);
|
bool run(const QString& ip, unsigned short port);
|
||||||
void stop(bool reset = false);
|
void stop(bool reset = false);
|
||||||
|
|
||||||
@ -68,7 +65,6 @@ public:
|
|||||||
|
|
||||||
QStringList baned() const;
|
QStringList baned() const;
|
||||||
|
|
||||||
bool getRSA(quint32, RSAKeyPair & res) const;
|
|
||||||
QByteArray getToken(quint32 address) const;
|
QByteArray getToken(quint32 address) const;
|
||||||
bool setToken(quint32 address, const QByteArray &token);
|
bool setToken(quint32 address, const QByteArray &token);
|
||||||
|
|
@ -1,19 +1,8 @@
|
|||||||
#include "clientprotocol.h"
|
#include "clientprotocol.h"
|
||||||
#include "gamedata.h"
|
|
||||||
#include "getitem.h"
|
|
||||||
#include "login.h"
|
|
||||||
#include "player.h"
|
|
||||||
#include "updateplayerdata.h"
|
|
||||||
|
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
#include <factorynetobjects.h>
|
|
||||||
#include <map.h>
|
#include <map.h>
|
||||||
#include <pubkey.h>
|
|
||||||
#include <snake.h>
|
|
||||||
#include <websocket.h>
|
|
||||||
|
|
||||||
#define DEFAULT_GAME_PORT 7777
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
namespace ClientProtocol {
|
||||||
|
|
||||||
@ -28,25 +17,13 @@ bool Header::isValid() const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (static_cast<Command>(command) == Command::Undefined) {
|
return true;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (static_cast<Type>(type) == Type::Undefined) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (static_cast<Type>(type) == Type::Responke) {
|
|
||||||
return static_cast<Command>(command) != Command::Undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
return isValidSize(command, size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Header::reset() {
|
void Header::reset() {
|
||||||
size = 0;
|
size = 0;
|
||||||
command = static_cast<quint8>(Command::Undefined);
|
command = 0;
|
||||||
type = static_cast<quint8>(Type::Responke);
|
triggerCommnad = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Package::Package() {
|
Package::Package() {
|
||||||
@ -65,64 +42,6 @@ bool Package::isValid() const {
|
|||||||
return hdr.size == static_cast<unsigned int> (data.size());
|
return hdr.size == static_cast<unsigned int> (data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseNetworkObject* Package::parse() const {
|
|
||||||
if (!isValid())
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
auto obj = FactoryNetObjects::build(hdr.command);
|
|
||||||
|
|
||||||
if (!obj) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream stream(data);
|
|
||||||
obj->readFromStream(stream);
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Package::create(const BaseNetworkObject *obj, Type type, const Header *old) {
|
|
||||||
|
|
||||||
if (!obj) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto command = static_cast<Command>(obj->getClass());
|
|
||||||
|
|
||||||
if (command == Command::Undefined) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream stream(&data, QIODevice::ReadWrite);
|
|
||||||
obj->writeToStream(stream);
|
|
||||||
|
|
||||||
return create(command, type, old);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Package::create(Command cmd, Type type, const QByteArray &data, const Header* old) {
|
|
||||||
this->data = data;
|
|
||||||
return create(cmd, type, old);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Package::create(Command cmd, Type type, const Header *old) {
|
|
||||||
|
|
||||||
|
|
||||||
if (cmd == Command::Undefined) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
hdr.command = static_cast<quint8>(cmd);
|
|
||||||
hdr.type = static_cast<quint8>(type);
|
|
||||||
hdr.size = static_cast<unsigned short>(data.size());
|
|
||||||
|
|
||||||
if (type == Type::Responke) {
|
|
||||||
signPackage(old);
|
|
||||||
}
|
|
||||||
|
|
||||||
return isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray Package::toBytes() const {
|
QByteArray Package::toBytes() const {
|
||||||
QByteArray res;
|
QByteArray res;
|
||||||
res.append(reinterpret_cast<char*>(const_cast<Header*>(&hdr)),
|
res.append(reinterpret_cast<char*>(const_cast<Header*>(&hdr)),
|
||||||
@ -137,77 +56,7 @@ void Package::reset() {
|
|||||||
data.clear();
|
data.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Package::signPackage(const Header *oldHeader) {
|
|
||||||
|
|
||||||
if (!oldHeader || !oldHeader->isValid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
hdr.sig = oldHeader->sig;
|
|
||||||
hdr.requestCommand = oldHeader->command;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isValidSize(quint8 type, unsigned int size) {
|
|
||||||
|
|
||||||
if (!FactoryNetObjects::isInited()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FactoryNetObjects::isRegisteredType(type)) {
|
|
||||||
return size == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FactoryNetObjects::getSize(type).isValid(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool initClientProtockol() {
|
bool initClientProtockol() {
|
||||||
if (!FactoryNetObjects::regType<Login>(
|
|
||||||
static_cast<quint8>(Command::Login))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FactoryNetObjects::regType<UpdatePlayerData>(
|
|
||||||
static_cast<quint8>(Command::UpdatePlayerData))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FactoryNetObjects::regType<GameData>(
|
|
||||||
static_cast<quint8>(Command::GameData))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FactoryNetObjects::regType<GetItem>(
|
|
||||||
static_cast<quint8>(Command::GetItem))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FactoryNetObjects::regType<Player>(
|
|
||||||
static_cast<quint8>(Command::Player))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FactoryNetObjects::regType<Snake>(
|
|
||||||
static_cast<quint8>(Command::Snake))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FactoryNetObjects::regType<Map>(
|
|
||||||
static_cast<quint8>(Command::Map))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FactoryNetObjects::regType<PubKey>(
|
|
||||||
static_cast<quint8>(Command::PubKey))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FactoryNetObjects::regType<WebSocket>(
|
|
||||||
static_cast<quint8>(Command::WebSocket))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,44 +4,14 @@
|
|||||||
#include "clientprotocol_global.h"
|
#include "clientprotocol_global.h"
|
||||||
|
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
#include <snakeutils.h>
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#define BASE_ENCRYPTION_BITS 256
|
|
||||||
#define BASE_RSA_BITS static_cast<QRSAEncryption::Rsa>(BASE_ENCRYPTION_BITS)
|
|
||||||
#define BASE_HASH_BITS 256
|
|
||||||
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
namespace ClientProtocol {
|
||||||
|
|
||||||
class BaseNetworkObject;
|
|
||||||
|
|
||||||
enum class Type: quint8 {
|
|
||||||
Undefined = 0x00,
|
|
||||||
Responke = 0x01,
|
|
||||||
Request = 0x02,
|
|
||||||
Stream = 0x03,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class Command: quint8 {
|
|
||||||
Undefined = 0x00,
|
|
||||||
Ping = 0x01,
|
|
||||||
BadRequest = 0x02,
|
|
||||||
Login = 0x03,
|
|
||||||
UpdatePlayerData = 0x04,
|
|
||||||
GameData = 0x05,
|
|
||||||
GetItem = 0x06,
|
|
||||||
Player = 0x07,
|
|
||||||
Snake = 0x08,
|
|
||||||
Map = 0x09,
|
|
||||||
PubKey = 0x0a,
|
|
||||||
WebSocket = 0x0b
|
|
||||||
};
|
|
||||||
|
|
||||||
bool isValidSize(quint8 type, unsigned int size);
|
|
||||||
|
|
||||||
bool CLIENTPROTOCOLSHARED_EXPORT initClientProtockol();
|
bool CLIENTPROTOCOLSHARED_EXPORT initClientProtockol();
|
||||||
auto cast(const BaseNetworkObject *obj);
|
|
||||||
/**
|
/**
|
||||||
* @brief The Header struct 4 byte
|
* @brief The Header struct 4 byte
|
||||||
*/
|
*/
|
||||||
@ -51,12 +21,9 @@ struct CLIENTPROTOCOLSHARED_EXPORT Header {
|
|||||||
* @brief size - size of package data (not header)
|
* @brief size - size of package data (not header)
|
||||||
*/
|
*/
|
||||||
unsigned short size: 12;
|
unsigned short size: 12;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief type of package see Type
|
* @brief command of pacage
|
||||||
*/
|
|
||||||
quint8 type: 2;
|
|
||||||
/**
|
|
||||||
* @brief command of pacage see Command
|
|
||||||
*/
|
*/
|
||||||
quint8 command: 5;
|
quint8 command: 5;
|
||||||
|
|
||||||
@ -64,14 +31,7 @@ struct CLIENTPROTOCOLSHARED_EXPORT Header {
|
|||||||
* @brief command of pacage see Command (rquest from client)
|
* @brief command of pacage see Command (rquest from client)
|
||||||
* the server should write to which command it responds
|
* the server should write to which command it responds
|
||||||
*/
|
*/
|
||||||
quint8 requestCommand: 5;
|
quint8 triggerCommnad: 5;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief sig
|
|
||||||
* signed of package (package number)
|
|
||||||
*/
|
|
||||||
unsigned char sig : 8;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Header default constructor
|
* @brief Header default constructor
|
||||||
@ -113,54 +73,6 @@ struct CLIENTPROTOCOLSHARED_EXPORT Package {
|
|||||||
*/
|
*/
|
||||||
virtual bool isValid() const;
|
virtual bool isValid() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief parse
|
|
||||||
* @return Qmap of package (default key if "value")
|
|
||||||
*/
|
|
||||||
BaseNetworkObject * parse() const;
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
bool parse(T& res) {
|
|
||||||
auto obj = static_cast<T*>(parse());
|
|
||||||
|
|
||||||
if (!obj)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
res = *obj;
|
|
||||||
delete obj;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief create - fill package
|
|
||||||
* @param data - data of filled
|
|
||||||
* @param old header (only for request type)
|
|
||||||
* @return true if all done
|
|
||||||
*/
|
|
||||||
bool create(const BaseNetworkObject *data, Type type, const Header *old = nullptr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief create
|
|
||||||
* @param cmd command of package
|
|
||||||
* @param type type
|
|
||||||
* @param data - data of filled
|
|
||||||
* @param old - header (only for request type)
|
|
||||||
* @return true if all good
|
|
||||||
*/
|
|
||||||
bool create(Command cmd, Type type, const QByteArray& data, const Header* old = nullptr);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief create
|
|
||||||
* @param cmd command of package
|
|
||||||
* @param type type
|
|
||||||
* @param old header (only for request type)
|
|
||||||
* @return true if all good
|
|
||||||
*/
|
|
||||||
bool create(Command cmd, Type type, const Header* old = nullptr);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief toBytes
|
* @brief toBytes
|
||||||
* @return bytes array of packag
|
* @return bytes array of packag
|
||||||
@ -172,13 +84,6 @@ struct CLIENTPROTOCOLSHARED_EXPORT Package {
|
|||||||
*/
|
*/
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief signPackage sign package from old data
|
|
||||||
* @param oldHeader old data header
|
|
||||||
* @return true if all good
|
|
||||||
*/
|
|
||||||
bool signPackage(const Header* oldHeader);
|
|
||||||
|
|
||||||
virtual ~Package() = default;
|
virtual ~Package() = default;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -16,19 +16,11 @@ void Connectioninfo::setKarma(int value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RSAKeyPair Connectioninfo::getRSAKey() const {
|
QAbstractSocket *Connectioninfo::getSct() const {
|
||||||
return RSAKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Connectioninfo::setRSAKey(const RSAKeyPair &value) {
|
|
||||||
RSAKey = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTcpSocket *Connectioninfo::getSct() const {
|
|
||||||
return sct;
|
return sct;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connectioninfo::setSct(QTcpSocket *value) {
|
void Connectioninfo::setSct(QAbstractSocket *value) {
|
||||||
sct = value;
|
sct = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,13 +55,12 @@ void Connectioninfo::unBan() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Connectioninfo::isValid() const {
|
bool Connectioninfo::isValid() const {
|
||||||
return sct && !RSAKey.pub.isEmpty() && !RSAKey.priv.isEmpty();
|
return sct;
|
||||||
}
|
}
|
||||||
|
|
||||||
Connectioninfo::Connectioninfo(QTcpSocket *tcp, int kar, RSAKeyPair keys) {
|
Connectioninfo::Connectioninfo(QAbstractSocket *tcp, int kar) {
|
||||||
sct = tcp;
|
sct = tcp;
|
||||||
karma = kar;
|
karma = kar;
|
||||||
RSAKey = keys;
|
|
||||||
token = "";
|
token = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
#ifndef CONNECTIONINFO_H
|
#ifndef CONNECTIONINFO_H
|
||||||
#define CONNECTIONINFO_H
|
#define CONNECTIONINFO_H
|
||||||
|
|
||||||
#include "rsakeyspool.h"
|
|
||||||
#include "clientprotocol_global.h"
|
#include "clientprotocol_global.h"
|
||||||
|
|
||||||
class QTcpSocket;
|
#include <QByteArray>
|
||||||
|
|
||||||
|
class QAbstractSocket;
|
||||||
namespace ClientProtocol {
|
namespace ClientProtocol {
|
||||||
|
|
||||||
#define NOT_VALID_CARMA 0xFF
|
#define NOT_VALID_CARMA 0xFF
|
||||||
@ -14,9 +15,8 @@ namespace ClientProtocol {
|
|||||||
|
|
||||||
class CLIENTPROTOCOLSHARED_EXPORT Connectioninfo {
|
class CLIENTPROTOCOLSHARED_EXPORT Connectioninfo {
|
||||||
|
|
||||||
QTcpSocket *sct = nullptr;
|
QAbstractSocket *sct = nullptr;
|
||||||
int karma = DEFAULT_KARMA;
|
int karma = DEFAULT_KARMA;
|
||||||
RSAKeyPair RSAKey;
|
|
||||||
QByteArray token;
|
QByteArray token;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -28,17 +28,14 @@ public:
|
|||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
Connectioninfo(QTcpSocket * tcp = nullptr,
|
Connectioninfo(QAbstractSocket * tcp = nullptr,
|
||||||
int kar = NOT_VALID_CARMA,
|
int kar = NOT_VALID_CARMA);
|
||||||
RSAKeyPair keys = RSAKeyPair());
|
|
||||||
~Connectioninfo();
|
~Connectioninfo();
|
||||||
|
|
||||||
int getKarma() const;
|
int getKarma() const;
|
||||||
void setKarma(int value);
|
void setKarma(int value);
|
||||||
RSAKeyPair getRSAKey() const;
|
QAbstractSocket *getSct() const;
|
||||||
void setRSAKey(const RSAKeyPair &value);
|
void setSct(QAbstractSocket *value);
|
||||||
QTcpSocket *getSct() const;
|
|
||||||
void setSct(QTcpSocket *value);
|
|
||||||
QByteArray getToken() const;
|
QByteArray getToken() const;
|
||||||
void setToken(const QByteArray &value);
|
void setToken(const QByteArray &value);
|
||||||
};
|
};
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
#ifndef CP_H
|
|
||||||
#define CP_H
|
|
||||||
#include "server.h"
|
|
||||||
#include "client.h"
|
|
||||||
|
|
||||||
#endif // CP_H
|
|
@ -1,6 +0,0 @@
|
|||||||
#ifndef CPSERVER_H
|
|
||||||
#define CPSERVER_H
|
|
||||||
|
|
||||||
#include "server.h"
|
|
||||||
|
|
||||||
#endif // CPSERVER_H
|
|
@ -1,40 +0,0 @@
|
|||||||
#include "factorynetobjects.h"
|
|
||||||
#include "clientprotocol.h"
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
QMap<quint8, BaseNetworkObject*> map;
|
|
||||||
QMap<quint8, NetworkClassSize> types_sizes;
|
|
||||||
|
|
||||||
BaseNetworkObject *FactoryNetObjects::build(quint8 type) {
|
|
||||||
if (!map.contains(type)) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return map.value(type)->create();
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseNetworkObject *FactoryNetObjects::build(quint8 type, const QByteArray &array) {
|
|
||||||
auto temp = build(type);
|
|
||||||
|
|
||||||
if (!temp) {
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
temp->fromBytes(array);
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClassSize FactoryNetObjects::getSize(quint8 type) {
|
|
||||||
return types_sizes.value(type, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FactoryNetObjects::isRegisteredType(quint8 type) {
|
|
||||||
return map.contains(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FactoryNetObjects::isInited() {
|
|
||||||
return map.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
#ifndef FACTORYNETOBJECTS_H
|
|
||||||
#define FACTORYNETOBJECTS_H
|
|
||||||
#include "clientprotocol_global.h"
|
|
||||||
#include "basenetworkobject.h"
|
|
||||||
#include <QMap>
|
|
||||||
#include <typeinfo>
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
extern QMap<quint8, BaseNetworkObject*> map;
|
|
||||||
extern QMap<quint8, NetworkClassSize> types_sizes;
|
|
||||||
|
|
||||||
class CLIENTPROTOCOLSHARED_EXPORT FactoryNetObjects {
|
|
||||||
private:
|
|
||||||
|
|
||||||
public:
|
|
||||||
FactoryNetObjects() = delete;
|
|
||||||
|
|
||||||
static BaseNetworkObject *build(quint8 type);
|
|
||||||
static BaseNetworkObject *build(quint8 type, const QByteArray& array);
|
|
||||||
|
|
||||||
static NetworkClassSize getSize(quint8 type);
|
|
||||||
static bool isRegisteredType(quint8 type);
|
|
||||||
static bool isInited();
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
static bool regType(quint8 id) {
|
|
||||||
if (map.contains(id)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto tempObj = new T();
|
|
||||||
map.insert(id, tempObj);
|
|
||||||
types_sizes.insert(id, tempObj->classSize());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // FACTORYNETOBJECTS_H
|
|
@ -1,32 +0,0 @@
|
|||||||
#include "networkclasssize.h"
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
bool NetworkClassSize::isStaticType() {
|
|
||||||
return min == max;
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClassSize::NetworkClassSize(unsigned int size) {
|
|
||||||
operator=(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClassSize::NetworkClassSize(unsigned int min, unsigned int maxDif) {
|
|
||||||
operator=(min);
|
|
||||||
max += maxDif;
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClassSize &NetworkClassSize::operator =(unsigned int size) {
|
|
||||||
min = max = size;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClassSize &NetworkClassSize::operator +(const NetworkClassSize & other) {
|
|
||||||
min += other.min;
|
|
||||||
max += other.max;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NetworkClassSize::isValid(unsigned int size) const {
|
|
||||||
return size <= max && size >= min;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
#ifndef NETWORKCLASSSIZE_H
|
|
||||||
#define NETWORKCLASSSIZE_H
|
|
||||||
|
|
||||||
#include "clientprotocol_global.h"
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
struct CLIENTPROTOCOLSHARED_EXPORT NetworkClassSize {
|
|
||||||
unsigned int min = 0;
|
|
||||||
unsigned int max = 0;
|
|
||||||
|
|
||||||
bool isStaticType();
|
|
||||||
|
|
||||||
NetworkClassSize(unsigned int size);
|
|
||||||
NetworkClassSize(unsigned int min, unsigned int max);
|
|
||||||
|
|
||||||
NetworkClassSize& operator = (unsigned int size);
|
|
||||||
NetworkClassSize& operator + (const NetworkClassSize& );
|
|
||||||
|
|
||||||
bool isValid(unsigned int size) const;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // NETWORKCLASSSIZE_H
|
|
@ -1,27 +0,0 @@
|
|||||||
#include "rsakeyspool.h"
|
|
||||||
#include <QMutexLocker>
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
bool RSAKeysPool::take(QRSAEncryption::Rsa rsa, RSAKeyPair& res) {
|
|
||||||
QMutexLocker locker(&multithread);
|
|
||||||
|
|
||||||
if (pool.value(rsa).isEmpty()) {
|
|
||||||
emit sigKeyTaked();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
res = pool.value(rsa).begin().value();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RSAKeysPool::addNewKey(QRSAEncryption::Rsa rsa, const RSAKeyPair& key) {
|
|
||||||
QMutexLocker locker(&multithread);
|
|
||||||
pool[rsa].insert(static_cast<int>(time(nullptr)), key);
|
|
||||||
}
|
|
||||||
|
|
||||||
int RSAKeysPool::size(QRSAEncryption::Rsa rsa) const {
|
|
||||||
return pool.value(rsa).size();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
#ifndef RSAKEYSPOOL_H
|
|
||||||
#define RSAKEYSPOOL_H
|
|
||||||
#include <QHash>
|
|
||||||
#include <QObject>
|
|
||||||
#include <qrsaencryption.h>
|
|
||||||
#include <QMutex>
|
|
||||||
#include <QMap>
|
|
||||||
#include "clientprotocol_global.h"
|
|
||||||
|
|
||||||
namespace ClientProtocol {
|
|
||||||
|
|
||||||
struct RSAKeyPair {
|
|
||||||
QByteArray pub;
|
|
||||||
QByteArray priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef QMap<int, RSAKeyPair> KeysPool;
|
|
||||||
typedef QHash<QRSAEncryption::Rsa, KeysPool> PoolData;
|
|
||||||
class CLIENTPROTOCOLSHARED_EXPORT RSAKeysPool: public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
private:
|
|
||||||
PoolData pool;
|
|
||||||
|
|
||||||
QMutex multithread;
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool take(QRSAEncryption::Rsa rsa, RSAKeyPair &res);
|
|
||||||
void addNewKey(QRSAEncryption::Rsa rsa, const RSAKeyPair& key);
|
|
||||||
int size(QRSAEncryption::Rsa rsa) const;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
void sigKeyTaked();
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif // RSAKEYSPOOL_H
|
|
@ -29,8 +29,7 @@ CONFIG(release, debug|release): {
|
|||||||
|
|
||||||
HEADERS +=
|
HEADERS +=
|
||||||
|
|
||||||
include($$PWD/../../QuasarAppLib/QuasarLib.pri)
|
include($$PWD/../QuasarAppLib/QuasarLib.pri)
|
||||||
include($$PWD/../ServerProtocol/ServerProtocol.pri)
|
include($$PWD/../ServerProtocol/ServerProtocol.pri)
|
||||||
include($$PWD/../ClientProtocol/ClientProtocol.pri)
|
include($$PWD/../ClientProtocol/ClientProtocol.pri)
|
||||||
include($$PWD/../../SnakeUtils/SnakeUtils.pri)
|
|
||||||
include($$PWD/../Server/Server.pri)
|
include($$PWD/../Server/Server.pri)
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
QT -= gui
|
|
||||||
|
|
||||||
CONFIG += c++17 console
|
|
||||||
CONFIG -= app_bundle
|
|
||||||
|
|
||||||
# The following define makes your compiler emit warnings if you use
|
|
||||||
# any Qt feature that has been marked deprecated (the exact warnings
|
|
||||||
# depend on your compiler). Please consult the documentation of the
|
|
||||||
# deprecated API in order to know how to port your code away from it.
|
|
||||||
DEFINES += QT_DEPRECATED_WARNINGS
|
|
||||||
|
|
||||||
# You can also make your code fail to compile if it uses deprecated APIs.
|
|
||||||
# In order to do so, uncomment the following line.
|
|
||||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
main.cpp \
|
|
||||||
serverutils.cpp
|
|
||||||
|
|
||||||
CONFIG(release, debug|release): {
|
|
||||||
DESTDIR = $$PWD/build/release
|
|
||||||
|
|
||||||
} else {
|
|
||||||
DESTDIR = $$PWD/build/debug
|
|
||||||
}
|
|
||||||
|
|
||||||
include($$PWD/../QuasarAppLib/Etalons/qmake/install_prefix.pri)
|
|
||||||
include($$PWD/../QuasarAppLib/QuasarLib.pri)
|
|
||||||
|
|
||||||
target_dir.files += QUASARAPP_LIB_OUTPUT_DIR
|
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
serverutils.h
|
|
1
QuasarAppLib
Submodule
1
QuasarAppLib
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 8a5cd74f220a59aa3da04330f561b105f4008714
|
@ -51,9 +51,8 @@ HEADERS += \
|
|||||||
sqldbwriter.h \
|
sqldbwriter.h \
|
||||||
websocketcontroller.h
|
websocketcontroller.h
|
||||||
|
|
||||||
include($$PWD/../../QuasarAppLib/QuasarLib.pri)
|
include($$PWD/../QuasarAppLib/QuasarLib.pri)
|
||||||
include($$PWD/../ServerProtocol/ServerProtocol.pri)
|
include($$PWD/../ServerProtocol/ServerProtocol.pri)
|
||||||
include($$PWD/../ClientProtocol/ClientProtocol.pri)
|
include($$PWD/../ClientProtocol/ClientProtocol.pri)
|
||||||
include($$PWD/../../SnakeUtils/SnakeUtils.pri)
|
|
||||||
|
|
||||||
RESOURCES += sqlres.qrc
|
RESOURCES += sqlres.qrc
|
||||||
|
@ -269,13 +269,13 @@ MainServer::MainServer(bool forceKeys ,QObject *ptr):
|
|||||||
QObject (ptr) {
|
QObject (ptr) {
|
||||||
|
|
||||||
_keyReactor = new KeysReactor(forceKeys , this);
|
_keyReactor = new KeysReactor(forceKeys , this);
|
||||||
_serverDaemon = new ClientProtocol::Server(_keyReactor->getPool(), this);
|
_serverDaemon = new ClientProtocol::BaseServer(_keyReactor->getPool(), this);
|
||||||
_websocketctrl = new WebSocketController(_serverDaemon, this);
|
_websocketctrl = new WebSocketController(_serverDaemon, this);
|
||||||
_terminalPort = new ServerProtocol::Server(this);
|
_terminalPort = new ServerProtocol::Server(this);
|
||||||
|
|
||||||
_db = new SqlDBCache();
|
_db = new SqlDBCache();
|
||||||
|
|
||||||
connect(_serverDaemon, &ClientProtocol::Server::incomingReques,
|
connect(_serverDaemon, &ClientProtocol::BaseServer::incomingReques,
|
||||||
this, &MainServer::handleRequest);
|
this, &MainServer::handleRequest);
|
||||||
|
|
||||||
connect(_terminalPort, &ServerProtocol::Server::incomingRequest,
|
connect(_terminalPort, &ServerProtocol::Server::incomingRequest,
|
||||||
|
@ -10,7 +10,7 @@ namespace ServerProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace ClientProtocol {
|
namespace ClientProtocol {
|
||||||
class Server;
|
class BaseServer;
|
||||||
class BaseNetworkObject;
|
class BaseNetworkObject;
|
||||||
class Login;
|
class Login;
|
||||||
class RSAKeyPair;
|
class RSAKeyPair;
|
||||||
@ -25,7 +25,7 @@ class SERVERSHARED_EXPORT MainServer: public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
ServerProtocol::Server *_terminalPort = nullptr;
|
ServerProtocol::Server *_terminalPort = nullptr;
|
||||||
ClientProtocol::Server *_serverDaemon= nullptr;
|
ClientProtocol::BaseServer *_serverDaemon= nullptr;
|
||||||
SqlDBCache *_db = nullptr;
|
SqlDBCache *_db = nullptr;
|
||||||
KeysReactor *_keyReactor = nullptr;
|
KeysReactor *_keyReactor = nullptr;
|
||||||
WebSocketController* _websocketctrl = nullptr;
|
WebSocketController* _websocketctrl = nullptr;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "websocketcontroller.h"
|
#include "websocketcontroller.h"
|
||||||
#include <cpserver.h>
|
#include <cpserver.h>
|
||||||
|
|
||||||
WebSocketController::WebSocketController(ClientProtocol::Server *server, QObject* obj):
|
WebSocketController::WebSocketController(ClientProtocol::BaseServer *server, QObject* obj):
|
||||||
QObject (obj) {
|
QObject (obj) {
|
||||||
|
|
||||||
assert( server );
|
assert( server );
|
||||||
|
@ -9,7 +9,7 @@ class Item;
|
|||||||
class PlayerDBData;
|
class PlayerDBData;
|
||||||
|
|
||||||
namespace ClientProtocol {
|
namespace ClientProtocol {
|
||||||
class Server;
|
class BaseServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class KEY_TYPE, class VALUE_TYPE>
|
template <class KEY_TYPE, class VALUE_TYPE>
|
||||||
@ -22,13 +22,13 @@ private:
|
|||||||
MultiHash<char, quint32> _subscribs;
|
MultiHash<char, quint32> _subscribs;
|
||||||
MultiHash<int, quint32> _subscribsObjIds;
|
MultiHash<int, quint32> _subscribsObjIds;
|
||||||
|
|
||||||
ClientProtocol::Server *_serverDaemon = nullptr;
|
ClientProtocol::BaseServer *_serverDaemon = nullptr;
|
||||||
|
|
||||||
void foreachSubscribers(const Item &newData, const QSet<quint32> &subscribersList);
|
void foreachSubscribers(const Item &newData, const QSet<quint32> &subscribersList);
|
||||||
void foreachSubscribers(const PlayerDBData &newData, const QSet<quint32> &subscribersList);
|
void foreachSubscribers(const PlayerDBData &newData, const QSet<quint32> &subscribersList);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WebSocketController(ClientProtocol::Server * server, QObject* obj = nullptr);
|
WebSocketController(ClientProtocol::BaseServer * server, QObject* obj = nullptr);
|
||||||
void subscribe(quint32 address, ClientProtocol::Command cmd, int id);
|
void subscribe(quint32 address, ClientProtocol::Command cmd, int id);
|
||||||
void unsubscribe(quint32 address, ClientProtocol::Command cmd, int id);
|
void unsubscribe(quint32 address, ClientProtocol::Command cmd, int id);
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -30,7 +30,7 @@ CONFIG(release, debug|release): {
|
|||||||
DESTDIR = $$PWD/build/debug
|
DESTDIR = $$PWD/build/debug
|
||||||
}
|
}
|
||||||
|
|
||||||
#include($$PWD/../../QuasarAppLib/QuasarLib.pri)
|
include($$PWD/../QuasarAppLib/QuasarLib.pri)
|
||||||
|
|
||||||
DISTFILES += \
|
DISTFILES += \
|
||||||
ServerProtocol.pri
|
ServerProtocol.pri
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
TEMPLATE = subdirs
|
|
||||||
CONFIG += ordered
|
|
||||||
|
|
||||||
SUBDIRS += \
|
|
||||||
ServerProtocol \
|
|
||||||
ClientProtocol \
|
|
||||||
# Terminal \
|
|
||||||
# Server \
|
|
||||||
# Daemon \
|
|
||||||
# serverProtocolTests \
|
|
@ -26,6 +26,6 @@ CONFIG(release, debug|release): {
|
|||||||
DESTDIR = $$PWD/build/debug
|
DESTDIR = $$PWD/build/debug
|
||||||
}
|
}
|
||||||
|
|
||||||
include($$PWD/../../QuasarAppLib/QuasarLib.pri)
|
include($$PWD/../QuasarAppLib/QuasarLib.pri)
|
||||||
include($$PWD/../ServerProtocol/ServerProtocol.pri)
|
include($$PWD/../ServerProtocol/ServerProtocol.pri)
|
||||||
|
|
||||||
|
@ -19,11 +19,10 @@ CONFIG(release, debug|release): {
|
|||||||
DESTDIR = $$PWD/build/debug
|
DESTDIR = $$PWD/build/debug
|
||||||
}
|
}
|
||||||
|
|
||||||
include($$PWD/../../QuasarAppLib/QuasarLib.pri)
|
include($$PWD/../QuasarAppLib/QuasarLib.pri)
|
||||||
include($$PWD/../ServerProtocol/ServerProtocol.pri)
|
include($$PWD/../ServerProtocol/ServerProtocol.pri)
|
||||||
include($$PWD/../ClientProtocol/ClientProtocol.pri)
|
include($$PWD/../ClientProtocol/ClientProtocol.pri)
|
||||||
include($$PWD/../../SnakeUtils/SnakeUtils.pri)
|
include($$PWD/../Server/Server.pri)
|
||||||
include($$PWD/../../SnakeServer/Server/Server.pri)
|
|
||||||
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user