mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-05-04 21:49:43 +00:00
Merge branch 'terminal'
This commit is contained in:
commit
efe3def359
2
.gitignore
vendored
2
.gitignore
vendored
@ -77,3 +77,5 @@ deployTests/
|
||||
installer/SnakeInstaller
|
||||
|
||||
Distro/
|
||||
|
||||
*.db
|
||||
|
@ -80,12 +80,12 @@ void Client::incommingData() {
|
||||
}
|
||||
}
|
||||
|
||||
Client::Client(QObject *ptr):
|
||||
Client::Client(const QString &addrress, unsigned short port, QObject *ptr):
|
||||
QObject (ptr) {
|
||||
|
||||
_destination = new QTcpSocket(this);
|
||||
|
||||
_destination->connectToHost(DEFAULT_SNAKE_SERVER, DEFAULT_SNAKE_PORT);
|
||||
_destination->connectToHost(addrress, port);
|
||||
|
||||
connect(_destination, &QTcpSocket::readyRead,
|
||||
this, &Client::incommingData);
|
||||
|
@ -36,7 +36,9 @@ private slots:
|
||||
void incommingData();
|
||||
|
||||
public:
|
||||
explicit Client(QObject * ptr = nullptr);
|
||||
explicit Client(const QString& addrress = LOCAL_SNAKE_SERVER,
|
||||
unsigned short port = DEFAULT_SNAKE_PORT,
|
||||
QObject * ptr = nullptr);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,6 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#define DEFAULT_SNAKE_SERVER "127.0.0.1"
|
||||
#define LOCAL_SNAKE_SERVER "127.0.0.1"
|
||||
|
||||
#define DEFAULT_SNAKE_PORT 7777
|
||||
|
@ -9,13 +9,13 @@ namespace ClientProtocol {
|
||||
bool Server::parsePackage(const Package &pkg, QTcpSocket* sender) {
|
||||
if (!pkg.isValid()) {
|
||||
QuasarAppUtils::Params::verboseLog("incomming package is not valid!");
|
||||
changeKarma(qHash(sender->peerAddress()), CRITICAL_ERROOR);
|
||||
changeKarma(sender->peerAddress().toIPv4Address(), CRITICAL_ERROOR);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sender->isValid()) {
|
||||
QuasarAppUtils::Params::verboseLog("incomming package is not valid!");
|
||||
changeKarma(qHash(sender->peerAddress()), LOGICK_ERROOR);
|
||||
changeKarma(sender->peerAddress().toIPv4Address(), LOGICK_ERROOR);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -42,10 +42,8 @@ bool Server::parsePackage(const Package &pkg, QTcpSocket* sender) {
|
||||
|
||||
default: {
|
||||
|
||||
BaseNetworkObject *obj = pkg.parse();
|
||||
|
||||
emit incomingReques(obj, qHash(sender->peerAddress()));
|
||||
delete obj;
|
||||
emit incomingReques(static_cast<Command>(pkg.hdr.command),
|
||||
pkg.data, sender->peerAddress().toIPv4Address());
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,6 +73,9 @@ bool Server::sendPackage(Package &pkg, QTcpSocket * target) {
|
||||
|
||||
void Server::ban(quint32 target) {
|
||||
_connections[target].karma = BANED_KARMA;
|
||||
if (_connections[target].sct) {
|
||||
_connections[target].sct->close();
|
||||
}
|
||||
}
|
||||
|
||||
void Server::unBan(quint32 target) {
|
||||
@ -82,15 +83,14 @@ void Server::unBan(quint32 target) {
|
||||
}
|
||||
|
||||
void Server::registerSocket(QTcpSocket *socket) {
|
||||
auto address = qHash(socket->peerAddress());
|
||||
auto address = socket->peerAddress().toIPv4Address();
|
||||
|
||||
if (!_connections[address].sct) {
|
||||
_connections[address].karma = DEFAULT_KARMA;
|
||||
_connections[address].sct = socket;
|
||||
|
||||
_connections[address].karma = DEFAULT_KARMA;
|
||||
_connections[address].sct = socket;
|
||||
connect(socket, &QTcpSocket::readyRead, this, &Server::avelableBytes);
|
||||
connect(socket, &QTcpSocket::disconnected, this, &Server::handleDisconected);
|
||||
|
||||
connect(socket, &QTcpSocket::readyRead, this, &Server::avelableBytes);
|
||||
}
|
||||
}
|
||||
|
||||
bool Server::changeKarma(quint32 addresss, int diff) {
|
||||
@ -109,7 +109,7 @@ bool Server::changeKarma(quint32 addresss, int diff) {
|
||||
}
|
||||
|
||||
bool Server::isBaned(const QTcpSocket * adr) const {
|
||||
return _connections.value(qHash(adr->peerAddress())).karma < 1;
|
||||
return _connections.value(adr->peerAddress().toIPv4Address()).karma < 1;
|
||||
}
|
||||
|
||||
void Server::saveKarma() const {
|
||||
@ -120,6 +120,20 @@ bool Server::loadKarma() {
|
||||
return false;
|
||||
}
|
||||
|
||||
int Server::connectionsCount() const {
|
||||
int count = 0;
|
||||
for (auto i : _connections) {
|
||||
if (i.sct) {
|
||||
if (!i.sct->isValid()) {
|
||||
// log about warning
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void Server::avelableBytes() {
|
||||
auto client = dynamic_cast<QTcpSocket*>(sender());
|
||||
|
||||
@ -145,6 +159,29 @@ void Server::avelableBytes() {
|
||||
}
|
||||
}
|
||||
|
||||
void Server::handleDisconected() {
|
||||
auto _sender = dynamic_cast<QTcpSocket*>(sender());
|
||||
|
||||
if (_sender) {
|
||||
// log error
|
||||
|
||||
unsigned int address = _sender->peerAddress().toIPv4Address();
|
||||
if (_connections.contains(address)) {
|
||||
_connections[address].sct = nullptr;
|
||||
_sender->deleteLater();
|
||||
} else {
|
||||
QuasarAppUtils::Params::verboseLog("system error in void Server::handleDisconected()"
|
||||
" address not valid",
|
||||
QuasarAppUtils::Error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
QuasarAppUtils::Params::verboseLog("system error in void Server::handleDisconected()"
|
||||
"dynamic_cast fail!",
|
||||
QuasarAppUtils::Error);
|
||||
}
|
||||
|
||||
void Server::handleIncommingConnection() {
|
||||
while (hasPendingConnections()) {
|
||||
auto socket = nextPendingConnection();
|
||||
@ -165,7 +202,6 @@ Server::Server(QObject *ptr) :
|
||||
}
|
||||
|
||||
Server::~Server() {
|
||||
|
||||
}
|
||||
|
||||
bool Server::run(const QString &ip, unsigned short port) {
|
||||
@ -194,6 +230,8 @@ void Server::badRequest(quint32 address) {
|
||||
|
||||
Package pcg;
|
||||
if (!(pcg.create(Command::BadRequest, Type::Responke))) {
|
||||
QuasarAppUtils::Params::verboseLog("Bad request detected, bud responce command nor received!",
|
||||
QuasarAppUtils::Error);
|
||||
};
|
||||
|
||||
if (!sendPackage(pcg, client.sct)) {
|
||||
@ -204,9 +242,9 @@ void Server::badRequest(quint32 address) {
|
||||
QString Server::getWorkState() const {
|
||||
if (isListening()) {
|
||||
if (hasPendingConnections())
|
||||
return "Work";
|
||||
else {
|
||||
return "overload";
|
||||
else {
|
||||
return "Work";
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,14 +252,14 @@ QString Server::getWorkState() const {
|
||||
}
|
||||
|
||||
QString Server::connectionState() const {
|
||||
return QString("%0 / %1").arg(_connections.size()).arg(maxPendingConnections());
|
||||
return QString("%0 / %1").arg(connectionsCount()).arg(maxPendingConnections());
|
||||
}
|
||||
|
||||
QStringList Server::baned() const {
|
||||
QStringList list = {};
|
||||
for (auto i : _connections) {
|
||||
if (i.karma <= 0) {
|
||||
list.push_back(i.sct->peerAddress().toString());
|
||||
for (auto i = _connections.begin(); i != _connections.end(); ++i) {
|
||||
if (i.value().karma <= 0) {
|
||||
list.push_back(QHostAddress(i.key()).toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ namespace ClientProtocol {
|
||||
|
||||
struct Connectioninfo {
|
||||
|
||||
QTcpSocket *sct;
|
||||
QTcpSocket *sct = nullptr;
|
||||
int karma;
|
||||
|
||||
Connectioninfo(QTcpSocket * tcp = nullptr,
|
||||
@ -43,8 +43,11 @@ private:
|
||||
void saveKarma() const;
|
||||
bool loadKarma();
|
||||
|
||||
int connectionsCount() const;
|
||||
|
||||
private slots:
|
||||
void avelableBytes();
|
||||
void handleDisconected();
|
||||
void handleIncommingConnection();
|
||||
|
||||
public:
|
||||
@ -72,7 +75,7 @@ public:
|
||||
|
||||
QStringList baned() const;
|
||||
signals:
|
||||
void incomingReques(BaseNetworkObject *map, const quint32 &sender);
|
||||
void incomingReques(Command cmd, const QByteArray &data, const quint32 &sender);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -17,14 +17,31 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString address = "";
|
||||
unsigned short port = 0;
|
||||
QString db = "";
|
||||
if(QuasarAppUtils::Params::isEndable("address")) {
|
||||
address = QuasarAppUtils::Params::getStrArg("address");
|
||||
}
|
||||
|
||||
if(QuasarAppUtils::Params::isEndable("port")) {
|
||||
port = static_cast<unsigned short>(QuasarAppUtils::Params::getArg("port").toUInt());
|
||||
}
|
||||
|
||||
if(QuasarAppUtils::Params::isEndable("db")) {
|
||||
db = QuasarAppUtils::Params::getStrArg("db");
|
||||
}
|
||||
|
||||
|
||||
if(ServerUtils::runDaemon()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
MainServer loclaServer;
|
||||
if (!loclaServer.run()) {
|
||||
MainServer mainServer;
|
||||
|
||||
if (!mainServer.run(address, port, db)) {
|
||||
QuasarAppUtils::Params::verboseLog("server is not run!");
|
||||
ServerUtils::helpDaemon();
|
||||
return 1;
|
||||
|
@ -1,8 +1,11 @@
|
||||
#include "mainserver.h"
|
||||
#include "sqldbcache.h"
|
||||
#include <spserver.h>
|
||||
#include <cpserver.h>
|
||||
#include <quasarapp.h>
|
||||
#include <basenetworkobject.h>
|
||||
#include <login.h>
|
||||
#include <QCoreApplication>
|
||||
|
||||
bool MainServer::restartSrver(const QString &ip, unsigned short port) {
|
||||
if (_serverDaemon->isListening()) {
|
||||
@ -16,16 +19,27 @@ bool MainServer::restartSrver(const QString &ip, unsigned short port) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainServer::handleRequest(ClientProtocol::BaseNetworkObject *obj,
|
||||
void MainServer::handleRequest(ClientProtocol::Command cmd,
|
||||
const QByteArray& data,
|
||||
const quint32 &addres) {
|
||||
|
||||
Q_UNUSED(addres);
|
||||
|
||||
auto command = static_cast<ClientProtocol::Command>
|
||||
(obj->getClass());
|
||||
|
||||
switch (command) {
|
||||
switch (cmd) {
|
||||
case ClientProtocol::Command::Login: {
|
||||
|
||||
ClientProtocol::Login loginData;
|
||||
loginData.fromBytes(data);
|
||||
|
||||
|
||||
if (!loginData.isValid()) {
|
||||
_serverDaemon->badRequest(addres);
|
||||
return ;
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -64,32 +78,55 @@ void MainServer::handleTerminalRequest(QVariantMap obj) {
|
||||
break;
|
||||
}
|
||||
case ServerProtocol::Ban: {
|
||||
auto address = static_cast<quint32>(obj.value("address").toInt());
|
||||
auto address = obj.value("address").toUInt();
|
||||
|
||||
_serverDaemon->ban(address);
|
||||
auto banedList = _serverDaemon->baned();
|
||||
res ["Baned List"] = banedList;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ServerProtocol::Unban: {
|
||||
auto address = static_cast<quint32>(obj.value("address").toInt());
|
||||
|
||||
auto address = obj.value("address").toUInt();
|
||||
_serverDaemon->unBan(address);
|
||||
auto banedList = _serverDaemon->baned();
|
||||
|
||||
res ["Baned List"] = banedList;
|
||||
break;
|
||||
}
|
||||
|
||||
case ServerProtocol::Restart: {
|
||||
auto address = obj.value("address").toString();
|
||||
auto port = static_cast<quint16>(obj.value("address").toInt());
|
||||
auto port = static_cast<quint16>(obj.value("port").toInt());
|
||||
|
||||
if (!restartSrver(address, port)) {
|
||||
QuasarAppUtils::Params::verboseLog("server restart fail!");
|
||||
}
|
||||
|
||||
res ["Work State"] = _serverDaemon->getWorkState();
|
||||
res ["Address"] = QString("%0:%1").
|
||||
arg(_serverDaemon->serverAddress().toString()).
|
||||
arg(_serverDaemon->serverPort());
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ServerProtocol::Stop: {
|
||||
|
||||
res ["Res"] = "Server stoped!";
|
||||
_terminalPort->sendResponce(res, command);
|
||||
_serverDaemon->stop();
|
||||
QCoreApplication::processEvents();
|
||||
QCoreApplication::quit();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
default:
|
||||
QuasarAppUtils::Params::verboseLog("server get undefined command!");
|
||||
res ["Error"] = "Server get undefined command!";
|
||||
break;
|
||||
}
|
||||
|
||||
@ -102,6 +139,8 @@ MainServer::MainServer(QObject *ptr):
|
||||
_serverDaemon = new ClientProtocol::Server(this);
|
||||
_terminalPort = new ServerProtocol::Server(this);
|
||||
|
||||
_db = new SqlDBCache();
|
||||
|
||||
connect(_serverDaemon, &ClientProtocol::Server::incomingReques,
|
||||
this, &MainServer::handleRequest);
|
||||
|
||||
@ -110,13 +149,23 @@ MainServer::MainServer(QObject *ptr):
|
||||
|
||||
}
|
||||
|
||||
bool MainServer::run() {
|
||||
bool MainServer::run(const QString &ip, unsigned short port, const QString& db,
|
||||
const QString& terminalServer, bool terminalForce) {
|
||||
|
||||
if (!_terminalPort->run(DEFAULT_SERVER)) {
|
||||
if (!_db->initDb((db.size())? db: DEFAULT_DB_PATH)) {
|
||||
QuasarAppUtils::Params::verboseLog("init db fail!", QuasarAppUtils::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!restartSrver(DEFAULT_SNAKE_SERVER, DEFAULT_SNAKE_PORT)) {
|
||||
if (!_terminalPort->run((terminalServer.isEmpty())? DEFAULT_SERVER : terminalServer,
|
||||
terminalForce)) {
|
||||
QuasarAppUtils::Params::verboseLog("run termonal fail!", QuasarAppUtils::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!restartSrver(ip.isEmpty()? LOCAL_SNAKE_SERVER: ip,
|
||||
port ? port : DEFAULT_SNAKE_PORT)) {
|
||||
QuasarAppUtils::Params::verboseLog("restart server fail", QuasarAppUtils::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <serverprotocol.h>
|
||||
#include "server_global.h"
|
||||
#include <QHostAddress>
|
||||
#include <clientprotocol.h>
|
||||
|
||||
namespace ServerProtocol {
|
||||
class Server;
|
||||
@ -13,12 +14,16 @@ namespace ClientProtocol {
|
||||
class BaseNetworkObject;
|
||||
}
|
||||
|
||||
class SqlDBCache;
|
||||
|
||||
class SERVERSHARED_EXPORT MainServer: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
ServerProtocol::Server *_terminalPort = nullptr;
|
||||
ClientProtocol::Server *_serverDaemon= nullptr;
|
||||
SqlDBCache* _db = nullptr;
|
||||
|
||||
|
||||
bool payItem(int player, int idItem);
|
||||
bool sellItem(int player, int idItem);
|
||||
@ -26,14 +31,16 @@ private:
|
||||
bool restartSrver(const QString& ip, unsigned short port);
|
||||
|
||||
private slots:
|
||||
void handleRequest(ClientProtocol::BaseNetworkObject *obj,
|
||||
void handleRequest(ClientProtocol::Command cmd, const QByteArray &data,
|
||||
const quint32& addres);
|
||||
void handleTerminalRequest(QVariantMap obj);
|
||||
|
||||
public:
|
||||
MainServer(QObject *ptr = nullptr);
|
||||
bool run();
|
||||
bool run(const QString& ip = "", unsigned short port = 0, const QString &db = "",
|
||||
const QString &terminalServer = "", bool terminalForce = false);
|
||||
virtual ~MainServer();
|
||||
|
||||
};
|
||||
|
||||
#endif // SERVER_H
|
||||
|
@ -147,8 +147,8 @@ SqlDBCache::~SqlDBCache() {
|
||||
globalUpdateDataBase(SqlDBCasheWriteMode::Force);
|
||||
}
|
||||
|
||||
bool SqlDBCache::initDb(const QString &sql, const QString &path) {
|
||||
if (!SqlDBWriter::initDb(sql, path)) {
|
||||
bool SqlDBCache::initDb(const QString &pdbath) {
|
||||
if (!SqlDBWriter::initDb(pdbath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -45,8 +45,7 @@ public:
|
||||
SqlDBCache(qint64 updateInterval = DEFAULT_UPDATE_INTERVAL);
|
||||
~SqlDBCache() override;
|
||||
|
||||
bool initDb(const QString &sql = DEFAULT_DB_NAME,
|
||||
const QString &path = DEFAULT_DB_PATH) override;
|
||||
bool initDb(const QString &pdbath = DEFAULT_DB_PATH) override;
|
||||
|
||||
Item getItem(int id) override;
|
||||
int saveItem(const Item& saveData) override;
|
||||
|
@ -414,12 +414,12 @@ SqlDBWriter::SqlDBWriter() {
|
||||
|
||||
}
|
||||
|
||||
bool SqlDBWriter::initDb(const QString& database, const QString &databasePath) {
|
||||
bool SqlDBWriter::initDb(const QString &databasePath) {
|
||||
QStringList drivers = QSqlDatabase::drivers();
|
||||
db = new QSqlDatabase();
|
||||
*db = QSqlDatabase::addDatabase("QSQLITE", database);
|
||||
|
||||
db->setDatabaseName(QFileInfo(databasePath).absolutePath() + "/" + database);
|
||||
*db = QSqlDatabase::addDatabase("QSQLITE", QFileInfo(databasePath).fileName());
|
||||
db->setDatabaseName(QFileInfo(databasePath).absoluteFilePath());
|
||||
query = new QSqlQuery(*db);
|
||||
|
||||
if (!db->open()) {
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <player.h>
|
||||
|
||||
#define DEFAULT_DB_NAME "SnakeDatabase.db"
|
||||
#define DEFAULT_DB_PATH QDir::homePath() + "/SnakeServer"
|
||||
#define DEFAULT_DB_PATH QDir::homePath() + "/SnakeServer/" + DEFAULT_DB_NAME
|
||||
#define DEFAULT_UPDATE_INTERVAL 3600000 // 1 hour
|
||||
|
||||
class QSqlQuery;
|
||||
@ -51,8 +51,7 @@ protected:
|
||||
public:
|
||||
SqlDBWriter();
|
||||
|
||||
virtual bool initDb(const QString &sql = DEFAULT_DB_NAME,
|
||||
const QString &path = DEFAULT_DB_PATH);
|
||||
virtual bool initDb(const QString &path = DEFAULT_DB_PATH);
|
||||
|
||||
virtual bool isValid() const;
|
||||
|
||||
|
@ -4,6 +4,9 @@
|
||||
#include <QLocalSocket>
|
||||
#include <quasarapp.h>
|
||||
#include <cstring>
|
||||
#include <QProcess>
|
||||
#include <QDateTime>
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace ServerProtocol {
|
||||
|
||||
@ -22,16 +25,17 @@ void Client::incommingData() {
|
||||
if (_downloadPackage.isValid()) {
|
||||
emit sigIncommingData(_downloadPackage.parse());
|
||||
_downloadPackage.reset();
|
||||
received = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Client::Client(QObject *ptr):
|
||||
Client::Client(const QString& server, QObject *ptr):
|
||||
QObject (ptr) {
|
||||
|
||||
_destination = new QLocalSocket(this);
|
||||
|
||||
_destination->connectToServer(DEFAULT_SERVER);
|
||||
_destination->connectToServer(server);
|
||||
|
||||
connect(_destination, &QLocalSocket::readyRead,
|
||||
this, &Client::incommingData);
|
||||
@ -85,7 +89,7 @@ bool Client::ban(const QHostAddress &address) {
|
||||
return false;
|
||||
|
||||
QVariantMap map;
|
||||
map["address"] = qHash(address);
|
||||
map["address"] = address.toIPv4Address();
|
||||
|
||||
pkg.fromMap(map);
|
||||
|
||||
@ -102,7 +106,7 @@ bool Client::unBan(const QHostAddress &address) {
|
||||
pkg.hdr.type = ServerProtocol::Request;
|
||||
|
||||
QVariantMap map;
|
||||
map["address"] = qHash(address);
|
||||
map["address"] = address.toIPv4Address();
|
||||
|
||||
pkg.fromMap(map);
|
||||
|
||||
@ -128,4 +132,62 @@ bool Client::restart(const QString &address, unsigned short port) {
|
||||
|
||||
return sendPackage(pkg);
|
||||
}
|
||||
|
||||
bool Client::start(const QString &address, unsigned short port) {
|
||||
QHostAddress test(address);
|
||||
|
||||
QStringList params = {"daemon"};
|
||||
|
||||
if (!test.isNull()) {
|
||||
params.push_back("-address");
|
||||
params.push_back(address);
|
||||
|
||||
}
|
||||
|
||||
if (port > 0) {
|
||||
params.push_back("-port");
|
||||
params.push_back(QString::number(port));
|
||||
}
|
||||
|
||||
QProcess p;
|
||||
QProcessEnvironment env;
|
||||
|
||||
p.setProcessEnvironment(env);
|
||||
p.start("snake-d", params);
|
||||
|
||||
if (p.waitForFinished(1000) && p.exitCode() == 0) {
|
||||
emit sigIncommingData({{"Res", "server started"}});
|
||||
} else {
|
||||
emit sigIncommingData({{"Res", "server started fail " + p.readAll()}});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Client::stop() {
|
||||
|
||||
ServerProtocol::Package pkg;
|
||||
pkg.hdr.command = ServerProtocol::Stop;
|
||||
pkg.hdr.type = ServerProtocol::Request;
|
||||
|
||||
QVariantMap map;
|
||||
pkg.fromMap(map);
|
||||
|
||||
return sendPackage(pkg);
|
||||
}
|
||||
|
||||
bool Client::wait(bool & forWait, int msec) {
|
||||
auto curmsec = QDateTime::currentMSecsSinceEpoch() + msec;
|
||||
while (curmsec > QDateTime::currentMSecsSinceEpoch() && !forWait) {
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
QCoreApplication::processEvents();
|
||||
return forWait;
|
||||
}
|
||||
|
||||
bool Client::wait(int msec)
|
||||
{
|
||||
received = false;
|
||||
return wait(received, msec);
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ class SERVERPROTOCOLSHARED_EXPORT Client : public QObject
|
||||
private:
|
||||
QLocalSocket *_destination;
|
||||
Package _downloadPackage;
|
||||
bool received = false;
|
||||
|
||||
bool sendPackage(const Package& pkg);
|
||||
|
||||
@ -22,12 +23,17 @@ private slots:
|
||||
void incommingData();
|
||||
|
||||
public:
|
||||
explicit Client(QObject * ptr = nullptr);
|
||||
explicit Client(const QString &server = DEFAULT_SERVER, QObject * ptr = nullptr);
|
||||
bool ping();
|
||||
bool getState();
|
||||
bool ban(const QHostAddress& address);
|
||||
bool unBan(const QHostAddress& address);
|
||||
bool restart(const QString &address, unsigned short port);
|
||||
bool start(const QString &address, unsigned short port);
|
||||
bool stop();
|
||||
bool wait(bool &forWait, int msec = 10000);
|
||||
bool wait(int msec = 10000);
|
||||
|
||||
|
||||
signals:
|
||||
void sigIncommingData(const QVariantMap& map);
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "server.h"
|
||||
|
||||
|
||||
|
||||
namespace ServerProtocol {
|
||||
|
||||
void Server::parsePackage(const Package& pkg) {
|
||||
@ -44,9 +43,9 @@ void Server::parsePackage(const Package& pkg) {
|
||||
|
||||
default: {
|
||||
QVariantMap res;
|
||||
res["command"] = pkg.hdr.command;
|
||||
QDataStream stream(pkg.data);
|
||||
stream >> res;
|
||||
res["command"] = pkg.hdr.command;
|
||||
emit incomingRequest(res);
|
||||
};
|
||||
}
|
||||
@ -120,9 +119,13 @@ Server::~Server() {
|
||||
close();
|
||||
}
|
||||
|
||||
bool Server::run(const QString &name) {
|
||||
bool Server::run(const QString &name, bool force) {
|
||||
|
||||
if (!listen(name) && !(QFile::remove("/tmp/" + name) && listen(name))) {
|
||||
if (force) {
|
||||
QFile::remove("/tmp/" + name);
|
||||
}
|
||||
|
||||
if (!listen(name)) {
|
||||
QuasarAppUtils::Params::verboseLog("listing fail " + this->errorString());
|
||||
return false;
|
||||
}
|
||||
@ -138,7 +141,7 @@ bool Server::sendResponce(QVariantMap res, Command command) {
|
||||
pck.hdr.command = static_cast<unsigned char>(command);
|
||||
|
||||
if (res.isEmpty()) {
|
||||
res["responce"] = "error: command not supported!";
|
||||
res["Error"] = "command not supported!";
|
||||
}
|
||||
|
||||
pck.fromMap(res);
|
||||
|
@ -24,7 +24,7 @@ protected:
|
||||
public:
|
||||
explicit Server(QObject * ptr = nullptr);
|
||||
~Server() override;
|
||||
bool run(const QString& name);
|
||||
bool run(const QString& name, bool force = false);
|
||||
bool sendResponce(QVariantMap res, Command command);
|
||||
|
||||
bool sendPackage(Package &pkg);
|
||||
|
@ -18,9 +18,10 @@ enum Command: unsigned char {
|
||||
Undefined = 0x00,
|
||||
Ping = 0x01,
|
||||
State = 0x02,
|
||||
Restart = 0x03,
|
||||
Unban = 0x04,
|
||||
Ban = 0x05
|
||||
Stop = 0x03,
|
||||
Restart = 0x04,
|
||||
Unban = 0x05,
|
||||
Ban = 0x06
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,10 @@ void ServerUtils::helpDaemon() {
|
||||
qInfo() << "";
|
||||
qInfo() << "Options:";
|
||||
qInfo() << " help / h : show help.";
|
||||
qInfo() << " daemon / d : show help.";
|
||||
qInfo() << " daemon / d : start like daemon.";
|
||||
qInfo() << " -port (port) : start with custom port.";
|
||||
qInfo() << " -address (address) : start with custom address.";
|
||||
qInfo() << " -db (path/to/db.file) : start with custom db";
|
||||
|
||||
qInfo() << " verbose : show debug log";
|
||||
|
||||
@ -28,11 +31,14 @@ void ServerUtils::helpClient() {
|
||||
qInfo() << "";
|
||||
qInfo() << "Options:";
|
||||
qInfo() << " help / h : show help.";
|
||||
qInfo() << " Ping : debug commnad";
|
||||
qInfo() << " State : show information about deamon";
|
||||
qInfo() << " -Ban (address) : ban user with address";
|
||||
qInfo() << " -Unban (address) : unban user with address";
|
||||
qInfo() << " -Restart (address:port) : restarrt server deamon with new address and port";
|
||||
qInfo() << " ping : debug commnad";
|
||||
qInfo() << " state : show information about deamon";
|
||||
qInfo() << " stop : stop server deamon";
|
||||
qInfo() << " -ban (address) : ban user with address";
|
||||
qInfo() << " -unban (address) : unban user with address";
|
||||
qInfo() << " -restart (address:port) : restarrt server deamon with new address and port";
|
||||
qInfo() << " -start (address:port) : start server deamon with custom address";
|
||||
qInfo() << " start : start server deamon with default address";
|
||||
|
||||
qInfo() << " verbose : show debug log";
|
||||
|
||||
|
@ -31,43 +31,59 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
} else if (QuasarAppUtils::Params::isEndable("Help") ||
|
||||
} else if (QuasarAppUtils::Params::isEndable("help") ||
|
||||
QuasarAppUtils::Params::isEndable("h")) {
|
||||
|
||||
ServerUtils::helpClient();
|
||||
return 0;
|
||||
|
||||
} else if (QuasarAppUtils::Params::isEndable("State")) {
|
||||
} else if (QuasarAppUtils::Params::isEndable("state")) {
|
||||
|
||||
if (!cli.getState()) {
|
||||
qCritical() << "command not sendet!";
|
||||
return 1;
|
||||
};
|
||||
|
||||
} else if (QuasarAppUtils::Params::isEndable("Ban")) {
|
||||
} else if (QuasarAppUtils::Params::isEndable("ban")) {
|
||||
|
||||
auto address = QuasarAppUtils::Params::getStrArg("Ban");
|
||||
auto address = QuasarAppUtils::Params::getStrArg("ban");
|
||||
|
||||
if (!cli.ban(QHostAddress(address))) {
|
||||
qCritical() << "command not sendet!";
|
||||
return 1;
|
||||
}
|
||||
|
||||
} else if (QuasarAppUtils::Params::isEndable("Unban")) {
|
||||
} else if (QuasarAppUtils::Params::isEndable("unban")) {
|
||||
|
||||
auto address = QuasarAppUtils::Params::getStrArg("Ban");
|
||||
auto address = QuasarAppUtils::Params::getStrArg("unban");
|
||||
if (!cli.unBan(QHostAddress(address))) {
|
||||
qCritical() << "command not sendet!";
|
||||
return 1;
|
||||
}
|
||||
|
||||
} else if (QuasarAppUtils::Params::isEndable("Restart")) {
|
||||
} else if (QuasarAppUtils::Params::isEndable("restart")) {
|
||||
|
||||
QStringList address = QuasarAppUtils::Params::getStrArg("Restart").split(":");
|
||||
if (!cli.restart(address[0], static_cast<quint16>(address[1].toShort()))) {
|
||||
QStringList address = QuasarAppUtils::Params::getStrArg("restart").split(":");
|
||||
if (!cli.restart(address.value(0), address.value(1).toUShort())) {
|
||||
qCritical() << "command not sendet!";
|
||||
return 1;
|
||||
}
|
||||
} else if (QuasarAppUtils::Params::isEndable("stop")) {
|
||||
|
||||
if (!cli.stop()) {
|
||||
qCritical() << "command not sendet!";
|
||||
return 1;
|
||||
}
|
||||
} else if (QuasarAppUtils::Params::isEndable("start")) {
|
||||
|
||||
QStringList params = QuasarAppUtils::Params::getStrArg("restart").split(":");
|
||||
|
||||
if (!cli.start(params.value(0), params.value(1).toUShort())) {
|
||||
qCritical() << "Server not started!";
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
ServerUtils::helpClient();
|
||||
|
@ -10,21 +10,27 @@
|
||||
|
||||
#include <snake.h>
|
||||
#include <playerdbdata.h>
|
||||
#include <mainserver.h>
|
||||
|
||||
#include "factorynetobjects.h"
|
||||
|
||||
// add necessary includes here
|
||||
|
||||
#define TEST_LOCAL_SERVER QString(DEFAULT_SERVER) + "Test"
|
||||
#define TEST_SERVER_ADDRESS LOCAL_SNAKE_SERVER
|
||||
#define TEST_SERVER_PORT 27777
|
||||
|
||||
class testSankeServer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
void testPingServerProtockol();
|
||||
void testStateServerProtockol();
|
||||
void testBanServerProtockol();
|
||||
void testUnBanServerProtockol();
|
||||
void testRestartServerProtockol();
|
||||
void testPingServerProtockol(ServerProtocol::Client &cle);
|
||||
void testStateServerProtockol(ServerProtocol::Client &cle);
|
||||
void testBanServerProtockol(ServerProtocol::Client& cle);
|
||||
void testUnBanServerProtockol(ServerProtocol::Client& cle);
|
||||
void testRestartServerProtockol(ServerProtocol::Client& cle);
|
||||
void testStopServerProtockol(ServerProtocol::Client& cle);
|
||||
|
||||
void testPingClientProtockol();
|
||||
void testLogin();
|
||||
@ -51,90 +57,140 @@ private slots:
|
||||
|
||||
};
|
||||
|
||||
testSankeServer::testSankeServer()
|
||||
{
|
||||
testSankeServer::testSankeServer() {
|
||||
QuasarAppUtils::Params::setArg("verbose", 3);
|
||||
|
||||
}
|
||||
|
||||
testSankeServer::~testSankeServer()
|
||||
{
|
||||
testSankeServer::~testSankeServer() {
|
||||
|
||||
}
|
||||
|
||||
void testSankeServer::initTestCase()
|
||||
{
|
||||
void testSankeServer::initTestCase() {
|
||||
ClientProtocol::initClientProtockol();
|
||||
}
|
||||
|
||||
void testSankeServer::cleanupTestCase()
|
||||
{
|
||||
void testSankeServer::cleanupTestCase() {
|
||||
|
||||
}
|
||||
|
||||
void testSankeServer::testPingServerProtockol()
|
||||
{
|
||||
QuasarAppUtils::Params::setEnable("verbose", true);
|
||||
void testSankeServer::testPingServerProtockol(ServerProtocol::Client &cle) {
|
||||
|
||||
int argc =0;
|
||||
char * argv[] = {nullptr};
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
auto serv = new ServerProtocol::Server(this);
|
||||
|
||||
QVERIFY(serv->run(DEFAULT_SERVER));
|
||||
|
||||
auto client = new ServerProtocol::Client(this);
|
||||
|
||||
bool isWork = false;
|
||||
QObject::connect(client, &ServerProtocol::Client::sigIncommingData,
|
||||
[&isWork, &app] (const QVariantMap& map) {
|
||||
bool received = false;
|
||||
|
||||
QMetaObject::Connection m_connection;
|
||||
|
||||
m_connection = QObject::connect(&cle, &ServerProtocol::Client::sigIncommingData,
|
||||
[&isWork, &received, &m_connection] (const QVariantMap& map) {
|
||||
|
||||
isWork = map["res"].toString() == "Pong";
|
||||
app.exit(0);
|
||||
disconnect(m_connection);
|
||||
received = true;
|
||||
|
||||
|
||||
});
|
||||
|
||||
QVERIFY(client->ping());
|
||||
QVERIFY(cle.ping());
|
||||
|
||||
QTimer::singleShot(1000, [&app](){
|
||||
app.exit(0);
|
||||
});
|
||||
|
||||
app.exec();
|
||||
QVERIFY(cle.wait(received, 1000));
|
||||
|
||||
QVERIFY(isWork);
|
||||
|
||||
delete serv;
|
||||
delete client;
|
||||
|
||||
}
|
||||
|
||||
void testSankeServer::testStateServerProtockol()
|
||||
{
|
||||
ServerProtocol::Client cle;
|
||||
void testSankeServer::testStateServerProtockol(ServerProtocol::Client& cle) {
|
||||
|
||||
bool isWork = false;
|
||||
bool received = false;
|
||||
|
||||
QMetaObject::Connection m_connection;
|
||||
|
||||
m_connection = QObject::connect(&cle, &ServerProtocol::Client::sigIncommingData,
|
||||
[&isWork, &received, &m_connection] (const QVariantMap& map) {
|
||||
|
||||
isWork = !map.contains("Error");
|
||||
received = true;
|
||||
|
||||
disconnect(m_connection);
|
||||
|
||||
});
|
||||
|
||||
|
||||
QVERIFY(cle.getState());
|
||||
QVERIFY(cle.wait(received, 1000));
|
||||
QVERIFY(isWork);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void testSankeServer::testBanServerProtockol()
|
||||
{
|
||||
ServerProtocol::Client cle;
|
||||
void testSankeServer::testBanServerProtockol(ServerProtocol::Client& cle) {
|
||||
|
||||
bool isWork = false;
|
||||
bool received = false;
|
||||
|
||||
QMetaObject::Connection m_connection;
|
||||
|
||||
m_connection = QObject::connect(&cle, &ServerProtocol::Client::sigIncommingData,
|
||||
[&isWork, &received, &m_connection] (const QVariantMap& map) {
|
||||
|
||||
isWork = !map.contains("Error");
|
||||
received = true;
|
||||
disconnect(m_connection);
|
||||
});
|
||||
|
||||
QVERIFY(!cle.ban(QHostAddress()));
|
||||
|
||||
QVERIFY(cle.ban(QHostAddress("192.192.192.192")));
|
||||
QVERIFY(cle.wait(received, 1000));
|
||||
|
||||
QVERIFY(isWork);
|
||||
|
||||
}
|
||||
|
||||
void testSankeServer::testUnBanServerProtockol()
|
||||
void testSankeServer::testUnBanServerProtockol(ServerProtocol::Client& cle)
|
||||
{
|
||||
ServerProtocol::Client cle;
|
||||
|
||||
bool isWork = false;
|
||||
bool received = false;
|
||||
|
||||
QMetaObject::Connection m_connection;
|
||||
|
||||
m_connection = QObject::connect(&cle, &ServerProtocol::Client::sigIncommingData,
|
||||
[&isWork, &received, &m_connection] (const QVariantMap& map) {
|
||||
|
||||
isWork = !map.contains("Error");
|
||||
received = true;
|
||||
disconnect(m_connection);
|
||||
|
||||
});
|
||||
|
||||
QVERIFY(!cle.unBan(QHostAddress()));
|
||||
|
||||
QVERIFY(cle.unBan(QHostAddress("192.192.192.192")));
|
||||
QVERIFY(cle.wait(received, 1000));
|
||||
|
||||
QVERIFY(isWork);
|
||||
|
||||
}
|
||||
|
||||
void testSankeServer::testRestartServerProtockol()
|
||||
{
|
||||
ServerProtocol::Client cle;
|
||||
void testSankeServer::testRestartServerProtockol(ServerProtocol::Client& cle) {
|
||||
|
||||
bool isWork = false;
|
||||
bool received = false;
|
||||
|
||||
QMetaObject::Connection m_connection;
|
||||
|
||||
m_connection = QObject::connect(&cle, &ServerProtocol::Client::sigIncommingData,
|
||||
[&isWork, &received, &m_connection] (const QVariantMap& map) {
|
||||
|
||||
isWork = !map.contains("Error");
|
||||
received = true;
|
||||
disconnect(m_connection);
|
||||
|
||||
});
|
||||
|
||||
QVERIFY(!cle.restart("lolo", 0));
|
||||
|
||||
QVERIFY(!cle.restart("192.168.1.999", 0));
|
||||
@ -144,13 +200,57 @@ void testSankeServer::testRestartServerProtockol()
|
||||
QVERIFY(!cle.restart("-1.168.1.999", 77));
|
||||
QVERIFY(!cle.restart("192.168.-1.99", 7777));
|
||||
|
||||
QVERIFY(cle.restart("192.168.1.9", 3456));
|
||||
QVERIFY(cle.restart("127.168.1.9", 3456));
|
||||
|
||||
cle.wait(received, 1000);
|
||||
QVERIFY(isWork);
|
||||
|
||||
isWork = false;
|
||||
received = false;
|
||||
|
||||
m_connection = QObject::connect(&cle, &ServerProtocol::Client::sigIncommingData,
|
||||
[&isWork, &received, &m_connection] (const QVariantMap& map) {
|
||||
|
||||
isWork = map.value("Address") == QString("%0:%1").
|
||||
arg(TEST_SERVER_ADDRESS).
|
||||
arg(TEST_SERVER_PORT) &&
|
||||
!map.contains("Error");
|
||||
received = true;
|
||||
disconnect(m_connection);
|
||||
|
||||
});
|
||||
|
||||
QVERIFY(cle.restart(TEST_SERVER_ADDRESS, TEST_SERVER_PORT));
|
||||
|
||||
cle.wait(received, 1000);
|
||||
QVERIFY(isWork);
|
||||
|
||||
}
|
||||
|
||||
void testSankeServer::testPingClientProtockol() {
|
||||
void testSankeServer::testStopServerProtockol(ServerProtocol::Client& cle) {
|
||||
|
||||
QuasarAppUtils::Params::setEnable("verbose", true);
|
||||
bool isWork = false;
|
||||
bool received = false;
|
||||
|
||||
QMetaObject::Connection m_connection;
|
||||
|
||||
m_connection = QObject::connect(&cle, &ServerProtocol::Client::sigIncommingData,
|
||||
[&isWork, &received, &m_connection] (const QVariantMap& map) {
|
||||
|
||||
isWork = !map.contains("Error");
|
||||
received = true;
|
||||
disconnect(m_connection);
|
||||
|
||||
});
|
||||
|
||||
QVERIFY(cle.stop());
|
||||
|
||||
cle.wait(received, 1000);
|
||||
|
||||
QVERIFY(!received || isWork);
|
||||
}
|
||||
|
||||
void testSankeServer::testPingClientProtockol() {
|
||||
|
||||
int argc = 0;
|
||||
char * argv[] = {nullptr};
|
||||
@ -159,9 +259,11 @@ void testSankeServer::testPingClientProtockol() {
|
||||
|
||||
auto serv = new ClientProtocol::Server(this);
|
||||
|
||||
QVERIFY(serv->run(LOCAL_SNAKE_SERVER, DEFAULT_SNAKE_PORT));
|
||||
QVERIFY(serv->run(TEST_SERVER_ADDRESS, TEST_SERVER_PORT));
|
||||
|
||||
auto client = new ClientProtocol::Client(this);
|
||||
auto client = new ClientProtocol::Client(TEST_SERVER_ADDRESS,
|
||||
TEST_SERVER_PORT,
|
||||
this);
|
||||
|
||||
bool isWork = false;
|
||||
QObject::connect(client, &ClientProtocol::Client::sigIncommingData,
|
||||
@ -188,7 +290,7 @@ void testSankeServer::testPingClientProtockol() {
|
||||
}
|
||||
|
||||
void testSankeServer::testLogin() {
|
||||
ClientProtocol::Client cle;
|
||||
ClientProtocol::Client cle(TEST_SERVER_ADDRESS, TEST_SERVER_PORT);
|
||||
|
||||
auto pass = QCryptographicHash::hash("testpass", QCryptographicHash::Sha512);
|
||||
QVERIFY(!cle.login("Test@gmail.com", pass));
|
||||
@ -199,7 +301,7 @@ void testSankeServer::testLogin() {
|
||||
}
|
||||
|
||||
void testSankeServer::testUserData() {
|
||||
ClientProtocol::Client cle;
|
||||
ClientProtocol::Client cle(TEST_SERVER_ADDRESS, TEST_SERVER_PORT);
|
||||
|
||||
QVERIFY(!cle.updateData());
|
||||
|
||||
@ -212,7 +314,7 @@ void testSankeServer::testUserData() {
|
||||
|
||||
void testSankeServer::testGetItem() {
|
||||
|
||||
ClientProtocol::Client cle;
|
||||
ClientProtocol::Client cle(TEST_SERVER_ADDRESS, TEST_SERVER_PORT);
|
||||
|
||||
QVERIFY(!cle.updateData());
|
||||
|
||||
@ -225,7 +327,7 @@ void testSankeServer::testGetItem() {
|
||||
|
||||
void testSankeServer::testApplyData() {
|
||||
|
||||
ClientProtocol::Client cle;
|
||||
ClientProtocol::Client cle(TEST_SERVER_ADDRESS, TEST_SERVER_PORT);
|
||||
|
||||
|
||||
auto token = QCryptographicHash::hash("testtoken", QCryptographicHash::Sha256);
|
||||
@ -245,7 +347,7 @@ void testSankeServer::testBaseSql() {
|
||||
SqlDBWriter db;
|
||||
QFile::remove("./test.db");
|
||||
|
||||
bool init = db.initDb("test.db", "./");
|
||||
bool init = db.initDb("./test.db");
|
||||
|
||||
if (!init) {
|
||||
QFile::remove("./test.db");
|
||||
@ -344,7 +446,7 @@ void testSankeServer::testSqlCache() {
|
||||
|
||||
QFile::remove("./test2.db");
|
||||
|
||||
bool init = db.initDb("test2.db", "./");
|
||||
bool init = db.initDb("./test2.db");
|
||||
|
||||
if (!init) {
|
||||
QFile::remove("./test2.db");
|
||||
@ -462,21 +564,35 @@ void testSankeServer::testSql() {
|
||||
}
|
||||
|
||||
void testSankeServer::testServerProtockol() {
|
||||
testPingServerProtockol();
|
||||
|
||||
auto serv = new ServerProtocol::Server(this);
|
||||
QVERIFY(serv->run(DEFAULT_SERVER));
|
||||
testStateServerProtockol();
|
||||
testBanServerProtockol();
|
||||
testUnBanServerProtockol();
|
||||
testRestartServerProtockol();
|
||||
int argc =0;
|
||||
char * argv[] = {nullptr};
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
auto serv = new MainServer(this);
|
||||
QVERIFY(serv->run(TEST_SERVER_ADDRESS, TEST_SERVER_PORT , "", TEST_LOCAL_SERVER, true));
|
||||
ServerProtocol::Client cle(TEST_LOCAL_SERVER);
|
||||
|
||||
QTimer::singleShot(0, [this, &app, &cle]() {
|
||||
testPingServerProtockol(cle);
|
||||
testStateServerProtockol(cle);
|
||||
testBanServerProtockol(cle);
|
||||
testUnBanServerProtockol(cle);
|
||||
testRestartServerProtockol(cle);
|
||||
testStopServerProtockol(cle);
|
||||
app.exit(0);
|
||||
});
|
||||
|
||||
app.exec();
|
||||
|
||||
}
|
||||
|
||||
void testSankeServer::testClientProtockol() {
|
||||
testPingClientProtockol();
|
||||
|
||||
auto serv = new ClientProtocol::Server(this);
|
||||
QVERIFY(serv->run(LOCAL_SNAKE_SERVER, DEFAULT_SNAKE_PORT));
|
||||
QVERIFY(serv->run(TEST_SERVER_ADDRESS, TEST_SERVER_PORT));
|
||||
|
||||
testLogin();
|
||||
testGetItem();
|
||||
|
@ -7,7 +7,7 @@ DEPLOY_SERVER = $$PWD/../SnakeServer/Daemon/build/release,$$PWD/../SnakeServer/T
|
||||
win32:LUPDATE = $$QT_DIR/lupdate.exe
|
||||
win32:LRELEASE = $$QT_DIR/lrelease.exe
|
||||
|
||||
win32:DEPLOYER = cqtdeployer.exe
|
||||
win32:DEPLOYER = %cqtdeployer%
|
||||
|
||||
win32:OUT_FILE = SnakeInstaller.exe
|
||||
|
||||
@ -94,7 +94,8 @@ for(command, commands) {
|
||||
|
||||
INSTALL_SERVER_DIR = ~/SnakeServer
|
||||
|
||||
BASE_DEPLOY_FLAGS = clear -qmake $$QMAKE_QMAKE -libDir $$PWD/../ -recursiveDepth 5 -ignore Snake/data
|
||||
IGNORE_ENV=$$PWD/../Distro/,$$PWD/../deployTests,$$PWD/packages/Snake/data/
|
||||
BASE_DEPLOY_FLAGS = clear -qmake $$QMAKE_QMAKE -libDir $$PWD/../ -recursiveDepth 5 -ignoreEnv $$IGNORE_ENV
|
||||
BASE_DEPLOY_FLAGS_SERVER = $$BASE_DEPLOY_FLAGS -targetDir $$INSTALL_SERVER_DIR
|
||||
BASE_DEPLOY_FLAGS_SNAKE = $$BASE_DEPLOY_FLAGS -targetDir $$PWD/packages/Snake/data
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user