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 112979 - Teach gnome-vfs HTTP method to not use the proxy for some hosts
Teach gnome-vfs HTTP method to not use the proxy for some hosts
Status: RESOLVED FIXED
Product: gnome-vfs
Classification: Deprecated
Component: Module: http
cvs (head)
Other Linux
: Normal normal
: 2.6
Assigned To: Malcolm Tredinnick
Malcolm Tredinnick
Depends on:
Blocks: 44098 113219 113221 113222
 
 
Reported: 2003-05-14 12:48 UTC by Malcolm Tredinnick
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Ignore some hosts when dealing with a proxy (13.32 KB, patch)
2003-05-19 13:21 UTC, Malcolm Tredinnick
none Details | Review
New patch incorporating review comments (12.88 KB, patch)
2003-05-20 16:03 UTC, Malcolm Tredinnick
none Details | Review

Description Malcolm Tredinnick 2003-05-14 12:48:46 UTC
This is the technical portion of bug #44098: respecting the contents of a
gconf key which specifies which hosts to access directly (i.e. not via the
configured HTTP proxy). I have started to work on this one.

My current plan is to allow the following ignorable host specifications:
   - fully qualified domain names (e.g. localhost, foo.bar.com)
   - domain name suffixes (e.g. *.bar.com)
   - IP addresses (192.168.0.1, 1:2:3::::5)
   - IP networks (192.168.0.0, 192.168.128.0/17 -- in the first case, the
netmask will be deduced from the class of the IP address).
Comment 1 Christophe Fergeau 2003-05-14 13:09:30 UTC
It might be worth also taking into account IPv6 addresses in your implementation.
Comment 2 Malcolm Tredinnick 2003-05-14 13:17:21 UTC
Yes, agreed. This is what I was hinting at with the 1:2:3:::::5 IP
address above (except that I left out a colon). :-)
Comment 3 Christophe Fergeau 2003-05-14 13:36:05 UTC
Ooops, sorry, it was buried in the ipv4 addresses and I didn't notice it

/me goes to buy some new eyes ;)
Comment 4 Alexander Larsson 2003-05-16 13:44:13 UTC
go malcolm!
Comment 5 Malcolm Tredinnick 2003-05-19 13:21:13 UTC
Created attachment 16629 [details] [review]
Ignore some hosts when dealing with a proxy
Comment 6 Malcolm Tredinnick 2003-05-19 13:24:12 UTC
This patch implements more or less everything that is promised and I
have tested it for a few situations (ph34r my IPv6 usermode linux
skills, d00dz! My brain hurts after setting all that up).

