21#include <easyssl/x509.h>
22#include <easyssl/rsassl.h>
24#include <QSslConfiguration>
25#include <QSslCertificate>
32#include <QtConcurrent>
42#include <qaglobalutils.h>
57 _senderThread =
new QThread();
58 _senderThread->setObjectName(
"Sender");
60 _senderThread->start();
68 addApiParser<BigDataParser>();
70 auto abstractNodeParser = addApiParserNative<AbstractNodeParser>();
77 qRegisterMetaType<QSharedPointer<QH::AbstractTask>>();
79 qRegisterMetaType<QList<QSslError>>();
83 this, &AbstractNode::handleBeginWork);
92 _senderThread->quit();
93 _senderThread->wait();
95 for (
auto it: std::as_const(_receiveData)) {
102 delete _senderThread;
103 delete _socketWorker;
104 delete _tasksheduller;
105 delete _apiVersionParser;
114 if (addres.isEmpty()) {
119 QuasarAppUtils::Params::log(
"Run fail " + this->errorString(),
120 QuasarAppUtils::Error);
122 QuasarAppUtils::Params::log(
"Address:: " + adr.
toString(),
123 QuasarAppUtils::Error);
149 _connectionsMutex.lock();
150 for (
const auto &i : std::as_const(_connections)) {
153 _connectionsMutex.unlock();
155 _workersMutex.lock();
156 for (
auto it: std::as_const(_workers)) {
157 if (!it->isFinished()) {
159 it->waitForFinished();
162 _workersMutex.unlock();
168 QMutexLocker locer(&_connectionsMutex);
170 if (!_connections.contains(
id)) {
180 QMutexLocker locer(&_connectionsMutex);
182 if (!_connections.contains(
id)) {
197 QMutexLocker locer(&_connectionsMutex);
199 if (!_connections.contains(target) || _connections[target]) {
203 _connections[target]->unBan();
209 QAbstractSocket *socket;
214 socket =
new SslSocket(
nullptr);
232 return _socketWorker->
run(action);
241 if (action && (!peer || peer->status() < status)) {
242 auto &actionsList = _connectActions[status];
256 QHostInfo::lookupHost(domain, [
this, port, domain, action, status](QHostInfo info) {
258 if (info.error() != QHostInfo::NoError) {
259 QuasarAppUtils::Params::log(
"The domain name :" + domain +
260 " has error: " + info.errorString(),
261 QuasarAppUtils::Error);
262 addNodeFailed(AddNodeError::HostNotFound);
266 auto addresses = info.addresses();
268 if (addresses.size() > 1) {
269 QuasarAppUtils::Params::log(
"The domain name :" + domain +
270 " has more 1 ip addresses.",
271 QuasarAppUtils::Warning);
313 std::bind(&AbstractNode::handleForceRemoveNode,
325QSslConfiguration AbstractNode::getSslConfig()
const {
329QSslConfiguration AbstractNode::selfSignedSslConfiguration(
const EasySSL::SslSrtData &sslData) {
330 QSslConfiguration res = QSslConfiguration::defaultConfiguration();
335 EasySSL::X509 generator(QSharedPointer<EasySSL::RSASSL>::create());
336 EasySSL::SelfSignedSertificate certificate = generator.create(sslData);
337 res.setPrivateKey(certificate.key);
338 res.setLocalCertificate(certificate.crt);
339 res.setPeerVerifyMode(QSslSocket::VerifyNone);
344bool AbstractNode::configureSslSocket(AbstractNodeInfo *node,
bool fServer) {
349 auto socket =
dynamic_cast<SslSocket*
>(node->sct());
352 QuasarAppUtils::Params::log(
"Invalid ssl socket!! Connection not secure",
353 QuasarAppUtils::Error);
357 socket->setSslConfiguration(_ssl);
359 auto address = node->networkAddress();
360 connect(socket, &QSslSocket::encrypted,
this ,[
this,
address]() {
364 connect(socket, &SslSocket::sslErrorsOcurred,
365 this, &AbstractNode::handleSslErrorOcurredPrivate, Qt::DirectConnection);
370 socket->startServerEncryption();
372 socket->startClientEncryption();
377 return _socketWorker->
run(action);
380const QList<QSslError> &AbstractNode::ignoreSslErrors()
const {
381 return _ignoreSslErrors;
384void AbstractNode::setIgnoreSslErrors(
const QList<QSslError> &newIgnoreSslErrors) {
385 _ignoreSslErrors = newIgnoreSslErrors;
388bool AbstractNode::useSelfSignedSslConfiguration(
const EasySSL::SslSrtData &crtData) {
394 _ssl = selfSignedSslConfiguration(crtData);
395 _mode = SslMode::InitSelfSigned;
397 if(!_ignoreSslErrors.contains(QSslError{QSslError::SelfSignedCertificate}))
398 _ignoreSslErrors.push_back(QSslError{QSslError::SelfSignedCertificate});
400 if(!_ignoreSslErrors.contains(QSslError{QSslError::SelfSignedCertificateInChain}))
401 _ignoreSslErrors.push_back(QSslError{QSslError::SelfSignedCertificateInChain});
403 return !_ssl.isNull();
406bool AbstractNode::useSystemSslConfiguration(QSslConfiguration config) {
412 _mode = SslMode::InitFromSystem;
414 return !_ssl.isNull();
417bool AbstractNode::disableSSL() {
427void AbstractNode::handleEncrypted(AbstractNodeInfo *node) {
431void AbstractNode::handleSslErrorOcurredPrivate(SslSocket * sslScocket,
const QList<QSslError> &errors) {
433 QList<QSslError> ignore;
434 for (
auto &error : errors) {
436 if (!_ignoreSslErrors.contains(QSslError{error.error()})) {
437 handleSslErrorOcurred(sslScocket, error);
443 if (ignore.isEmpty())
447 sslScocket->ignoreSslErrors(ignore);
452void AbstractNode::handleSslErrorOcurred(SslSocket *scket,
453 const QSslError &error) {
454 QuasarAppUtils::Params::log(scket->peerAddress().toString() +
" : " + error.errorString(),
455 QuasarAppUtils::Error);
457 QuasarAppUtils::Params::log(
"Error code: " + QString::number(error.error()),
458 QuasarAppUtils::Error);
464 return _closeConnectionAfterBadRequest;
468 _closeConnectionAfterBadRequest = newCloseConnectionAfterBadRequest;
472 return _sendBadRequestErrors;
476 _sendBadRequestErrors = val;
479const QSharedPointer<iParser> &
480AbstractNode::addApiParserImpl(
const QSharedPointer<iParser> &parserObject) {
497 cliAddress = *clientAddress;
499 cliAddress =
HostAddress{socket->peerAddress(), socket->peerPort()};
502 _connectionsMutex.lock();
504 if (_connections.contains(cliAddress)) {
505 auto info =_connections.value(cliAddress);
506 info->setSct(socket);
507 info->setIsLocal(clientAddress);
509 _connectionsMutex.unlock();
511 if (!info->isValid()) {
521 info->setIsLocal(clientAddress);
523 _connections[cliAddress] = info;
525 _connectionsMutex.unlock();
528 this, &AbstractNode::avelableBytes, Qt::DirectConnection);
532 this, &AbstractNode::handleNodeStatusChanged,
533 Qt::QueuedConnection);
536 handleNodeStatusChanged(info, info->status());
542 Qt::QueuedConnection);
545 QTimer::singleShot(
WAIT_TIME,
this, [
this, cliAddress]() {
546 checkConfirmendOfNode(
getInfoPtr(cliAddress));
554ParserResult AbstractNode::parsePackage(
const QSharedPointer<AbstractData> &pkg,
557 return _apiVersionParser->
parsePackage(pkg, pkgHeader, sender);
560QSharedPointer<AbstractData> AbstractNode::genPackage(
unsigned short cmd,
561 AbstractNodeInfo *sender)
const {
562 if (_apiVersionParser)
573 if (!target || !target->isValid()) {
574 QuasarAppUtils::Params::log(
"destination server not valid!",
575 QuasarAppUtils::Error);
579 if (!target->waitForConnected()) {
580 QuasarAppUtils::Params::log(
"no connected to server! " + target->errorString(),
581 QuasarAppUtils::Error);
599 QuasarAppUtils::Params::log(
"Response not sent because client == null");
608 bool convert =
false;
620 auto wrap = QSharedPointer<BigDataWraper>::create();
629 QuasarAppUtils::Params::log(
"Response not sent because dont create package from object",
630 QuasarAppUtils::Error);
635 QuasarAppUtils::Params::log(
"Response not sent!",
636 QuasarAppUtils::Error);
648 QuasarAppUtils::Params::log(
"Bad request detected, bud response command not sent!"
649 " because trust not changed",
650 QuasarAppUtils::Error);
652 QuasarAppUtils::Params::log(
"SECURITY LOG: Force block the " +
address.
toString() +
653 " because trust defined",
654 QuasarAppUtils::Error);
668 QuasarAppUtils::Params::log(
"Bad request sendet to adderess: " +
670 QuasarAppUtils::Info);
700 return "Not running";
704 return QString(
"%0 / %1").arg(
connectionsCount()).arg(maxPendingConnections());
708 QList<HostAddress> list = {};
710 QMutexLocker locer(&_connectionsMutex);
712 for (
auto i = _connections.begin(); i != _connections.end(); ++i) {
713 if (i.value()->isBanned()) {
714 list.push_back(i.key());
724 QMutexLocker locer(&_connectionsMutex);
726 for (
auto i : _connections) {
727 if (i->isConnected()) {
737 QMutexLocker locer(&_connectionsMutex);
739 for (
auto i : _connections) {
754 if (!(info && info->
isValid())) {
763 QAbstractSocket* socket =
nullptr;
769 socket =
new SslSocket(
nullptr);
776 socket->setSocketDescriptor(handle);
779 QuasarAppUtils::Params::log(
"Income connection from banned address",
780 QuasarAppUtils::Error);
788 QuasarAppUtils::Params::log(
"Failed to register new socket",
789 QuasarAppUtils::Error);
799 _socketWorker->
run(action);
808 auto objTrust = ptr->trust();
818 ptr->setTrust(objTrust + diff);
830 if (!_connections.contains(
id)) {
834 if (!_receiveData.contains(
id)) {
835 _receiveData.insert(
id,
new ReceiveData());
838 auto &pkg = _receiveData[id]->_pkg;
839 auto &hdrArray = _receiveData[id]->_hdrArray;
842 const int headerSize =
sizeof(Header);
844 auto socket = sender->
sct();
852 auto array = hdrArray;
853 while (socket->bytesAvailable() > 0) {
854 array += socket->readAll();
857 const int arraySize = array.size();
860 while (arraySize > workIndex) {
862 int offset = arraySize - workIndex;
864 if (pkg.hdr.isValid()) {
867 int dataLength = std::min(
static_cast<int>(pkg.hdr.size - pkg.data.size()),
868 arraySize - workIndex);
869 pkg.data.append(array.mid(workIndex, dataLength));
871 workIndex += dataLength;
874 }
else if (offset >= headerSize) {
881 array.data() + workIndex, headerSize);
883 if (!pkg.hdr.isValid())
886 int dataLength = std::min(
static_cast<int>(pkg.hdr.size),
887 arraySize - headerSize - workIndex);
889 pkg.data.append(array.mid(workIndex + headerSize, dataLength));
891 workIndex += headerSize + dataLength;
896 unsigned char dataLength =
static_cast<unsigned char>(arraySize - workIndex);
897 hdrArray += array.mid(workIndex, dataLength);
898 workIndex += dataLength;
902 newWork(pkg, sender,
id);
905 }
else if (
static_cast<unsigned int>(pkg.data.size()) >= pkg.hdr.size) {
906 QuasarAppUtils::Params::log(
"Invalid Package received." + pkg.toString(),
907 QuasarAppUtils::Warning);
916void AbstractNode::handleWorkerStoped() {
917 auto senderObject =
dynamic_cast<QFutureWatcher <bool>*
>(sender());
921 _workersMutex.lock();
922 _workers.remove(senderObject);
923 _workersMutex.unlock();
929void AbstractNode::handleForceRemoveNode(HostAddress node) {
932 info->removeSocket();
936void AbstractNode::handleBeginWork(QSharedPointer<QH::AbstractTask> work) {
938 auto executeObject = [
this, work]() ->
bool {
942 return work->execute(
this);
945 QMutexLocker locer(&_threadPoolMutex);
948 auto worker =
new QFutureWatcher <bool>();
949 worker->setFuture(QtConcurrent::run(_threadPool, executeObject));
951 _workersMutex.lock();
952 _workers.insert(worker);
953 _workersMutex.unlock();
956 connect(worker, &QFutureWatcher<bool>::finished,
957 this, &AbstractNode::handleWorkerStoped);
961bool AbstractNode::listen(
const HostAddress &address) {
965QSharedPointer<AbstractData>
971 QuasarAppUtils::Params::log(
"You try parse not registered package type."
972 " Plese use the registerPackageType method befor parsing."
973 " Example invoke registerPackageType<MyData>() into constructor of you client and server nodes.");
978 value->fromPakcage(pkg);
983 QMutexLocker locer(&_connectionsMutex);
985 return _connections.keys();
990 QList<HostAddress> result;
992 QMutexLocker locer(&_connectionsMutex);
993 for (
auto i : _connections) {
994 if (i->isConnected()) {
995 result.push_back(i->networkAddress());
1006 QuasarAppUtils::Params::log(
"The remote host not found or dns server not responce.",
1007 QuasarAppUtils::Error);
1013 QuasarAppUtils::Params::log(
"The remote node is banned or serve is overload.",
1014 QuasarAppUtils::Error);
1019 QuasarAppUtils::Params::log(
"The unknown error ocurred.",
1020 QuasarAppUtils::Error);
1032 if (!parser || parser->node() !=
this)
1035 return !addApiParserImpl(parser).isNull();
1041 return _tasksheduller->
shedule(task);
1045 _tasksheduller->
remove(taskId);
1058 auto executeObject = [pkg, sender, id,
this]() {
1066#ifdef HEART_PRINT_PACKAGES
1067 QuasarAppUtils::Params::log(QString(
"Package received! %0").arg(data->toString()), QuasarAppUtils::Info);
1072 auto message = QString(
"Package not parsed! %0 \nresult: %1. \n%2").
1075 QuasarAppUtils::Params::log(message, QuasarAppUtils::Info);
1096 QuasarAppUtils::Params::log(_apiVersionParser->
toString(), QuasarAppUtils::Info);
1102 _confirmNodeMutex.lock();
1103 sender->updateConfirmStatus();
1104 _confirmNodeMutex.unlock();
1111 QMutexLocker locer(&_threadPoolMutex);
1114 auto worker =
new QFutureWatcher <bool>();
1115 worker->setFuture(QtConcurrent::run(_threadPool, executeObject));
1117 _workersMutex.lock();
1118 _workers.insert(worker);
1119 _workersMutex.unlock();
1121 connect(worker, &QFutureWatcher<bool>::finished,
1122 this, &AbstractNode::handleWorkerStoped);
1131 return _connections;
1147 auto socket =
dynamic_cast<SslSocket*
>(node->
sct());
1150 QuasarAppUtils::Params::log(
"Failed to preparet to configure ssl socket.",
1151 QuasarAppUtils::Error);
1157 if (!socket->isEncrypted()) {
1158 if (!configureSslSocket(node, !node->
isLocal())) {
1159 QuasarAppUtils::Params::log(
"Failed to configure ssl socket.",
1160 QuasarAppUtils::Error);
1184 QuasarAppUtils::Params::log(
"Failed to sent version information to dist node",
1185 QuasarAppUtils::Error);
1199 QAbstractSocket::SocketError errorCode,
1200 QString errorString) {
1203 QString message(
"Network error occured on the %0 node. Message: %1");
1204 QuasarAppUtils::Params::log(
1206 QuasarAppUtils::Error);
1222void AbstractNode::initThreadId()
const {
1226void AbstractNode::initThreadPool() {
1229 QMutexLocker lock(&_threadPoolMutex);
1230 _threadPool =
new QThreadPool();
1231 _threadPool->setObjectName(
"PackageWorker");
1232 _threadPool->setMaxThreadCount(QThread::idealThreadCount());
1236void AbstractNode::deinitThreadPool() {
1237 QMutexLocker lock(&_threadPoolMutex);
1245 _threadPool =
nullptr;
1249 static auto thread = QThread::currentThread();
The APIVersionParser class This is main parser forthe main command. This parsers work only with the A...
QSharedPointer< PKG::AbstractData > searchPackage(unsigned short cmd, AbstractNodeInfo *sender) const
searchPackage This method search package recursive in all registered pararsers. Searching will be in ...
QHash< QString, QSharedPointer< QH::iParser > > selectParser(const VersionData &distVersion) const
selectParser This method select api parser betwin nodes.
const QSharedPointer< QH::iParser > & addApiParser(const QSharedPointer< QH::iParser > &parserObject)
addApiParser This method add new Api parser for this node.
ParserResult parsePackage(const QSharedPointer< PKG::AbstractData > &pkg, const Header &pkgHeader, AbstractNodeInfo *sender) override
parsePackage This is main method of all childs classes of an AbstractNode class. This method work on ...
void sigNoLongerSupport(const QString &ApiKey, unsigned short version)
sigNoLongerSupport This signal will be emit when node receive incomplite versions.
QString toString() const override
toString This method show all supported commands and them names.
bool sendSupportedAPI(AbstractNodeInfo *dist) const
sendSupportedAPI This method sents all ainformation about suppported api.
The AbstractNodeInfo class contains information about client or server connection and tcp socket of n...
const PackagesVersionData & multiVersionPackages() const
multiVersionPackages This is list of packages of one api package tah support multiple versions.
bool isLocal() const
isLocal return true if connection opened on this node.
NodeCoonectionStatus status() const
status This method return status of the node connection.
void sigReadyRead(QH::AbstractNodeInfo *thisNode)
sigReadyRead This is wrapper signal for the QAbstractSocket::readyRead signal.
HostAddress networkAddress() const
networkAddress This method return network address of current node or client.
void statusChaned(QH::AbstractNodeInfo *thisNode, QH::NodeCoonectionStatus status)
statusChaned This signal emitted when nodes status is changed.
virtual void removeSocket()
removeSocket This method use for remove socket. You can override this method for handle this event.
virtual bool isValid() const
isValid - Check valid of node. This method check connect status of socket.
QAbstractSocket * sct() const
sct This method return socket of connection.
virtual bool isBanned() const
isBanned - check node which banned.
void sigErrorOccurred(QH::AbstractNodeInfo *thisNode, QAbstractSocket::SocketError socketError, QString message)
sigErrorOccurred This is wrapper signal for the QAbstractSocket::errorOccurred signal.
virtual bool isConnected() const
isConnected - Check of node connect status.
void sigPingReceived(const QSharedPointer< QH::PKG::Ping > &ping)
sigPingReceived This method emited
int sheduledTaskCount() const
sheduledTaskCount This method return count of sheduled tasks.
QHash< HostAddress, AbstractNodeInfo * > connections() const
connections - Return hash map of all connections of this node.
QSharedPointer< PKG::AbstractData > prepareData(const Package &pkg, AbstractNodeInfo *sender) const
prepareData This is private method for preparing package from the byteArray.
QList< HostAddress > connectionsList() const
connectionsList This method return list of all node connections
bool fSendBadRequestErrors() const
fSendBadRequestErrors This property enable or disable sending feedback to connected node when them se...
virtual void nodeErrorOccured(QH::AbstractNodeInfo *nodeInfo, QAbstractSocket::SocketError errorCode, QString errorString)
nodeErrorOccured This slot invoked when error ocured in the nodeInfo.
virtual void addNodeFailed(AddNodeError error)
addNodeFailed This method will be invoked when trying to add new node are failed. So override this me...
virtual void nodeAddedSucessful(AbstractNodeInfo *node)
nodeAddedSucessful This method will be invoked when new node added successful.
QSharedPointer< QH::iParser > selectParser(unsigned short cmd, AbstractNodeInfo *sender) const
selectParser This method select parser by command and sender.
bool removeNode(const HostAddress &nodeAdderess)
removeNode - Remove node and disconnected forom node (server).
virtual void stop()
stop - Stopped this node and close all network connections.
virtual bool changeTrust(const HostAddress &id, int diff)
changeTrust This method change trust of connected node.
virtual void nodeConnected(AbstractNodeInfo *node)
nodeConnected This method invocked when the node status changed to "connected" default implementatio ...
QList< HostAddress > banedList() const
banedList This method retrun list of banned clients of nodes.
virtual QString connectionState() const
connectionState This method return string value about the cocction state.
virtual bool sendPackage(const Package &pkg, QAbstractSocket *target) const
sendPackage This method prepare and send to target address a package.
bool sheduleTask(const QSharedPointer< AbstractTask > &task)
sheduleTask This method shedule execute task on this node.
virtual bool isBanned(const AbstractNodeInfo *socket) const
isBanned This method checks if the node is banned.
static QThread * mainThreadID()
mainThreadID This method return the pointer to main thread
virtual AbstractNodeInfo * createNodeInfo(QAbstractSocket *socket, const HostAddress *clientAddress=nullptr) const
createNodeInfo This method create a nodeInfo object. override this method for create your own nodeInf...
bool addApiParser(const QSharedPointer< iParser > &parser)
addApiParser This method add new Api parser for this node.
bool addNode(const HostAddress &address)
addNode - Connect to node (server) with address.
void removeTask(int taskId)
removeTask This method remove task from sheduler.
virtual void ban(const HostAddress &target)
ban - This method set for target connection a trust property to 0 and target connection will been abo...
HostAddress address() const
address - Thim method return own network address of current node (server).
virtual void badRequest(const HostAddress &address, const Header &req, const PKG::ErrorData &err, qint8 diff=REQUEST_ERROR)
badRequest This method is send data about error of request.
SslMode getMode() const
getMode - This method return SSL mode of corrent node (server).
void prepareForDelete() override
prepareForDelete This method must be prepare object for delete. Override this for working main functi...
AbstractNode(QObject *ptr=nullptr)
AbstractNode - Base constructor of node.
virtual WorkState getWorkState() const
getWorkState - This method collect general information about this server. For more information about ...
void incomingConnection(qintptr handle) override final
incomingConnection This is ovverided method of QTCPServer.
QList< HostAddress > activeConnectionsList() const
activeConnectionsList This method return list of actived nodes connections
virtual AbstractNodeInfo * getInfoPtr(const HostAddress &id)
getInfoPtr - This method return information class pointer about netwok connection....
virtual bool registerSocket(QAbstractSocket *socket, const HostAddress *address=nullptr)
registerSocket This method registration new socket object.
void sigNoLongerSupport(const QString &ApiKey, unsigned short version)
sigNoLongerSupport is some as a APIVersionParser::sigNoLongerSupport. This signal just retronslate th...
virtual void nodeConfirmend(AbstractNodeInfo *node)
nodeConfirmend This method invocked when the node status changed to "confirmend" default implementati...
virtual QString getWorkStateString() const
getWorkStateString This method generate string about work state of server.
void setSendBadRequestErrors(bool value)
setSendBadRequestErrors This method enable or disable the fSendBadRequestErrors property.
virtual bool run(const QString &addres, unsigned short port)
run This method implement deployment a network node (server) on selected address.
virtual void unBan(const HostAddress &target)
unBan - This method set for target connection a trust property to 100.
bool ping(const HostAddress &address)
ping This method send ping package to address for testing connection.
virtual void nodeDisconnected(AbstractNodeInfo *node)
nodeConnected This method invocked when the node status changed to "disconnected" default implementat...
void setCloseConnectionAfterBadRequest(bool value)
setSendBadRequestErrors This method enable or disable the fcloseConnectionAfterBadRequest property.
int confirmendCount() const
connectionsCount - Return count of nodes with status confirmend.
bool fCloseConnectionAfterBadRequest() const
fCloseConnectionAfterBadRequest This propery enable or disable droping connection after badRequests....
int connectionsCount() const
connectionsCount - Return count fo connections (connections with status connected)
virtual unsigned int sendData(const PKG::AbstractData *resp, const HostAddress &address, const Header *req=nullptr)
sendData This method send data object another to node
virtual void receivePing(const QSharedPointer< QH::PKG::Ping > &ping)
receivePing This method invoked when node receive new ping object.
The AsyncLauncher class is wraper of the Async class for support moving invokes to thread of the curr...
bool run(const Job &action, bool wait=false)
run This method run the action function in the work thread of this object.
std::function< bool()> Job
The DataSender class this class create a queue for sendet data to network.
bool sendData(const QByteArray &array, void *target, bool await=false) const
sendPackagePrivate This slot move send package to a main thread.
The Host Address class this is wrapper of QHostAddress. Contains the NetworkAddress and network port.
unsigned short port() const
The port method return port of node.
QString toString() const
toString this method convert the Host Address value to string value.
The AbstractData class is provide base functions for transport data by network For create you own pac...
virtual bool toPackage(Package &package, const DistVersion &reqVersion, unsigned int triggerHash=0) const
toPackage This method convert this class object to the package. For more info see Package class.
virtual unsigned short cmd() const =0
cmd - This is command of this object, (for generate cmd use macross QH_PACKAGE)
The BadRequest class send response about error to client.
The CloseConnection class - This commanad is request for close connection on parent node of connectio...
The Ping class - test class for translate data on network.
The Package struct. This is base structure for transporting data by network between QH nodes....
QByteArray data
data This is source data of package.
virtual bool isValid() const
isValid This method validation a current package. Default implementation is checked a header and comp...
Header hdr
hdr This is header of package. For more information see the Header struct.
QString toString() const
toString This method convert a package information to a string label.
static unsigned int maximumSize()
maximumSize This method return maximu size of pacakge. If pacakge large the maximum size then package...
QByteArray toBytes() const
toBytes This method convert a current object to bytes array.
The TaskScheduler class This class contains queue of all shedule tasks.
void sigPushWork(QSharedPointer< QH::AbstractTask > work)
sigPushWork This signal emited when the task work neet to execute.
bool shedule(const QSharedPointer< AbstractTask > &task)
shedule This method shedule new task in this node.
int taskCount() const
taskCount This method return tasks count.
bool remove(const QSharedPointer< AbstractTask > &task)
remove This method remove the task from a tasks queue.
The AbstractSocket class This class is wraper of the QAbstract socket with slot implementation of the...
The WorkState class is simple class with data of work state of node.
void setActiveConnections(const QList< HostAddress > &newActiveConnections)
setActiveConnections this method sets new list of active connections.
void setMaxConnectionCount(int value)
setMaxConnectionCount this method set a new value of limit of connections.
void setIsRun(bool value)
setIsRun This method set new value for run flag.
void setBanedList(const QList< HostAddress > &banedList)
setBanedList -this method set banned list for this object.
void setConnections(const QList< HostAddress > &connections)
setConnections This method sets connections list.
static QString pareseResultToString(const ParserResult &parseResult)
pareseResultToString This method convert ParserResult value to string.
#define WAIT_CONFIRM_TIME
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
ParserResult
The ParserResult enum. Error - parser detect a errorob package. NotProcessed - the parser does not kn...
@ NotProcessed
the parser does not know what to do with the package or has not finished processing it.
@ Error
parser detect a errorob package.
@ Processed
the parser finished processing correctly.
NodeCoonectionStatus
The AbstractNodeState enum - This is status of the known nodes or clients.
@ Connected
The node with this status has socket status is connected.
@ NotConnected
This node not sent data about its envirement and status of node socket is disconnected.
AddNodeError
The AddNodeError enum contains error code that can be occured after invoke the AbstractNode::addNode ...
@ RegisterSocketFailed
This error ocurred when you try add baned node or server is overrload.
@ HostNotFound
This error ocurred when DNS server not responce to node or node can't find the server ip address by h...
@ Baned
Node with this trust value is forbidden.
@ Undefined
Undefined node.
SslMode
The SslMode enum This enum contatins options for set ssl mode of node (server). For more information ...
@ NoSSL
This is not secure connection without ssl encription. It is default value of new any node see Abstrac...
The ErrorData struct is simple structure for contains data of the error.