Web lists-archives.com

Re: network connectivity with proxy




On Mon, Sep 10, 2018 at 10:31 PM Alexander Semke <alexander.semke@xxxxxx> wrote:
>
> Hi,
>
> in Knights and in LabPlot I realized recently, while being in a corporate
> network behind a proxy, that the connection to public internet servers is not
> possible. E.g. in Khights the connection to the FICS-server is done like
>
> QTcpSocket* socket = new QTcpSocket(this);
> socket->connectToHost(address, port);
>
> How to properly handle the proxy settings? Reading system settings (from the
> environment?) and calling QTcpSocket::setProxy() or
> QNetworkProxy::setApplicationProxy() somewhere  in main.cpp doesn't sound to
> me like the "standard way to do this".

If I am not mistaken Qt already looks in the environment variables for
http_proxy, https_proxy etc. etc. (I don't think Plasma sets those
from the KCM though). To that end a no-code solution is setting those.
Obviously that's not very integrated in plasma.

> In KDE's system settings there're already settings for the proxy. How to use
> them and how to deal with this on windows and mac os x where this is not
> available? Should the applications have this configuration in their settings?

There is KTcpSocket (in KIO). But at a glance I don't actually see the
class implementing proxy handling correctly, nor does it look
particularly well documented, so I am not sure it should be used.
So... maybe fix KTcpSocket first, then use it ;)

KProtocolManager is the way to get the proxy settings in your
application from which you can construct a QNetworkProxy and set that
either on an application level or per-socket (you should be able to
find some examples of that via lxr.kde.org).

That's not ideal I'd have to say though. On OSX and Windows figures
the proxy stuff out automatically as far as I know (KProtocolManager
would be falling back to QNetwork on those platforms I'd presume).

[1] https://api.kde.org/frameworks/kio/html/classKProtocolManager.html

HS