blob: 36aeb175f7f85b5b7a95501d6b462e460d6502af (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// Copyright 2005-2021 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
#ifndef MUMBLE_CONNECTION_H_
#define MUMBLE_CONNECTION_H_
#include <QtCore/QtGlobal>
#ifdef Q_OS_WIN
# include "win.h"
#endif
#include "crypto/CryptState.h"
#include "crypto/CryptStateOCB2.h"
#include <QtCore/QElapsedTimer>
#include <QtCore/QList>
#include <QtCore/QMutex>
#include <QtCore/QObject>
#include <QtNetwork/QSslSocket>
#include <memory>
#ifdef Q_OS_WIN
# include <ws2tcpip.h>
#endif
namespace google {
namespace protobuf {
class Message;
}
} // namespace google
class Connection : public QObject {
private:
Q_OBJECT
Q_DISABLE_COPY(Connection)
protected:
QSslSocket *qtsSocket;
QElapsedTimer qtLastPacket;
unsigned int uiType;
int iPacketLength;
#ifdef Q_OS_WIN
static HANDLE hQoS;
DWORD dwFlow;
#endif
protected slots:
void socketRead();
void socketError(QAbstractSocket::SocketError);
void socketDisconnected();
void socketSslErrors(const QList< QSslError > &errors);
public slots:
void proceedAnyway();
signals:
void encrypted();
void connectionClosed(QAbstractSocket::SocketError, const QString &reason);
void message(unsigned int type, const QByteArray &);
void handleSslErrors(const QList< QSslError > &);
public:
Connection(QObject *parent, QSslSocket *qtsSocket);
~Connection();
static void messageToNetwork(const ::google::protobuf::Message &msg, unsigned int msgType, QByteArray &cache);
void sendMessage(const ::google::protobuf::Message &msg, unsigned int msgType, QByteArray &cache);
void sendMessage(const QByteArray &qbaMsg);
void disconnectSocket(bool force = false);
void forceFlush();
qint64 activityTime() const;
void resetActivityTime();
#ifdef MURMUR
/// qmCrypt locks access to csCrypt.
QMutex qmCrypt;
#endif
std::unique_ptr< CryptState > csCrypt;
QList< QSslCertificate > peerCertificateChain() const;
QSslCipher sessionCipher() const;
QSsl::SslProtocol sessionProtocol() const;
QString sessionProtocolString() const;
QHostAddress peerAddress() const;
quint16 peerPort() const;
/// Look up the local address of this Connection.
QHostAddress localAddress() const;
/// Look up the local port of this Connection.
quint16 localPort() const;
bool bDisconnectedEmitted;
void setToS();
#ifdef Q_OS_WIN
static void setQoS(HANDLE hParentQoS);
#endif
};
#endif
|