summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShane Kearns <ext-shane.2.kearns@nokia.com>2012-04-20 14:04:29 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-04-25 10:03:02 (GMT)
commit1ca3a778a0b5a7c1e1c918bc6fd4dde2be40278d (patch)
tree76fecc53cf773f404aa331fb551668a589b65d09
parentea171150de245b5eea0e04f766f37a39c8800e67 (diff)
downloadQt-1ca3a778a0b5a7c1e1c918bc6fd4dde2be40278d.zip
Qt-1ca3a778a0b5a7c1e1c918bc6fd4dde2be40278d.tar.gz
Qt-1ca3a778a0b5a7c1e1c918bc6fd4dde2be40278d.tar.bz2
Windows - "bypass proxy for local..." also affects IP addresses
If the "bypass proxy for local addresses" option is enabled in the windows proxy configuration, then do not use the proxy for any IP address in the subnet of any network interface. As the systemProxyForQuery api is now offering HTTP proxy tunnels for TCP sockets, this change avoids local ad-hoc network connections being routed through the proxy. In the case where the local address was on a different interface to the proxy server, it may have been unreachable through the proxy. For example IP over USB or Bluetooth. Change-Id: I0842732832a7795112be029d923ed168edc008d6 (modified version of fffc900f78a191970c4eebced9c1af016a9ea6f4 in QtBase) Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/network/kernel/qnetworkproxy_win.cpp21
-rw-r--r--tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp4
2 files changed, 23 insertions, 2 deletions
diff --git a/src/network/kernel/qnetworkproxy_win.cpp b/src/network/kernel/qnetworkproxy_win.cpp
index 107b2e5..90aae0a 100644
--- a/src/network/kernel/qnetworkproxy_win.cpp
+++ b/src/network/kernel/qnetworkproxy_win.cpp
@@ -47,6 +47,7 @@
#include <qstringlist.h>
#include <qregexp.h>
#include <qurl.h>
+#include <qnetworkinterface.h>
#include <string.h>
#include <qt_windows.h>
@@ -191,10 +192,26 @@ static bool isBypassed(const QString &host, const QStringList &bypassList)
QHostAddress ipAddress;
bool isIpAddress = ipAddress.setAddress(host);
+ // always exclude loopback
+ if (isIpAddress && (ipAddress == QHostAddress::LocalHost || ipAddress == QHostAddress::LocalHostIPv6))
+ return true;
+
// does it match the list of exclusions?
foreach (const QString &entry, bypassList) {
- if (isSimple && entry == QLatin1String("<local>"))
- return true;
+ if (entry == QLatin1String("<local>")) {
+ if (isSimple)
+ return true;
+ if (isIpAddress) {
+ //exclude all local subnets
+ foreach (const QNetworkInterface &iface, QNetworkInterface::allInterfaces()) {
+ foreach (const QNetworkAddressEntry netaddr, iface.addressEntries()) {
+ if (ipAddress.isInSubnet(netaddr.ip(), netaddr.prefixLength())) {
+ return true;
+ }
+ }
+ }
+ }
+ }
if (isIpAddress && ipAddress.isInSubnet(QHostAddress::parseSubnet(entry))) {
return true; // excluded
} else {
diff --git a/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
index 490f5df..d82c6f2 100644
--- a/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
+++ b/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
@@ -131,6 +131,10 @@ void tst_QNetworkProxyFactory::systemProxyForQuery_data()
QTest::newRow("imap") << (int)QNetworkProxyQuery::TcpSocket << QUrl() << QString() << QString("qt-project.org") << 0 << (int)QNetworkProxy::TunnelingCapability;
QTest::newRow("autobind-server") << (int)QNetworkProxyQuery::TcpServer << QUrl() << QString() << QString() << 0 << (int)QNetworkProxy::ListeningCapability;
QTest::newRow("web-server") << (int)QNetworkProxyQuery::TcpServer << QUrl() << QString() << QString() << 80 << (int)QNetworkProxy::ListeningCapability;
+ //windows: these should be bypassed if "bypass proxy server for local addresses" is ticked
+ foreach (QHostAddress address, QNetworkInterface::allAddresses()) {
+ QTest::newRow(qPrintable(address.toString())) << (int)QNetworkProxyQuery::TcpSocket << QUrl() << QString() << address.toString() << 0 << 0;
+ }
//UDP
QTest::newRow("udp") << (int)QNetworkProxyQuery::UdpSocket << QUrl() << QString() << QString() << 0 << (int)QNetworkProxy::UdpTunnelingCapability;