Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Mar 2007 13:23:03 GMT
From:      Alexander Pohoyda<alexander.pohoyda@gmx.net>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/110388: Missing NO_PROXY support in fetch(3)
Message-ID:  <200703161323.l2GDN3D4084352@www.freebsd.org>
Resent-Message-ID: <200703161330.l2GDU2Za043466@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         110388
>Category:       misc
>Synopsis:       Missing NO_PROXY support in fetch(3)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 16 13:30:01 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Alexander Pohoyda
>Release:        7.0
>Organization:
SAP AG
>Environment:
There is no problem. This is a feature request.
>Description:
fetch(3) tool, which uses the libfetch library, supports HTTP_PROXY and FTP_PROXY env. variables.  However, if the *_PROXY variable is set, there's no way to exclude some domain name suffixes from being requested over that proxy.
This is very annoying.

>How-To-Repeat:
$ setenv HTTP_PROXY "proxy:8080"
$ fetch http://some-remote.machine/some-file
$ fetch http://local-machine/file

The first fetch works, because we must use the proxy to request the external pages, but the second fetch does not work.

>Fix:
Please apply the attached patch.


Patch attached with submission follows:

--- ftp.c.orig	Fri Mar 16 13:56:09 2007
+++ ftp.c	Fri Mar 16 14:08:36 2007
@@ -924,6 +924,22 @@
 {
 	conn_t *conn;
 	int oflag;
+	char *no_proxy, *no_proxy_item;
+	size_t b, s;
+
+	if ((no_proxy = getenv("NO_PROXY")) != NULL) {
+		b = strlen(url->host);
+		while ((no_proxy_item = strsep(&no_proxy, ",")) != NULL) {
+			s = strlen(no_proxy_item);
+			if (b > s && strcasecmp(url->host + b - s,
+						no_proxy_item) == 0) {
+				/* disable proxy */
+				fetchFreeURL(purl);
+				purl = NULL;
+				break;
+			}
+		}
+	}
 
 	/* check if we should use HTTP instead */
 	if (purl && strcasecmp(purl->scheme, SCHEME_HTTP) == 0) {
--- http.c.orig	Fri Mar 16 13:56:04 2007
+++ http.c	Fri Mar 16 14:06:32 2007
@@ -779,6 +779,22 @@
 	FILE *f;
 	hdr_t h;
 	char hbuf[MAXHOSTNAMELEN + 7], *host;
+	char *no_proxy, *no_proxy_item;
+	size_t b, s;
+
+	if ((no_proxy = getenv("NO_PROXY")) != NULL) {
+		b = strlen(URL->host);
+		while ((no_proxy_item = strsep(&no_proxy, ",")) != NULL) {
+			s = strlen(no_proxy_item);
+			if (b > s && strcasecmp(URL->host + b - s,
+						no_proxy_item) == 0) {
+				/* disable proxy */
+				fetchFreeURL(purl);
+				purl = NULL;
+				break;
+			}
+		}
+	}
 
 	direct = CHECK_FLAG('d');
 	noredirect = CHECK_FLAG('A');

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200703161323.l2GDN3D4084352>