summaryrefslogtreecommitdiffstats
path: root/src/server/net
diff options
context:
space:
mode:
authorChristian Klinger2016-09-29 15:40:18 +0200
committerChristian Klinger2016-09-29 15:40:18 +0200
commit3d82bfc698165bb20f3c38d42f2b77ab855c1edf (patch)
tree2c170bcdd5c89259bb0b530fa11fdfe701c99850 /src/server/net
parentadded an information dialog that displays ip and hostname. (diff)
downloadpvs2-3d82bfc698165bb20f3c38d42f2b77ab855c1edf.tar.gz
pvs2-3d82bfc698165bb20f3c38d42f2b77ab855c1edf.tar.xz
pvs2-3d82bfc698165bb20f3c38d42f2b77ab855c1edf.zip
astyle.
Diffstat (limited to 'src/server/net')
-rw-r--r--src/server/net/certmanager.cpp184
-rw-r--r--src/server/net/certmanager.h58
-rw-r--r--src/server/net/client.cpp116
-rw-r--r--src/server/net/client.h9
-rw-r--r--src/server/net/discoverylistener.cpp30
-rw-r--r--src/server/net/filedownloader.cpp19
-rw-r--r--src/server/net/listenserver.cpp3
-rw-r--r--src/server/net/sslserver.cpp25
8 files changed, 195 insertions, 249 deletions
diff --git a/src/server/net/certmanager.cpp b/src/server/net/certmanager.cpp
index b85966a..e91fed3 100644
--- a/src/server/net/certmanager.cpp
+++ b/src/server/net/certmanager.cpp
@@ -1,94 +1,90 @@
-/*
- # Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg
- #
- # This program is free software distributed under the GPL version 2.
- # See http://openslx.org/COPYING
- #
- # If you have any feedback please consult http://openslx.org/feedback and
- # send your suggestions, praise, or complaints to feedback@openslx.org
- #
- # General information about OpenSLX can be found at http://openslx.org/
- # -----------------------------------------------------------------------------
- # src/util/CertManager.cpp
- # - Manage SSL certificates
- # - provide access by name
- # -----------------------------------------------------------------------------
- */
-
-#include "certmanager.h"
-#include "../util/util.h"
-#include <QMap>
-#include <QDir>
-#include <QDebug>
-#include <QFileInfo>
-#include <QSettings>
-#include <cstdlib>
-
-namespace CertManager
-{
-static QMap<QString, QSslCertificate> _certs;
-static QMap<QString, QSslKey> _keys;
-
-static void generateFiles(QString& key, QString& cert);
-static bool loadFiles(QString& keyFile, QString& certFile, QSslKey &key, QSslCertificate &cert);
-
-bool getPrivateKeyAndCert(const QString &name, QSslKey &key, QSslCertificate &cert)
-{
- if (_keys.contains(name))
- {
- key = _keys[name];
- cert = _certs[name];
- return true;
- }
- QString certFile = QDir::homePath().append("/").append(CERTSTORAGE).append(name);
- QString keyFile = certFile;
- keyFile.append(".rsa");
- certFile.append(".crt");
- //
- if (!loadFiles(keyFile, certFile, key, cert))
- {
- generateFiles(keyFile, certFile);
- if (!loadFiles(keyFile, certFile, key, cert))
- qDebug() << "error while creating cert and key files\n";
- return false;
- }
- _certs.insert(name, cert);
- _keys.insert(name, key);
- return true;
-}
-
-static bool loadFiles(QString& keyFile, QString& certFile, QSslKey &key, QSslCertificate &cert)
-{
- QFileInfo keyInfo(keyFile);
- QFileInfo certInfo(certFile);
- if (keyInfo.exists() && certInfo.exists())
- { // Both files exist, see if they're valid and return
- QFile kf(keyFile);
- kf.open(QFile::ReadOnly);
- key = QSslKey(&kf, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
- QList<QSslCertificate> certlist = QSslCertificate::fromPath(certFile);
- if (!key.isNull() && !certlist.empty())
- {
- cert = certlist.first();
- if (!cert.isNull())
- {
- return true;
- }
- }
- }
- return false;
-}
-
-static void generateFiles(QString& key, QString& cert)
-{
- char tmp[1000];
- remove(key.toLocal8Bit().data());
- remove(cert.toLocal8Bit().data());
- snprintf(tmp, 1000,
- "openssl req -x509 -nodes -days 3650 -newkey rsa:1024 -subj '/C=DE/ST=BaWue/L=Freiburg/CN=openslx.org' -keyout \"%s\" -out \"%s\"",
- key.toLocal8Bit().data(), cert.toLocal8Bit().data());
- system(tmp);
- snprintf(tmp, 1000, "chmod 0600 \"%s\" \"%s\"", key.toLocal8Bit().data(), cert.toLocal8Bit().data());
- system(tmp);
-}
-}
+/*
+ # Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg
+ #
+ # This program is free software distributed under the GPL version 2.
+ # See http://openslx.org/COPYING
+ #
+ # If you have any feedback please consult http://openslx.org/feedback and
+ # send your suggestions, praise, or complaints to feedback@openslx.org
+ #
+ # General information about OpenSLX can be found at http://openslx.org/
+ # -----------------------------------------------------------------------------
+ # src/util/CertManager.cpp
+ # - Manage SSL certificates
+ # - provide access by name
+ # -----------------------------------------------------------------------------
+ */
+
+#include "certmanager.h"
+#include "../util/util.h"
+#include <QMap>
+#include <QDir>
+#include <QDebug>
+#include <QFileInfo>
+#include <QSettings>
+#include <cstdlib>
+
+namespace CertManager
+{
+static QMap<QString, QSslCertificate> _certs;
+static QMap<QString, QSslKey> _keys;
+
+static void generateFiles(QString& key, QString& cert);
+static bool loadFiles(QString& keyFile, QString& certFile, QSslKey &key, QSslCertificate &cert);
+
+bool getPrivateKeyAndCert(const QString &name, QSslKey &key, QSslCertificate &cert)
+{
+ if (_keys.contains(name)) {
+ key = _keys[name];
+ cert = _certs[name];
+ return true;
+ }
+ QString certFile = QDir::homePath().append("/").append(CERTSTORAGE).append(name);
+ QString keyFile = certFile;
+ keyFile.append(".rsa");
+ certFile.append(".crt");
+ //
+ if (!loadFiles(keyFile, certFile, key, cert)) {
+ generateFiles(keyFile, certFile);
+ if (!loadFiles(keyFile, certFile, key, cert))
+ qDebug() << "error while creating cert and key files\n";
+ return false;
+ }
+ _certs.insert(name, cert);
+ _keys.insert(name, key);
+ return true;
+}
+
+static bool loadFiles(QString& keyFile, QString& certFile, QSslKey &key, QSslCertificate &cert)
+{
+ QFileInfo keyInfo(keyFile);
+ QFileInfo certInfo(certFile);
+ if (keyInfo.exists() && certInfo.exists()) {
+ // Both files exist, see if they're valid and return
+ QFile kf(keyFile);
+ kf.open(QFile::ReadOnly);
+ key = QSslKey(&kf, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
+ QList<QSslCertificate> certlist = QSslCertificate::fromPath(certFile);
+ if (!key.isNull() && !certlist.empty()) {
+ cert = certlist.first();
+ if (!cert.isNull()) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+static void generateFiles(QString& key, QString& cert)
+{
+ char tmp[1000];
+ remove(key.toLocal8Bit().data());
+ remove(cert.toLocal8Bit().data());
+ snprintf(tmp, 1000,
+ "openssl req -x509 -nodes -days 3650 -newkey rsa:1024 -subj '/C=DE/ST=BaWue/L=Freiburg/CN=openslx.org' -keyout \"%s\" -out \"%s\"",
+ key.toLocal8Bit().data(), cert.toLocal8Bit().data());
+ system(tmp);
+ snprintf(tmp, 1000, "chmod 0600 \"%s\" \"%s\"", key.toLocal8Bit().data(), cert.toLocal8Bit().data());
+ system(tmp);
+}
+}
diff --git a/src/server/net/certmanager.h b/src/server/net/certmanager.h
index c69bc23..fee2691 100644
--- a/src/server/net/certmanager.h
+++ b/src/server/net/certmanager.h
@@ -1,29 +1,29 @@
-/*
-# Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg
-#
-# This program is free software distributed under the GPL version 2.
-# See http://openslx.org/COPYING
-#
-# If you have any feedback please consult http://openslx.org/feedback and
-# send your suggestions, praise, or complaints to feedback@openslx.org
-#
-# General information about OpenSLX can be found at http://openslx.org/
-# -----------------------------------------------------------------------------
-# src/util/CertManager.cpp
-# - Manage SSL certificates
-# - provide access by name
-# -----------------------------------------------------------------------------
-*/
-
-#ifndef CERTMANAGER_H_
-#define CERTMANAGER_H_
-
-#include <QtNetwork/QSslCertificate>
-#include <QtNetwork/QSslKey>
-
-namespace CertManager
-{
- bool getPrivateKeyAndCert(const QString &name, QSslKey &key, QSslCertificate &cert);
-}
-
-#endif /* CERTMANAGER_H_ */
+/*
+# Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# src/util/CertManager.cpp
+# - Manage SSL certificates
+# - provide access by name
+# -----------------------------------------------------------------------------
+*/
+
+#ifndef CERTMANAGER_H_
+#define CERTMANAGER_H_
+
+#include <QtNetwork/QSslCertificate>
+#include <QtNetwork/QSslKey>
+
+namespace CertManager
+{
+bool getPrivateKeyAndCert(const QString &name, QSslKey &key, QSslCertificate &cert);
+}
+
+#endif /* CERTMANAGER_H_ */
diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp
index 84c45a9..5cd5c30 100644
--- a/src/server/net/client.cpp
+++ b/src/server/net/client.cpp
@@ -33,13 +33,13 @@ Client::Client(QSslSocket* socket) : _socket(socket)
qDebug("*** Client %s created.", qPrintable(_socket->peerAddress().toString()));
// Connect important signals
connect(_socket, SIGNAL(disconnected()),
- this, SLOT(disconnect()));
+ this, SLOT(disconnect()));
connect(_socket, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(disconnect()));
+ this, SLOT(disconnect()));
connect(_socket, SIGNAL(sslErrors(const QList<QSslError> &)),
- this, SLOT(disconnect()));
+ this, SLOT(disconnect()));
connect(_socket, SIGNAL(readyRead()),
- this, SLOT(onDataArrival()));
+ this, SLOT(onDataArrival()));
// Send challenge
_challenge.resize(CHALLENGE_LEN);
for (int i = 0; i < CHALLENGE_LEN; ++i)
@@ -64,23 +64,18 @@ Client::~Client()
/******************************************************************************/
void Client::timerEvent(QTimerEvent* event)
{
- if (event->timerId() == _timerPingTimeout)
- {
- if (_pingTimeout < QDateTime::currentMSecsSinceEpoch())
- {
+ if (event->timerId() == _timerPingTimeout) {
+ if (_pingTimeout < QDateTime::currentMSecsSinceEpoch()) {
qDebug() << "Client" << _socket->peerAddress().toString() << "has a ping timeout.";
killTimer(_timerPingTimeout);
this->disconnect();
}
- }
- else if (event->timerId() == _timerIdAuthTimeout)
- {
+ } else if (event->timerId() == _timerIdAuthTimeout) {
// Client did not send login request within 3 seconds
killTimer(_timerIdAuthTimeout);
_timerIdAuthTimeout = 0;
this->disconnect();
- }
- else
+ } else
killTimer(event->timerId());
}
@@ -90,8 +85,7 @@ void Client::sendMessage(NetworkMessage& message)
if (_socket->state() != QAbstractSocket::ConnectedState)
return;
message.writeMessage(_socket);
- if (!message.writeComplete())
- {
+ if (!message.writeComplete()) {
qCritical() << "SendMessage to client " << _name << "@" << _socket->peerAddress().toString() << " failed!";
}
}
@@ -99,8 +93,7 @@ void Client::sendMessage(NetworkMessage& message)
/******************************************************************************/
void Client::requestThumb(const int width, const int height)
{
- if (_socket->state() != QAbstractSocket::ConnectedState)
- {
+ if (_socket->state() != QAbstractSocket::ConnectedState) {
qDebug("requestThumb called in bad state");
return;
}
@@ -115,25 +108,21 @@ void Client::requestThumb(const int width, const int height)
void Client::onDataArrival()
{
//
- if (_socket->state() != QAbstractSocket::ConnectedState)
- {
+ if (_socket->state() != QAbstractSocket::ConnectedState) {
qDebug("dataArrival called in bad state");
return;
}
bool ret;
- while (_socket->bytesAvailable() > 0)
- {
+ while (_socket->bytesAvailable() > 0) {
ret = _fromClient.readMessage(_socket); // let the message read data from socket
- if (ret == NM_READ_FAILED) // error parsing msg, disconnect client!
- {
+ if (ret == NM_READ_FAILED) { // error parsing msg, disconnect client!
this->disconnect();
return;
}
if (ret == NM_READ_INCOMPLETE)
return;
- if (_fromClient.readComplete()) // message is complete
- {
+ if (_fromClient.readComplete()) { // message is complete
this->handleMsg();
_fromClient.reset();
}
@@ -145,47 +134,35 @@ void Client::handleMsg()
{
_pingTimeout = QDateTime::currentMSecsSinceEpoch() + PING_TIMEOUT_MS;
const QString &id = _fromClient.getFieldString(_ID);
- if (id.isEmpty())
- {
+ if (id.isEmpty()) {
qDebug("Received message with empty ID field. ignored.");
return;
}
- if (_authed == 2)
- {
+ if (_authed == 2) {
// Following messages are only valid of the client is already authenticated
- if (id == _THUMB)
- {
+ if (id == _THUMB) {
QPixmap pixmap;
const QByteArray& rawImage = _fromClient.getFieldBytes("IMG");
/* size 0 means the client is in exam-mode and therefore doesn't send any thumbnail */
if (rawImage.size() > 0) {
- if (!pixmap.loadFromData(rawImage))
- {
+ if (!pixmap.loadFromData(rawImage)) {
qDebug("Could not decode thumbnail image from client.");
return;
}
_rawRemoteScreen = QByteArray(rawImage);
emit thumbUpdated(this, pixmap, rawImage);
}
- }
- else if (id == _VNCSERVER)
- {
+ } else if (id == _VNCSERVER) {
// Client tells about startup of vnc server
const int port = _fromClient.getFieldString("PORT").toInt();
- if (port <= 0)
- {
- if (_vncPort <= 0)
- {
- qDebug() << "Starting VNC server on client" << _name << " (" << _socket->peerAddress().toString()+_vncPort << ") failed.";
- }
- else
- {
+ if (port <= 0) {
+ if (_vncPort <= 0) {
+ qDebug() << "Starting VNC server on client" << _name << " (" << _socket->peerAddress().toString() + _vncPort << ") failed.";
+ } else {
qDebug() << "Client " << _name << " stopped its VNC server";
}
- }
- else
- {
+ } else {
_vncRoPass = _fromClient.getFieldString("ROPASS");
_vncRwPass = _fromClient.getFieldString("RWPASS");
qDebug() << "Client " << _name << " started its VNC server";
@@ -193,20 +170,15 @@ void Client::handleMsg()
_vncPort = port;
emit vncServerStateChange(this);
emit stateChanged();
- }
- else if (id == _VNCCLIENT)
- {
+ } else if (id == _VNCCLIENT) {
// Client tells us that it started or stopped displaying a remote screen via VNC
const int projectionSource = (int)_fromClient.getFieldString("CLIENTID").toInt();
- if (_fromClient.getFieldString("ENABLED").toInt() != 0)
- {
+ if (_fromClient.getFieldString("ENABLED").toInt() != 0) {
qDebug() << "Client " << _name << " started its VNC client (watching " << projectionSource << ")";
_projectionSource = projectionSource;
_isActiveVncClient = true;
emit vncClientStateChange(this);
- }
- else
- {
+ } else {
qDebug() << "Client " << _name << " stopped its VNC client (watched " << projectionSource << ")";
_isActiveVncClient = false;
emit vncClientStateChange(this);
@@ -217,10 +189,8 @@ void Client::handleMsg()
}
// Not authed yet, only care about login requests
- if (_authed == 1)
- {
- if (id == _LOGIN)
- {
+ if (_authed == 1) {
+ if (id == _LOGIN) {
killTimer(_timerIdAuthTimeout);
_timerIdAuthTimeout = 0;
ClientLogin request;
@@ -233,8 +203,7 @@ void Client::handleMsg()
qDebug() << "Login request by " << request.name << (request.examMode ? "(in exam mode)" : "");
// emit event, see if request is accepted
emit authenticating(this, &request);
- if (!request.accept)
- {
+ if (!request.accept) {
qDebug("Request denied.");
this->disconnect(); // Nope
return;
@@ -253,16 +222,14 @@ void Client::handleMsg()
}
// Did not pass challenge yet
- if (_authed == 0)
- {
+ if (_authed == 0) {
// Waiting for challenge reply by client
- if (id == _CHALLENGE)
- {
+ if (id == _CHALLENGE) {
QByteArray hash(_fromClient.getFieldBytes(_HASH));
QByteArray challenge(_fromClient.getFieldBytes(_CHALLENGE));
if (genSha1(&Global::sessionNameArray(), &_challenge) != hash
- && !(Global::getCurrentRoom()->clientPositions.contains(_socket->peerAddress().toString())))
- { // Challenge reply is invalid, drop client
+ && !(Global::getCurrentRoom()->clientPositions.contains(_socket->peerAddress().toString()))) {
+ // Challenge reply is invalid, drop client
NetworkMessage msgErr;
msgErr.buildErrorMessage("Challenge reply invalid.");
msgErr.writeMessage(_socket);
@@ -310,8 +277,7 @@ void Client::startVncClient(const Client * const to)
msg.setField("ROPASS", to->_vncRoPass);
msg.setField("CLIENTID", QString::number(to->_id));
msg.setField("CAPTION", to->_name + " @ " + to->_host);
- if (!to->_rawRemoteScreen.isEmpty())
- {
+ if (!to->_rawRemoteScreen.isEmpty()) {
msg.setField(_THUMB, to->_rawRemoteScreen);
}
sendMessage(msg);
@@ -333,18 +299,18 @@ void Client::stopVncClient()
*/
bool Client::isManagerMachine()
{
- foreach (const QHostAddress &address, QNetworkInterface::allAddresses())
- if (address != QHostAddress(QHostAddress::LocalHost)
- && this != NULL
- && this->ip() == address.toString())
- return true;
+ foreach (const QHostAddress & address, QNetworkInterface::allAddresses())
+ if (address != QHostAddress(QHostAddress::LocalHost)
+ && this != NULL
+ && this->ip() == address.toString())
+ return true;
return false;
}
/******************************************************************************/
void Client::lockScreen(bool lock)
{
- if (!_isTutor && _locked != lock && !isManagerMachine()){
+ if (!_isTutor && _locked != lock && !isManagerMachine()) {
_locked = lock;
NetworkMessage msg;
msg.setField(_ID, _LOCK);
diff --git a/src/server/net/client.h b/src/server/net/client.h
index 872d0e1..e7c9c5c 100644
--- a/src/server/net/client.h
+++ b/src/server/net/client.h
@@ -12,8 +12,7 @@
#define NO_SOURCE 0
-struct ClientLogin
-{
+struct ClientLogin {
bool accept;
QString name;
QString host;
@@ -39,13 +38,13 @@ public:
inline const bool isActiveVncClient() const { return _isActiveVncClient; }
inline const bool isActiveVncServer() const { return _vncPort > 0; }
inline const bool isLocked() const { return _locked; }
- inline const int desiredProjectionSource(){ return _desiredSource; }
+ inline const int desiredProjectionSource() { return _desiredSource; }
inline const int projectionSource() const { return _projectionSource; }
inline const int isExamMode() const { return _isExamMode; }
// Setters
- inline void setTutor(bool enable){ _isTutor = enable; }
- inline void setDesiredProjectionSource(int id){_desiredSource = id;}
+ inline void setTutor(bool enable) { _isTutor = enable; }
+ inline void setDesiredProjectionSource(int id) {_desiredSource = id;}
inline void setExamMode(bool mode) { _isExamMode = mode; }
//Send message stuff
diff --git a/src/server/net/discoverylistener.cpp b/src/server/net/discoverylistener.cpp
index 892ca53..8eb1091 100644
--- a/src/server/net/discoverylistener.cpp
+++ b/src/server/net/discoverylistener.cpp
@@ -55,21 +55,18 @@ DiscoveryListener::~DiscoveryListener()
static quint16 hash(const QHostAddress& host)
{
static quint16 seed1 = 0, seed2 = 0;
- while (seed1 == 0) // Make sure the algorithm uses different seeds each time the program is
- { // run to prevent hash collision attacks
+ while (seed1 == 0) { // Make sure the algorithm uses different seeds each time the program is
+ // run to prevent hash collision attacks
seed1 = (quint16)(qrand() & 0xffff);
seed2 = (quint16)(qrand() & 0xffff);
}
quint8 data[16], len;
- if (host.protocol() == QAbstractSocket::IPv4Protocol)
- {
+ if (host.protocol() == QAbstractSocket::IPv4Protocol) {
// IPv4
quint32 addr = host.toIPv4Address();
len = 4;
memcpy(data, &addr, len);
- }
- else if (QAbstractSocket::IPv6Protocol)
- {
+ } else if (QAbstractSocket::IPv6Protocol) {
// IPv6
len = 16;
// Fast version (might break with future qt versions)
@@ -79,9 +76,7 @@ static quint16 hash(const QHostAddress& host)
for (int i = 0; i < len; ++i)
data[i] = addr[i];
*/
- }
- else
- {
+ } else {
// Durr?
len = 2;
data[0] = (quint16)qrand();
@@ -89,8 +84,7 @@ static quint16 hash(const QHostAddress& host)
}
quint16 result = 0;
quint16 mod = seed1;
- for (quint8 i = 0; i < len; ++i)
- {
+ for (quint8 i = 0; i < len; ++i) {
result = ((result << 1) + data[i]) ^ mod; // because of the shift this algo is not suitable for len(input) > 8
mod += seed2 + data[i];
}
@@ -107,8 +101,7 @@ static quint16 hash(const QHostAddress& host)
*/
void DiscoveryListener::timerEvent(QTimerEvent* event)
{
- for (int i = 0; i < SPAM_MODERATE_AT_ONCE; ++i)
- {
+ for (int i = 0; i < SPAM_MODERATE_AT_ONCE; ++i) {
if (++_counterResetPos >= SD_PACKET_TABLE_SIZE)
_counterResetPos = 0;
if (_packetCounter[_counterResetPos] > 10)
@@ -130,14 +123,12 @@ void DiscoveryListener::onReadyRead()
char data[UDPBUFSIZ];
QHostAddress addr;
quint16 port;
- while (_socket.hasPendingDatagrams())
- {
+ while (_socket.hasPendingDatagrams()) {
const qint64 size = _socket.readDatagram(data, UDPBUFSIZ, &addr, &port);
if (size <= 0)
continue;
const quint16 bucket = hash(addr) % SD_PACKET_TABLE_SIZE;
- if (_packetCounter[bucket] > SPAM_CUTOFF)
- {
+ if (_packetCounter[bucket] > SPAM_CUTOFF) {
qDebug() << "SD: Potential (D)DoS from " << _socket.peerAddress().toString();
// emit some signal and pop up a big warning that someone is flooding/ddosing the PVS SD
// ... on the other hand, will the user understand? ;)
@@ -160,8 +151,7 @@ void DiscoveryListener::onReadyRead()
continue;
// If so, check if the submitted hash seems valid
if (genSha1(&Global::sessionNameArray(), &salt1, &iplist) != hash &&
- !(Global::getCurrentRoom()->clientPositions.contains(addr.toString())))
- {
+ !(Global::getCurrentRoom()->clientPositions.contains(addr.toString()))) {
// did not match local session name and client is not in same room.
continue;
}
diff --git a/src/server/net/filedownloader.cpp b/src/server/net/filedownloader.cpp
index aa27948..b930869 100644
--- a/src/server/net/filedownloader.cpp
+++ b/src/server/net/filedownloader.cpp
@@ -10,27 +10,32 @@
#include "filedownloader.h"
FileDownloader::FileDownloader(QObject *parent) :
- QObject(parent) {
+ QObject(parent)
+{
connect(&m_WebCtrl, SIGNAL(finished(QNetworkReply*)),
- SLOT(fileDownloaded(QNetworkReply*)));
+ SLOT(fileDownloaded(QNetworkReply*)));
}
-FileDownloader::~FileDownloader() {
+FileDownloader::~FileDownloader()
+{
}
-void FileDownloader::connectSlot(QObject* obj, const char* slot) {
+void FileDownloader::connectSlot(QObject* obj, const char* slot)
+{
QObject::connect(this, SIGNAL(downloaded(QByteArray&)),
- obj, slot);
+ obj, slot);
}
-void FileDownloader::fileDownloaded(QNetworkReply* pReply) {
+void FileDownloader::fileDownloaded(QNetworkReply* pReply)
+{
QByteArray downloadedData = pReply->readAll();
//emit a signal
pReply->deleteLater();
emit downloaded(downloadedData);
}
-void FileDownloader::downloadFile(const QUrl& fileUrl) {
+void FileDownloader::downloadFile(const QUrl& fileUrl)
+{
m_WebCtrl.get(QNetworkRequest(fileUrl));
}
diff --git a/src/server/net/listenserver.cpp b/src/server/net/listenserver.cpp
index ba56177..1ce5016 100644
--- a/src/server/net/listenserver.cpp
+++ b/src/server/net/listenserver.cpp
@@ -31,8 +31,7 @@ ListenServer::~ListenServer()
void ListenServer::newClientConnection()
{
QSslSocket* sock;
- while ((sock = (QSslSocket*)_server.nextPendingConnection()) != NULL)
- {
+ while ((sock = (QSslSocket*)_server.nextPendingConnection()) != NULL) {
Client* client = new Client(sock); // TODO: what happens with disconnected clients
emit newClient(client);
}
diff --git a/src/server/net/sslserver.cpp b/src/server/net/sslserver.cpp
index ffbf262..3d8f924 100644
--- a/src/server/net/sslserver.cpp
+++ b/src/server/net/sslserver.cpp
@@ -46,15 +46,12 @@ void SslServer::incomingConnection(int socketDescriptor)
serverSocket->setPeerVerifyMode(QSslSocket::VerifyNone);
serverSocket->setProtocol(QSsl::TlsV1SslV3);
//printf("Keylen %d\n", serverSocket->privateKey().length());
- if (serverSocket->setSocketDescriptor(socketDescriptor))
- {
+ if (serverSocket->setSocketDescriptor(socketDescriptor)) {
// Once the connection is successfully encrypted, raise our newConnection event
connect(serverSocket, SIGNAL(encrypted()), this, SIGNAL(newConnection()));
serverSocket->startServerEncryption();
_pending.push_back(serverSocket);
- }
- else
- {
+ } else {
serverSocket->deleteLater();
}
}
@@ -67,8 +64,7 @@ void SslServer::sslErrors(const QList<QSslError> & errors)
void SslServer::timerEvent(QTimerEvent* event)
{
// Remove all sockets marked for deletion
- while (!_delete.isEmpty())
- {
+ while (!_delete.isEmpty()) {
QSslSocket *sock = _delete.takeFirst();
sock->blockSignals(true);
sock->deleteLater();
@@ -79,8 +75,7 @@ void SslServer::timerEvent(QTimerEvent* event)
bool SslServer::hasPendingConnections()
{
- for (QList<QSslSocket*>::iterator it(_pending.begin()); it != _pending.end(); it++)
- {
+ for (QList<QSslSocket*>::iterator it(_pending.begin()); it != _pending.end(); it++) {
qDebug("State: %d - Encrypted: %d", (int)(*it)->state(), (*it)->isEncrypted());
if ((*it)->state() == QAbstractSocket::ConnectedState && (*it)->isEncrypted())
return true;
@@ -90,10 +85,8 @@ bool SslServer::hasPendingConnections()
QTcpSocket* SslServer::nextPendingConnection()
{
- for (QList<QSslSocket*>::iterator it(_pending.begin()); it != _pending.end(); it++)
- {
- if ((*it)->state() == QAbstractSocket::ConnectedState && (*it)->isEncrypted())
- {
+ for (QList<QSslSocket*>::iterator it(_pending.begin()); it != _pending.end(); it++) {
+ if ((*it)->state() == QAbstractSocket::ConnectedState && (*it)->isEncrypted()) {
QSslSocket *sock = *it;
QObject::disconnect(sock, SIGNAL(encrypted()), this, SIGNAL(newConnection()));
_pending.removeAll(sock);
@@ -101,10 +94,8 @@ QTcpSocket* SslServer::nextPendingConnection()
return sock;
}
}
- for (QList<QSslSocket*>::iterator it(_delete.begin()); it != _delete.end(); it++)
- {
- if ((*it)->state() == QAbstractSocket::ConnectedState && (*it)->isEncrypted())
- {
+ for (QList<QSslSocket*>::iterator it(_delete.begin()); it != _delete.end(); it++) {
+ if ((*it)->state() == QAbstractSocket::ConnectedState && (*it)->isEncrypted()) {
QSslSocket *sock = *it;
QObject::disconnect(sock, SIGNAL(encrypted()), this, SIGNAL(newConnection()));
_pending.removeAll(sock);