Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtNetwork module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qsocks5socketengine_p.h" | - |
43 | | - |
44 | #ifndef QT_NO_SOCKS5 | - |
45 | | - |
46 | #include "qtcpsocket.h" | - |
47 | #include "qudpsocket.h" | - |
48 | #include "qtcpserver.h" | - |
49 | #include "qdebug.h" | - |
50 | #include "qhash.h" | - |
51 | #include "qqueue.h" | - |
52 | #include "qelapsedtimer.h" | - |
53 | #include "qmutex.h" | - |
54 | #include "qthread.h" | - |
55 | #include "qcoreapplication.h" | - |
56 | #include "qurl.h" | - |
57 | #include "qauthenticator.h" | - |
58 | #include <qendian.h> | - |
59 | #include <qnetworkinterface.h> | - |
60 | | - |
61 | QT_BEGIN_NAMESPACE | - |
62 | | - |
63 | static const int MaxWriteBufferSize = 128*1024; | - |
64 | | - |
65 | //#define QSOCKS5SOCKETLAYER_DEBUG | - |
66 | | - |
67 | #define MAX_DATA_DUMP 256 | - |
68 | #if !defined(Q_OS_WINCE) | - |
69 | #define SOCKS5_BLOCKING_BIND_TIMEOUT 5000 | - |
70 | #else | - |
71 | #define SOCKS5_BLOCKING_BIND_TIMEOUT 10000 | - |
72 | #endif | - |
73 | | - |
74 | #define Q_INIT_CHECK(returnValue) do { \ | - |
75 | if (!d->data) { \ | - |
76 | return returnValue; \ | - |
77 | } } while (0) | - |
78 | | - |
79 | #define S5_VERSION_5 0x05 | - |
80 | #define S5_CONNECT 0x01 | - |
81 | #define S5_BIND 0x02 | - |
82 | #define S5_UDP_ASSOCIATE 0x03 | - |
83 | #define S5_IP_V4 0x01 | - |
84 | #define S5_DOMAINNAME 0x03 | - |
85 | #define S5_IP_V6 0x04 | - |
86 | #define S5_SUCCESS 0x00 | - |
87 | #define S5_R_ERROR_SOCKS_FAILURE 0x01 | - |
88 | #define S5_R_ERROR_CON_NOT_ALLOWED 0x02 | - |
89 | #define S5_R_ERROR_NET_UNREACH 0x03 | - |
90 | #define S5_R_ERROR_HOST_UNREACH 0x04 | - |
91 | #define S5_R_ERROR_CONN_REFUSED 0x05 | - |
92 | #define S5_R_ERROR_TTL 0x06 | - |
93 | #define S5_R_ERROR_CMD_NOT_SUPPORTED 0x07 | - |
94 | #define S5_R_ERROR_ADD_TYPE_NOT_SUPORTED 0x08 | - |
95 | | - |
96 | #define S5_AUTHMETHOD_NONE 0x00 | - |
97 | #define S5_AUTHMETHOD_PASSWORD 0x02 | - |
98 | #define S5_AUTHMETHOD_NOTACCEPTABLE 0xFF | - |
99 | | - |
100 | #define S5_PASSWORDAUTH_VERSION 0x01 | - |
101 | | - |
102 | #ifdef QSOCKS5SOCKETLAYER_DEBUG | - |
103 | # define QSOCKS5_Q_DEBUG qDebug() << this | - |
104 | # define QSOCKS5_D_DEBUG qDebug() << q_ptr | - |
105 | # define QSOCKS5_DEBUG qDebug() << "[QSocks5]" | - |
106 | static QString s5StateToString(QSocks5SocketEnginePrivate::Socks5State s) | - |
107 | { | - |
108 | switch (s) { | - |
109 | case QSocks5SocketEnginePrivate::Uninitialized: return QLatin1String("Uninitialized"); | - |
110 | case QSocks5SocketEnginePrivate::ConnectError: return QLatin1String("ConnectError"); | - |
111 | case QSocks5SocketEnginePrivate::AuthenticationMethodsSent: return QLatin1String("AuthenticationMethodsSent"); | - |
112 | case QSocks5SocketEnginePrivate::Authenticating: return QLatin1String("Authenticating"); | - |
113 | case QSocks5SocketEnginePrivate::AuthenticatingError: return QLatin1String("AuthenticatingError"); | - |
114 | case QSocks5SocketEnginePrivate::RequestMethodSent: return QLatin1String("RequestMethodSent"); | - |
115 | case QSocks5SocketEnginePrivate::RequestError: return QLatin1String("RequestError"); | - |
116 | case QSocks5SocketEnginePrivate::Connected: return QLatin1String("Connected"); | - |
117 | case QSocks5SocketEnginePrivate::UdpAssociateSuccess: return QLatin1String("UdpAssociateSuccess"); | - |
118 | case QSocks5SocketEnginePrivate::BindSuccess: return QLatin1String("BindSuccess"); | - |
119 | case QSocks5SocketEnginePrivate::ControlSocketError: return QLatin1String("ControlSocketError"); | - |
120 | case QSocks5SocketEnginePrivate::SocksError: return QLatin1String("SocksError"); | - |
121 | case QSocks5SocketEnginePrivate::HostNameLookupError: return QLatin1String("HostNameLookupError"); | - |
122 | default: break; | - |
123 | } | - |
124 | return QLatin1String("unknown state"); | - |
125 | } | - |
126 | | - |
127 | static QString dump(const QByteArray &buf) | - |
128 | { | - |
129 | QString data; | - |
130 | for (int i = 0; i < qMin<int>(MAX_DATA_DUMP, buf.size()); ++i) { | - |
131 | if (i) data += QLatin1Char(' '); | - |
132 | uint val = (unsigned char)buf.at(i); | - |
133 | // data += QString("0x%1").arg(val, 3, 16, QLatin1Char('0')); | - |
134 | data += QString::number(val); | - |
135 | } | - |
136 | if (buf.size() > MAX_DATA_DUMP) | - |
137 | data += QLatin1String(" ..."); | - |
138 | | - |
139 | return QString::fromLatin1("size: %1 data: { %2 }").arg(buf.size()).arg(data); | - |
140 | } | - |
141 | | - |
142 | #else | - |
143 | # define QSOCKS5_DEBUG if (0) qDebug() | - |
144 | # define QSOCKS5_Q_DEBUG if (0) qDebug() | - |
145 | # define QSOCKS5_D_DEBUG if (0) qDebug() | - |
146 | | - |
147 | static inline QString s5StateToString(QSocks5SocketEnginePrivate::Socks5State) { return QString(); } never executed: return QString(); | 0 |
148 | static inline QString dump(const QByteArray &) { return QString(); } never executed: return QString(); | 0 |
149 | #endif | - |
150 | | - |
151 | /* | - |
152 | inserts the host address in buf at pos and updates pos. | - |
153 | if the func fails the data in buf and the vallue of pos is undefined | - |
154 | */ | - |
155 | static bool qt_socks5_set_host_address_and_port(const QHostAddress &address, quint16 port, QByteArray *pBuf) | - |
156 | { | - |
157 | QSOCKS5_DEBUG << "setting [" << address << ':' << port << ']'; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 157, __PRETTY_FUNCTION__).debug() << "setting [" << address << ':' << port << ']'; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:313386 |
| 0-313386 |
158 | | - |
159 | union { executed (the execution status of this line is deduced): union { | - |
160 | quint16 port; executed (the execution status of this line is deduced): quint16 port; | - |
161 | quint32 ipv4; executed (the execution status of this line is deduced): quint32 ipv4; | - |
162 | QIPv6Address ipv6; executed (the execution status of this line is deduced): QIPv6Address ipv6; | - |
163 | char ptr; executed (the execution status of this line is deduced): char ptr; | - |
164 | } data; executed (the execution status of this line is deduced): } data; | - |
165 | | - |
166 | // add address | - |
167 | if (address.protocol() == QAbstractSocket::IPv4Protocol) { evaluated: address.protocol() == QAbstractSocket::IPv4Protocol yes Evaluation Count:313362 | yes Evaluation Count:24 |
| 24-313362 |
168 | data.ipv4 = qToBigEndian<quint32>(address.toIPv4Address()); executed (the execution status of this line is deduced): data.ipv4 = qToBigEndian<quint32>(address.toIPv4Address()); | - |
169 | pBuf->append(S5_IP_V4); executed (the execution status of this line is deduced): pBuf->append(0x01); | - |
170 | pBuf->append(QByteArray::fromRawData(&data.ptr, sizeof data.ipv4)); executed (the execution status of this line is deduced): pBuf->append(QByteArray::fromRawData(&data.ptr, sizeof data.ipv4)); | - |
171 | } else if (address.protocol() == QAbstractSocket::IPv6Protocol) { executed: } Execution Count:313362 partially evaluated: address.protocol() == QAbstractSocket::IPv6Protocol yes Evaluation Count:24 | no Evaluation Count:0 |
| 0-313362 |
172 | data.ipv6 = address.toIPv6Address(); executed (the execution status of this line is deduced): data.ipv6 = address.toIPv6Address(); | - |
173 | pBuf->append(S5_IP_V6); executed (the execution status of this line is deduced): pBuf->append(0x04); | - |
174 | pBuf->append(QByteArray::fromRawData(&data.ptr, sizeof data.ipv6)); executed (the execution status of this line is deduced): pBuf->append(QByteArray::fromRawData(&data.ptr, sizeof data.ipv6)); | - |
175 | } else { executed: } Execution Count:24 | 24 |
176 | return false; never executed: return false; | 0 |
177 | } | - |
178 | | - |
179 | // add port | - |
180 | data.port = qToBigEndian<quint16>(port); executed (the execution status of this line is deduced): data.port = qToBigEndian<quint16>(port); | - |
181 | pBuf->append(QByteArray::fromRawData(&data.ptr, sizeof data.port)); executed (the execution status of this line is deduced): pBuf->append(QByteArray::fromRawData(&data.ptr, sizeof data.port)); | - |
182 | return true; executed: return true; Execution Count:313386 | 313386 |
183 | } | - |
184 | | - |
185 | /* | - |
186 | like above, but for a hostname | - |
187 | */ | - |
188 | static bool qt_socks5_set_host_name_and_port(const QString &hostname, quint16 port, QByteArray *pBuf) | - |
189 | { | - |
190 | QSOCKS5_DEBUG << "setting [" << hostname << ':' << port << ']'; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 190, __PRETTY_FUNCTION__).debug() << "setting [" << hostname << ':' << port << ']'; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:45 |
| 0-45 |
191 | | - |
192 | QByteArray encodedHostName = QUrl::toAce(hostname); executed (the execution status of this line is deduced): QByteArray encodedHostName = QUrl::toAce(hostname); | - |
193 | QByteArray &buf = *pBuf; executed (the execution status of this line is deduced): QByteArray &buf = *pBuf; | - |
194 | | - |
195 | if (encodedHostName.length() > 255) partially evaluated: encodedHostName.length() > 255 no Evaluation Count:0 | yes Evaluation Count:45 |
| 0-45 |
196 | return false; never executed: return false; | 0 |
197 | | - |
198 | buf.append(S5_DOMAINNAME); executed (the execution status of this line is deduced): buf.append(0x03); | - |
199 | buf.append(uchar(encodedHostName.length())); executed (the execution status of this line is deduced): buf.append(uchar(encodedHostName.length())); | - |
200 | buf.append(encodedHostName); executed (the execution status of this line is deduced): buf.append(encodedHostName); | - |
201 | | - |
202 | // add port | - |
203 | union { executed (the execution status of this line is deduced): union { | - |
204 | quint16 port; executed (the execution status of this line is deduced): quint16 port; | - |
205 | char ptr; executed (the execution status of this line is deduced): char ptr; | - |
206 | } data; executed (the execution status of this line is deduced): } data; | - |
207 | data.port = qToBigEndian<quint16>(port); executed (the execution status of this line is deduced): data.port = qToBigEndian<quint16>(port); | - |
208 | buf.append(QByteArray::fromRawData(&data.ptr, sizeof data.port)); executed (the execution status of this line is deduced): buf.append(QByteArray::fromRawData(&data.ptr, sizeof data.port)); | - |
209 | | - |
210 | return true; executed: return true; Execution Count:45 | 45 |
211 | } | - |
212 | | - |
213 | | - |
214 | /* | - |
215 | retrives the host address in buf at pos and updates pos. | - |
216 | return 1 if OK, 0 if need more data, -1 if error | - |
217 | if the func fails the value of the address and the pos is undefined | - |
218 | */ | - |
219 | static int qt_socks5_get_host_address_and_port(const QByteArray &buf, QHostAddress *pAddress, quint16 *pPort, int *pPos) | - |
220 | { | - |
221 | int ret = -1; executed (the execution status of this line is deduced): int ret = -1; | - |
222 | int pos = *pPos; executed (the execution status of this line is deduced): int pos = *pPos; | - |
223 | const unsigned char *pBuf = reinterpret_cast<const unsigned char*>(buf.constData()); executed (the execution status of this line is deduced): const unsigned char *pBuf = reinterpret_cast<const unsigned char*>(buf.constData()); | - |
224 | QHostAddress address; executed (the execution status of this line is deduced): QHostAddress address; | - |
225 | quint16 port = 0; executed (the execution status of this line is deduced): quint16 port = 0; | - |
226 | | - |
227 | if (buf.size() - pos < 1) { partially evaluated: buf.size() - pos < 1 no Evaluation Count:0 | yes Evaluation Count:20729 |
| 0-20729 |
228 | QSOCKS5_DEBUG << "need more data address/port"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 228, __PRETTY_FUNCTION__).debug() << "need more data address/port"; never evaluated: 0 | 0 |
229 | return 0; never executed: return 0; | 0 |
230 | } | - |
231 | if (pBuf[pos] == S5_IP_V4) { partially evaluated: pBuf[pos] == 0x01 yes Evaluation Count:20729 | no Evaluation Count:0 |
| 0-20729 |
232 | pos++; executed (the execution status of this line is deduced): pos++; | - |
233 | if (buf.size() - pos < 4) { partially evaluated: buf.size() - pos < 4 no Evaluation Count:0 | yes Evaluation Count:20729 |
| 0-20729 |
234 | QSOCKS5_DEBUG << "need more data for ip4 address"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 234, __PRETTY_FUNCTION__).debug() << "need more data for ip4 address"; never evaluated: 0 | 0 |
235 | return 0; never executed: return 0; | 0 |
236 | } | - |
237 | address.setAddress(qFromBigEndian<quint32>(&pBuf[pos])); executed (the execution status of this line is deduced): address.setAddress(qFromBigEndian<quint32>(&pBuf[pos])); | - |
238 | pos += 4; executed (the execution status of this line is deduced): pos += 4; | - |
239 | ret = 1; executed (the execution status of this line is deduced): ret = 1; | - |
240 | } else if (pBuf[pos] == S5_IP_V6) { executed: } Execution Count:20729 never evaluated: pBuf[pos] == 0x04 | 0-20729 |
241 | pos++; never executed (the execution status of this line is deduced): pos++; | - |
242 | if (buf.size() - pos < 16) { never evaluated: buf.size() - pos < 16 | 0 |
243 | QSOCKS5_DEBUG << "need more data for ip6 address"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 243, __PRETTY_FUNCTION__).debug() << "need more data for ip6 address"; never evaluated: 0 | 0 |
244 | return 0; never executed: return 0; | 0 |
245 | } | - |
246 | QIPv6Address add; never executed (the execution status of this line is deduced): QIPv6Address add; | - |
247 | for (int i = 0; i < 16; ++i) | 0 |
248 | add[i] = buf[pos++]; never executed: add[i] = buf[pos++]; | 0 |
249 | address.setAddress(add); never executed (the execution status of this line is deduced): address.setAddress(add); | - |
250 | ret = 1; never executed (the execution status of this line is deduced): ret = 1; | - |
251 | } else if (pBuf[pos] == S5_DOMAINNAME){ never executed: } never evaluated: pBuf[pos] == 0x03 | 0 |
252 | // just skip it | - |
253 | pos++; never executed (the execution status of this line is deduced): pos++; | - |
254 | qDebug() << "skipping hostname of len" << uint(pBuf[pos]); never executed (the execution status of this line is deduced): QMessageLogger("socket/qsocks5socketengine.cpp", 254, __PRETTY_FUNCTION__).debug() << "skipping hostname of len" << uint(pBuf[pos]); | - |
255 | pos += uchar(pBuf[pos]); never executed (the execution status of this line is deduced): pos += uchar(pBuf[pos]); | - |
256 | } else { | 0 |
257 | QSOCKS5_DEBUG << "invalid address type" << (int)pBuf[pos]; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 257, __PRETTY_FUNCTION__).debug() << "invalid address type" << (int)pBuf[pos]; never evaluated: 0 | 0 |
258 | ret = -1; never executed (the execution status of this line is deduced): ret = -1; | - |
259 | } | 0 |
260 | | - |
261 | if (ret == 1) { partially evaluated: ret == 1 yes Evaluation Count:20729 | no Evaluation Count:0 |
| 0-20729 |
262 | if (buf.size() - pos < 2) { partially evaluated: buf.size() - pos < 2 no Evaluation Count:0 | yes Evaluation Count:20729 |
| 0-20729 |
263 | QSOCKS5_DEBUG << "need more data for port"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 263, __PRETTY_FUNCTION__).debug() << "need more data for port"; never evaluated: 0 | 0 |
264 | return 0; never executed: return 0; | 0 |
265 | } | - |
266 | port = qFromBigEndian<quint16>(&pBuf[pos]); executed (the execution status of this line is deduced): port = qFromBigEndian<quint16>(&pBuf[pos]); | - |
267 | pos += 2; executed (the execution status of this line is deduced): pos += 2; | - |
268 | } executed: } Execution Count:20729 | 20729 |
269 | | - |
270 | if (ret == 1) { partially evaluated: ret == 1 yes Evaluation Count:20729 | no Evaluation Count:0 |
| 0-20729 |
271 | QSOCKS5_DEBUG << "got [" << address << ':' << port << ']'; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 271, __PRETTY_FUNCTION__).debug() << "got [" << address << ':' << port << ']'; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:20729 |
| 0-20729 |
272 | *pAddress = address; executed (the execution status of this line is deduced): *pAddress = address; | - |
273 | *pPort = port; executed (the execution status of this line is deduced): *pPort = port; | - |
274 | *pPos = pos; executed (the execution status of this line is deduced): *pPos = pos; | - |
275 | } executed: } Execution Count:20729 | 20729 |
276 | | - |
277 | return ret; executed: return ret; Execution Count:20729 | 20729 |
278 | } | - |
279 | | - |
280 | /* | - |
281 | Returns the difference between msecs and elapsed. If msecs is -1, | - |
282 | however, -1 is returned. | - |
283 | */ | - |
284 | static int qt_timeout_value(int msecs, int elapsed) | - |
285 | { | - |
286 | if (msecs == -1) partially evaluated: msecs == -1 no Evaluation Count:0 | yes Evaluation Count:386 |
| 0-386 |
287 | return -1; never executed: return -1; | 0 |
288 | | - |
289 | int timeout = msecs - elapsed; executed (the execution status of this line is deduced): int timeout = msecs - elapsed; | - |
290 | return timeout < 0 ? 0 : timeout; executed: return timeout < 0 ? 0 : timeout; Execution Count:386 | 386 |
291 | } | - |
292 | | - |
293 | struct QSocks5Data | - |
294 | { | - |
295 | QTcpSocket *controlSocket; | - |
296 | QSocks5Authenticator *authenticator; | - |
297 | }; | - |
298 | | - |
299 | struct QSocks5ConnectData : public QSocks5Data | - |
300 | { | - |
301 | QByteArray readBuffer; | - |
302 | }; | - |
303 | | - |
304 | struct QSocks5BindData : public QSocks5Data | - |
305 | { | - |
306 | QHostAddress localAddress; | - |
307 | quint16 localPort; | - |
308 | QHostAddress peerAddress; | - |
309 | quint16 peerPort; | - |
310 | QElapsedTimer timeStamp; | - |
311 | }; | - |
312 | | - |
313 | struct QSocks5RevivedDatagram | - |
314 | { | - |
315 | QByteArray data; | - |
316 | QHostAddress address; | - |
317 | quint16 port; | - |
318 | }; | - |
319 | | - |
320 | #ifndef QT_NO_UDPSOCKET | - |
321 | struct QSocks5UdpAssociateData : public QSocks5Data | - |
322 | { | - |
323 | QUdpSocket *udpSocket; | - |
324 | QHostAddress associateAddress; | - |
325 | quint16 associatePort; | - |
326 | QQueue<QSocks5RevivedDatagram> pendingDatagrams; | - |
327 | }; | - |
328 | #endif | - |
329 | | - |
330 | // needs to be thread safe | - |
331 | class QSocks5BindStore : public QObject | - |
332 | { | - |
333 | public: | - |
334 | QSocks5BindStore(); | - |
335 | ~QSocks5BindStore(); | - |
336 | | - |
337 | void add(qintptr socketDescriptor, QSocks5BindData *bindData); | - |
338 | bool contains(qintptr socketDescriptor); | - |
339 | QSocks5BindData *retrieve(qintptr socketDescriptor); | - |
340 | | - |
341 | protected: | - |
342 | void timerEvent(QTimerEvent * event); | - |
343 | | - |
344 | QMutex mutex; | - |
345 | int sweepTimerId; | - |
346 | //socket descriptor, data, timestamp | - |
347 | QHash<int, QSocks5BindData *> store; | - |
348 | }; | - |
349 | | - |
350 | Q_GLOBAL_STATIC(QSocks5BindStore, socks5BindStore) never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:618 partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) no Evaluation Count:0 | yes Evaluation Count:10 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:10 | yes Evaluation Count:608 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:10 | no Evaluation Count:0 |
| 0-618 |
351 | | - |
352 | QSocks5BindStore::QSocks5BindStore() | - |
353 | : mutex(QMutex::Recursive) | - |
354 | , sweepTimerId(-1) | - |
355 | { | - |
356 | QCoreApplication *app = QCoreApplication::instance(); executed (the execution status of this line is deduced): QCoreApplication *app = QCoreApplication::instance(); | - |
357 | if (app && app->thread() != thread()) partially evaluated: app yes Evaluation Count:10 | no Evaluation Count:0 |
evaluated: app->thread() != thread() yes Evaluation Count:2 | yes Evaluation Count:8 |
| 0-10 |
358 | moveToThread(app->thread()); executed: moveToThread(app->thread()); Execution Count:2 | 2 |
359 | } executed: } Execution Count:10 | 10 |
360 | | - |
361 | QSocks5BindStore::~QSocks5BindStore() | - |
362 | { | - |
363 | } | - |
364 | | - |
365 | void QSocks5BindStore::add(qintptr socketDescriptor, QSocks5BindData *bindData) | - |
366 | { | - |
367 | QMutexLocker lock(&mutex); executed (the execution status of this line is deduced): QMutexLocker lock(&mutex); | - |
368 | if (store.contains(socketDescriptor)) { partially evaluated: store.contains(socketDescriptor) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
369 | // qDebug() << "delete it"; | - |
370 | } | 0 |
371 | bindData->timeStamp.start(); executed (the execution status of this line is deduced): bindData->timeStamp.start(); | - |
372 | store.insert(socketDescriptor, bindData); executed (the execution status of this line is deduced): store.insert(socketDescriptor, bindData); | - |
373 | // start sweep timer if not started | - |
374 | if (sweepTimerId == -1) partially evaluated: sweepTimerId == -1 yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
375 | sweepTimerId = startTimer(60000); executed: sweepTimerId = startTimer(60000); Execution Count:1 | 1 |
376 | } executed: } Execution Count:1 | 1 |
377 | | - |
378 | bool QSocks5BindStore::contains(qintptr socketDescriptor) | - |
379 | { | - |
380 | QMutexLocker lock(&mutex); executed (the execution status of this line is deduced): QMutexLocker lock(&mutex); | - |
381 | return store.contains(socketDescriptor); executed: return store.contains(socketDescriptor); Execution Count:616 | 616 |
382 | } | - |
383 | | - |
384 | QSocks5BindData *QSocks5BindStore::retrieve(qintptr socketDescriptor) | - |
385 | { | - |
386 | QMutexLocker lock(&mutex); executed (the execution status of this line is deduced): QMutexLocker lock(&mutex); | - |
387 | if (!store.contains(socketDescriptor)) partially evaluated: !store.contains(socketDescriptor) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
388 | return 0; never executed: return 0; | 0 |
389 | QSocks5BindData *bindData = store.take(socketDescriptor); executed (the execution status of this line is deduced): QSocks5BindData *bindData = store.take(socketDescriptor); | - |
390 | if (bindData) { partially evaluated: bindData yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
391 | if (bindData->controlSocket->thread() != QThread::currentThread()) { partially evaluated: bindData->controlSocket->thread() != QThread::currentThread() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
392 | qWarning("Can not access socks5 bind data from different thread"); never executed (the execution status of this line is deduced): QMessageLogger("socket/qsocks5socketengine.cpp", 392, __PRETTY_FUNCTION__).warning("Can not access socks5 bind data from different thread"); | - |
393 | return 0; never executed: return 0; | 0 |
394 | } | - |
395 | } else { executed: } Execution Count:1 | 1 |
396 | QSOCKS5_DEBUG << "__ERROR__ binddata == 0"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 396, __PRETTY_FUNCTION__).debug() << "__ERROR__ binddata == 0"; never evaluated: 0 | 0 |
397 | } | 0 |
398 | // stop the sweep timer if not needed | - |
399 | if (store.isEmpty()) { partially evaluated: store.isEmpty() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
400 | killTimer(sweepTimerId); executed (the execution status of this line is deduced): killTimer(sweepTimerId); | - |
401 | sweepTimerId = -1; executed (the execution status of this line is deduced): sweepTimerId = -1; | - |
402 | } executed: } Execution Count:1 | 1 |
403 | return bindData; executed: return bindData; Execution Count:1 | 1 |
404 | } | - |
405 | | - |
406 | void QSocks5BindStore::timerEvent(QTimerEvent * event) | - |
407 | { | - |
408 | QMutexLocker lock(&mutex); never executed (the execution status of this line is deduced): QMutexLocker lock(&mutex); | - |
409 | if (event->timerId() == sweepTimerId) { never evaluated: event->timerId() == sweepTimerId | 0 |
410 | QSOCKS5_DEBUG << "QSocks5BindStore performing sweep"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 410, __PRETTY_FUNCTION__).debug() << "QSocks5BindStore performing sweep"; never evaluated: 0 | 0 |
411 | QMutableHashIterator<int, QSocks5BindData *> it(store); never executed (the execution status of this line is deduced): QMutableHashIterator<int, QSocks5BindData *> it(store); | - |
412 | while (it.hasNext()) { never evaluated: it.hasNext() | 0 |
413 | it.next(); never executed (the execution status of this line is deduced): it.next(); | - |
414 | if (it.value()->timeStamp.hasExpired(350000)) { never evaluated: it.value()->timeStamp.hasExpired(350000) | 0 |
415 | QSOCKS5_DEBUG << "QSocks5BindStore removing JJJJ"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 415, __PRETTY_FUNCTION__).debug() << "QSocks5BindStore removing JJJJ"; never evaluated: 0 | 0 |
416 | it.remove(); never executed (the execution status of this line is deduced): it.remove(); | - |
417 | } | 0 |
418 | } | 0 |
419 | } | 0 |
420 | } | 0 |
421 | | - |
422 | QSocks5Authenticator::QSocks5Authenticator() | - |
423 | { | - |
424 | } | - |
425 | | - |
426 | QSocks5Authenticator::~QSocks5Authenticator() | - |
427 | { | - |
428 | } | - |
429 | | - |
430 | char QSocks5Authenticator::methodId() | - |
431 | { | - |
432 | return 0x00; executed: return 0x00; Execution Count:126 | 126 |
433 | } | - |
434 | | - |
435 | bool QSocks5Authenticator::beginAuthenticate(QTcpSocket *socket, bool *completed) | - |
436 | { | - |
437 | Q_UNUSED(socket); never executed (the execution status of this line is deduced): (void)socket;; | - |
438 | *completed = true; never executed (the execution status of this line is deduced): *completed = true; | - |
439 | return true; never executed: return true; | 0 |
440 | } | - |
441 | | - |
442 | bool QSocks5Authenticator::continueAuthenticate(QTcpSocket *socket, bool *completed) | - |
443 | { | - |
444 | Q_UNUSED(socket); never executed (the execution status of this line is deduced): (void)socket;; | - |
445 | *completed = true; never executed (the execution status of this line is deduced): *completed = true; | - |
446 | return true; never executed: return true; | 0 |
447 | } | - |
448 | | - |
449 | bool QSocks5Authenticator::seal(const QByteArray buf, QByteArray *sealedBuf) | - |
450 | { | - |
451 | *sealedBuf = buf; executed (the execution status of this line is deduced): *sealedBuf = buf; | - |
452 | return true; executed: return true; Execution Count:313562 | 313562 |
453 | } | - |
454 | | - |
455 | bool QSocks5Authenticator::unSeal(const QByteArray sealedBuf, QByteArray *buf) | - |
456 | { | - |
457 | *buf = sealedBuf; executed (the execution status of this line is deduced): *buf = sealedBuf; | - |
458 | return true; executed: return true; Execution Count:20878 | 20878 |
459 | } | - |
460 | | - |
461 | bool QSocks5Authenticator::unSeal(QTcpSocket *sealedSocket, QByteArray *buf) | - |
462 | { | - |
463 | return unSeal(sealedSocket->readAll(), buf); executed: return unSeal(sealedSocket->readAll(), buf); Execution Count:247 | 247 |
464 | } | - |
465 | | - |
466 | QSocks5PasswordAuthenticator::QSocks5PasswordAuthenticator(const QString &userName, const QString &password) | - |
467 | { | - |
468 | this->userName = userName; executed (the execution status of this line is deduced): this->userName = userName; | - |
469 | this->password = password; executed (the execution status of this line is deduced): this->password = password; | - |
470 | } executed: } Execution Count:21 | 21 |
471 | | - |
472 | char QSocks5PasswordAuthenticator::methodId() | - |
473 | { | - |
474 | return 0x02; executed: return 0x02; Execution Count:42 | 42 |
475 | } | - |
476 | | - |
477 | bool QSocks5PasswordAuthenticator::beginAuthenticate(QTcpSocket *socket, bool *completed) | - |
478 | { | - |
479 | *completed = false; executed (the execution status of this line is deduced): *completed = false; | - |
480 | QByteArray uname = userName.toLatin1(); executed (the execution status of this line is deduced): QByteArray uname = userName.toLatin1(); | - |
481 | QByteArray passwd = password.toLatin1(); executed (the execution status of this line is deduced): QByteArray passwd = password.toLatin1(); | - |
482 | QByteArray dataBuf(3 + uname.size() + passwd.size(), 0); executed (the execution status of this line is deduced): QByteArray dataBuf(3 + uname.size() + passwd.size(), 0); | - |
483 | char *buf = dataBuf.data(); executed (the execution status of this line is deduced): char *buf = dataBuf.data(); | - |
484 | int pos = 0; executed (the execution status of this line is deduced): int pos = 0; | - |
485 | buf[pos++] = S5_PASSWORDAUTH_VERSION; executed (the execution status of this line is deduced): buf[pos++] = 0x01; | - |
486 | buf[pos++] = uname.size(); executed (the execution status of this line is deduced): buf[pos++] = uname.size(); | - |
487 | memcpy(&buf[pos], uname.data(), uname.size()); executed (the execution status of this line is deduced): memcpy(&buf[pos], uname.data(), uname.size()); | - |
488 | pos += uname.size(); executed (the execution status of this line is deduced): pos += uname.size(); | - |
489 | buf[pos++] = passwd.size(); executed (the execution status of this line is deduced): buf[pos++] = passwd.size(); | - |
490 | memcpy(&buf[pos], passwd.data(), passwd.size()); executed (the execution status of this line is deduced): memcpy(&buf[pos], passwd.data(), passwd.size()); | - |
491 | return socket->write(dataBuf) == dataBuf.size(); executed: return socket->write(dataBuf) == dataBuf.size(); Execution Count:21 | 21 |
492 | } | - |
493 | | - |
494 | bool QSocks5PasswordAuthenticator::continueAuthenticate(QTcpSocket *socket, bool *completed) | - |
495 | { | - |
496 | *completed = false; executed (the execution status of this line is deduced): *completed = false; | - |
497 | | - |
498 | if (socket->bytesAvailable() < 2) partially evaluated: socket->bytesAvailable() < 2 no Evaluation Count:0 | yes Evaluation Count:21 |
| 0-21 |
499 | return true; never executed: return true; | 0 |
500 | | - |
501 | QByteArray buf = socket->read(2); executed (the execution status of this line is deduced): QByteArray buf = socket->read(2); | - |
502 | if (buf.at(0) == S5_PASSWORDAUTH_VERSION && buf.at(1) == 0x00) { partially evaluated: buf.at(0) == 0x01 yes Evaluation Count:21 | no Evaluation Count:0 |
partially evaluated: buf.at(1) == 0x00 yes Evaluation Count:21 | no Evaluation Count:0 |
| 0-21 |
503 | *completed = true; executed (the execution status of this line is deduced): *completed = true; | - |
504 | return true; executed: return true; Execution Count:21 | 21 |
505 | } | - |
506 | | - |
507 | // must disconnect | - |
508 | socket->close(); never executed (the execution status of this line is deduced): socket->close(); | - |
509 | return false; never executed: return false; | 0 |
510 | } | - |
511 | | - |
512 | QString QSocks5PasswordAuthenticator::errorString() | - |
513 | { | - |
514 | return QLatin1String("Socks5 user name or password incorrect"); never executed: return QLatin1String("Socks5 user name or password incorrect"); | 0 |
515 | } | - |
516 | | - |
517 | | - |
518 | | - |
519 | QSocks5SocketEnginePrivate::QSocks5SocketEnginePrivate() | - |
520 | : socks5State(Uninitialized) | - |
521 | , readNotificationEnabled(false) | - |
522 | , writeNotificationEnabled(false) | - |
523 | , exceptNotificationEnabled(false) | - |
524 | , socketDescriptor(-1) | - |
525 | , data(0) | - |
526 | , connectData(0) | - |
527 | #ifndef QT_NO_UDPSOCKET | - |
528 | , udpData(0) | - |
529 | #endif | - |
530 | , bindData(0) | - |
531 | , readNotificationActivated(false) | - |
532 | , writeNotificationActivated(false) | - |
533 | , readNotificationPending(false) | - |
534 | , writeNotificationPending(false) | - |
535 | , connectionNotificationPending(false) | - |
536 | { | - |
537 | mode = NoMode; executed (the execution status of this line is deduced): mode = NoMode; | - |
538 | } executed: } Execution Count:129 | 129 |
539 | | - |
540 | QSocks5SocketEnginePrivate::~QSocks5SocketEnginePrivate() | - |
541 | { | - |
542 | } | - |
543 | | - |
544 | void QSocks5SocketEnginePrivate::initialize(Socks5Mode socks5Mode) | - |
545 | { | - |
546 | Q_Q(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEngine * const q = q_func(); | - |
547 | | - |
548 | mode = socks5Mode; executed (the execution status of this line is deduced): mode = socks5Mode; | - |
549 | if (mode == ConnectMode) { evaluated: mode == ConnectMode yes Evaluation Count:49 | yes Evaluation Count:79 |
| 49-79 |
550 | connectData = new QSocks5ConnectData; executed (the execution status of this line is deduced): connectData = new QSocks5ConnectData; | - |
551 | data = connectData; executed (the execution status of this line is deduced): data = connectData; | - |
552 | #ifndef QT_NO_UDPSOCKET | - |
553 | } else if (mode == UdpAssociateMode) { executed: } Execution Count:49 evaluated: mode == UdpAssociateMode yes Evaluation Count:71 | yes Evaluation Count:8 |
| 8-71 |
554 | udpData = new QSocks5UdpAssociateData; executed (the execution status of this line is deduced): udpData = new QSocks5UdpAssociateData; | - |
555 | data = udpData; executed (the execution status of this line is deduced): data = udpData; | - |
556 | udpData->udpSocket = new QUdpSocket(q); executed (the execution status of this line is deduced): udpData->udpSocket = new QUdpSocket(q); | - |
557 | #ifndef QT_NO_BEARERMANAGEMENT | - |
558 | udpData->udpSocket->setProperty("_q_networksession", q->property("_q_networksession")); executed (the execution status of this line is deduced): udpData->udpSocket->setProperty("_q_networksession", q->property("_q_networksession")); | - |
559 | #endif | - |
560 | udpData->udpSocket->setProxy(QNetworkProxy::NoProxy); executed (the execution status of this line is deduced): udpData->udpSocket->setProxy(QNetworkProxy::NoProxy); | - |
561 | QObject::connect(udpData->udpSocket, SIGNAL(readyRead()), executed (the execution status of this line is deduced): QObject::connect(udpData->udpSocket, "2""readyRead()", | - |
562 | q, SLOT(_q_udpSocketReadNotification()), executed (the execution status of this line is deduced): q, "1""_q_udpSocketReadNotification()", | - |
563 | Qt::DirectConnection); executed (the execution status of this line is deduced): Qt::DirectConnection); | - |
564 | #endif // QT_NO_UDPSOCKET | - |
565 | } else if (mode == BindMode) { executed: } Execution Count:71 partially evaluated: mode == BindMode yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-71 |
566 | bindData = new QSocks5BindData; executed (the execution status of this line is deduced): bindData = new QSocks5BindData; | - |
567 | data = bindData; executed (the execution status of this line is deduced): data = bindData; | - |
568 | } executed: } Execution Count:8 | 8 |
569 | | - |
570 | data->controlSocket = new QTcpSocket(q); executed (the execution status of this line is deduced): data->controlSocket = new QTcpSocket(q); | - |
571 | #ifndef QT_NO_BEARERMANAGEMENT | - |
572 | data->controlSocket->setProperty("_q_networksession", q->property("_q_networksession")); executed (the execution status of this line is deduced): data->controlSocket->setProperty("_q_networksession", q->property("_q_networksession")); | - |
573 | #endif | - |
574 | data->controlSocket->setProxy(QNetworkProxy::NoProxy); executed (the execution status of this line is deduced): data->controlSocket->setProxy(QNetworkProxy::NoProxy); | - |
575 | QObject::connect(data->controlSocket, SIGNAL(connected()), q, SLOT(_q_controlSocketConnected()), executed (the execution status of this line is deduced): QObject::connect(data->controlSocket, "2""connected()", q, "1""_q_controlSocketConnected()", | - |
576 | Qt::DirectConnection); executed (the execution status of this line is deduced): Qt::DirectConnection); | - |
577 | QObject::connect(data->controlSocket, SIGNAL(readyRead()), q, SLOT(_q_controlSocketReadNotification()), executed (the execution status of this line is deduced): QObject::connect(data->controlSocket, "2""readyRead()", q, "1""_q_controlSocketReadNotification()", | - |
578 | Qt::DirectConnection); executed (the execution status of this line is deduced): Qt::DirectConnection); | - |
579 | QObject::connect(data->controlSocket, SIGNAL(bytesWritten(qint64)), q, SLOT(_q_controlSocketBytesWritten()), executed (the execution status of this line is deduced): QObject::connect(data->controlSocket, "2""bytesWritten(qint64)", q, "1""_q_controlSocketBytesWritten()", | - |
580 | Qt::DirectConnection); executed (the execution status of this line is deduced): Qt::DirectConnection); | - |
581 | QObject::connect(data->controlSocket, SIGNAL(error(QAbstractSocket::SocketError)), executed (the execution status of this line is deduced): QObject::connect(data->controlSocket, "2""error(QAbstractSocket::SocketError)", | - |
582 | q, SLOT(_q_controlSocketError(QAbstractSocket::SocketError)), executed (the execution status of this line is deduced): q, "1""_q_controlSocketError(QAbstractSocket::SocketError)", | - |
583 | Qt::DirectConnection); executed (the execution status of this line is deduced): Qt::DirectConnection); | - |
584 | QObject::connect(data->controlSocket, SIGNAL(disconnected()), q, SLOT(_q_controlSocketDisconnected()), executed (the execution status of this line is deduced): QObject::connect(data->controlSocket, "2""disconnected()", q, "1""_q_controlSocketDisconnected()", | - |
585 | Qt::DirectConnection); executed (the execution status of this line is deduced): Qt::DirectConnection); | - |
586 | QObject::connect(data->controlSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), executed (the execution status of this line is deduced): QObject::connect(data->controlSocket, "2""stateChanged(QAbstractSocket::SocketState)", | - |
587 | q, SLOT(_q_controlSocketStateChanged(QAbstractSocket::SocketState)), executed (the execution status of this line is deduced): q, "1""_q_controlSocketStateChanged(QAbstractSocket::SocketState)", | - |
588 | Qt::DirectConnection); executed (the execution status of this line is deduced): Qt::DirectConnection); | - |
589 | | - |
590 | if (!proxyInfo.user().isEmpty() || !proxyInfo.password().isEmpty()) { partially evaluated: !proxyInfo.user().isEmpty() no Evaluation Count:0 | yes Evaluation Count:128 |
partially evaluated: !proxyInfo.password().isEmpty() no Evaluation Count:0 | yes Evaluation Count:128 |
| 0-128 |
591 | QSOCKS5_D_DEBUG << "using username/password authentication; user =" << proxyInfo.user(); never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 591, __PRETTY_FUNCTION__).debug() << "using username/password authentication; user =" << proxyInfo.user(); never evaluated: 0 | 0 |
592 | data->authenticator = new QSocks5PasswordAuthenticator(proxyInfo.user(), proxyInfo.password()); never executed (the execution status of this line is deduced): data->authenticator = new QSocks5PasswordAuthenticator(proxyInfo.user(), proxyInfo.password()); | - |
593 | } else { | 0 |
594 | QSOCKS5_D_DEBUG << "not using authentication"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 594, __PRETTY_FUNCTION__).debug() << "not using authentication"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:128 |
| 0-128 |
595 | data->authenticator = new QSocks5Authenticator(); executed (the execution status of this line is deduced): data->authenticator = new QSocks5Authenticator(); | - |
596 | } executed: } Execution Count:128 | 128 |
597 | } | - |
598 | | - |
599 | void QSocks5SocketEnginePrivate::setErrorState(Socks5State state, const QString &extraMessage) | - |
600 | { | - |
601 | Q_Q(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEngine * const q = q_func(); | - |
602 | | - |
603 | switch (state) { | - |
604 | case Uninitialized: | - |
605 | case Authenticating: | - |
606 | case AuthenticationMethodsSent: | - |
607 | case RequestMethodSent: | - |
608 | case Connected: | - |
609 | case UdpAssociateSuccess: | - |
610 | case BindSuccess: | - |
611 | // these aren't error states | - |
612 | return; | 0 |
613 | | - |
614 | case ConnectError: | - |
615 | case ControlSocketError: { | - |
616 | QAbstractSocket::SocketError controlSocketError = data->controlSocket->error(); executed (the execution status of this line is deduced): QAbstractSocket::SocketError controlSocketError = data->controlSocket->error(); | - |
617 | if (socks5State != Connected) { partially evaluated: socks5State != Connected yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
618 | switch (controlSocketError) { | - |
619 | case QAbstractSocket::ConnectionRefusedError: | - |
620 | q->setError(QAbstractSocket::ProxyConnectionRefusedError, executed (the execution status of this line is deduced): q->setError(QAbstractSocket::ProxyConnectionRefusedError, | - |
621 | QSocks5SocketEngine::tr("Connection to proxy refused")); executed (the execution status of this line is deduced): QSocks5SocketEngine::tr("Connection to proxy refused")); | - |
622 | break; executed: break; Execution Count:1 | 1 |
623 | case QAbstractSocket::RemoteHostClosedError: | - |
624 | q->setError(QAbstractSocket::ProxyConnectionClosedError, never executed (the execution status of this line is deduced): q->setError(QAbstractSocket::ProxyConnectionClosedError, | - |
625 | QSocks5SocketEngine::tr("Connection to proxy closed prematurely")); never executed (the execution status of this line is deduced): QSocks5SocketEngine::tr("Connection to proxy closed prematurely")); | - |
626 | break; | 0 |
627 | case QAbstractSocket::HostNotFoundError: | - |
628 | q->setError(QAbstractSocket::ProxyNotFoundError, executed (the execution status of this line is deduced): q->setError(QAbstractSocket::ProxyNotFoundError, | - |
629 | QSocks5SocketEngine::tr("Proxy host not found")); executed (the execution status of this line is deduced): QSocks5SocketEngine::tr("Proxy host not found")); | - |
630 | break; executed: break; Execution Count:1 | 1 |
631 | case QAbstractSocket::SocketTimeoutError: | - |
632 | if (state == ConnectError) { partially evaluated: state == ConnectError no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
633 | q->setError(QAbstractSocket::ProxyConnectionTimeoutError, never executed (the execution status of this line is deduced): q->setError(QAbstractSocket::ProxyConnectionTimeoutError, | - |
634 | QSocks5SocketEngine::tr("Connection to proxy timed out")); never executed (the execution status of this line is deduced): QSocks5SocketEngine::tr("Connection to proxy timed out")); | - |
635 | break; | 0 |
636 | } | - |
637 | /* fall through */ | - |
638 | default: code before this statement executed: default: Execution Count:1 | 1 |
639 | q->setError(controlSocketError, data->controlSocket->errorString()); executed (the execution status of this line is deduced): q->setError(controlSocketError, data->controlSocket->errorString()); | - |
640 | break; executed: break; Execution Count:1 | 1 |
641 | } | - |
642 | } else { executed: } Execution Count:3 | 3 |
643 | q->setError(controlSocketError, data->controlSocket->errorString()); never executed (the execution status of this line is deduced): q->setError(controlSocketError, data->controlSocket->errorString()); | - |
644 | } | 0 |
645 | break; executed: break; Execution Count:3 | 3 |
646 | } | - |
647 | | - |
648 | case AuthenticatingError: | - |
649 | q->setError(QAbstractSocket::ProxyAuthenticationRequiredError, executed (the execution status of this line is deduced): q->setError(QAbstractSocket::ProxyAuthenticationRequiredError, | - |
650 | extraMessage.isEmpty() ? executed (the execution status of this line is deduced): extraMessage.isEmpty() ? | - |
651 | QSocks5SocketEngine::tr("Proxy authentication failed") : executed (the execution status of this line is deduced): QSocks5SocketEngine::tr("Proxy authentication failed") : | - |
652 | QSocks5SocketEngine::tr("Proxy authentication failed: %1").arg(extraMessage)); executed (the execution status of this line is deduced): QSocks5SocketEngine::tr("Proxy authentication failed: %1").arg(extraMessage)); | - |
653 | break; executed: break; Execution Count:2 | 2 |
654 | | - |
655 | case RequestError: | - |
656 | // error code set by caller (overload) | - |
657 | break; executed: break; Execution Count:24 | 24 |
658 | | - |
659 | case SocksError: | - |
660 | q->setError(QAbstractSocket::ProxyProtocolError, never executed (the execution status of this line is deduced): q->setError(QAbstractSocket::ProxyProtocolError, | - |
661 | QSocks5SocketEngine::tr("SOCKS version 5 protocol error")); never executed (the execution status of this line is deduced): QSocks5SocketEngine::tr("SOCKS version 5 protocol error")); | - |
662 | break; | 0 |
663 | | - |
664 | case HostNameLookupError: | - |
665 | q->setError(QAbstractSocket::HostNotFoundError, executed (the execution status of this line is deduced): q->setError(QAbstractSocket::HostNotFoundError, | - |
666 | QAbstractSocket::tr("Host not found")); executed (the execution status of this line is deduced): QAbstractSocket::tr("Host not found")); | - |
667 | break; executed: break; Execution Count:2 | 2 |
668 | } | - |
669 | | - |
670 | q->setState(QAbstractSocket::UnconnectedState); executed (the execution status of this line is deduced): q->setState(QAbstractSocket::UnconnectedState); | - |
671 | socks5State = state; executed (the execution status of this line is deduced): socks5State = state; | - |
672 | } executed: } Execution Count:31 | 31 |
673 | | - |
674 | void QSocks5SocketEnginePrivate::setErrorState(Socks5State state, Socks5Error socks5error) | - |
675 | { | - |
676 | Q_Q(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEngine * const q = q_func(); | - |
677 | switch (socks5error) { | - |
678 | case SocksFailure: | - |
679 | q->setError(QAbstractSocket::NetworkError, never executed (the execution status of this line is deduced): q->setError(QAbstractSocket::NetworkError, | - |
680 | QSocks5SocketEngine::tr("General SOCKSv5 server failure")); never executed (the execution status of this line is deduced): QSocks5SocketEngine::tr("General SOCKSv5 server failure")); | - |
681 | break; | 0 |
682 | case ConnectionNotAllowed: | - |
683 | q->setError(QAbstractSocket::SocketAccessError, never executed (the execution status of this line is deduced): q->setError(QAbstractSocket::SocketAccessError, | - |
684 | QSocks5SocketEngine::tr("Connection not allowed by SOCKSv5 server")); never executed (the execution status of this line is deduced): QSocks5SocketEngine::tr("Connection not allowed by SOCKSv5 server")); | - |
685 | break; | 0 |
686 | case NetworkUnreachable: | - |
687 | q->setError(QAbstractSocket::NetworkError, never executed (the execution status of this line is deduced): q->setError(QAbstractSocket::NetworkError, | - |
688 | QAbstractSocket::tr("Network unreachable")); never executed (the execution status of this line is deduced): QAbstractSocket::tr("Network unreachable")); | - |
689 | break; | 0 |
690 | case HostUnreachable: | - |
691 | q->setError(QAbstractSocket::HostNotFoundError, never executed (the execution status of this line is deduced): q->setError(QAbstractSocket::HostNotFoundError, | - |
692 | QAbstractSocket::tr("Host not found")); never executed (the execution status of this line is deduced): QAbstractSocket::tr("Host not found")); | - |
693 | break; | 0 |
694 | case ConnectionRefused: | - |
695 | q->setError(QAbstractSocket::ConnectionRefusedError, never executed (the execution status of this line is deduced): q->setError(QAbstractSocket::ConnectionRefusedError, | - |
696 | QAbstractSocket::tr("Connection refused")); never executed (the execution status of this line is deduced): QAbstractSocket::tr("Connection refused")); | - |
697 | break; | 0 |
698 | case TTLExpired: | - |
699 | q->setError(QAbstractSocket::NetworkError, never executed (the execution status of this line is deduced): q->setError(QAbstractSocket::NetworkError, | - |
700 | QSocks5SocketEngine::tr("TTL expired")); never executed (the execution status of this line is deduced): QSocks5SocketEngine::tr("TTL expired")); | - |
701 | break; | 0 |
702 | case CommandNotSupported: | - |
703 | q->setError(QAbstractSocket::UnsupportedSocketOperationError, never executed (the execution status of this line is deduced): q->setError(QAbstractSocket::UnsupportedSocketOperationError, | - |
704 | QSocks5SocketEngine::tr("SOCKSv5 command not supported")); never executed (the execution status of this line is deduced): QSocks5SocketEngine::tr("SOCKSv5 command not supported")); | - |
705 | break; | 0 |
706 | case AddressTypeNotSupported: | - |
707 | q->setError(QAbstractSocket::UnsupportedSocketOperationError, executed (the execution status of this line is deduced): q->setError(QAbstractSocket::UnsupportedSocketOperationError, | - |
708 | QSocks5SocketEngine::tr("Address type not supported")); executed (the execution status of this line is deduced): QSocks5SocketEngine::tr("Address type not supported")); | - |
709 | break; executed: break; Execution Count:24 | 24 |
710 | | - |
711 | default: | - |
712 | q->setError(QAbstractSocket::UnknownSocketError, never executed (the execution status of this line is deduced): q->setError(QAbstractSocket::UnknownSocketError, | - |
713 | QSocks5SocketEngine::tr("Unknown SOCKSv5 proxy error code 0x%1").arg(int(socks5error), 16)); never executed (the execution status of this line is deduced): QSocks5SocketEngine::tr("Unknown SOCKSv5 proxy error code 0x%1").arg(int(socks5error), 16)); | - |
714 | break; | 0 |
715 | } | - |
716 | | - |
717 | setErrorState(state, QString()); executed (the execution status of this line is deduced): setErrorState(state, QString()); | - |
718 | } executed: } Execution Count:24 | 24 |
719 | | - |
720 | void QSocks5SocketEnginePrivate::reauthenticate() | - |
721 | { | - |
722 | Q_Q(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEngine * const q = q_func(); | - |
723 | | - |
724 | // we require authentication | - |
725 | QAuthenticator auth; executed (the execution status of this line is deduced): QAuthenticator auth; | - |
726 | emit q->proxyAuthenticationRequired(proxyInfo, &auth); executed (the execution status of this line is deduced): q->proxyAuthenticationRequired(proxyInfo, &auth); | - |
727 | | - |
728 | if (!auth.user().isEmpty() || !auth.password().isEmpty()) { evaluated: !auth.user().isEmpty() yes Evaluation Count:21 | yes Evaluation Count:2 |
partially evaluated: !auth.password().isEmpty() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-21 |
729 | // we have new credentials, let's try again | - |
730 | QSOCKS5_DEBUG << "authentication failure: retrying connection"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 730, __PRETTY_FUNCTION__).debug() << "authentication failure: retrying connection"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:21 |
| 0-21 |
731 | socks5State = QSocks5SocketEnginePrivate::Uninitialized; executed (the execution status of this line is deduced): socks5State = QSocks5SocketEnginePrivate::Uninitialized; | - |
732 | | - |
733 | delete data->authenticator; executed (the execution status of this line is deduced): delete data->authenticator; | - |
734 | proxyInfo.setUser(auth.user()); executed (the execution status of this line is deduced): proxyInfo.setUser(auth.user()); | - |
735 | proxyInfo.setPassword(auth.password()); executed (the execution status of this line is deduced): proxyInfo.setPassword(auth.password()); | - |
736 | data->authenticator = new QSocks5PasswordAuthenticator(proxyInfo.user(), proxyInfo.password()); executed (the execution status of this line is deduced): data->authenticator = new QSocks5PasswordAuthenticator(proxyInfo.user(), proxyInfo.password()); | - |
737 | | - |
738 | data->controlSocket->blockSignals(true); executed (the execution status of this line is deduced): data->controlSocket->blockSignals(true); | - |
739 | data->controlSocket->abort(); executed (the execution status of this line is deduced): data->controlSocket->abort(); | - |
740 | data->controlSocket->blockSignals(false); executed (the execution status of this line is deduced): data->controlSocket->blockSignals(false); | - |
741 | data->controlSocket->connectToHost(proxyInfo.hostName(), proxyInfo.port()); executed (the execution status of this line is deduced): data->controlSocket->connectToHost(proxyInfo.hostName(), proxyInfo.port()); | - |
742 | } else { executed: } Execution Count:21 | 21 |
743 | // authentication failure | - |
744 | | - |
745 | setErrorState(AuthenticatingError); executed (the execution status of this line is deduced): setErrorState(AuthenticatingError); | - |
746 | data->controlSocket->close(); executed (the execution status of this line is deduced): data->controlSocket->close(); | - |
747 | emitConnectionNotification(); executed (the execution status of this line is deduced): emitConnectionNotification(); | - |
748 | } executed: } Execution Count:2 | 2 |
749 | } | - |
750 | | - |
751 | void QSocks5SocketEnginePrivate::parseAuthenticationMethodReply() | - |
752 | { | - |
753 | // not enough data to begin | - |
754 | if (data->controlSocket->bytesAvailable() < 2) partially evaluated: data->controlSocket->bytesAvailable() < 2 no Evaluation Count:0 | yes Evaluation Count:146 |
| 0-146 |
755 | return; | 0 |
756 | | - |
757 | QByteArray buf = data->controlSocket->read(2); executed (the execution status of this line is deduced): QByteArray buf = data->controlSocket->read(2); | - |
758 | if (buf.at(0) != S5_VERSION_5) { partially evaluated: buf.at(0) != 0x05 no Evaluation Count:0 | yes Evaluation Count:146 |
| 0-146 |
759 | QSOCKS5_D_DEBUG << "Socks5 version incorrect"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 759, __PRETTY_FUNCTION__).debug() << "Socks5 version incorrect"; never evaluated: 0 | 0 |
760 | setErrorState(SocksError); never executed (the execution status of this line is deduced): setErrorState(SocksError); | - |
761 | data->controlSocket->close(); never executed (the execution status of this line is deduced): data->controlSocket->close(); | - |
762 | emitConnectionNotification(); never executed (the execution status of this line is deduced): emitConnectionNotification(); | - |
763 | return; | 0 |
764 | } | - |
765 | | - |
766 | bool authComplete = false; executed (the execution status of this line is deduced): bool authComplete = false; | - |
767 | if (uchar(buf.at(1)) == S5_AUTHMETHOD_NONE) { evaluated: uchar(buf.at(1)) == 0x00 yes Evaluation Count:102 | yes Evaluation Count:44 |
| 44-102 |
768 | authComplete = true; executed (the execution status of this line is deduced): authComplete = true; | - |
769 | } else if (uchar(buf.at(1)) == S5_AUTHMETHOD_NOTACCEPTABLE) { executed: } Execution Count:102 evaluated: uchar(buf.at(1)) == 0xFF yes Evaluation Count:23 | yes Evaluation Count:21 |
| 21-102 |
770 | reauthenticate(); executed (the execution status of this line is deduced): reauthenticate(); | - |
771 | return; executed: return; Execution Count:23 | 23 |
772 | } else if (buf.at(1) != data->authenticator->methodId() partially evaluated: buf.at(1) != data->authenticator->methodId() no Evaluation Count:0 | yes Evaluation Count:21 |
| 0-21 |
773 | || !data->authenticator->beginAuthenticate(data->controlSocket, &authComplete)) { partially evaluated: !data->authenticator->beginAuthenticate(data->controlSocket, &authComplete) no Evaluation Count:0 | yes Evaluation Count:21 |
| 0-21 |
774 | setErrorState(AuthenticatingError, QLatin1String("Socks5 host did not support authentication method.")); never executed (the execution status of this line is deduced): setErrorState(AuthenticatingError, QLatin1String("Socks5 host did not support authentication method.")); | - |
775 | socketError = QAbstractSocket::SocketAccessError; // change the socket error never executed (the execution status of this line is deduced): socketError = QAbstractSocket::SocketAccessError; | - |
776 | emitConnectionNotification(); never executed (the execution status of this line is deduced): emitConnectionNotification(); | - |
777 | return; | 0 |
778 | } | - |
779 | | - |
780 | if (authComplete) evaluated: authComplete yes Evaluation Count:102 | yes Evaluation Count:21 |
| 21-102 |
781 | sendRequestMethod(); executed: sendRequestMethod(); Execution Count:102 | 102 |
782 | else | - |
783 | socks5State = Authenticating; executed: socks5State = Authenticating; Execution Count:21 | 21 |
784 | } | - |
785 | | - |
786 | void QSocks5SocketEnginePrivate::parseAuthenticatingReply() | - |
787 | { | - |
788 | bool authComplete = false; executed (the execution status of this line is deduced): bool authComplete = false; | - |
789 | if (!data->authenticator->continueAuthenticate(data->controlSocket, &authComplete)) { partially evaluated: !data->authenticator->continueAuthenticate(data->controlSocket, &authComplete) no Evaluation Count:0 | yes Evaluation Count:21 |
| 0-21 |
790 | reauthenticate(); never executed (the execution status of this line is deduced): reauthenticate(); | - |
791 | return; | 0 |
792 | } | - |
793 | if (authComplete) partially evaluated: authComplete yes Evaluation Count:21 | no Evaluation Count:0 |
| 0-21 |
794 | sendRequestMethod(); executed: sendRequestMethod(); Execution Count:21 | 21 |
795 | } executed: } Execution Count:21 | 21 |
796 | | - |
797 | void QSocks5SocketEnginePrivate::sendRequestMethod() | - |
798 | { | - |
799 | QHostAddress address; executed (the execution status of this line is deduced): QHostAddress address; | - |
800 | quint16 port = 0; executed (the execution status of this line is deduced): quint16 port = 0; | - |
801 | char command = 0; executed (the execution status of this line is deduced): char command = 0; | - |
802 | if (mode == ConnectMode) { evaluated: mode == ConnectMode yes Evaluation Count:46 | yes Evaluation Count:77 |
| 46-77 |
803 | command = S5_CONNECT; executed (the execution status of this line is deduced): command = 0x01; | - |
804 | address = peerAddress; executed (the execution status of this line is deduced): address = peerAddress; | - |
805 | port = peerPort; executed (the execution status of this line is deduced): port = peerPort; | - |
806 | } else if (mode == BindMode) { executed: } Execution Count:46 evaluated: mode == BindMode yes Evaluation Count:6 | yes Evaluation Count:71 |
| 6-71 |
807 | command = S5_BIND; executed (the execution status of this line is deduced): command = 0x02; | - |
808 | address = localAddress; executed (the execution status of this line is deduced): address = localAddress; | - |
809 | port = localPort; executed (the execution status of this line is deduced): port = localPort; | - |
810 | } else { executed: } Execution Count:6 | 6 |
811 | #ifndef QT_NO_UDPSOCKET | - |
812 | command = S5_UDP_ASSOCIATE; executed (the execution status of this line is deduced): command = 0x03; | - |
813 | address = localAddress; //data->controlSocket->localAddress(); executed (the execution status of this line is deduced): address = localAddress; | - |
814 | port = localPort; executed (the execution status of this line is deduced): port = localPort; | - |
815 | #endif | - |
816 | } executed: } Execution Count:71 | 71 |
817 | | - |
818 | QByteArray buf; executed (the execution status of this line is deduced): QByteArray buf; | - |
819 | buf.reserve(270); // big enough for domain name; executed (the execution status of this line is deduced): buf.reserve(270); | - |
820 | buf[0] = S5_VERSION_5; executed (the execution status of this line is deduced): buf[0] = 0x05; | - |
821 | buf[1] = command; executed (the execution status of this line is deduced): buf[1] = command; | - |
822 | buf[2] = 0x00; executed (the execution status of this line is deduced): buf[2] = 0x00; | - |
823 | if (peerName.isEmpty() && !qt_socks5_set_host_address_and_port(address, port, &buf)) { evaluated: peerName.isEmpty() yes Evaluation Count:78 | yes Evaluation Count:45 |
partially evaluated: !qt_socks5_set_host_address_and_port(address, port, &buf) no Evaluation Count:0 | yes Evaluation Count:78 |
| 0-78 |
824 | QSOCKS5_DEBUG << "error setting address" << address << " : " << port; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 824, __PRETTY_FUNCTION__).debug() << "error setting address" << address << " : " << port; never evaluated: 0 | 0 |
825 | //### set error code .... | - |
826 | return; | 0 |
827 | } else if (!peerName.isEmpty() && !qt_socks5_set_host_name_and_port(peerName, port, &buf)) { evaluated: !peerName.isEmpty() yes Evaluation Count:45 | yes Evaluation Count:78 |
partially evaluated: !qt_socks5_set_host_name_and_port(peerName, port, &buf) no Evaluation Count:0 | yes Evaluation Count:45 |
| 0-78 |
828 | QSOCKS5_DEBUG << "error setting peer name" << peerName << " : " << port; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 828, __PRETTY_FUNCTION__).debug() << "error setting peer name" << peerName << " : " << port; never evaluated: 0 | 0 |
829 | //### set error code .... | - |
830 | return; | 0 |
831 | } | - |
832 | QSOCKS5_DEBUG << "sending" << dump(buf); never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 832, __PRETTY_FUNCTION__).debug() << "sending" << dump(buf); partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:123 |
| 0-123 |
833 | QByteArray sealedBuf; executed (the execution status of this line is deduced): QByteArray sealedBuf; | - |
834 | if (!data->authenticator->seal(buf, &sealedBuf)) { partially evaluated: !data->authenticator->seal(buf, &sealedBuf) no Evaluation Count:0 | yes Evaluation Count:123 |
| 0-123 |
835 | // ### Handle this error. | - |
836 | } | 0 |
837 | data->controlSocket->write(sealedBuf); executed (the execution status of this line is deduced): data->controlSocket->write(sealedBuf); | - |
838 | data->controlSocket->flush(); executed (the execution status of this line is deduced): data->controlSocket->flush(); | - |
839 | socks5State = RequestMethodSent; executed (the execution status of this line is deduced): socks5State = RequestMethodSent; | - |
840 | } executed: } Execution Count:123 | 123 |
841 | | - |
842 | void QSocks5SocketEnginePrivate::parseRequestMethodReply() | - |
843 | { | - |
844 | Q_Q(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEngine * const q = q_func(); | - |
845 | QSOCKS5_DEBUG << "parseRequestMethodReply()"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 845, __PRETTY_FUNCTION__).debug() << "parseRequestMethodReply()"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:124 |
| 0-124 |
846 | | - |
847 | QByteArray inBuf; executed (the execution status of this line is deduced): QByteArray inBuf; | - |
848 | if (!data->authenticator->unSeal(data->controlSocket, &inBuf)) { partially evaluated: !data->authenticator->unSeal(data->controlSocket, &inBuf) no Evaluation Count:0 | yes Evaluation Count:124 |
| 0-124 |
849 | // ### check error and not just not enough data | - |
850 | QSOCKS5_DEBUG << "unSeal failed, needs more data"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 850, __PRETTY_FUNCTION__).debug() << "unSeal failed, needs more data"; never evaluated: 0 | 0 |
851 | return; | 0 |
852 | } | - |
853 | | - |
854 | inBuf.prepend(receivedHeaderFragment); executed (the execution status of this line is deduced): inBuf.prepend(receivedHeaderFragment); | - |
855 | receivedHeaderFragment.clear(); executed (the execution status of this line is deduced): receivedHeaderFragment.clear(); | - |
856 | QSOCKS5_DEBUG << dump(inBuf); never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 856, __PRETTY_FUNCTION__).debug() << dump(inBuf); partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:124 |
| 0-124 |
857 | if (inBuf.size() < 3) { partially evaluated: inBuf.size() < 3 no Evaluation Count:0 | yes Evaluation Count:124 |
| 0-124 |
858 | QSOCKS5_DEBUG << "need more data for request reply header .. put this data somewhere"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 858, __PRETTY_FUNCTION__).debug() << "need more data for request reply header .. put this data somewhere"; never evaluated: 0 | 0 |
859 | receivedHeaderFragment = inBuf; never executed (the execution status of this line is deduced): receivedHeaderFragment = inBuf; | - |
860 | return; | 0 |
861 | } | - |
862 | | - |
863 | QHostAddress address; executed (the execution status of this line is deduced): QHostAddress address; | - |
864 | quint16 port = 0; executed (the execution status of this line is deduced): quint16 port = 0; | - |
865 | | - |
866 | if (inBuf.at(0) != S5_VERSION_5 || inBuf.at(2) != 0x00) { partially evaluated: inBuf.at(0) != 0x05 no Evaluation Count:0 | yes Evaluation Count:124 |
partially evaluated: inBuf.at(2) != 0x00 no Evaluation Count:0 | yes Evaluation Count:124 |
| 0-124 |
867 | QSOCKS5_DEBUG << "socks protocol error"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 867, __PRETTY_FUNCTION__).debug() << "socks protocol error"; never evaluated: 0 | 0 |
868 | setErrorState(SocksError); never executed (the execution status of this line is deduced): setErrorState(SocksError); | - |
869 | } else if (inBuf.at(1) != S5_SUCCESS) { never executed: } evaluated: inBuf.at(1) != 0x00 yes Evaluation Count:26 | yes Evaluation Count:98 |
| 0-98 |
870 | Socks5Error socks5Error = Socks5Error(inBuf.at(1)); executed (the execution status of this line is deduced): Socks5Error socks5Error = Socks5Error(inBuf.at(1)); | - |
871 | QSOCKS5_DEBUG << "Request error :" << socks5Error; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 871, __PRETTY_FUNCTION__).debug() << "Request error :" << socks5Error; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-26 |
872 | if ((socks5Error == SocksFailure || socks5Error == ConnectionNotAllowed) partially evaluated: socks5Error == SocksFailure no Evaluation Count:0 | yes Evaluation Count:26 |
evaluated: socks5Error == ConnectionNotAllowed yes Evaluation Count:2 | yes Evaluation Count:24 |
| 0-26 |
873 | && !peerName.isEmpty()) { partially evaluated: !peerName.isEmpty() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
874 | // Dante seems to use this error code to indicate hostname resolution failure | - |
875 | setErrorState(HostNameLookupError); executed (the execution status of this line is deduced): setErrorState(HostNameLookupError); | - |
876 | } else { executed: } Execution Count:2 | 2 |
877 | setErrorState(RequestError, socks5Error); executed (the execution status of this line is deduced): setErrorState(RequestError, socks5Error); | - |
878 | } executed: } Execution Count:24 | 24 |
879 | } else { | - |
880 | // connection success, retrieve the remote addresses | - |
881 | int pos = 3; executed (the execution status of this line is deduced): int pos = 3; | - |
882 | int err = qt_socks5_get_host_address_and_port(inBuf, &address, &port, &pos); executed (the execution status of this line is deduced): int err = qt_socks5_get_host_address_and_port(inBuf, &address, &port, &pos); | - |
883 | if (err == -1) { partially evaluated: err == -1 no Evaluation Count:0 | yes Evaluation Count:98 |
| 0-98 |
884 | QSOCKS5_DEBUG << "error getting address"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 884, __PRETTY_FUNCTION__).debug() << "error getting address"; never evaluated: 0 | 0 |
885 | setErrorState(SocksError); never executed (the execution status of this line is deduced): setErrorState(SocksError); | - |
886 | } else if (err == 0) { never executed: } partially evaluated: err == 0 no Evaluation Count:0 | yes Evaluation Count:98 |
| 0-98 |
887 | //need more data | - |
888 | receivedHeaderFragment = inBuf; never executed (the execution status of this line is deduced): receivedHeaderFragment = inBuf; | - |
889 | return; | 0 |
890 | } else { | - |
891 | inBuf.remove(0, pos); executed (the execution status of this line is deduced): inBuf.remove(0, pos); | - |
892 | for (int i = inBuf.size() - 1; i >= 0 ; --i) partially evaluated: i >= 0 no Evaluation Count:0 | yes Evaluation Count:98 |
| 0-98 |
893 | data->controlSocket->ungetChar(inBuf.at(i)); never executed: data->controlSocket->ungetChar(inBuf.at(i)); | 0 |
894 | } executed: } Execution Count:98 | 98 |
895 | } | - |
896 | | - |
897 | if (socks5State == RequestMethodSent) { evaluated: socks5State == RequestMethodSent yes Evaluation Count:97 | yes Evaluation Count:27 |
| 27-97 |
898 | // no error | - |
899 | localAddress = address; executed (the execution status of this line is deduced): localAddress = address; | - |
900 | localPort = port; executed (the execution status of this line is deduced): localPort = port; | - |
901 | | - |
902 | if (mode == ConnectMode) { evaluated: mode == ConnectMode yes Evaluation Count:44 | yes Evaluation Count:53 |
| 44-53 |
903 | socks5State = Connected; executed (the execution status of this line is deduced): socks5State = Connected; | - |
904 | // notify the upper layer that we're done | - |
905 | q->setState(QAbstractSocket::ConnectedState); executed (the execution status of this line is deduced): q->setState(QAbstractSocket::ConnectedState); | - |
906 | emitConnectionNotification(); executed (the execution status of this line is deduced): emitConnectionNotification(); | - |
907 | } else if (mode == BindMode) { executed: } Execution Count:44 evaluated: mode == BindMode yes Evaluation Count:6 | yes Evaluation Count:47 |
| 6-47 |
908 | socks5State = BindSuccess; executed (the execution status of this line is deduced): socks5State = BindSuccess; | - |
909 | q->setState(QAbstractSocket::ListeningState); executed (the execution status of this line is deduced): q->setState(QAbstractSocket::ListeningState); | - |
910 | } else { executed: } Execution Count:6 | 6 |
911 | socks5State = UdpAssociateSuccess; executed (the execution status of this line is deduced): socks5State = UdpAssociateSuccess; | - |
912 | } executed: } Execution Count:47 | 47 |
913 | } else if (socks5State == BindSuccess) { evaluated: socks5State == BindSuccess yes Evaluation Count:1 | yes Evaluation Count:26 |
| 1-26 |
914 | // no error and we got a connection | - |
915 | bindData->peerAddress = address; executed (the execution status of this line is deduced): bindData->peerAddress = address; | - |
916 | bindData->peerPort = port; executed (the execution status of this line is deduced): bindData->peerPort = port; | - |
917 | | - |
918 | emitReadNotification(); executed (the execution status of this line is deduced): emitReadNotification(); | - |
919 | } else { executed: } Execution Count:1 | 1 |
920 | // got an error | - |
921 | data->controlSocket->close(); executed (the execution status of this line is deduced): data->controlSocket->close(); | - |
922 | emitConnectionNotification(); executed (the execution status of this line is deduced): emitConnectionNotification(); | - |
923 | } executed: } Execution Count:26 | 26 |
924 | } | - |
925 | | - |
926 | void QSocks5SocketEnginePrivate::_q_emitPendingReadNotification() | - |
927 | { | - |
928 | Q_Q(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEngine * const q = q_func(); | - |
929 | readNotificationPending = false; executed (the execution status of this line is deduced): readNotificationPending = false; | - |
930 | if (readNotificationEnabled) { partially evaluated: readNotificationEnabled yes Evaluation Count:141 | no Evaluation Count:0 |
| 0-141 |
931 | QSOCKS5_D_DEBUG << "emitting readNotification"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 931, __PRETTY_FUNCTION__).debug() << "emitting readNotification"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:141 |
| 0-141 |
932 | QPointer<QSocks5SocketEngine> qq = q; executed (the execution status of this line is deduced): QPointer<QSocks5SocketEngine> qq = q; | - |
933 | emit q->readNotification(); executed (the execution status of this line is deduced): q->readNotification(); | - |
934 | if (!qq) evaluated: !qq yes Evaluation Count:4 | yes Evaluation Count:137 |
| 4-137 |
935 | return; executed: return; Execution Count:4 | 4 |
936 | // check if there needs to be a new zero read notification | - |
937 | if (data && data->controlSocket->state() == QAbstractSocket::UnconnectedState partially evaluated: data yes Evaluation Count:137 | no Evaluation Count:0 |
partially evaluated: data->controlSocket->state() == QAbstractSocket::UnconnectedState no Evaluation Count:0 | yes Evaluation Count:137 |
| 0-137 |
938 | && data->controlSocket->error() == QAbstractSocket::RemoteHostClosedError) { never evaluated: data->controlSocket->error() == QAbstractSocket::RemoteHostClosedError | 0 |
939 | connectData->readBuffer.clear(); never executed (the execution status of this line is deduced): connectData->readBuffer.clear(); | - |
940 | emitReadNotification(); never executed (the execution status of this line is deduced): emitReadNotification(); | - |
941 | } | 0 |
942 | } executed: } Execution Count:137 | 137 |
943 | } executed: } Execution Count:137 | 137 |
944 | | - |
945 | void QSocks5SocketEnginePrivate::emitReadNotification() | - |
946 | { | - |
947 | Q_Q(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEngine * const q = q_func(); | - |
948 | readNotificationActivated = true; executed (the execution status of this line is deduced): readNotificationActivated = true; | - |
949 | if (readNotificationEnabled && !readNotificationPending) { evaluated: readNotificationEnabled yes Evaluation Count:12643 | yes Evaluation Count:6 |
evaluated: !readNotificationPending yes Evaluation Count:167 | yes Evaluation Count:12476 |
| 6-12643 |
950 | QSOCKS5_D_DEBUG << "queueing readNotification"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 950, __PRETTY_FUNCTION__).debug() << "queueing readNotification"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:167 |
| 0-167 |
951 | readNotificationPending = true; executed (the execution status of this line is deduced): readNotificationPending = true; | - |
952 | QMetaObject::invokeMethod(q, "_q_emitPendingReadNotification", Qt::QueuedConnection); executed (the execution status of this line is deduced): QMetaObject::invokeMethod(q, "_q_emitPendingReadNotification", Qt::QueuedConnection); | - |
953 | } executed: } Execution Count:167 | 167 |
954 | } executed: } Execution Count:12649 | 12649 |
955 | | - |
956 | void QSocks5SocketEnginePrivate::_q_emitPendingWriteNotification() | - |
957 | { | - |
958 | writeNotificationPending = false; executed (the execution status of this line is deduced): writeNotificationPending = false; | - |
959 | Q_Q(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEngine * const q = q_func(); | - |
960 | if (writeNotificationEnabled) { evaluated: writeNotificationEnabled yes Evaluation Count:132 | yes Evaluation Count:73 |
| 73-132 |
961 | QSOCKS5_D_DEBUG << "emitting writeNotification"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 961, __PRETTY_FUNCTION__).debug() << "emitting writeNotification"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:132 |
| 0-132 |
962 | emit q->writeNotification(); executed (the execution status of this line is deduced): q->writeNotification(); | - |
963 | } executed: } Execution Count:132 | 132 |
964 | } executed: } Execution Count:205 | 205 |
965 | | - |
966 | void QSocks5SocketEnginePrivate::emitWriteNotification() | - |
967 | { | - |
968 | Q_Q(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEngine * const q = q_func(); | - |
969 | writeNotificationActivated = true; executed (the execution status of this line is deduced): writeNotificationActivated = true; | - |
970 | if (writeNotificationEnabled && !writeNotificationPending) { partially evaluated: writeNotificationEnabled yes Evaluation Count:284 | no Evaluation Count:0 |
evaluated: !writeNotificationPending yes Evaluation Count:208 | yes Evaluation Count:76 |
| 0-284 |
971 | QSOCKS5_D_DEBUG << "queueing writeNotification"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 971, __PRETTY_FUNCTION__).debug() << "queueing writeNotification"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:208 |
| 0-208 |
972 | writeNotificationPending = true; executed (the execution status of this line is deduced): writeNotificationPending = true; | - |
973 | QMetaObject::invokeMethod(q, "_q_emitPendingWriteNotification", Qt::QueuedConnection); executed (the execution status of this line is deduced): QMetaObject::invokeMethod(q, "_q_emitPendingWriteNotification", Qt::QueuedConnection); | - |
974 | } executed: } Execution Count:208 | 208 |
975 | } executed: } Execution Count:284 | 284 |
976 | | - |
977 | void QSocks5SocketEnginePrivate::_q_emitPendingConnectionNotification() | - |
978 | { | - |
979 | connectionNotificationPending = false; executed (the execution status of this line is deduced): connectionNotificationPending = false; | - |
980 | Q_Q(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEngine * const q = q_func(); | - |
981 | QSOCKS5_D_DEBUG << "emitting connectionNotification"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 981, __PRETTY_FUNCTION__).debug() << "emitting connectionNotification"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:48 |
| 0-48 |
982 | emit q->connectionNotification(); executed (the execution status of this line is deduced): q->connectionNotification(); | - |
983 | } executed: } Execution Count:48 | 48 |
984 | | - |
985 | void QSocks5SocketEnginePrivate::emitConnectionNotification() | - |
986 | { | - |
987 | Q_Q(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEngine * const q = q_func(); | - |
988 | QSOCKS5_D_DEBUG << "queueing connectionNotification"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 988, __PRETTY_FUNCTION__).debug() << "queueing connectionNotification"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:74 |
| 0-74 |
989 | connectionNotificationPending = true; executed (the execution status of this line is deduced): connectionNotificationPending = true; | - |
990 | QMetaObject::invokeMethod(q, "_q_emitPendingConnectionNotification", Qt::QueuedConnection); executed (the execution status of this line is deduced): QMetaObject::invokeMethod(q, "_q_emitPendingConnectionNotification", Qt::QueuedConnection); | - |
991 | } executed: } Execution Count:74 | 74 |
992 | | - |
993 | QSocks5SocketEngine::QSocks5SocketEngine(QObject *parent) | - |
994 | :QAbstractSocketEngine(*new QSocks5SocketEnginePrivate(), parent) | - |
995 | { | - |
996 | } executed: } Execution Count:129 | 129 |
997 | | - |
998 | QSocks5SocketEngine::~QSocks5SocketEngine() | - |
999 | { | - |
1000 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1001 | | - |
1002 | if (d->data) { evaluated: d->data yes Evaluation Count:128 | yes Evaluation Count:1 |
| 1-128 |
1003 | delete d->data->authenticator; executed (the execution status of this line is deduced): delete d->data->authenticator; | - |
1004 | delete d->data->controlSocket; executed (the execution status of this line is deduced): delete d->data->controlSocket; | - |
1005 | } executed: } Execution Count:128 | 128 |
1006 | if (d->connectData) evaluated: d->connectData yes Evaluation Count:50 | yes Evaluation Count:79 |
| 50-79 |
1007 | delete d->connectData; executed: delete d->connectData; Execution Count:50 | 50 |
1008 | #ifndef QT_NO_UDPSOCKET | - |
1009 | if (d->udpData) { evaluated: d->udpData yes Evaluation Count:71 | yes Evaluation Count:58 |
| 58-71 |
1010 | delete d->udpData->udpSocket; executed (the execution status of this line is deduced): delete d->udpData->udpSocket; | - |
1011 | delete d->udpData; executed (the execution status of this line is deduced): delete d->udpData; | - |
1012 | } executed: } Execution Count:71 | 71 |
1013 | #endif | - |
1014 | if (d->bindData) evaluated: d->bindData yes Evaluation Count:7 | yes Evaluation Count:122 |
| 7-122 |
1015 | delete d->bindData; executed: delete d->bindData; Execution Count:7 | 7 |
1016 | } executed: } Execution Count:129 | 129 |
1017 | | - |
1018 | static QBasicAtomicInt descriptorCounter = Q_BASIC_ATOMIC_INITIALIZER(1); | - |
1019 | | - |
1020 | bool QSocks5SocketEngine::initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol) | - |
1021 | { | - |
1022 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1023 | | - |
1024 | d->socketDescriptor = descriptorCounter.fetchAndAddRelaxed(1); executed (the execution status of this line is deduced): d->socketDescriptor = descriptorCounter.fetchAndAddRelaxed(1); | - |
1025 | | - |
1026 | d->socketType = type; executed (the execution status of this line is deduced): d->socketType = type; | - |
1027 | d->socketProtocol = protocol; executed (the execution status of this line is deduced): d->socketProtocol = protocol; | - |
1028 | | - |
1029 | return true; executed: return true; Execution Count:128 | 128 |
1030 | } | - |
1031 | | - |
1032 | bool QSocks5SocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState) | - |
1033 | { | - |
1034 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1035 | | - |
1036 | QSOCKS5_Q_DEBUG << "initialize" << socketDescriptor; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1036, __PRETTY_FUNCTION__).debug() << "initialize" << socketDescriptor; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1037 | | - |
1038 | // this is only valid for the other side of a bind, nothing else is supported | - |
1039 | | - |
1040 | if (socketState != QAbstractSocket::ConnectedState) { partially evaluated: socketState != QAbstractSocket::ConnectedState no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1041 | //### must be connected state ??? | - |
1042 | return false; never executed: return false; | 0 |
1043 | } | - |
1044 | | - |
1045 | QSocks5BindData *bindData = socks5BindStore()->retrieve(socketDescriptor); executed (the execution status of this line is deduced): QSocks5BindData *bindData = socks5BindStore()->retrieve(socketDescriptor); | - |
1046 | if (bindData) { partially evaluated: bindData yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1047 | | - |
1048 | d->socketState = QAbstractSocket::ConnectedState; executed (the execution status of this line is deduced): d->socketState = QAbstractSocket::ConnectedState; | - |
1049 | d->socketType = QAbstractSocket::TcpSocket; executed (the execution status of this line is deduced): d->socketType = QAbstractSocket::TcpSocket; | - |
1050 | d->connectData = new QSocks5ConnectData; executed (the execution status of this line is deduced): d->connectData = new QSocks5ConnectData; | - |
1051 | d->data = d->connectData; executed (the execution status of this line is deduced): d->data = d->connectData; | - |
1052 | d->mode = QSocks5SocketEnginePrivate::ConnectMode; executed (the execution status of this line is deduced): d->mode = QSocks5SocketEnginePrivate::ConnectMode; | - |
1053 | d->data->controlSocket = bindData->controlSocket; executed (the execution status of this line is deduced): d->data->controlSocket = bindData->controlSocket; | - |
1054 | bindData->controlSocket = 0; executed (the execution status of this line is deduced): bindData->controlSocket = 0; | - |
1055 | d->data->controlSocket->setParent(this); executed (the execution status of this line is deduced): d->data->controlSocket->setParent(this); | - |
1056 | d->socketProtocol = d->data->controlSocket->localAddress().protocol(); executed (the execution status of this line is deduced): d->socketProtocol = d->data->controlSocket->localAddress().protocol(); | - |
1057 | d->data->authenticator = bindData->authenticator; executed (the execution status of this line is deduced): d->data->authenticator = bindData->authenticator; | - |
1058 | bindData->authenticator = 0; executed (the execution status of this line is deduced): bindData->authenticator = 0; | - |
1059 | d->localPort = bindData->localPort; executed (the execution status of this line is deduced): d->localPort = bindData->localPort; | - |
1060 | d->localAddress = bindData->localAddress; executed (the execution status of this line is deduced): d->localAddress = bindData->localAddress; | - |
1061 | d->peerPort = bindData->peerPort; executed (the execution status of this line is deduced): d->peerPort = bindData->peerPort; | - |
1062 | d->peerAddress = bindData->peerAddress; executed (the execution status of this line is deduced): d->peerAddress = bindData->peerAddress; | - |
1063 | delete bindData; executed (the execution status of this line is deduced): delete bindData; | - |
1064 | | - |
1065 | QObject::connect(d->data->controlSocket, SIGNAL(connected()), this, SLOT(_q_controlSocketConnected()), executed (the execution status of this line is deduced): QObject::connect(d->data->controlSocket, "2""connected()", this, "1""_q_controlSocketConnected()", | - |
1066 | Qt::DirectConnection); executed (the execution status of this line is deduced): Qt::DirectConnection); | - |
1067 | QObject::connect(d->data->controlSocket, SIGNAL(readyRead()), this, SLOT(_q_controlSocketReadNotification()), executed (the execution status of this line is deduced): QObject::connect(d->data->controlSocket, "2""readyRead()", this, "1""_q_controlSocketReadNotification()", | - |
1068 | Qt::DirectConnection); executed (the execution status of this line is deduced): Qt::DirectConnection); | - |
1069 | QObject::connect(d->data->controlSocket, SIGNAL(bytesWritten(qint64)), this, SLOT(_q_controlSocketBytesWritten()), executed (the execution status of this line is deduced): QObject::connect(d->data->controlSocket, "2""bytesWritten(qint64)", this, "1""_q_controlSocketBytesWritten()", | - |
1070 | Qt::DirectConnection); executed (the execution status of this line is deduced): Qt::DirectConnection); | - |
1071 | QObject::connect(d->data->controlSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(_q_controlSocketError(QAbstractSocket::SocketError)), executed (the execution status of this line is deduced): QObject::connect(d->data->controlSocket, "2""error(QAbstractSocket::SocketError)", this, "1""_q_controlSocketError(QAbstractSocket::SocketError)", | - |
1072 | Qt::DirectConnection); executed (the execution status of this line is deduced): Qt::DirectConnection); | - |
1073 | QObject::connect(d->data->controlSocket, SIGNAL(disconnected()), this, SLOT(_q_controlSocketDisconnected()), executed (the execution status of this line is deduced): QObject::connect(d->data->controlSocket, "2""disconnected()", this, "1""_q_controlSocketDisconnected()", | - |
1074 | Qt::DirectConnection); executed (the execution status of this line is deduced): Qt::DirectConnection); | - |
1075 | QObject::connect(d->data->controlSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), executed (the execution status of this line is deduced): QObject::connect(d->data->controlSocket, "2""stateChanged(QAbstractSocket::SocketState)", | - |
1076 | this, SLOT(_q_controlSocketStateChanged(QAbstractSocket::SocketState)), executed (the execution status of this line is deduced): this, "1""_q_controlSocketStateChanged(QAbstractSocket::SocketState)", | - |
1077 | Qt::DirectConnection); executed (the execution status of this line is deduced): Qt::DirectConnection); | - |
1078 | | - |
1079 | d->socks5State = QSocks5SocketEnginePrivate::Connected; executed (the execution status of this line is deduced): d->socks5State = QSocks5SocketEnginePrivate::Connected; | - |
1080 | | - |
1081 | if (d->data->controlSocket->bytesAvailable() != 0) partially evaluated: d->data->controlSocket->bytesAvailable() != 0 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1082 | d->_q_controlSocketReadNotification(); never executed: d->_q_controlSocketReadNotification(); | 0 |
1083 | return true; executed: return true; Execution Count:1 | 1 |
1084 | } | - |
1085 | return false; never executed: return false; | 0 |
1086 | } | - |
1087 | | - |
1088 | void QSocks5SocketEngine::setProxy(const QNetworkProxy &networkProxy) | - |
1089 | { | - |
1090 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1091 | d->proxyInfo = networkProxy; executed (the execution status of this line is deduced): d->proxyInfo = networkProxy; | - |
1092 | } executed: } Execution Count:128 | 128 |
1093 | | - |
1094 | qintptr QSocks5SocketEngine::socketDescriptor() const | - |
1095 | { | - |
1096 | Q_D(const QSocks5SocketEngine); executed (the execution status of this line is deduced): const QSocks5SocketEnginePrivate * const d = d_func(); | - |
1097 | return d->socketDescriptor; executed: return d->socketDescriptor; Execution Count:215 | 215 |
1098 | } | - |
1099 | | - |
1100 | bool QSocks5SocketEngine::isValid() const | - |
1101 | { | - |
1102 | Q_D(const QSocks5SocketEngine); executed (the execution status of this line is deduced): const QSocks5SocketEnginePrivate * const d = d_func(); | - |
1103 | return d->socketType != QAbstractSocket::UnknownSocketType executed: return d->socketType != QAbstractSocket::UnknownSocketType && d->socks5State != QSocks5SocketEnginePrivate::SocksError && (d->socketError == QAbstractSocket::UnknownSocketError || d->socketError == QAbstractSocket::SocketTimeoutError || d->socketError == QAbstractSocket::UnfinishedSocketOperationError); Execution Count:646223 | 646223 |
1104 | && d->socks5State != QSocks5SocketEnginePrivate::SocksError executed: return d->socketType != QAbstractSocket::UnknownSocketType && d->socks5State != QSocks5SocketEnginePrivate::SocksError && (d->socketError == QAbstractSocket::UnknownSocketError || d->socketError == QAbstractSocket::SocketTimeoutError || d->socketError == QAbstractSocket::UnfinishedSocketOperationError); Execution Count:646223 | 646223 |
1105 | && (d->socketError == QAbstractSocket::UnknownSocketError executed: return d->socketType != QAbstractSocket::UnknownSocketType && d->socks5State != QSocks5SocketEnginePrivate::SocksError && (d->socketError == QAbstractSocket::UnknownSocketError || d->socketError == QAbstractSocket::SocketTimeoutError || d->socketError == QAbstractSocket::UnfinishedSocketOperationError); Execution Count:646223 | 646223 |
1106 | || d->socketError == QAbstractSocket::SocketTimeoutError executed: return d->socketType != QAbstractSocket::UnknownSocketType && d->socks5State != QSocks5SocketEnginePrivate::SocksError && (d->socketError == QAbstractSocket::UnknownSocketError || d->socketError == QAbstractSocket::SocketTimeoutError || d->socketError == QAbstractSocket::UnfinishedSocketOperationError); Execution Count:646223 | 646223 |
1107 | || d->socketError == QAbstractSocket::UnfinishedSocketOperationError); executed: return d->socketType != QAbstractSocket::UnknownSocketType && d->socks5State != QSocks5SocketEnginePrivate::SocksError && (d->socketError == QAbstractSocket::UnknownSocketError || d->socketError == QAbstractSocket::SocketTimeoutError || d->socketError == QAbstractSocket::UnfinishedSocketOperationError); Execution Count:646223 | 646223 |
1108 | } | - |
1109 | | - |
1110 | bool QSocks5SocketEngine::connectInternal() | - |
1111 | { | - |
1112 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1113 | | - |
1114 | if (!d->data) { partially evaluated: !d->data yes Evaluation Count:51 | no Evaluation Count:0 |
| 0-51 |
1115 | if (socketType() == QAbstractSocket::TcpSocket) { evaluated: socketType() == QAbstractSocket::TcpSocket yes Evaluation Count:49 | yes Evaluation Count:2 |
| 2-49 |
1116 | d->initialize(QSocks5SocketEnginePrivate::ConnectMode); executed (the execution status of this line is deduced): d->initialize(QSocks5SocketEnginePrivate::ConnectMode); | - |
1117 | #ifndef QT_NO_UDPSOCKET | - |
1118 | } else if (socketType() == QAbstractSocket::UdpSocket) { executed: } Execution Count:49 partially evaluated: socketType() == QAbstractSocket::UdpSocket yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-49 |
1119 | d->initialize(QSocks5SocketEnginePrivate::UdpAssociateMode); executed (the execution status of this line is deduced): d->initialize(QSocks5SocketEnginePrivate::UdpAssociateMode); | - |
1120 | // all udp needs to be bound | - |
1121 | if (!bind(QHostAddress(QLatin1String("0.0.0.0")), 0)) partially evaluated: !bind(QHostAddress(QLatin1String("0.0.0.0")), 0) no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1122 | return false; never executed: return false; | 0 |
1123 | | - |
1124 | setState(QAbstractSocket::ConnectedState); executed (the execution status of this line is deduced): setState(QAbstractSocket::ConnectedState); | - |
1125 | return true; executed: return true; Execution Count:2 | 2 |
1126 | #endif | - |
1127 | } else { | - |
1128 | qFatal("QSocks5SocketEngine::connectToHost: in QTcpServer mode"); never executed (the execution status of this line is deduced): QMessageLogger("socket/qsocks5socketengine.cpp", 1128, __PRETTY_FUNCTION__).fatal("QSocks5SocketEngine::connectToHost: in QTcpServer mode"); | - |
1129 | return false; never executed: return false; | 0 |
1130 | } | - |
1131 | } | - |
1132 | | - |
1133 | if (d->socks5State == QSocks5SocketEnginePrivate::Uninitialized partially evaluated: d->socks5State == QSocks5SocketEnginePrivate::Uninitialized yes Evaluation Count:49 | no Evaluation Count:0 |
| 0-49 |
1134 | && d->socketState != QAbstractSocket::ConnectingState) { partially evaluated: d->socketState != QAbstractSocket::ConnectingState yes Evaluation Count:49 | no Evaluation Count:0 |
| 0-49 |
1135 | setState(QAbstractSocket::ConnectingState); executed (the execution status of this line is deduced): setState(QAbstractSocket::ConnectingState); | - |
1136 | //limit buffer in internal socket, data is buffered in the external socket under application control | - |
1137 | d->data->controlSocket->setReadBufferSize(65536); executed (the execution status of this line is deduced): d->data->controlSocket->setReadBufferSize(65536); | - |
1138 | d->data->controlSocket->connectToHost(d->proxyInfo.hostName(), d->proxyInfo.port()); executed (the execution status of this line is deduced): d->data->controlSocket->connectToHost(d->proxyInfo.hostName(), d->proxyInfo.port()); | - |
1139 | return false; executed: return false; Execution Count:49 | 49 |
1140 | } | - |
1141 | return false; never executed: return false; | 0 |
1142 | } | - |
1143 | | - |
1144 | bool QSocks5SocketEngine::connectToHost(const QHostAddress &address, quint16 port) | - |
1145 | { | - |
1146 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1147 | QSOCKS5_DEBUG << "connectToHost" << address << ':' << port; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1147, __PRETTY_FUNCTION__).debug() << "connectToHost" << address << ':' << port; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
1148 | | - |
1149 | setPeerAddress(address); executed (the execution status of this line is deduced): setPeerAddress(address); | - |
1150 | setPeerPort(port); executed (the execution status of this line is deduced): setPeerPort(port); | - |
1151 | d->peerName.clear(); executed (the execution status of this line is deduced): d->peerName.clear(); | - |
1152 | | - |
1153 | return connectInternal(); executed: return connectInternal(); Execution Count:3 | 3 |
1154 | } | - |
1155 | | - |
1156 | bool QSocks5SocketEngine::connectToHostByName(const QString &hostname, quint16 port) | - |
1157 | { | - |
1158 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1159 | | - |
1160 | setPeerAddress(QHostAddress()); executed (the execution status of this line is deduced): setPeerAddress(QHostAddress()); | - |
1161 | setPeerPort(port); executed (the execution status of this line is deduced): setPeerPort(port); | - |
1162 | d->peerName = hostname; executed (the execution status of this line is deduced): d->peerName = hostname; | - |
1163 | | - |
1164 | return connectInternal(); executed: return connectInternal(); Execution Count:48 | 48 |
1165 | } | - |
1166 | | - |
1167 | void QSocks5SocketEnginePrivate::_q_controlSocketConnected() | - |
1168 | { | - |
1169 | QSOCKS5_DEBUG << "_q_controlSocketConnected"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1169, __PRETTY_FUNCTION__).debug() << "_q_controlSocketConnected"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:147 |
| 0-147 |
1170 | QByteArray buf(3, 0); executed (the execution status of this line is deduced): QByteArray buf(3, 0); | - |
1171 | buf[0] = S5_VERSION_5; executed (the execution status of this line is deduced): buf[0] = 0x05; | - |
1172 | buf[1] = 0x01; executed (the execution status of this line is deduced): buf[1] = 0x01; | - |
1173 | buf[2] = data->authenticator->methodId(); executed (the execution status of this line is deduced): buf[2] = data->authenticator->methodId(); | - |
1174 | data->controlSocket->write(buf); executed (the execution status of this line is deduced): data->controlSocket->write(buf); | - |
1175 | socks5State = AuthenticationMethodsSent; executed (the execution status of this line is deduced): socks5State = AuthenticationMethodsSent; | - |
1176 | } executed: } Execution Count:147 | 147 |
1177 | | - |
1178 | void QSocks5SocketEnginePrivate::_q_controlSocketReadNotification() | - |
1179 | { | - |
1180 | QSOCKS5_D_DEBUG << "_q_controlSocketReadNotification socks5state" << s5StateToString(socks5State) never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1180, __PRETTY_FUNCTION__).debug() << "_q_controlSocketReadNotification socks5state" << s5StateToString(socks5State) << "bytes available" << data->controlSocket->bytesAvailable(); partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:414 |
| 0-414 |
1181 | << "bytes available" << data->controlSocket->bytesAvailable(); never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1180, __PRETTY_FUNCTION__).debug() << "_q_controlSocketReadNotification socks5state" << s5StateToString(socks5State) << "bytes available" << data->controlSocket->bytesAvailable(); | 0 |
1182 | | - |
1183 | if (data->controlSocket->bytesAvailable() == 0) { partially evaluated: data->controlSocket->bytesAvailable() == 0 no Evaluation Count:0 | yes Evaluation Count:414 |
| 0-414 |
1184 | QSOCKS5_D_DEBUG << "########## bogus read why do we get these ... on windows only"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1184, __PRETTY_FUNCTION__).debug() << "########## bogus read why do we get these ... on windows only"; never evaluated: 0 | 0 |
1185 | return; | 0 |
1186 | } | - |
1187 | | - |
1188 | switch (socks5State) { | - |
1189 | case AuthenticationMethodsSent: | - |
1190 | parseAuthenticationMethodReply(); executed (the execution status of this line is deduced): parseAuthenticationMethodReply(); | - |
1191 | break; executed: break; Execution Count:146 | 146 |
1192 | case Authenticating: | - |
1193 | parseAuthenticatingReply(); executed (the execution status of this line is deduced): parseAuthenticatingReply(); | - |
1194 | break; executed: break; Execution Count:21 | 21 |
1195 | case RequestMethodSent: | - |
1196 | parseRequestMethodReply(); executed (the execution status of this line is deduced): parseRequestMethodReply(); | - |
1197 | break; executed: break; Execution Count:123 | 123 |
1198 | case Connected: { | - |
1199 | QByteArray buf; executed (the execution status of this line is deduced): QByteArray buf; | - |
1200 | if (!data->authenticator->unSeal(data->controlSocket, &buf)) { partially evaluated: !data->authenticator->unSeal(data->controlSocket, &buf) no Evaluation Count:0 | yes Evaluation Count:123 |
| 0-123 |
1201 | // qDebug() << "unseal error maybe need to wait for more data"; | - |
1202 | } | 0 |
1203 | if (buf.size()) { partially evaluated: buf.size() yes Evaluation Count:123 | no Evaluation Count:0 |
| 0-123 |
1204 | QSOCKS5_DEBUG << dump(buf); never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1204, __PRETTY_FUNCTION__).debug() << dump(buf); partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:123 |
| 0-123 |
1205 | connectData->readBuffer += buf; executed (the execution status of this line is deduced): connectData->readBuffer += buf; | - |
1206 | emitReadNotification(); executed (the execution status of this line is deduced): emitReadNotification(); | - |
1207 | } executed: } Execution Count:123 | 123 |
1208 | break; executed: break; Execution Count:123 | 123 |
1209 | } | - |
1210 | case BindSuccess: | - |
1211 | // only get here if command is bind | - |
1212 | if (mode == BindMode) { partially evaluated: mode == BindMode yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1213 | parseRequestMethodReply(); executed (the execution status of this line is deduced): parseRequestMethodReply(); | - |
1214 | break; executed: break; Execution Count:1 | 1 |
1215 | } | - |
1216 | | - |
1217 | // fall through | - |
1218 | default: code before this statement never executed: default: | 0 |
1219 | qWarning("QSocks5SocketEnginePrivate::_q_controlSocketReadNotification: " never executed (the execution status of this line is deduced): QMessageLogger("socket/qsocks5socketengine.cpp", 1219, __PRETTY_FUNCTION__).warning("QSocks5SocketEnginePrivate::_q_controlSocketReadNotification: " | - |
1220 | "Unexpectedly received data while in state=%d and mode=%d", never executed (the execution status of this line is deduced): "Unexpectedly received data while in state=%d and mode=%d", | - |
1221 | socks5State, mode); never executed (the execution status of this line is deduced): socks5State, mode); | - |
1222 | break; | 0 |
1223 | }; | - |
1224 | } executed: } Execution Count:414 | 414 |
1225 | | - |
1226 | void QSocks5SocketEnginePrivate::_q_controlSocketBytesWritten() | - |
1227 | { | - |
1228 | QSOCKS5_DEBUG << "_q_controlSocketBytesWritten"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1228, __PRETTY_FUNCTION__).debug() << "_q_controlSocketBytesWritten"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:474 |
| 0-474 |
1229 | | - |
1230 | if (socks5State != Connected evaluated: socks5State != Connected yes Evaluation Count:291 | yes Evaluation Count:183 |
| 183-291 |
1231 | || (mode == ConnectMode partially evaluated: mode == ConnectMode yes Evaluation Count:183 | no Evaluation Count:0 |
| 0-183 |
1232 | && data->controlSocket->bytesToWrite())) evaluated: data->controlSocket->bytesToWrite() yes Evaluation Count:52 | yes Evaluation Count:131 |
| 52-131 |
1233 | return; executed: return; Execution Count:343 | 343 |
1234 | if (data->controlSocket->bytesToWrite() < MaxWriteBufferSize) { partially evaluated: data->controlSocket->bytesToWrite() < MaxWriteBufferSize yes Evaluation Count:131 | no Evaluation Count:0 |
| 0-131 |
1235 | emitWriteNotification(); executed (the execution status of this line is deduced): emitWriteNotification(); | - |
1236 | writeNotificationActivated = false; executed (the execution status of this line is deduced): writeNotificationActivated = false; | - |
1237 | } executed: } Execution Count:131 | 131 |
1238 | } executed: } Execution Count:131 | 131 |
1239 | | - |
1240 | void QSocks5SocketEnginePrivate::_q_controlSocketError(QAbstractSocket::SocketError error) | - |
1241 | { | - |
1242 | QSOCKS5_D_DEBUG << "controlSocketError" << error << data->controlSocket->errorString(); never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1242, __PRETTY_FUNCTION__).debug() << "controlSocketError" << error << data->controlSocket->errorString(); partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:22 |
| 0-22 |
1243 | | - |
1244 | if (error == QAbstractSocket::SocketTimeoutError) evaluated: error == QAbstractSocket::SocketTimeoutError yes Evaluation Count:20 | yes Evaluation Count:2 |
| 2-20 |
1245 | return; // ignore this error -- comes from the waitFor* functions executed: return; Execution Count:20 | 20 |
1246 | | - |
1247 | if (error == QAbstractSocket::RemoteHostClosedError partially evaluated: error == QAbstractSocket::RemoteHostClosedError no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1248 | && socks5State == Connected) { never evaluated: socks5State == Connected | 0 |
1249 | // clear the read buffer in connect mode so that bytes available returns 0 | - |
1250 | // if there already is a read notification pending then this will be processed first | - |
1251 | if (!readNotificationPending) never evaluated: !readNotificationPending | 0 |
1252 | connectData->readBuffer.clear(); never executed: connectData->readBuffer.clear(); | 0 |
1253 | emitReadNotification(); never executed (the execution status of this line is deduced): emitReadNotification(); | - |
1254 | data->controlSocket->close(); never executed (the execution status of this line is deduced): data->controlSocket->close(); | - |
1255 | // cause a disconnect in the outer socket | - |
1256 | emitWriteNotification(); never executed (the execution status of this line is deduced): emitWriteNotification(); | - |
1257 | } else if (socks5State == Uninitialized never executed: } partially evaluated: socks5State == Uninitialized yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1258 | || socks5State == AuthenticationMethodsSent never evaluated: socks5State == AuthenticationMethodsSent | 0 |
1259 | || socks5State == Authenticating never evaluated: socks5State == Authenticating | 0 |
1260 | || socks5State == RequestMethodSent) { never evaluated: socks5State == RequestMethodSent | 0 |
1261 | setErrorState(socks5State == Uninitialized ? ConnectError : ControlSocketError); executed (the execution status of this line is deduced): setErrorState(socks5State == Uninitialized ? ConnectError : ControlSocketError); | - |
1262 | data->controlSocket->close(); executed (the execution status of this line is deduced): data->controlSocket->close(); | - |
1263 | emitConnectionNotification(); executed (the execution status of this line is deduced): emitConnectionNotification(); | - |
1264 | } else { executed: } Execution Count:2 | 2 |
1265 | q_func()->setError(data->controlSocket->error(), data->controlSocket->errorString()); never executed (the execution status of this line is deduced): q_func()->setError(data->controlSocket->error(), data->controlSocket->errorString()); | - |
1266 | emitReadNotification(); never executed (the execution status of this line is deduced): emitReadNotification(); | - |
1267 | emitWriteNotification(); never executed (the execution status of this line is deduced): emitWriteNotification(); | - |
1268 | } | 0 |
1269 | } | - |
1270 | | - |
1271 | void QSocks5SocketEnginePrivate::_q_controlSocketDisconnected() | - |
1272 | { | - |
1273 | QSOCKS5_D_DEBUG << "_q_controlSocketDisconnected"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1273, __PRETTY_FUNCTION__).debug() << "_q_controlSocketDisconnected"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:126 |
| 0-126 |
1274 | } executed: } Execution Count:126 | 126 |
1275 | | - |
1276 | void QSocks5SocketEnginePrivate::_q_controlSocketStateChanged(QAbstractSocket::SocketState state) | - |
1277 | { | - |
1278 | QSOCKS5_D_DEBUG << "_q_controlSocketStateChanged" << state; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1278, __PRETTY_FUNCTION__).debug() << "_q_controlSocketStateChanged" << state; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:698 |
| 0-698 |
1279 | } executed: } Execution Count:698 | 698 |
1280 | | - |
1281 | #ifndef QT_NO_UDPSOCKET | - |
1282 | void QSocks5SocketEnginePrivate::checkForDatagrams() const | - |
1283 | { | - |
1284 | // udp should be unbuffered so we need to do some polling at certain points | - |
1285 | if (udpData->udpSocket->hasPendingDatagrams()) evaluated: udpData->udpSocket->hasPendingDatagrams() yes Evaluation Count:12448 | yes Evaluation Count:633334 |
| 12448-633334 |
1286 | const_cast<QSocks5SocketEnginePrivate *>(this)->_q_udpSocketReadNotification(); executed: const_cast<QSocks5SocketEnginePrivate *>(this)->_q_udpSocketReadNotification(); Execution Count:12448 | 12448 |
1287 | } executed: } Execution Count:645782 | 645782 |
1288 | | - |
1289 | void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification() | - |
1290 | { | - |
1291 | QSOCKS5_D_DEBUG << "_q_udpSocketReadNotification()"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1291, __PRETTY_FUNCTION__).debug() << "_q_udpSocketReadNotification()"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:12503 |
| 0-12503 |
1292 | | - |
1293 | // check some state stuff | - |
1294 | if (!udpData->udpSocket->hasPendingDatagrams()) { partially evaluated: !udpData->udpSocket->hasPendingDatagrams() no Evaluation Count:0 | yes Evaluation Count:12503 |
| 0-12503 |
1295 | QSOCKS5_D_DEBUG << "false read ??"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1295, __PRETTY_FUNCTION__).debug() << "false read ??"; never evaluated: 0 | 0 |
1296 | return; | 0 |
1297 | } | - |
1298 | | - |
1299 | while (udpData->udpSocket->hasPendingDatagrams()) { evaluated: udpData->udpSocket->hasPendingDatagrams() yes Evaluation Count:20631 | yes Evaluation Count:12503 |
| 12503-20631 |
1300 | QByteArray sealedBuf(udpData->udpSocket->pendingDatagramSize(), 0); executed (the execution status of this line is deduced): QByteArray sealedBuf(udpData->udpSocket->pendingDatagramSize(), 0); | - |
1301 | QSOCKS5_D_DEBUG << "new datagram"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1301, __PRETTY_FUNCTION__).debug() << "new datagram"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:20631 |
| 0-20631 |
1302 | udpData->udpSocket->readDatagram(sealedBuf.data(), sealedBuf.size()); executed (the execution status of this line is deduced): udpData->udpSocket->readDatagram(sealedBuf.data(), sealedBuf.size()); | - |
1303 | QByteArray inBuf; executed (the execution status of this line is deduced): QByteArray inBuf; | - |
1304 | if (!data->authenticator->unSeal(sealedBuf, &inBuf)) { partially evaluated: !data->authenticator->unSeal(sealedBuf, &inBuf) no Evaluation Count:0 | yes Evaluation Count:20631 |
| 0-20631 |
1305 | QSOCKS5_D_DEBUG << "failed unsealing datagram discarding"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1305, __PRETTY_FUNCTION__).debug() << "failed unsealing datagram discarding"; never evaluated: 0 | 0 |
1306 | return; | 0 |
1307 | } | - |
1308 | QSOCKS5_DEBUG << dump(inBuf); never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1308, __PRETTY_FUNCTION__).debug() << dump(inBuf); partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:20631 |
| 0-20631 |
1309 | int pos = 0; executed (the execution status of this line is deduced): int pos = 0; | - |
1310 | const char *buf = inBuf.constData(); executed (the execution status of this line is deduced): const char *buf = inBuf.constData(); | - |
1311 | if (inBuf.size() < 4) { partially evaluated: inBuf.size() < 4 no Evaluation Count:0 | yes Evaluation Count:20631 |
| 0-20631 |
1312 | QSOCKS5_D_DEBUG << "bugus udp data, discarding"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1312, __PRETTY_FUNCTION__).debug() << "bugus udp data, discarding"; never evaluated: 0 | 0 |
1313 | return; | 0 |
1314 | } | - |
1315 | QSocks5RevivedDatagram datagram; executed (the execution status of this line is deduced): QSocks5RevivedDatagram datagram; | - |
1316 | if (buf[pos++] != 0 || buf[pos++] != 0) { partially evaluated: buf[pos++] != 0 no Evaluation Count:0 | yes Evaluation Count:20631 |
partially evaluated: buf[pos++] != 0 no Evaluation Count:0 | yes Evaluation Count:20631 |
| 0-20631 |
1317 | QSOCKS5_D_DEBUG << "invalid datagram discarding"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1317, __PRETTY_FUNCTION__).debug() << "invalid datagram discarding"; never evaluated: 0 | 0 |
1318 | return; | 0 |
1319 | } | - |
1320 | if (buf[pos++] != 0) { //### add fragmentation reading support partially evaluated: buf[pos++] != 0 no Evaluation Count:0 | yes Evaluation Count:20631 |
| 0-20631 |
1321 | QSOCKS5_D_DEBUG << "don't support fragmentation yet disgarding"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1321, __PRETTY_FUNCTION__).debug() << "don't support fragmentation yet disgarding"; never evaluated: 0 | 0 |
1322 | return; | 0 |
1323 | } | - |
1324 | if (qt_socks5_get_host_address_and_port(inBuf, &datagram.address, &datagram.port, &pos) != 1) { partially evaluated: qt_socks5_get_host_address_and_port(inBuf, &datagram.address, &datagram.port, &pos) != 1 no Evaluation Count:0 | yes Evaluation Count:20631 |
| 0-20631 |
1325 | QSOCKS5_D_DEBUG << "failed to get address from datagram disgarding"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1325, __PRETTY_FUNCTION__).debug() << "failed to get address from datagram disgarding"; never evaluated: 0 | 0 |
1326 | return; | 0 |
1327 | } | - |
1328 | datagram.data = QByteArray(&buf[pos], inBuf.size() - pos); executed (the execution status of this line is deduced): datagram.data = QByteArray(&buf[pos], inBuf.size() - pos); | - |
1329 | udpData->pendingDatagrams.enqueue(datagram); executed (the execution status of this line is deduced): udpData->pendingDatagrams.enqueue(datagram); | - |
1330 | } executed: } Execution Count:20631 | 20631 |
1331 | emitReadNotification(); executed (the execution status of this line is deduced): emitReadNotification(); | - |
1332 | } executed: } Execution Count:12503 | 12503 |
1333 | #endif // QT_NO_UDPSOCKET | - |
1334 | | - |
1335 | bool QSocks5SocketEngine::bind(const QHostAddress &addr, quint16 port) | - |
1336 | { | - |
1337 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1338 | | - |
1339 | // when bind wee will block until the bind is finished as the info from the proxy server is needed | - |
1340 | | - |
1341 | QHostAddress address; executed (the execution status of this line is deduced): QHostAddress address; | - |
1342 | if (addr.protocol() == QAbstractSocket::AnyIPProtocol) evaluated: addr.protocol() == QAbstractSocket::AnyIPProtocol yes Evaluation Count:53 | yes Evaluation Count:26 |
| 26-53 |
1343 | address = QHostAddress::AnyIPv4; //SOCKS5 doesn't support dual stack, and there isn't any implementation of udp on ipv6 yet executed: address = QHostAddress::AnyIPv4; Execution Count:53 | 53 |
1344 | else | - |
1345 | address = addr; executed: address = addr; Execution Count:26 | 26 |
1346 | | - |
1347 | if (!d->data) { evaluated: !d->data yes Evaluation Count:77 | yes Evaluation Count:2 |
| 2-77 |
1348 | if (socketType() == QAbstractSocket::TcpSocket) { evaluated: socketType() == QAbstractSocket::TcpSocket yes Evaluation Count:8 | yes Evaluation Count:69 |
| 8-69 |
1349 | d->initialize(QSocks5SocketEnginePrivate::BindMode); executed (the execution status of this line is deduced): d->initialize(QSocks5SocketEnginePrivate::BindMode); | - |
1350 | #ifndef QT_NO_UDPSOCKET | - |
1351 | } else if (socketType() == QAbstractSocket::UdpSocket) { executed: } Execution Count:8 partially evaluated: socketType() == QAbstractSocket::UdpSocket yes Evaluation Count:69 | no Evaluation Count:0 |
| 0-69 |
1352 | d->initialize(QSocks5SocketEnginePrivate::UdpAssociateMode); executed (the execution status of this line is deduced): d->initialize(QSocks5SocketEnginePrivate::UdpAssociateMode); | - |
1353 | #endif | - |
1354 | } else { executed: } Execution Count:69 | 69 |
1355 | //### something invalid | - |
1356 | return false; never executed: return false; | 0 |
1357 | } | - |
1358 | } | - |
1359 | | - |
1360 | #ifndef QT_NO_UDPSOCKET | - |
1361 | if (d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode) { evaluated: d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode yes Evaluation Count:71 | yes Evaluation Count:8 |
| 8-71 |
1362 | if (!d->udpData->udpSocket->bind(address, port)) { partially evaluated: !d->udpData->udpSocket->bind(address, port) no Evaluation Count:0 | yes Evaluation Count:71 |
| 0-71 |
1363 | QSOCKS5_Q_DEBUG << "local udp bind failed"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1363, __PRETTY_FUNCTION__).debug() << "local udp bind failed"; never evaluated: 0 | 0 |
1364 | setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); never executed (the execution status of this line is deduced): setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); | - |
1365 | return false; never executed: return false; | 0 |
1366 | } | - |
1367 | d->localAddress = d->udpData->udpSocket->localAddress(); executed (the execution status of this line is deduced): d->localAddress = d->udpData->udpSocket->localAddress(); | - |
1368 | d->localPort = d->udpData->udpSocket->localPort(); executed (the execution status of this line is deduced): d->localPort = d->udpData->udpSocket->localPort(); | - |
1369 | } else executed: } Execution Count:71 | 71 |
1370 | #endif | - |
1371 | if (d->mode == QSocks5SocketEnginePrivate::BindMode) { partially evaluated: d->mode == QSocks5SocketEnginePrivate::BindMode yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
1372 | d->localAddress = address; executed (the execution status of this line is deduced): d->localAddress = address; | - |
1373 | d->localPort = port; executed (the execution status of this line is deduced): d->localPort = port; | - |
1374 | } else { executed: } Execution Count:8 | 8 |
1375 | //### something invalid | - |
1376 | return false; never executed: return false; | 0 |
1377 | } | - |
1378 | | - |
1379 | int msecs = SOCKS5_BLOCKING_BIND_TIMEOUT; executed (the execution status of this line is deduced): int msecs = 5000; | - |
1380 | QElapsedTimer stopWatch; executed (the execution status of this line is deduced): QElapsedTimer stopWatch; | - |
1381 | stopWatch.start(); executed (the execution status of this line is deduced): stopWatch.start(); | - |
1382 | d->data->controlSocket->connectToHost(d->proxyInfo.hostName(), d->proxyInfo.port()); executed (the execution status of this line is deduced): d->data->controlSocket->connectToHost(d->proxyInfo.hostName(), d->proxyInfo.port()); | - |
1383 | if (!d->waitForConnected(msecs, 0) || evaluated: !d->waitForConnected(msecs, 0) yes Evaluation Count:1 | yes Evaluation Count:78 |
| 1-78 |
1384 | d->data->controlSocket->state() == QAbstractSocket::UnconnectedState) { evaluated: d->data->controlSocket->state() == QAbstractSocket::UnconnectedState yes Evaluation Count:25 | yes Evaluation Count:53 |
| 25-53 |
1385 | // waitForConnected sets the error state and closes the socket | - |
1386 | QSOCKS5_Q_DEBUG << "waitForConnected to proxy server" << d->data->controlSocket->errorString(); never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1386, __PRETTY_FUNCTION__).debug() << "waitForConnected to proxy server" << d->data->controlSocket->errorString(); partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-26 |
1387 | return false; executed: return false; Execution Count:26 | 26 |
1388 | } | - |
1389 | if (d->socks5State == QSocks5SocketEnginePrivate::BindSuccess) { evaluated: d->socks5State == QSocks5SocketEnginePrivate::BindSuccess yes Evaluation Count:6 | yes Evaluation Count:47 |
| 6-47 |
1390 | setState(QAbstractSocket::BoundState); executed (the execution status of this line is deduced): setState(QAbstractSocket::BoundState); | - |
1391 | return true; executed: return true; Execution Count:6 | 6 |
1392 | #ifndef QT_NO_UDPSOCKET | - |
1393 | } else if (d->socks5State == QSocks5SocketEnginePrivate::UdpAssociateSuccess) { partially evaluated: d->socks5State == QSocks5SocketEnginePrivate::UdpAssociateSuccess yes Evaluation Count:47 | no Evaluation Count:0 |
| 0-47 |
1394 | setState(QAbstractSocket::BoundState); executed (the execution status of this line is deduced): setState(QAbstractSocket::BoundState); | - |
1395 | d->udpData->associateAddress = d->localAddress; executed (the execution status of this line is deduced): d->udpData->associateAddress = d->localAddress; | - |
1396 | d->localAddress = QHostAddress(); executed (the execution status of this line is deduced): d->localAddress = QHostAddress(); | - |
1397 | d->udpData->associatePort = d->localPort; executed (the execution status of this line is deduced): d->udpData->associatePort = d->localPort; | - |
1398 | d->localPort = 0; executed (the execution status of this line is deduced): d->localPort = 0; | - |
1399 | QUdpSocket dummy; executed (the execution status of this line is deduced): QUdpSocket dummy; | - |
1400 | #ifndef QT_NO_BEARERMANAGEMENT | - |
1401 | dummy.setProperty("_q_networksession", property("_q_networksession")); executed (the execution status of this line is deduced): dummy.setProperty("_q_networksession", property("_q_networksession")); | - |
1402 | #endif | - |
1403 | dummy.setProxy(QNetworkProxy::NoProxy); executed (the execution status of this line is deduced): dummy.setProxy(QNetworkProxy::NoProxy); | - |
1404 | if (!dummy.bind() partially evaluated: !dummy.bind() no Evaluation Count:0 | yes Evaluation Count:47 |
| 0-47 |
1405 | || writeDatagram(0,0, d->data->controlSocket->localAddress(), dummy.localPort()) != 0 partially evaluated: writeDatagram(0,0, d->data->controlSocket->localAddress(), dummy.localPort()) != 0 no Evaluation Count:0 | yes Evaluation Count:47 |
| 0-47 |
1406 | || !dummy.waitForReadyRead(qt_timeout_value(msecs, stopWatch.elapsed())) partially evaluated: !dummy.waitForReadyRead(qt_timeout_value(msecs, stopWatch.elapsed())) no Evaluation Count:0 | yes Evaluation Count:47 |
| 0-47 |
1407 | || dummy.readDatagram(0,0, &d->localAddress, &d->localPort) != 0) { partially evaluated: dummy.readDatagram(0,0, &d->localAddress, &d->localPort) != 0 no Evaluation Count:0 | yes Evaluation Count:47 |
| 0-47 |
1408 | QSOCKS5_DEBUG << "udp actual address and port lookup failed"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1408, __PRETTY_FUNCTION__).debug() << "udp actual address and port lookup failed"; never evaluated: 0 | 0 |
1409 | setState(QAbstractSocket::UnconnectedState); never executed (the execution status of this line is deduced): setState(QAbstractSocket::UnconnectedState); | - |
1410 | setError(dummy.error(), dummy.errorString()); never executed (the execution status of this line is deduced): setError(dummy.error(), dummy.errorString()); | - |
1411 | d->data->controlSocket->close(); never executed (the execution status of this line is deduced): d->data->controlSocket->close(); | - |
1412 | //### reset and error | - |
1413 | return false; never executed: return false; | 0 |
1414 | } | - |
1415 | QSOCKS5_DEBUG << "udp actual address and port" << d->localAddress << ':' << d->localPort; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1415, __PRETTY_FUNCTION__).debug() << "udp actual address and port" << d->localAddress << ':' << d->localPort; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:47 |
| 0-47 |
1416 | return true; executed: return true; Execution Count:47 | 47 |
1417 | #endif // QT_NO_UDPSOCKET | - |
1418 | } | - |
1419 | | - |
1420 | // binding timed out | - |
1421 | setError(QAbstractSocket::SocketTimeoutError, never executed (the execution status of this line is deduced): setError(QAbstractSocket::SocketTimeoutError, | - |
1422 | QLatin1String(QT_TRANSLATE_NOOP("QSocks5SocketEngine", "Network operation timed out"))); never executed (the execution status of this line is deduced): QLatin1String("Network operation timed out")); | - |
1423 | | - |
1424 | ///### delete d->udpSocket; | - |
1425 | ///### d->udpSocket = 0; | - |
1426 | return false; never executed: return false; | 0 |
1427 | } | - |
1428 | | - |
1429 | | - |
1430 | bool QSocks5SocketEngine::listen() | - |
1431 | { | - |
1432 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1433 | | - |
1434 | QSOCKS5_Q_DEBUG << "listen()"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1434, __PRETTY_FUNCTION__).debug() << "listen()"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
1435 | | - |
1436 | // check that we are in bound and then go to listening. | - |
1437 | if (d->socketState == QAbstractSocket::BoundState) { partially evaluated: d->socketState == QAbstractSocket::BoundState yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
1438 | d->socketState = QAbstractSocket::ListeningState; executed (the execution status of this line is deduced): d->socketState = QAbstractSocket::ListeningState; | - |
1439 | | - |
1440 | // check if we already have a connection | - |
1441 | if (d->socks5State == QSocks5SocketEnginePrivate::BindSuccess) partially evaluated: d->socks5State == QSocks5SocketEnginePrivate::BindSuccess yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
1442 | d->emitReadNotification(); executed: d->emitReadNotification(); Execution Count:6 | 6 |
1443 | | - |
1444 | return true; executed: return true; Execution Count:6 | 6 |
1445 | } | - |
1446 | return false; never executed: return false; | 0 |
1447 | } | - |
1448 | | - |
1449 | int QSocks5SocketEngine::accept() | - |
1450 | { | - |
1451 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1452 | // check we are listing --- | - |
1453 | | - |
1454 | QSOCKS5_Q_DEBUG << "accept()"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1454, __PRETTY_FUNCTION__).debug() << "accept()"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1455 | | - |
1456 | qintptr sd = -1; executed (the execution status of this line is deduced): qintptr sd = -1; | - |
1457 | switch (d->socks5State) { | - |
1458 | case QSocks5SocketEnginePrivate::BindSuccess: | - |
1459 | QSOCKS5_Q_DEBUG << "BindSuccess adding" << d->socketDescriptor << "to the bind store"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1459, __PRETTY_FUNCTION__).debug() << "BindSuccess adding" << d->socketDescriptor << "to the bind store"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1460 | d->data->controlSocket->disconnect(); executed (the execution status of this line is deduced): d->data->controlSocket->disconnect(); | - |
1461 | d->data->controlSocket->setParent(0); executed (the execution status of this line is deduced): d->data->controlSocket->setParent(0); | - |
1462 | d->bindData->localAddress = d->localAddress; executed (the execution status of this line is deduced): d->bindData->localAddress = d->localAddress; | - |
1463 | d->bindData->localPort = d->localPort; executed (the execution status of this line is deduced): d->bindData->localPort = d->localPort; | - |
1464 | sd = d->socketDescriptor; executed (the execution status of this line is deduced): sd = d->socketDescriptor; | - |
1465 | socks5BindStore()->add(sd, d->bindData); executed (the execution status of this line is deduced): socks5BindStore()->add(sd, d->bindData); | - |
1466 | d->data = 0; executed (the execution status of this line is deduced): d->data = 0; | - |
1467 | d->bindData = 0; executed (the execution status of this line is deduced): d->bindData = 0; | - |
1468 | d->socketDescriptor = 0; executed (the execution status of this line is deduced): d->socketDescriptor = 0; | - |
1469 | //### do something about this socket layer ... set it closed and an error about why ... | - |
1470 | // reset state and local port/address | - |
1471 | d->socks5State = QSocks5SocketEnginePrivate::Uninitialized; // ..?? executed (the execution status of this line is deduced): d->socks5State = QSocks5SocketEnginePrivate::Uninitialized; | - |
1472 | d->socketState = QAbstractSocket::UnconnectedState; executed (the execution status of this line is deduced): d->socketState = QAbstractSocket::UnconnectedState; | - |
1473 | break; executed: break; Execution Count:1 | 1 |
1474 | case QSocks5SocketEnginePrivate::ControlSocketError: | - |
1475 | setError(QAbstractSocket::ProxyProtocolError, QLatin1String("Control socket error")); never executed (the execution status of this line is deduced): setError(QAbstractSocket::ProxyProtocolError, QLatin1String("Control socket error")); | - |
1476 | break; | 0 |
1477 | default: | - |
1478 | setError(QAbstractSocket::ProxyProtocolError, QLatin1String("SOCKS5 proxy error")); never executed (the execution status of this line is deduced): setError(QAbstractSocket::ProxyProtocolError, QLatin1String("SOCKS5 proxy error")); | - |
1479 | break; | 0 |
1480 | } | - |
1481 | return sd; executed: return sd; Execution Count:1 | 1 |
1482 | } | - |
1483 | | - |
1484 | void QSocks5SocketEngine::close() | - |
1485 | { | - |
1486 | QSOCKS5_Q_DEBUG << "close()"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1486, __PRETTY_FUNCTION__).debug() << "close()"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:102 |
| 0-102 |
1487 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1488 | if (d->data && d->data->controlSocket) { evaluated: d->data yes Evaluation Count:101 | yes Evaluation Count:1 |
partially evaluated: d->data->controlSocket yes Evaluation Count:101 | no Evaluation Count:0 |
| 0-101 |
1489 | if (d->data->controlSocket->state() == QAbstractSocket::ConnectedState) { evaluated: d->data->controlSocket->state() == QAbstractSocket::ConnectedState yes Evaluation Count:98 | yes Evaluation Count:3 |
| 3-98 |
1490 | int msecs = 100; executed (the execution status of this line is deduced): int msecs = 100; | - |
1491 | QElapsedTimer stopWatch; executed (the execution status of this line is deduced): QElapsedTimer stopWatch; | - |
1492 | stopWatch.start(); executed (the execution status of this line is deduced): stopWatch.start(); | - |
1493 | while (!d->data->controlSocket->bytesToWrite()) { partially evaluated: !d->data->controlSocket->bytesToWrite() yes Evaluation Count:98 | no Evaluation Count:0 |
| 0-98 |
1494 | if (!d->data->controlSocket->waitForBytesWritten(qt_timeout_value(msecs, stopWatch.elapsed()))) partially evaluated: !d->data->controlSocket->waitForBytesWritten(qt_timeout_value(msecs, stopWatch.elapsed())) yes Evaluation Count:98 | no Evaluation Count:0 |
| 0-98 |
1495 | break; executed: break; Execution Count:98 | 98 |
1496 | } | 0 |
1497 | } executed: } Execution Count:98 | 98 |
1498 | d->data->controlSocket->close(); executed (the execution status of this line is deduced): d->data->controlSocket->close(); | - |
1499 | } executed: } Execution Count:101 | 101 |
1500 | #ifndef QT_NO_UDPSOCKET | - |
1501 | if (d->udpData && d->udpData->udpSocket) evaluated: d->udpData yes Evaluation Count:47 | yes Evaluation Count:55 |
partially evaluated: d->udpData->udpSocket yes Evaluation Count:47 | no Evaluation Count:0 |
| 0-55 |
1502 | d->udpData->udpSocket->close(); executed: d->udpData->udpSocket->close(); Execution Count:47 | 47 |
1503 | #endif | - |
1504 | } executed: } Execution Count:102 | 102 |
1505 | | - |
1506 | qint64 QSocks5SocketEngine::bytesAvailable() const | - |
1507 | { | - |
1508 | Q_D(const QSocks5SocketEngine); never executed (the execution status of this line is deduced): const QSocks5SocketEnginePrivate * const d = d_func(); | - |
1509 | if (d->mode == QSocks5SocketEnginePrivate::ConnectMode) partially evaluated: d->mode == QSocks5SocketEnginePrivate::ConnectMode yes Evaluation Count:123 | no Evaluation Count:0 |
| 0-123 |
1510 | return d->connectData->readBuffer.size(); executed: return d->connectData->readBuffer.size(); Execution Count:123 | 123 |
1511 | #ifndef QT_NO_UDPSOCKET | - |
1512 | else if (d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode never evaluated: d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode | 0 |
1513 | && !d->udpData->pendingDatagrams.isEmpty()) never evaluated: !d->udpData->pendingDatagrams.isEmpty() | 0 |
1514 | return d->udpData->pendingDatagrams.first().data.size(); never executed: return d->udpData->pendingDatagrams.first().data.size(); | 0 |
1515 | #endif | - |
1516 | return 0; never executed: return 0; | 0 |
1517 | } | - |
1518 | | - |
1519 | qint64 QSocks5SocketEngine::read(char *data, qint64 maxlen) | - |
1520 | { | - |
1521 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1522 | QSOCKS5_Q_DEBUG << "read( , maxlen = " << maxlen << ')'; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1522, __PRETTY_FUNCTION__).debug() << "read( , maxlen = " << maxlen << ')'; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:162 |
| 0-162 |
1523 | if (d->mode == QSocks5SocketEnginePrivate::ConnectMode) { evaluated: d->mode == QSocks5SocketEnginePrivate::ConnectMode yes Evaluation Count:152 | yes Evaluation Count:10 |
| 10-152 |
1524 | if (d->connectData->readBuffer.size() == 0) { evaluated: d->connectData->readBuffer.size() == 0 yes Evaluation Count:29 | yes Evaluation Count:123 |
| 29-123 |
1525 | if (d->data->controlSocket->state() == QAbstractSocket::UnconnectedState) { partially evaluated: d->data->controlSocket->state() == QAbstractSocket::UnconnectedState no Evaluation Count:0 | yes Evaluation Count:29 |
| 0-29 |
1526 | //imitate remote closed | - |
1527 | close(); never executed (the execution status of this line is deduced): close(); | - |
1528 | setError(QAbstractSocket::RemoteHostClosedError, never executed (the execution status of this line is deduced): setError(QAbstractSocket::RemoteHostClosedError, | - |
1529 | QLatin1String("Remote host closed connection###")); never executed (the execution status of this line is deduced): QLatin1String("Remote host closed connection###")); | - |
1530 | setState(QAbstractSocket::UnconnectedState); never executed (the execution status of this line is deduced): setState(QAbstractSocket::UnconnectedState); | - |
1531 | return -1; never executed: return -1; | 0 |
1532 | } else { | - |
1533 | return 0; // nothing to be read executed: return 0; Execution Count:29 | 29 |
1534 | } | - |
1535 | } | - |
1536 | qint64 copy = qMin<qint64>(d->connectData->readBuffer.size(), maxlen); executed (the execution status of this line is deduced): qint64 copy = qMin<qint64>(d->connectData->readBuffer.size(), maxlen); | - |
1537 | memcpy(data, d->connectData->readBuffer.constData(), copy); executed (the execution status of this line is deduced): memcpy(data, d->connectData->readBuffer.constData(), copy); | - |
1538 | d->connectData->readBuffer.remove(0, copy); executed (the execution status of this line is deduced): d->connectData->readBuffer.remove(0, copy); | - |
1539 | QSOCKS5_DEBUG << "read" << dump(QByteArray(data, copy)); never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1539, __PRETTY_FUNCTION__).debug() << "read" << dump(QByteArray(data, copy)); partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:123 |
| 0-123 |
1540 | return copy; executed: return copy; Execution Count:123 | 123 |
1541 | #ifndef QT_NO_UDPSOCKET | - |
1542 | } else if (d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode) { partially evaluated: d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode yes Evaluation Count:10 | no Evaluation Count:0 |
| 0-10 |
1543 | return readDatagram(data, maxlen); executed: return readDatagram(data, maxlen); Execution Count:10 | 10 |
1544 | #endif | - |
1545 | } | - |
1546 | return 0; never executed: return 0; | 0 |
1547 | } | - |
1548 | | - |
1549 | qint64 QSocks5SocketEngine::write(const char *data, qint64 len) | - |
1550 | { | - |
1551 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1552 | QSOCKS5_Q_DEBUG << "write" << dump(QByteArray(data, len)); never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1552, __PRETTY_FUNCTION__).debug() << "write" << dump(QByteArray(data, len)); partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:313341 |
| 0-313341 |
1553 | | - |
1554 | if (d->mode == QSocks5SocketEnginePrivate::ConnectMode) { evaluated: d->mode == QSocks5SocketEnginePrivate::ConnectMode yes Evaluation Count:131 | yes Evaluation Count:313210 |
| 131-313210 |
1555 | // clamp down the amount of bytes to transfer at once | - |
1556 | len = qMin<qint64>(len, MaxWriteBufferSize) - d->data->controlSocket->bytesToWrite(); executed (the execution status of this line is deduced): len = qMin<qint64>(len, MaxWriteBufferSize) - d->data->controlSocket->bytesToWrite(); | - |
1557 | if (len <= 0) partially evaluated: len <= 0 no Evaluation Count:0 | yes Evaluation Count:131 |
| 0-131 |
1558 | return 0; never executed: return 0; | 0 |
1559 | | - |
1560 | QByteArray buf = QByteArray::fromRawData(data, len); executed (the execution status of this line is deduced): QByteArray buf = QByteArray::fromRawData(data, len); | - |
1561 | QByteArray sealedBuf; executed (the execution status of this line is deduced): QByteArray sealedBuf; | - |
1562 | if (!d->data->authenticator->seal(buf, &sealedBuf)) { partially evaluated: !d->data->authenticator->seal(buf, &sealedBuf) no Evaluation Count:0 | yes Evaluation Count:131 |
| 0-131 |
1563 | // ### Handle this error. | - |
1564 | } | 0 |
1565 | | - |
1566 | qint64 written = d->data->controlSocket->write(sealedBuf); executed (the execution status of this line is deduced): qint64 written = d->data->controlSocket->write(sealedBuf); | - |
1567 | if (written <= 0) { partially evaluated: written <= 0 no Evaluation Count:0 | yes Evaluation Count:131 |
| 0-131 |
1568 | QSOCKS5_Q_DEBUG << "native write returned" << written; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1568, __PRETTY_FUNCTION__).debug() << "native write returned" << written; never evaluated: 0 | 0 |
1569 | return written; never executed: return written; | 0 |
1570 | } | - |
1571 | d->data->controlSocket->waitForBytesWritten(0); executed (the execution status of this line is deduced): d->data->controlSocket->waitForBytesWritten(0); | - |
1572 | //NB: returning len rather than written for the OK case, because the "sealing" may increase the length | - |
1573 | return len; executed: return len; Execution Count:131 | 131 |
1574 | #ifndef QT_NO_UDPSOCKET | - |
1575 | } else if (d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode) { partially evaluated: d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode yes Evaluation Count:313210 | no Evaluation Count:0 |
| 0-313210 |
1576 | // send to connected address | - |
1577 | return writeDatagram(data, len, d->peerAddress, d->peerPort); executed: return writeDatagram(data, len, d->peerAddress, d->peerPort); Execution Count:313210 | 313210 |
1578 | #endif | - |
1579 | } | - |
1580 | //### set an error ??? | - |
1581 | return -1; never executed: return -1; | 0 |
1582 | } | - |
1583 | | - |
1584 | #ifndef QT_NO_UDPSOCKET | - |
1585 | #ifndef QT_NO_NETWORKINTERFACE | - |
1586 | bool QSocks5SocketEngine::joinMulticastGroup(const QHostAddress &, | - |
1587 | const QNetworkInterface &) | - |
1588 | { | - |
1589 | setError(QAbstractSocket::UnsupportedSocketOperationError, never executed (the execution status of this line is deduced): setError(QAbstractSocket::UnsupportedSocketOperationError, | - |
1590 | QLatin1String("Operation on socket is not supported")); never executed (the execution status of this line is deduced): QLatin1String("Operation on socket is not supported")); | - |
1591 | return false; never executed: return false; | 0 |
1592 | } | - |
1593 | | - |
1594 | bool QSocks5SocketEngine::leaveMulticastGroup(const QHostAddress &, | - |
1595 | const QNetworkInterface &) | - |
1596 | { | - |
1597 | setError(QAbstractSocket::UnsupportedSocketOperationError, never executed (the execution status of this line is deduced): setError(QAbstractSocket::UnsupportedSocketOperationError, | - |
1598 | QLatin1String("Operation on socket is not supported")); never executed (the execution status of this line is deduced): QLatin1String("Operation on socket is not supported")); | - |
1599 | return false; never executed: return false; | 0 |
1600 | } | - |
1601 | | - |
1602 | | - |
1603 | QNetworkInterface QSocks5SocketEngine::multicastInterface() const | - |
1604 | { | - |
1605 | return QNetworkInterface(); never executed: return QNetworkInterface(); | 0 |
1606 | } | - |
1607 | | - |
1608 | bool QSocks5SocketEngine::setMulticastInterface(const QNetworkInterface &) | - |
1609 | { | - |
1610 | setError(QAbstractSocket::UnsupportedSocketOperationError, executed (the execution status of this line is deduced): setError(QAbstractSocket::UnsupportedSocketOperationError, | - |
1611 | QLatin1String("Operation on socket is not supported")); executed (the execution status of this line is deduced): QLatin1String("Operation on socket is not supported")); | - |
1612 | return false; executed: return false; Execution Count:4 | 4 |
1613 | } | - |
1614 | #endif // QT_NO_NETWORKINTERFACE | - |
1615 | | - |
1616 | qint64 QSocks5SocketEngine::readDatagram(char *data, qint64 maxlen, QHostAddress *addr, | - |
1617 | quint16 *port) | - |
1618 | { | - |
1619 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1620 | | - |
1621 | d->checkForDatagrams(); executed (the execution status of this line is deduced): d->checkForDatagrams(); | - |
1622 | | - |
1623 | if (d->udpData->pendingDatagrams.isEmpty()) evaluated: d->udpData->pendingDatagrams.isEmpty() yes Evaluation Count:302210 | yes Evaluation Count:20631 |
| 20631-302210 |
1624 | return 0; executed: return 0; Execution Count:302210 | 302210 |
1625 | | - |
1626 | QSocks5RevivedDatagram datagram = d->udpData->pendingDatagrams.dequeue(); executed (the execution status of this line is deduced): QSocks5RevivedDatagram datagram = d->udpData->pendingDatagrams.dequeue(); | - |
1627 | int copyLen = qMin<int>(maxlen, datagram.data.size()); executed (the execution status of this line is deduced): int copyLen = qMin<int>(maxlen, datagram.data.size()); | - |
1628 | memcpy(data, datagram.data.constData(), copyLen); executed (the execution status of this line is deduced): memcpy(data, datagram.data.constData(), copyLen); | - |
1629 | if (addr) evaluated: addr yes Evaluation Count:13 | yes Evaluation Count:20618 |
| 13-20618 |
1630 | *addr = datagram.address; executed: *addr = datagram.address; Execution Count:13 | 13 |
1631 | if (port) evaluated: port yes Evaluation Count:13 | yes Evaluation Count:20618 |
| 13-20618 |
1632 | *port = datagram.port; executed: *port = datagram.port; Execution Count:13 | 13 |
1633 | return copyLen; executed: return copyLen; Execution Count:20631 | 20631 |
1634 | } | - |
1635 | | - |
1636 | qint64 QSocks5SocketEngine::writeDatagram(const char *data, qint64 len, const QHostAddress &address, | - |
1637 | quint16 port) | - |
1638 | { | - |
1639 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1640 | | - |
1641 | // it is possible to send with out first binding with udp, but socks5 requires a bind. | - |
1642 | if (!d->data) { partially evaluated: !d->data no Evaluation Count:0 | yes Evaluation Count:313308 |
| 0-313308 |
1643 | d->initialize(QSocks5SocketEnginePrivate::UdpAssociateMode); never executed (the execution status of this line is deduced): d->initialize(QSocks5SocketEnginePrivate::UdpAssociateMode); | - |
1644 | // all udp needs to be bound | - |
1645 | if (!bind(QHostAddress(QLatin1String("0.0.0.0")), 0)) { never evaluated: !bind(QHostAddress(QLatin1String("0.0.0.0")), 0) | 0 |
1646 | //### set error | - |
1647 | return -1; never executed: return -1; | 0 |
1648 | } | - |
1649 | } | 0 |
1650 | | - |
1651 | QByteArray outBuf; executed (the execution status of this line is deduced): QByteArray outBuf; | - |
1652 | outBuf.reserve(270 + len); executed (the execution status of this line is deduced): outBuf.reserve(270 + len); | - |
1653 | outBuf[0] = 0x00; executed (the execution status of this line is deduced): outBuf[0] = 0x00; | - |
1654 | outBuf[1] = 0x00; executed (the execution status of this line is deduced): outBuf[1] = 0x00; | - |
1655 | outBuf[2] = 0x00; executed (the execution status of this line is deduced): outBuf[2] = 0x00; | - |
1656 | if (!qt_socks5_set_host_address_and_port(address, port, &outBuf)) { partially evaluated: !qt_socks5_set_host_address_and_port(address, port, &outBuf) no Evaluation Count:0 | yes Evaluation Count:313308 |
| 0-313308 |
1657 | } | 0 |
1658 | outBuf += QByteArray(data, len); executed (the execution status of this line is deduced): outBuf += QByteArray(data, len); | - |
1659 | QSOCKS5_DEBUG << "sending" << dump(outBuf); never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1659, __PRETTY_FUNCTION__).debug() << "sending" << dump(outBuf); partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:313308 |
| 0-313308 |
1660 | QByteArray sealedBuf; executed (the execution status of this line is deduced): QByteArray sealedBuf; | - |
1661 | if (!d->data->authenticator->seal(outBuf, &sealedBuf)) { partially evaluated: !d->data->authenticator->seal(outBuf, &sealedBuf) no Evaluation Count:0 | yes Evaluation Count:313308 |
| 0-313308 |
1662 | QSOCKS5_DEBUG << "sealing data failed"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1662, __PRETTY_FUNCTION__).debug() << "sealing data failed"; never evaluated: 0 | 0 |
1663 | setError(QAbstractSocket::SocketAccessError, d->data->authenticator->errorString()); never executed (the execution status of this line is deduced): setError(QAbstractSocket::SocketAccessError, d->data->authenticator->errorString()); | - |
1664 | return -1; never executed: return -1; | 0 |
1665 | } | - |
1666 | if (d->udpData->udpSocket->writeDatagram(sealedBuf, d->udpData->associateAddress, d->udpData->associatePort) != sealedBuf.size()) { partially evaluated: d->udpData->udpSocket->writeDatagram(sealedBuf, d->udpData->associateAddress, d->udpData->associatePort) != sealedBuf.size() no Evaluation Count:0 | yes Evaluation Count:313308 |
| 0-313308 |
1667 | //### try frgamenting | - |
1668 | if (d->udpData->udpSocket->error() == QAbstractSocket::DatagramTooLargeError) never evaluated: d->udpData->udpSocket->error() == QAbstractSocket::DatagramTooLargeError | 0 |
1669 | setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); never executed: setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); | 0 |
1670 | //### else maybe more serious error | - |
1671 | return -1; never executed: return -1; | 0 |
1672 | } | - |
1673 | | - |
1674 | return len; executed: return len; Execution Count:313308 | 313308 |
1675 | } | - |
1676 | | - |
1677 | bool QSocks5SocketEngine::hasPendingDatagrams() const | - |
1678 | { | - |
1679 | Q_D(const QSocks5SocketEngine); executed (the execution status of this line is deduced): const QSocks5SocketEnginePrivate * const d = d_func(); | - |
1680 | Q_INIT_CHECK(false); never executed: return false; executed: } Execution Count:322903 partially evaluated: !d->data no Evaluation Count:0 | yes Evaluation Count:322903 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:322903 |
| 0-322903 |
1681 | | - |
1682 | d->checkForDatagrams(); executed (the execution status of this line is deduced): d->checkForDatagrams(); | - |
1683 | | - |
1684 | return !d->udpData->pendingDatagrams.isEmpty(); executed: return !d->udpData->pendingDatagrams.isEmpty(); Execution Count:322903 | 322903 |
1685 | } | - |
1686 | | - |
1687 | qint64 QSocks5SocketEngine::pendingDatagramSize() const | - |
1688 | { | - |
1689 | Q_D(const QSocks5SocketEngine); executed (the execution status of this line is deduced): const QSocks5SocketEnginePrivate * const d = d_func(); | - |
1690 | | - |
1691 | d->checkForDatagrams(); executed (the execution status of this line is deduced): d->checkForDatagrams(); | - |
1692 | | - |
1693 | if (!d->udpData->pendingDatagrams.isEmpty()) partially evaluated: !d->udpData->pendingDatagrams.isEmpty() yes Evaluation Count:38 | no Evaluation Count:0 |
| 0-38 |
1694 | return d->udpData->pendingDatagrams.head().data.size(); executed: return d->udpData->pendingDatagrams.head().data.size(); Execution Count:38 | 38 |
1695 | return 0; never executed: return 0; | 0 |
1696 | } | - |
1697 | #endif // QT_NO_UDPSOCKET | - |
1698 | | - |
1699 | qint64 QSocks5SocketEngine::bytesToWrite() const | - |
1700 | { | - |
1701 | Q_D(const QSocks5SocketEngine); executed (the execution status of this line is deduced): const QSocks5SocketEnginePrivate * const d = d_func(); | - |
1702 | if (d->data && d->data->controlSocket) { partially evaluated: d->data yes Evaluation Count:277 | no Evaluation Count:0 |
partially evaluated: d->data->controlSocket yes Evaluation Count:277 | no Evaluation Count:0 |
| 0-277 |
1703 | return d->data->controlSocket->bytesToWrite(); executed: return d->data->controlSocket->bytesToWrite(); Execution Count:277 | 277 |
1704 | } else { | - |
1705 | return 0; never executed: return 0; | 0 |
1706 | } | - |
1707 | } | - |
1708 | | - |
1709 | int QSocks5SocketEngine::option(SocketOption option) const | - |
1710 | { | - |
1711 | Q_D(const QSocks5SocketEngine); executed (the execution status of this line is deduced): const QSocks5SocketEnginePrivate * const d = d_func(); | - |
1712 | if (d->data && d->data->controlSocket) { partially evaluated: d->data yes Evaluation Count:26 | no Evaluation Count:0 |
partially evaluated: d->data->controlSocket yes Evaluation Count:26 | no Evaluation Count:0 |
| 0-26 |
1713 | // convert the enum and call the real socket | - |
1714 | if (option == QAbstractSocketEngine::LowDelayOption) partially evaluated: option == QAbstractSocketEngine::LowDelayOption no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-26 |
1715 | return d->data->controlSocket->socketOption(QAbstractSocket::LowDelayOption).toInt(); never executed: return d->data->controlSocket->socketOption(QAbstractSocket::LowDelayOption).toInt(); | 0 |
1716 | if (option == QAbstractSocketEngine::KeepAliveOption) partially evaluated: option == QAbstractSocketEngine::KeepAliveOption no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-26 |
1717 | return d->data->controlSocket->socketOption(QAbstractSocket::KeepAliveOption).toInt(); never executed: return d->data->controlSocket->socketOption(QAbstractSocket::KeepAliveOption).toInt(); | 0 |
1718 | } executed: } Execution Count:26 | 26 |
1719 | return -1; executed: return -1; Execution Count:26 | 26 |
1720 | } | - |
1721 | | - |
1722 | bool QSocks5SocketEngine::setOption(SocketOption option, int value) | - |
1723 | { | - |
1724 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1725 | if (d->data && d->data->controlSocket) { evaluated: d->data yes Evaluation Count:69 | yes Evaluation Count:8 |
partially evaluated: d->data->controlSocket yes Evaluation Count:69 | no Evaluation Count:0 |
| 0-69 |
1726 | // convert the enum and call the real socket | - |
1727 | if (option == QAbstractSocketEngine::LowDelayOption) partially evaluated: option == QAbstractSocketEngine::LowDelayOption no Evaluation Count:0 | yes Evaluation Count:69 |
| 0-69 |
1728 | d->data->controlSocket->setSocketOption(QAbstractSocket::LowDelayOption, value); never executed: d->data->controlSocket->setSocketOption(QAbstractSocket::LowDelayOption, value); | 0 |
1729 | if (option == QAbstractSocketEngine::KeepAliveOption) evaluated: option == QAbstractSocketEngine::KeepAliveOption yes Evaluation Count:43 | yes Evaluation Count:26 |
| 26-43 |
1730 | d->data->controlSocket->setSocketOption(QAbstractSocket::KeepAliveOption, value); executed: d->data->controlSocket->setSocketOption(QAbstractSocket::KeepAliveOption, value); Execution Count:43 | 43 |
1731 | return true; executed: return true; Execution Count:69 | 69 |
1732 | } | - |
1733 | return false; executed: return false; Execution Count:8 | 8 |
1734 | } | - |
1735 | | - |
1736 | bool QSocks5SocketEnginePrivate::waitForConnected(int msecs, bool *timedOut) | - |
1737 | { | - |
1738 | if (data->controlSocket->state() == QAbstractSocket::UnconnectedState) partially evaluated: data->controlSocket->state() == QAbstractSocket::UnconnectedState no Evaluation Count:0 | yes Evaluation Count:139 |
| 0-139 |
1739 | return false; never executed: return false; | 0 |
1740 | | - |
1741 | const Socks5State wantedState = executed (the execution status of this line is deduced): const Socks5State wantedState = | - |
1742 | mode == ConnectMode ? Connected : evaluated: mode == ConnectMode yes Evaluation Count:3 | yes Evaluation Count:136 |
| 3-136 |
1743 | mode == BindMode ? BindSuccess : executed (the execution status of this line is deduced): mode == BindMode ? BindSuccess : | - |
1744 | UdpAssociateSuccess; executed (the execution status of this line is deduced): UdpAssociateSuccess; | - |
1745 | | - |
1746 | QElapsedTimer stopWatch; executed (the execution status of this line is deduced): QElapsedTimer stopWatch; | - |
1747 | stopWatch.start(); executed (the execution status of this line is deduced): stopWatch.start(); | - |
1748 | | - |
1749 | while (socks5State != wantedState) { evaluated: socks5State != wantedState yes Evaluation Count:182 | yes Evaluation Count:113 |
| 113-182 |
1750 | if (!data->controlSocket->waitForReadyRead(qt_timeout_value(msecs, stopWatch.elapsed()))) { evaluated: !data->controlSocket->waitForReadyRead(qt_timeout_value(msecs, stopWatch.elapsed())) yes Evaluation Count:26 | yes Evaluation Count:156 |
| 26-156 |
1751 | if (data->controlSocket->state() == QAbstractSocket::UnconnectedState) evaluated: data->controlSocket->state() == QAbstractSocket::UnconnectedState yes Evaluation Count:25 | yes Evaluation Count:1 |
| 1-25 |
1752 | return true; executed: return true; Execution Count:25 | 25 |
1753 | | - |
1754 | setErrorState(QSocks5SocketEnginePrivate::ControlSocketError); executed (the execution status of this line is deduced): setErrorState(QSocks5SocketEnginePrivate::ControlSocketError); | - |
1755 | if (timedOut && data->controlSocket->error() == QAbstractSocket::SocketTimeoutError) partially evaluated: timedOut no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: data->controlSocket->error() == QAbstractSocket::SocketTimeoutError | 0-1 |
1756 | *timedOut = true; never executed: *timedOut = true; | 0 |
1757 | return false; executed: return false; Execution Count:1 | 1 |
1758 | } | - |
1759 | } executed: } Execution Count:156 | 156 |
1760 | | - |
1761 | return true; executed: return true; Execution Count:113 | 113 |
1762 | } | - |
1763 | | - |
1764 | bool QSocks5SocketEngine::waitForRead(int msecs, bool *timedOut) | - |
1765 | { | - |
1766 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1767 | QSOCKS5_DEBUG << "waitForRead" << msecs; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1767, __PRETTY_FUNCTION__).debug() << "waitForRead" << msecs; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:59 |
| 0-59 |
1768 | | - |
1769 | d->readNotificationActivated = false; executed (the execution status of this line is deduced): d->readNotificationActivated = false; | - |
1770 | | - |
1771 | QElapsedTimer stopWatch; executed (the execution status of this line is deduced): QElapsedTimer stopWatch; | - |
1772 | stopWatch.start(); executed (the execution status of this line is deduced): stopWatch.start(); | - |
1773 | | - |
1774 | // are we connected yet? | - |
1775 | if (!d->waitForConnected(msecs, timedOut)) partially evaluated: !d->waitForConnected(msecs, timedOut) no Evaluation Count:0 | yes Evaluation Count:59 |
| 0-59 |
1776 | return false; never executed: return false; | 0 |
1777 | if (d->data->controlSocket->state() == QAbstractSocket::UnconnectedState) partially evaluated: d->data->controlSocket->state() == QAbstractSocket::UnconnectedState no Evaluation Count:0 | yes Evaluation Count:59 |
| 0-59 |
1778 | return true; never executed: return true; | 0 |
1779 | | - |
1780 | // we're connected | - |
1781 | if (d->mode == QSocks5SocketEnginePrivate::ConnectMode || evaluated: d->mode == QSocks5SocketEnginePrivate::ConnectMode yes Evaluation Count:2 | yes Evaluation Count:57 |
| 2-57 |
1782 | d->mode == QSocks5SocketEnginePrivate::BindMode) { evaluated: d->mode == QSocks5SocketEnginePrivate::BindMode yes Evaluation Count:1 | yes Evaluation Count:56 |
| 1-56 |
1783 | while (!d->readNotificationActivated) { evaluated: !d->readNotificationActivated yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3 |
1784 | if (!d->data->controlSocket->waitForReadyRead(qt_timeout_value(msecs, stopWatch.elapsed()))) { partially evaluated: !d->data->controlSocket->waitForReadyRead(qt_timeout_value(msecs, stopWatch.elapsed())) no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
1785 | if (d->data->controlSocket->state() == QAbstractSocket::UnconnectedState) never evaluated: d->data->controlSocket->state() == QAbstractSocket::UnconnectedState | 0 |
1786 | return true; never executed: return true; | 0 |
1787 | | - |
1788 | setError(d->data->controlSocket->error(), d->data->controlSocket->errorString()); never executed (the execution status of this line is deduced): setError(d->data->controlSocket->error(), d->data->controlSocket->errorString()); | - |
1789 | if (timedOut && d->data->controlSocket->error() == QAbstractSocket::SocketTimeoutError) never evaluated: timedOut never evaluated: d->data->controlSocket->error() == QAbstractSocket::SocketTimeoutError | 0 |
1790 | *timedOut = true; never executed: *timedOut = true; | 0 |
1791 | return false; never executed: return false; | 0 |
1792 | } | - |
1793 | } executed: } Execution Count:3 | 3 |
1794 | #ifndef QT_NO_UDPSOCKET | - |
1795 | } else { executed: } Execution Count:3 | 3 |
1796 | while (!d->readNotificationActivated) { evaluated: !d->readNotificationActivated yes Evaluation Count:56 | yes Evaluation Count:55 |
| 55-56 |
1797 | if (!d->udpData->udpSocket->waitForReadyRead(qt_timeout_value(msecs, stopWatch.elapsed()))) { evaluated: !d->udpData->udpSocket->waitForReadyRead(qt_timeout_value(msecs, stopWatch.elapsed())) yes Evaluation Count:1 | yes Evaluation Count:55 |
| 1-55 |
1798 | setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); executed (the execution status of this line is deduced): setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); | - |
1799 | if (timedOut && d->udpData->udpSocket->error() == QAbstractSocket::SocketTimeoutError) partially evaluated: timedOut no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: d->udpData->udpSocket->error() == QAbstractSocket::SocketTimeoutError | 0-1 |
1800 | *timedOut = true; never executed: *timedOut = true; | 0 |
1801 | return false; executed: return false; Execution Count:1 | 1 |
1802 | } | - |
1803 | } executed: } Execution Count:55 | 55 |
1804 | #endif // QT_NO_UDPSOCKET | - |
1805 | } executed: } Execution Count:55 | 55 |
1806 | | - |
1807 | | - |
1808 | bool ret = d->readNotificationActivated; executed (the execution status of this line is deduced): bool ret = d->readNotificationActivated; | - |
1809 | d->readNotificationActivated = false; executed (the execution status of this line is deduced): d->readNotificationActivated = false; | - |
1810 | | - |
1811 | QSOCKS5_DEBUG << "waitForRead returned" << ret; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1811, __PRETTY_FUNCTION__).debug() << "waitForRead returned" << ret; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:58 |
| 0-58 |
1812 | return ret; executed: return ret; Execution Count:58 | 58 |
1813 | } | - |
1814 | | - |
1815 | | - |
1816 | bool QSocks5SocketEngine::waitForWrite(int msecs, bool *timedOut) | - |
1817 | { | - |
1818 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1819 | QSOCKS5_DEBUG << "waitForWrite" << msecs; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1819, __PRETTY_FUNCTION__).debug() << "waitForWrite" << msecs; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1820 | | - |
1821 | QElapsedTimer stopWatch; executed (the execution status of this line is deduced): QElapsedTimer stopWatch; | - |
1822 | stopWatch.start(); executed (the execution status of this line is deduced): stopWatch.start(); | - |
1823 | | - |
1824 | // are we connected yet? | - |
1825 | if (!d->waitForConnected(msecs, timedOut)) partially evaluated: !d->waitForConnected(msecs, timedOut) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1826 | return false; never executed: return false; | 0 |
1827 | if (d->data->controlSocket->state() == QAbstractSocket::UnconnectedState) partially evaluated: d->data->controlSocket->state() == QAbstractSocket::UnconnectedState no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1828 | return true; never executed: return true; | 0 |
1829 | | - |
1830 | // we're connected | - |
1831 | | - |
1832 | // flush any bytes we may still have buffered in the time that we have left | - |
1833 | if (d->data->controlSocket->bytesToWrite()) partially evaluated: d->data->controlSocket->bytesToWrite() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1834 | d->data->controlSocket->waitForBytesWritten(qt_timeout_value(msecs, stopWatch.elapsed())); never executed: d->data->controlSocket->waitForBytesWritten(qt_timeout_value(msecs, stopWatch.elapsed())); | 0 |
1835 | while ((msecs == -1 || stopWatch.elapsed() < msecs) partially evaluated: msecs == -1 no Evaluation Count:0 | yes Evaluation Count:1 |
partially evaluated: stopWatch.elapsed() < msecs yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1836 | && d->data->controlSocket->state() == QAbstractSocket::ConnectedState partially evaluated: d->data->controlSocket->state() == QAbstractSocket::ConnectedState yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1837 | && d->data->controlSocket->bytesToWrite() >= MaxWriteBufferSize) partially evaluated: d->data->controlSocket->bytesToWrite() >= MaxWriteBufferSize no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1838 | d->data->controlSocket->waitForBytesWritten(qt_timeout_value(msecs, stopWatch.elapsed())); never executed: d->data->controlSocket->waitForBytesWritten(qt_timeout_value(msecs, stopWatch.elapsed())); | 0 |
1839 | return d->data->controlSocket->bytesToWrite() < MaxWriteBufferSize; executed: return d->data->controlSocket->bytesToWrite() < MaxWriteBufferSize; Execution Count:1 | 1 |
1840 | } | - |
1841 | | - |
1842 | bool QSocks5SocketEngine::waitForReadOrWrite(bool *readyToRead, bool *readyToWrite, | - |
1843 | bool checkRead, bool checkWrite, | - |
1844 | int msecs, bool *timedOut) | - |
1845 | { | - |
1846 | Q_UNUSED(checkRead); executed (the execution status of this line is deduced): (void)checkRead;; | - |
1847 | if (!checkWrite) { partially evaluated: !checkWrite yes Evaluation Count:58 | no Evaluation Count:0 |
| 0-58 |
1848 | bool canRead = waitForRead(msecs, timedOut); executed (the execution status of this line is deduced): bool canRead = waitForRead(msecs, timedOut); | - |
1849 | if (readyToRead) partially evaluated: readyToRead yes Evaluation Count:58 | no Evaluation Count:0 |
| 0-58 |
1850 | *readyToRead = canRead; executed: *readyToRead = canRead; Execution Count:58 | 58 |
1851 | return canRead; executed: return canRead; Execution Count:58 | 58 |
1852 | } | - |
1853 | | - |
1854 | bool canWrite = waitForWrite(msecs, timedOut); never executed (the execution status of this line is deduced): bool canWrite = waitForWrite(msecs, timedOut); | - |
1855 | if (readyToWrite) never evaluated: readyToWrite | 0 |
1856 | *readyToWrite = canWrite; never executed: *readyToWrite = canWrite; | 0 |
1857 | return canWrite; never executed: return canWrite; | 0 |
1858 | } | - |
1859 | | - |
1860 | bool QSocks5SocketEngine::isReadNotificationEnabled() const | - |
1861 | { | - |
1862 | Q_D(const QSocks5SocketEngine); executed (the execution status of this line is deduced): const QSocks5SocketEnginePrivate * const d = d_func(); | - |
1863 | return d->readNotificationEnabled; executed: return d->readNotificationEnabled; Execution Count:411 | 411 |
1864 | } | - |
1865 | | - |
1866 | void QSocks5SocketEngine::setReadNotificationEnabled(bool enable) | - |
1867 | { | - |
1868 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1869 | | - |
1870 | QSOCKS5_Q_DEBUG << "setReadNotificationEnabled(" << enable << ')'; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1870, __PRETTY_FUNCTION__).debug() << "setReadNotificationEnabled(" << enable << ')'; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:323232 |
| 0-323232 |
1871 | | - |
1872 | bool emitSignal = false; executed (the execution status of this line is deduced): bool emitSignal = false; | - |
1873 | if (!d->readNotificationEnabled evaluated: !d->readNotificationEnabled yes Evaluation Count:249 | yes Evaluation Count:322983 |
| 249-322983 |
1874 | && enable) { evaluated: enable yes Evaluation Count:203 | yes Evaluation Count:46 |
| 46-203 |
1875 | if (d->mode == QSocks5SocketEnginePrivate::ConnectMode) evaluated: d->mode == QSocks5SocketEnginePrivate::ConnectMode yes Evaluation Count:75 | yes Evaluation Count:128 |
| 75-128 |
1876 | emitSignal = !d->connectData->readBuffer.isEmpty(); executed: emitSignal = !d->connectData->readBuffer.isEmpty(); Execution Count:75 | 75 |
1877 | #ifndef QT_NO_UDPSOCKET | - |
1878 | else if (d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode) evaluated: d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode yes Evaluation Count:122 | yes Evaluation Count:6 |
| 6-122 |
1879 | emitSignal = !d->udpData->pendingDatagrams.isEmpty(); executed: emitSignal = !d->udpData->pendingDatagrams.isEmpty(); Execution Count:122 | 122 |
1880 | #endif | - |
1881 | else if (d->mode == QSocks5SocketEnginePrivate::BindMode partially evaluated: d->mode == QSocks5SocketEnginePrivate::BindMode yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
1882 | && d->socketState == QAbstractSocket::ListeningState partially evaluated: d->socketState == QAbstractSocket::ListeningState yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
1883 | && d->socks5State == QSocks5SocketEnginePrivate::BindSuccess) partially evaluated: d->socks5State == QSocks5SocketEnginePrivate::BindSuccess yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
1884 | emitSignal = true; executed: emitSignal = true; Execution Count:6 | 6 |
1885 | } | - |
1886 | | - |
1887 | d->readNotificationEnabled = enable; executed (the execution status of this line is deduced): d->readNotificationEnabled = enable; | - |
1888 | | - |
1889 | if (emitSignal) evaluated: emitSignal yes Evaluation Count:16 | yes Evaluation Count:323216 |
| 16-323216 |
1890 | d->emitReadNotification(); executed: d->emitReadNotification(); Execution Count:16 | 16 |
1891 | } executed: } Execution Count:323232 | 323232 |
1892 | | - |
1893 | bool QSocks5SocketEngine::isWriteNotificationEnabled() const | - |
1894 | { | - |
1895 | Q_D(const QSocks5SocketEngine); executed (the execution status of this line is deduced): const QSocks5SocketEnginePrivate * const d = d_func(); | - |
1896 | return d->writeNotificationEnabled; executed: return d->writeNotificationEnabled; Execution Count:166 | 166 |
1897 | } | - |
1898 | | - |
1899 | void QSocks5SocketEngine::setWriteNotificationEnabled(bool enable) | - |
1900 | { | - |
1901 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1902 | d->writeNotificationEnabled = enable; executed (the execution status of this line is deduced): d->writeNotificationEnabled = enable; | - |
1903 | if (enable && d->socketState == QAbstractSocket::ConnectedState) { evaluated: enable yes Evaluation Count:206 | yes Evaluation Count:309 |
evaluated: d->socketState == QAbstractSocket::ConnectedState yes Evaluation Count:205 | yes Evaluation Count:1 |
| 1-309 |
1904 | if (d->mode == QSocks5SocketEnginePrivate::ConnectMode && d->data->controlSocket->bytesToWrite()) evaluated: d->mode == QSocks5SocketEnginePrivate::ConnectMode yes Evaluation Count:203 | yes Evaluation Count:2 |
evaluated: d->data->controlSocket->bytesToWrite() yes Evaluation Count:52 | yes Evaluation Count:151 |
| 2-203 |
1905 | return; // will be emitted as a result of bytes written executed: return; Execution Count:52 | 52 |
1906 | d->emitWriteNotification(); executed (the execution status of this line is deduced): d->emitWriteNotification(); | - |
1907 | d->writeNotificationActivated = false; executed (the execution status of this line is deduced): d->writeNotificationActivated = false; | - |
1908 | } executed: } Execution Count:153 | 153 |
1909 | } executed: } Execution Count:463 | 463 |
1910 | | - |
1911 | bool QSocks5SocketEngine::isExceptionNotificationEnabled() const | - |
1912 | { | - |
1913 | Q_D(const QSocks5SocketEngine); executed (the execution status of this line is deduced): const QSocks5SocketEnginePrivate * const d = d_func(); | - |
1914 | return d->exceptNotificationEnabled; executed: return d->exceptNotificationEnabled; Execution Count:53 | 53 |
1915 | } | - |
1916 | | - |
1917 | void QSocks5SocketEngine::setExceptionNotificationEnabled(bool enable) | - |
1918 | { | - |
1919 | Q_D(QSocks5SocketEngine); executed (the execution status of this line is deduced): QSocks5SocketEnginePrivate * const d = d_func(); | - |
1920 | d->exceptNotificationEnabled = enable; executed (the execution status of this line is deduced): d->exceptNotificationEnabled = enable; | - |
1921 | } executed: } Execution Count:106 | 106 |
1922 | | - |
1923 | QAbstractSocketEngine * | - |
1924 | QSocks5SocketEngineHandler::createSocketEngine(QAbstractSocket::SocketType socketType, | - |
1925 | const QNetworkProxy &proxy, QObject *parent) | - |
1926 | { | - |
1927 | Q_UNUSED(socketType); executed (the execution status of this line is deduced): (void)socketType;; | - |
1928 | | - |
1929 | // proxy type must have been resolved by now | - |
1930 | if (proxy.type() != QNetworkProxy::Socks5Proxy) { evaluated: proxy.type() != QNetworkProxy::Socks5Proxy yes Evaluation Count:2761 | yes Evaluation Count:128 |
| 128-2761 |
1931 | QSOCKS5_DEBUG << "not proxying"; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1931, __PRETTY_FUNCTION__).debug() << "not proxying"; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:2761 |
| 0-2761 |
1932 | return 0; executed: return 0; Execution Count:2761 | 2761 |
1933 | } | - |
1934 | QScopedPointer<QSocks5SocketEngine> engine(new QSocks5SocketEngine(parent)); executed (the execution status of this line is deduced): QScopedPointer<QSocks5SocketEngine> engine(new QSocks5SocketEngine(parent)); | - |
1935 | engine->setProxy(proxy); executed (the execution status of this line is deduced): engine->setProxy(proxy); | - |
1936 | return engine.take(); executed: return engine.take(); Execution Count:128 | 128 |
1937 | } | - |
1938 | | - |
1939 | QAbstractSocketEngine *QSocks5SocketEngineHandler::createSocketEngine(qintptr socketDescriptor, QObject *parent) | - |
1940 | { | - |
1941 | QSOCKS5_DEBUG << "createSocketEngine" << socketDescriptor; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1941, __PRETTY_FUNCTION__).debug() << "createSocketEngine" << socketDescriptor; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:616 |
| 0-616 |
1942 | if (socks5BindStore()->contains(socketDescriptor)) { evaluated: socks5BindStore()->contains(socketDescriptor) yes Evaluation Count:1 | yes Evaluation Count:615 |
| 1-615 |
1943 | QSOCKS5_DEBUG << "bind store contains" << socketDescriptor; never executed: QMessageLogger("socket/qsocks5socketengine.cpp", 1943, __PRETTY_FUNCTION__).debug() << "bind store contains" << socketDescriptor; partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1944 | return new QSocks5SocketEngine(parent); executed: return new QSocks5SocketEngine(parent); Execution Count:1 | 1 |
1945 | } | - |
1946 | return 0; executed: return 0; Execution Count:615 | 615 |
1947 | } | - |
1948 | | - |
1949 | #endif // QT_NO_SOCKS5 | - |
1950 | | - |
1951 | QT_END_NAMESPACE | - |
1952 | | - |
| | |