2019-09-06 23:43:07 -04:00
|
|
|
#ifndef TCP_SERVER_H
|
|
|
|
#define TCP_SERVER_H
|
|
|
|
|
|
|
|
// This file is part of MRCI.
|
|
|
|
|
|
|
|
// MRCI is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// MRCI is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with MRCI under the LICENSE.md file. If not, see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#include "db.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "session.h"
|
|
|
|
#include "make_cert.h"
|
|
|
|
#include "openssl/ssl.h"
|
2019-11-08 22:06:09 -05:00
|
|
|
#include "unix_signal.h"
|
2019-09-12 01:29:46 -04:00
|
|
|
|
2019-09-06 23:43:07 -04:00
|
|
|
class TCPServer: public QTcpServer
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2020-04-05 15:51:11 -04:00
|
|
|
QNetworkAccessManager *qNam;
|
|
|
|
QSharedMemory *hostSharedMem;
|
|
|
|
QLocalServer *controlPipe;
|
|
|
|
QLocalSocket *controlSocket;
|
|
|
|
char *hostLoad;
|
2020-04-21 12:04:36 -04:00
|
|
|
QList<QSslCertificate> sslChain;
|
|
|
|
QSslKey sslKey;
|
2020-04-05 15:51:11 -04:00
|
|
|
QString hostKey;
|
2020-04-21 12:04:36 -04:00
|
|
|
QString wanIP;
|
2020-04-05 15:51:11 -04:00
|
|
|
quint32 maxSessions;
|
|
|
|
quint32 flags;
|
2019-09-06 23:43:07 -04:00
|
|
|
|
2020-04-21 12:04:36 -04:00
|
|
|
QString loadSSLData(bool onReload);
|
|
|
|
bool servOverloaded();
|
|
|
|
bool createPipe();
|
|
|
|
void applyPrivKey(const QString &path, QTextStream &msg);
|
|
|
|
void applyCerts(const QStringList &list, QTextStream &msg);
|
|
|
|
void incomingConnection(qintptr socketDescriptor);
|
2019-09-06 23:43:07 -04:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
|
|
void procPipeIn();
|
|
|
|
void newPipeConnection();
|
|
|
|
void closedPipeConnection();
|
|
|
|
void sessionEnded();
|
2019-11-08 22:06:09 -05:00
|
|
|
void setMaxSessions(quint32 value);
|
2020-04-05 15:51:11 -04:00
|
|
|
void replyFromIpify(QNetworkReply *reply);
|
2019-09-06 23:43:07 -04:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
void resServer();
|
|
|
|
void closeServer();
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
explicit TCPServer(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
bool start();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
|
|
void connectPeers(QSharedPointer<SessionCarrier> peer);
|
|
|
|
void endAllSessions();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TCP_SERVER_H
|