It _really_ needs a review though, since it feels very messy. All the
netmask messing around looks awkward, so rip into it and point out
what obvious function I am not using.
Comment 7 Christophe Fergeau 2003-05-19 14:47:04 UTC
I haven't read the patch carefully yet, but I already have a small nit ;)
For the type field of struct ProxyHostAddr, some 'IPv6' and 'IPv4' constants  (some #define or enum) would be more readable than the hardcoded 4 and 6 imo.
Comment 8 Alexander Larsson 2003-05-20 07:41:14 UTC
I had a quick look, and it looks good.
Some comments though:

Why are you doing the massive g_strdup_printf stuff to calculate the
mask from the width? Can't you just use (~0)<<width or something.

Why do you need this:
+		else {
+			inet_pton (AF_INET, "255.255.255.255", &mask);
+		}
I didn't see mask used in that case.

You're not correctly handling IPv6 addresses that are just wrapped
IPv4 addresses. I.E. ::ff:xx:xx:xx:xx need to match xxx.xxx.xxx.xxx in
the ignore list.

Also, I'm slightly worried about the case where you have IPv6
addresses in the ignore list, but log in on a box with !HAVE_IPV6,
although handling the IPv6 address like a hostname *should* work.
Comment 9 Malcolm Tredinnick 2003-05-20 12:59:12 UTC
Thanks for the review, guys. Addressing the comments in order:

Christophe: 
- agreed. I will make an enum with suitably named entries.

Alex:
- The width calculation: I need to pass a dotted quad to inet_pton, so
a certain amount of messing around seemed to be required. Are you
suggesting I just compute the value directly and then use ntohl() and
poke inside a struct in_addr directly? That should work, I guess and
it will make things a lot neater. The IPv6 case reduces to four tests
(struct in6_addr is an array of four uint32's) then.

- The 255.255.255.255 mask is so that we can be sure that the mask
structure is always filled in and so when comparing the IP addresses
later on, it will always be legal to do (in.s_addr & mask.s_addr).
However, the &mask bit is a blunder: it should be &elt->mask.

- I will fix IPv6-wrapped IPv4 addresses. I had forgotten about his case.

- I had intended for things to just fall through to the hostname case
when we encounter an IPv6 address without IPv6 support. The problem
with any other way of handling it is that we don't have the functions
available to process the addresses (or even detect that they are
IPv6). I will add a comment to clarify this to the next patch.
Comment 10 Malcolm Tredinnick 2003-05-20 16:03:55 UTC
Created attachment 16668 [details] [review]
New patch incorporating review comments
Comment 11 Alexander Larsson 2003-05-21 07:20:24 UTC
Looks good from a quick look.
I don't know if it matters much, but couldn't yo do the IPv6 mask
calculation like this:
for (i=0; i < width/32; i++)
     mask[i] = 0xffff;
mask[i] = htonl (~0 << width % 32);
Comment 12 Christophe Fergeau 2003-05-21 11:38:32 UTC
+        if (!has_error) {
+            gchar *dst = g_new0 (gchar, INET_ADDRSTRLEN);
+    
+            gl_ignore_addrs = g_slist_append (gl_ignore_addrs, elt);
+            DEBUG_HTTP (("Host %s/%s does not go through proxy.",
+                    hostname,
+                    inet_ntop(AF_INET, &elt->mask, dst, INET_ADDRSTRLEN)));
+            g_free (dst);
+        }

dst seems to only be used in the DEBUG_HTTP statement.
Could you #ifdef out the g_new0/g_free when DEBUG_HTTP_ENABLE isn't defined ?
Comment 13 Malcolm Tredinnick 2003-05-21 22:51:18 UTC
I can make both those changes. However, Christophe, your one will make
the code less readable by scattering a couple of #ifdefs around and
any decent compiler is going to optimise away the use of dst in that
case anyway, since it can see that it is not used anywhere else.
Still, it's not that important to worry about so I will make the change.
Comment 14 Malcolm Tredinnick 2003-05-21 22:57:45 UTC
Whoops. The fragment that Christophe posted is broken anyway. It will
not print a decent debug message when we are adding an IPv6 host. I'll
rewrite that bit completely (maybe make it an external function call
that can be #ifdef'd away in the non-debug case).
Comment 15 Christophe Fergeau 2003-05-22 07:48:03 UTC
#ifdef ENABLE_HTTP_DEBUG
        gchar *dst = g_new0 (gchar, INET_ADDRSTRLEN);
        printf (("Host %s/%s does not go through proxy.",
        hostname,
        inet_ntop(AF_INET, &elt->mask, dst, INET_ADDRSTRLEN)));
        g_free (dst);
#endif
gl_ignore_addrs = g_slist_append (gl_ignore_addrs, elt);

seems readable enough to me, but that's your code, feel free to do what you think is better ;)
Comment 16 Christophe Fergeau 2003-06-08 20:17:28 UTC
What's up with that bug ? Feature freeze is on monday (though I'm in
favour of considering it as a bug in the current proxy support rather
than a feature ;)
Comment 17 Malcolm Tredinnick 2003-06-09 00:36:25 UTC
I thought I was waiting on you guys. So far Alex has only indicated
that he has had a "quick look". Do you want another patch
incorporating the trivial changes mentioned above or what?

Note, however, that it is *highly_*unlikely I will get the work done
for 44098 today. Work has been too busy the last couple of weeks for
me to devote much time to this. I am going to try to do it, but it may
not make it, which will render this bug pretty moot for 2.4, since
nobody will be able to use it. :-(
Comment 18 Christophe Fergeau 2003-06-09 10:20:44 UTC
Oh, I thought you'd post a slightly updated patch since you said the
debug case in your last one didn't work. Even if it has no UI yet, I
think it's worth having it in, app writers know which key they are
supposed to use to get the hosts which shouldn't be proxied, and
people who really need this feature can set the key manually.
Comment 19 Alexander Larsson 2003-06-10 08:48:16 UTC
I'm fine with it going in as is. We can do more tuning later if needed.
Comment 20 Alexander Larsson 2003-09-16 14:20:02 UTC
is in.