From fffc900f78a191970c4eebced9c1af016a9ea6f4 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 20 Apr 2012 15:04:29 +0100 Subject: 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 Reviewed-by: Thiago Macieira --- src/network/kernel/qnetworkproxy_win.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/network') diff --git a/src/network/kernel/qnetworkproxy_win.cpp b/src/network/kernel/qnetworkproxy_win.cpp index c6efa7d93f..cb137f8b76 100644 --- a/src/network/kernel/qnetworkproxy_win.cpp +++ b/src/network/kernel/qnetworkproxy_win.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -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.isLoopback()) + return true; + // does it match the list of exclusions? foreach (const QString &entry, bypassList) { - if (isSimple && entry == QLatin1String("")) - return true; + if (entry == QLatin1String("")) { + 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 { -- cgit v1.2.3