After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 621249 - [PATCH] Use the system proxy settings
[PATCH] Use the system proxy settings
Status: RESOLVED FIXED
Product: tomboy
Classification: Applications
Component: General
1.3.x
Other All
: Normal enhancement
: 1.4.0
Assigned To: Tomboy Maintainers
Tomboy Maintainers
: 604016 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-06-10 21:22 UTC by Alejandro J. Cura
Modified: 2011-07-26 08:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Use the system proxy settings via libproxy (10.02 KB, patch)
2010-06-10 21:22 UTC, Alejandro J. Cura
committed Details | Review
Requested fixes (2.07 KB, patch)
2010-06-21 21:41 UTC, Alejandro J. Cura
committed Details | Review

Description Alejandro J. Cura 2010-06-10 21:22:52 UTC
Created attachment 163334 [details] [review]
Use the system proxy settings via libproxy

This patch uses libproxy (if installed) to get at the proxy configuration in all three major platforms, in order to setup the http client that WebSyncService uses. Since libproxy does not (yet) support getting the optional proxy credentials, this patch gets the credentials from the system proxy settings in GConf or from the tomboy config xml if GConf on other systems.

According to http://code.google.com/p/libproxy/wiki/Roadmap getting the proxy credentials is a feature planned for the next version (0.5) of libproxy.
Comment 1 Sandy Armstrong 2010-06-21 16:21:55 UTC
*** Bug 604016 has been marked as a duplicate of this bug. ***
Comment 2 Sandy Armstrong 2010-06-21 16:31:23 UTC
Review of attachment 163334 [details] [review]:

Overall looks good.  Some minor whitespace issues, and one question regarding scheme checking (keep in mind I know nothing about proxies, have never really used them).

::: Tomboy/Addins/WebSyncService/Api/ProxiedWebRequest.cs
@@ +21,3 @@
+			if (useLibProxy) {
+				try {
+					ApplyProxy(webRequest, uri);

whitespace around (

@@ +23,3 @@
+					ApplyProxy(webRequest, uri);
+
+					Console.WriteLine("WARNING: libproxy not installed");

Please use the Logger class instead of Console, and fix whitespace around (

@@ +34,3 @@
+		{
+			ProxyFactory pf = new LibProxy.ProxyFactory();
+			string[] proxies = pf.GetProxies(uri);

whitespace around (

@@ +37,3 @@
+			
+			foreach (string proxy in proxies) {
+				Uri proxyUri=new Uri(proxy);

whitespace around = and (

@@ +41,3 @@
+				if (scheme == "direct") {
+					break;
+				} else if (scheme == "http" || scheme == "https") {

Couldn't the user have different proxies for http and https?  Should this be checked against the URI?

In fact, maybe the first thing to do should be to extract the scheme from the URI, and then look for a libproxy proxy set up for that scheme?

@@ +44,3 @@
+					WebProxy webProxy = new WebProxy();
+					
+					if (UseAuthentication()) {

whitespace around (

@@ +46,3 @@
+					if (UseAuthentication()) {
+						ICredentials credentials = 
+							new NetworkCredential(GetAuthUser(), GetAuthPass());

whitespace around (
Comment 3 Alejandro J. Cura 2010-06-21 21:40:30 UTC
(In reply to comment #2)
> Review of attachment 163334 [details] [review]:
> 
> Overall looks good.  Some minor whitespace issues, and one question regarding
> scheme checking (keep in mind I know nothing about proxies, have never really
> used them).
> 
> @@ +41,3 @@
> +                if (scheme == "direct") {
> +                    break;
> +                } else if (scheme == "http" || scheme == "https") {
> 
> Couldn't the user have different proxies for http and https?  Should this be
> checked against the URI?
> 
> In fact, maybe the first thing to do should be to extract the scheme from the
> URI, and then look for a libproxy proxy set up for that scheme?

Hi, thanks for the review. I'm attaching a second patch with the suggested corrections, and I'm sorry for the style mismatches; my brain is kinda hardcoded for Python whitespace style rules :-)

Regarding proxies and uris: Yes, the user may have different proxies for http and https, and the system dependent selection of those proxies is handled by libproxy when pf.GetProxies is called with the "destination uri" that needs to be accessed. This means that a http proxy can be setup to reach https uris, and viceversa.

The return value of GetProxies is a list of some "proxy uris" that are able to reach the "destination uri" that needs to be accessed; it's over that list of proxy uris that this code goes over, trying to find a proxy uri whose scheme is "direct" (ie, no proxy) or one that WebProxy can handle (http or https). If the proxy uri has some other scheme (let's say socks4), the code has to skip it.
Comment 4 Alejandro J. Cura 2010-06-21 21:41:31 UTC
Created attachment 164252 [details] [review]
Requested fixes
Comment 5 Sandy Armstrong 2010-06-21 22:12:38 UTC
Thanks for taking the time to fix this, Alejandro. :-)  Great work!
Comment 6 Dominique Leuenberger 2010-07-05 16:15:27 UTC
(In reply to comment #0)

> According to http://code.google.com/p/libproxy/wiki/Roadmap getting the proxy
> credentials is a feature planned for the next version (0.5) of libproxy.

Hi,

A short 'notice' on the 'getting proxy credentials': libproxy DOES get the credentials from gconf since version 0.4.0. Just 'setting' them is not supported yet.

0.4.0 has been released on Feb 25 2010.
Comment 7 Leho Kraav (@lkraav :macmaN) 2011-07-26 08:43:12 UTC
libproxy is crashing tomboy at least on linux:

 * https://bugzilla.gnome.org/show_bug.cgi?id=647701
 * http://bugs.sabayon.org/show_bug.cgi?id=2404

tested up to 1.7.2 here.