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