Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-71604

Incomplete QNetworkProxyQuery created by QNativeSocketEngine

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.11.2, 5.12
    • None
    • Windows

    Description

      When the QNetworkSocketEngine (e.g. for QTCPSocket) checks if a proxy is used (QNativeSocketEnginePrivate::checkProxy) it passes an incomplete QNetworkProxyQuery to the QNetworkProxyFactory.
      This prevents the factory from using different proxy configurations depending on e.g. the peer hostname. For the system proxy on windows it leads to the proxy bypass being ignored, because the peer hostname is required to evaluate the bypass list.

      The following code shows the bug.

      #include <QCoreApplication>
      
      #include <QNetworkProxyFactory>
      #include <QTcpSocket>
      #include <QDebug>
      
      class MyFactory : public QNetworkProxyFactory
      {
      public:
      	virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery & query = QNetworkProxyQuery()) {
      		qDebug() << "Query: " << query.peerHostName() << ":" << query.peerPort();
      		return QList<QNetworkProxy>() << QNetworkProxy::NoProxy;
      	}
      };
      
      int main(int argc, char *argv[])
      {
      	QCoreApplication app(argc, argv);
      	QNetworkProxyFactory::setApplicationProxyFactory(new MyFactory());
      	QTcpSocket sock;
      	sock.connectToHost("192.0.2.1", 12345);
      
      	return app.exec();
      }
      

      The output is:
      Query: "192.0.2.1" : 12345
      Query: "" : -1
      The first line is originated in QAbstractSocketPrivate::resolveProxy.
      The second line in QNativeSocketEngine::connectToHost.

      For the second invocation of queryProxy the Query is only initialized with a type, but no hostname or port.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            cnn Qt Core & Network
            jvehlow jvehlow
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes