Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. QWebEnginePage is doing DNS queries locally, despite having a proxy set
Forum Updated to NodeBB v4.3 + New Features

QWebEnginePage is doing DNS queries locally, despite having a proxy set

Scheduled Pinned Locked Moved Unsolved QtWebEngine
1 Posts 1 Posters 231 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    andyduplain
    wrote on last edited by
    #1

    As a proof-of-concept I have set-up squid server on a Linux box and used ngrok to put it behind TLS. When I set this proxy up in Chrome (using Oxylabs Proxy Extension) I see no DNS queries happening locally, regardless of the site I visit (including the O365 auth page). However when using the same proxy set-up for my Qt app, I am seeing DNS queries on the proxy machine and DNS queries on the Windows machine.

    (I am using Wireshark to check for DNS queries on the Windows machine and tcpdump to check for DNS queries on the Linux machine)

    Is it possible to make QWebEngine act more like Chrome?

    Here is the code, which I think is pretty standard

    auto const& proxyHost = ...;
    auto const& proxyPort = ...;
    auto const& proxyUsername = ...;
    auto const& proxyPassword = ...;
    
    _networkProxy.setType(QNetworkProxy::HttpProxy);
    
    _networkProxy.setHostName(proxyHost);
    _networkProxy.setPort(quint16(proxyPort));
    _networkProxy.setUser(proxyUsername);
    _networkProxy.setPassword(proxyPassword);
    
    QNetworkProxy::setApplicationProxy(_networkProxy);
    
    auto const& authUrl = ...;
    
    _webProfile = new QWebEngineProfile(this);
    
    auto* settings = _webProfile->settings();
    settings->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, false);
    settings->setAttribute(QWebEngineSettings::LinksIncludedInFocusChain, false);
    settings->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, false);
    settings->setAttribute(QWebEngineSettings::NavigateOnDropEnabled, false);
    
    _webView = new QWebEngineView(this);
    _webPage = new QWebEnginePage(_webProfile, this);
    _webView->setPage(_webPage);
    
    auto* gridLayout = new QGridLayout;
    gridLayout->setContentsMargins(0, 0, 0, 0);
    gridLayout->addWidget(_webView);
    setLayout(gridLayout);
    
    _webPage->load(authUrl);
    
    show();
    setFocus();
    

    Is there anything more I can do to make sure the DNS queries are not leaked locally?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved