network connectivity with proxy

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

network connectivity with proxy

Alexander Semke-2
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".

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?


Regards,
Alexander


Reply | Threaded
Open this post in threaded view
|

Re: network connectivity with proxy

Harald Sitter-7
On Mon, Sep 10, 2018 at 10:31 PM Alexander Semke <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: network connectivity with proxy

Thiago Macieira
On Wednesday, 12 September 2018 04:17:35 PDT Harald Sitter wrote:
> 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.

The correct way is to configure your system properly. Qt will use libproxy and
will get the settings.

--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center



Reply | Threaded
Open this post in threaded view
|

Re: network connectivity with proxy

Albert Astals Cid-3
El divendres, 14 de setembre de 2018, a les 18:04:59 CEST, Thiago Macieira va escriure:
> On Wednesday, 12 September 2018 04:17:35 PDT Harald Sitter wrote:
> > 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.
>
> The correct way is to configure your system properly. Qt will use libproxy and
> will get the settings.

So this should be a bug reported against systemsettings or kded or something then?

Cheers,
  Albert


Reply | Threaded
Open this post in threaded view
|

Re: network connectivity with proxy

Christoph Feck-2
On 20.09.2018 00:03, Albert Astals Cid wrote:

> El divendres, 14 de setembre de 2018, a les 18:04:59 CEST, Thiago Macieira va escriure:
>> On Wednesday, 12 September 2018 04:17:35 PDT Harald Sitter wrote:
>>> 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.
>>
>> The correct way is to configure your system properly. Qt will use libproxy and
>> will get the settings.
>
> So this should be a bug reported against systemsettings or kded or something then?

libproxy can be compiled with KF5 support, so it can automatically read
the proxy settings that kcm_proxy writes. The problem is that this
support is/was disabled by default, because of
https://bugreports.qt.io/browse/QTBUG-52252

Distributions might need to check if they need to re-enable it.
Reply | Threaded
Open this post in threaded view
|

Re: network connectivity with proxy

Thiago Macieira
On Wednesday, 19 September 2018 15:20:27 PDT Christoph Feck wrote:
> On 20.09.2018 00:03, Albert Astals Cid wrote:
> > El divendres, 14 de setembre de 2018, a les 18:04:59 CEST, Thiago Macieira
va escriure:

> >> On Wednesday, 12 September 2018 04:17:35 PDT Harald Sitter wrote:
> >>> 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.
> >>
> >> The correct way is to configure your system properly. Qt will use
> >> libproxy and will get the settings.
> >
> > So this should be a bug reported against systemsettings or kded or
> > something then?
> libproxy can be compiled with KF5 support, so it can automatically read
> the proxy settings that kcm_proxy writes. The problem is that this
> support is/was disabled by default, because of
> https://bugreports.qt.io/browse/QTBUG-52252
>
> Distributions might need to check if they need to re-enable it.

libproxy tries to detect if you're running a Qt5 application.

In any case, I recommend using the pacrunner's libproxy instead of libproxy's
libproxy. The proxy settings won't be read from KDE's. Instead, they will be
centralised in the pacrunner daemon. KDE should provision it (it's just a D-
Bus call, plasma-nm can do it).

--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center