Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.6.2
-
None
-
Qt 4.6.2 Open source MSVC build. Windows 7 32 bits, (also happening on windows xp).
-
a7489b2ba3f2f3ea28d6fff0c835c12b0666af45 (5.0), 43d0891343e6d6ad9cf137dca7dba0e63d2e1851 (4.8)
Description
I have a socks proxy configured on the system proxy, and in our application we search for the system proxy with the method QNetworkProxyFactory::systemProxyForQuery.
The problem we are facing is that, even when the detected proxy has the correct ip address and the correct port is returning an proxy of type HTTP instead of socks.
Looking at the source code of qt the problem seems to be in this method :
static QList<QNetworkProxy> parseServerList(const QNetworkProxyQuery &query, const QStringList &proxyList) { // Reference documentation from Microsoft: // http://msdn.microsoft.com/en-us/library/aa383912(VS.85).aspx // // According to the website, the proxy server list is // one or more of the space- or semicolon-separated strings in the format: // ([<scheme>=][<scheme>"://"]<server>[":"<port>]) QList<QNetworkProxy> result; foreach (const QString &entry, proxyList) { int server = 0; int pos = entry.indexOf(QLatin1Char('=')); if (pos != -1) { QStringRef scheme = entry.leftRef(pos); if (scheme != query.protocolTag()) continue; server = pos + 1; } QNetworkProxy::ProxyType proxyType = QNetworkProxy::HttpProxy; quint16 port = 8080; pos = entry.indexOf(QLatin1String("://"), server); if (pos != -1) { QStringRef scheme = entry.midRef(server, pos - server); if (scheme == QLatin1String("http") || scheme == QLatin1String("https")) { // no-op // defaults are above } else if (scheme == QLatin1String("socks") || scheme == QLatin1String("socks5")) { proxyType = QNetworkProxy::Socks5Proxy; port = 1080; } else { // unknown proxy type continue; } server = pos + 3; } pos = entry.indexOf(QLatin1Char(':'), server); if (pos != -1) { bool ok; uint value = entry.mid(pos + 1).toUInt(&ok); if (!ok || value > 65535) continue; // invalid port number port = value; } else { pos = entry.length(); } result << QNetworkProxy(proxyType, entry.mid(server, pos - server), port); } return result; }
After the proxy type returned from the OS has been compared to the query protocol tag it does a search for the "://" string and then it changes the result proxy type, the problem is that the string returned by the OS has no "://" substring on it, hence, the proxy type is never changed from the value assigned initially (http).
This is the value of proxy list on my computer (windows 7 home premium 32 bits):
proxyList 0x00aae17c class QStringList * <3 items> 0 "ftp=192.168.30.49:21" 1 "http=192.168.30.49:80" 2 "socks=192.168.30.49:1080"