blob: c183462ec23f65c7cc238ee88b1ba18d4c84bef9 (
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
|
#ifndef WEBPROXYCONN_H
#define WEBPROXYCONN_H
#include <QtCore/QObject>
#include "sapconnection.h"
#include "sapsocket.h"
class WebProxyTrans;
class WebProxyConn : public QObject
{
Q_OBJECT
public:
WebProxyConn(SAPConnection *conn, QObject *parent = 0);
protected:
enum MessageType {
MessageRequest = 1,
MessageResponse = 2,
MessageError = 3,
MessageAbort = 4
};
struct Message {
quint8 command; // Seems to be always 1
quint8 subCommand; // Seems to be always 1
MessageType type;
quint8 transactionId; // Monotonically increasing
QByteArray payload;
};
static Message unpackMessage(const QByteArray &data);
static QByteArray packMessage(const Message &msg);
struct RequestHeader {
/** Whether this is a CONNECT request, i.e. tunnel. */
bool connect;
QString host;
int port;
};
static RequestHeader parseRequestHeader(const QByteArray &req);
static QByteArray removeHeaders(const QByteArray &req);
void sendMessage(const Message &msg);
void handleRequest(const Message &msg);
void handleAbort(const Message &msg);
private slots:
void handleMessageReceived();
void handleTransDataReceived(const QByteArray &data);
void handleTransDisconnected();
private:
SAPConnection *_conn;
SAPSocket *_in;
SAPSocket *_out;
QMap<int, WebProxyTrans*> _trans;
};
#endif // WEBPROXYCONN_H
|