Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IP Aliasing with QWebView (Qt / C++)

Let’s see if you can shed some light on my problem. [C++ with Qt 5.2, using Qt Creator]

Situation: I’ve got a PC with several local IP addresses assigned to the same interface (IP Aliases). The router has different configurations regarding bandwidth, NAT, connections, etc., for each local IP. I’m integrating this Local IP-switching to some Qt apps, in particular to an app that offers a nice browsing experience using QWebView.

What I need I : To be able to change which local IP QWebView uses to get its requests out.

The only thing I've managed to do -just a patch- is to use STUNNEL to map localhost ports to remote hosts through different local IPs, and using QNetworkProxy to make QWebView use those localhost ports as proxies. Thing is, for some reason proxying like this apparently spawns some problems: The user can't see several YouTuve videos, only seeing static background and "An error has occurred". This doesn't happen when using NetworkProxyFactory::setUseSystemConfiguration(true), as every video can be seen perfectly.

The question would be: How can I manage IP aliases with Qt? If that's not possible, do you have any idea why proxying through STUNNEL is failing? Maybe other transparent tunneling software to try out?

In input is appreciated. Thanks in advance!

like image 379
lgvidal Avatar asked Jan 22 '14 16:01

lgvidal


1 Answers

QWebView using QNetworkAccessManager to deal with requests/responses. Only useful thing you can override is a virtual

QNetworkReply * QNetworkAccessManager::createRequest(Operation op, 
const QNetworkRequest & req, QIODevice * outgoingData = 0) [virtual protected]

which unfortunately is not really useful for your purposes..

As well I don't think the Bearer thing will work either.

So, depending on how bad you need this functionality I would look into making changes in QNetworkAccessManager to be able to pass list of allowed interfaces/ip addresses, so QTcpSocket it will bind itself to specified IP address.. and then set this AccessManager to WebView.

As far as I know specifying bind address is not supported for QNetworkAccessManager

like image 156
evilruff Avatar answered Oct 18 '22 11:10

evilruff