| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/kernel/qnetworkproxy_generic.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | static bool ignoreProxyFor(const QNetworkProxyQuery &query) | - | ||||||||||||
| 5 | { | - | ||||||||||||
| 6 | const QByteArray noProxy = qgetenv("no_proxy").trimmed(); | - | ||||||||||||
| 7 | if (noProxy.isEmpty()
| 0-39 | ||||||||||||
| 8 | return executed 39 times by 1 test: false;return false;Executed by:
executed 39 times by 1 test: return false;Executed by:
| 39 | ||||||||||||
| 9 | - | |||||||||||||
| 10 | const QList<QByteArray> noProxyTokens = noProxy.split(','); | - | ||||||||||||
| 11 | - | |||||||||||||
| 12 | for (const QByteArray &rawToken : noProxyTokens) { | - | ||||||||||||
| 13 | QByteArray token = rawToken.trimmed(); | - | ||||||||||||
| 14 | QString peerHostName = query.peerHostName(); | - | ||||||||||||
| 15 | - | |||||||||||||
| 16 | - | |||||||||||||
| 17 | if (token.startsWith('*')
| 0 | ||||||||||||
| 18 | token = token.mid(1); never executed: token = token.mid(1); | 0 | ||||||||||||
| 19 | - | |||||||||||||
| 20 | - | |||||||||||||
| 21 | if (token.endsWith('.')
| 0 | ||||||||||||
| 22 | token = token.left(token.length()-1); never executed: token = token.left(token.length()-1); | 0 | ||||||||||||
| 23 | - | |||||||||||||
| 24 | - | |||||||||||||
| 25 | - | |||||||||||||
| 26 | if (!token.startsWith('.')
| 0 | ||||||||||||
| 27 | token.prepend('.'); never executed: token.prepend('.'); | 0 | ||||||||||||
| 28 | - | |||||||||||||
| 29 | if (!peerHostName.startsWith('.')
| 0 | ||||||||||||
| 30 | peerHostName.prepend('.'); never executed: peerHostName.prepend('.'); | 0 | ||||||||||||
| 31 | - | |||||||||||||
| 32 | if (peerHostName.endsWith(QString::fromLatin1(token))
| 0 | ||||||||||||
| 33 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||
| 34 | } never executed: end of block | 0 | ||||||||||||
| 35 | - | |||||||||||||
| 36 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 37 | } | - | ||||||||||||
| 38 | - | |||||||||||||
| 39 | QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkProxyQuery &query) | - | ||||||||||||
| 40 | { | - | ||||||||||||
| 41 | QList<QNetworkProxy> proxyList; | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | if (ignoreProxyFor(query)
| 0-39 | ||||||||||||
| 44 | return never executed: proxyList << QNetworkProxy::NoProxy;return proxyList << QNetworkProxy::NoProxy;never executed: return proxyList << QNetworkProxy::NoProxy; | 0 | ||||||||||||
| 45 | - | |||||||||||||
| 46 | - | |||||||||||||
| 47 | const QString queryProtocol = query.protocolTag(); | - | ||||||||||||
| 48 | QByteArray proxy_env; | - | ||||||||||||
| 49 | - | |||||||||||||
| 50 | if (queryProtocol == QLatin1String("http")
| 18-21 | ||||||||||||
| 51 | proxy_env = qgetenv("http_proxy"); executed 18 times by 1 test: proxy_env = qgetenv("http_proxy");Executed by:
| 18 | ||||||||||||
| 52 | else if (queryProtocol == QLatin1String("https")
| 2-19 | ||||||||||||
| 53 | proxy_env = qgetenv("https_proxy"); executed 2 times by 1 test: proxy_env = qgetenv("https_proxy");Executed by:
| 2 | ||||||||||||
| 54 | else if (queryProtocol == QLatin1String("ftp")
| 3-16 | ||||||||||||
| 55 | proxy_env = qgetenv("ftp_proxy"); executed 3 times by 1 test: proxy_env = qgetenv("ftp_proxy");Executed by:
| 3 | ||||||||||||
| 56 | else | - | ||||||||||||
| 57 | proxy_env = qgetenv("all_proxy"); executed 16 times by 1 test: proxy_env = qgetenv("all_proxy");Executed by:
| 16 | ||||||||||||
| 58 | - | |||||||||||||
| 59 | - | |||||||||||||
| 60 | if (proxy_env.isEmpty()
| 0-39 | ||||||||||||
| 61 | proxy_env = qgetenv("http_proxy"); executed 39 times by 1 test: proxy_env = qgetenv("http_proxy");Executed by:
| 39 | ||||||||||||
| 62 | - | |||||||||||||
| 63 | if (!proxy_env.isEmpty()
| 2-37 | ||||||||||||
| 64 | QUrl url = QUrl(QString::fromLocal8Bit(proxy_env)); | - | ||||||||||||
| 65 | const QString scheme = url.scheme(); | - | ||||||||||||
| 66 | if (scheme == QLatin1String("socks5")
| 1 | ||||||||||||
| 67 | QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, url.host(), | - | ||||||||||||
| 68 | url.port() ? url.port() : 1080, url.userName(), url.password()); | - | ||||||||||||
| 69 | proxyList << proxy; | - | ||||||||||||
| 70 | } executed 1 time by 1 test: else if (scheme == QLatin1String("socks5h")end of blockExecuted by:
| 0-1 | ||||||||||||
| 71 | QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, url.host(), | - | ||||||||||||
| 72 | url.port() ? url.port() : 1080, url.userName(), url.password()); | - | ||||||||||||
| 73 | proxy.setCapabilities(QNetworkProxy::HostNameLookupCapability); | - | ||||||||||||
| 74 | proxyList << proxy; | - | ||||||||||||
| 75 | } never executed: else if ((scheme.isEmpty()end of block
| 0-1 | ||||||||||||
| 76 | && query.queryType() != QNetworkProxyQuery::UdpSocket
| 0-1 | ||||||||||||
| 77 | && query.queryType() != QNetworkProxyQuery::TcpServer
| 0-1 | ||||||||||||
| 78 | QNetworkProxy proxy(QNetworkProxy::HttpProxy, url.host(), | - | ||||||||||||
| 79 | url.port() ? url.port() : 8080, url.userName(), url.password()); | - | ||||||||||||
| 80 | proxyList << proxy; | - | ||||||||||||
| 81 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||
| 82 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||
| 83 | if (proxyList.isEmpty()
| 2-37 | ||||||||||||
| 84 | proxyList << QNetworkProxy::NoProxy; executed 37 times by 1 test: proxyList << QNetworkProxy::NoProxy;Executed by:
| 37 | ||||||||||||
| 85 | - | |||||||||||||
| 86 | return executed 39 times by 1 test: proxyList;return proxyList;Executed by:
executed 39 times by 1 test: return proxyList;Executed by:
| 39 | ||||||||||||
| 87 | } | - | ||||||||||||
| 88 | - | |||||||||||||
| 89 | - | |||||||||||||
| Switch to Source code | Preprocessed file |