[prev in list] [next in list] [prev in thread] [next in thread]
List: subversion-cvs
Subject: svn commit: rev 1607 - trunk/subversion/libsvn_subr trunk/subversion/libsvn_ra_dav
From: kfogel () tigris ! org
Date: 2002-03-29 2:46:48
[Download RAW message or body]
Author: kfogel
Date: 2002-03-29 02:46 GMT
New Revision: 1607
Modified:
trunk/subversion/libsvn_ra_dav/session.c
trunk/subversion/libsvn_subr/config_file.c
Log:
Support the `no_proxy' exception to proxy defaults:
* subversion/libsvn_ra_dav/session.c
(match_in_list): New func.
(search_groups): Replace inline code with call to match_in_list.
(get_proxy): Recognize `no_proxy' for defaults.
* subversion/libsvn_subr/config_file.c
(svn_config_ensure): Mention the "no_proxy" trick in the template
for proxies files.
Modified: trunk/subversion/libsvn_subr/config_file.c
==============================================================================
--- trunk/subversion/libsvn_subr/config_file.c (original)
+++ trunk/subversion/libsvn_subr/config_file.c Thu Mar 28 20:46:43 2002
@@ -634,7 +634,12 @@
"### probably just want to put that server's information in\n"
"### the `default' section and not bother with `groups' or\n"
"### any other sections.\n"
+ "### \n"
+ "### If you go through a proxy for all but a few sites, you can\n"
+ "### list those exceptions under `no_proxy', see below. This only\n"
+ "### overrides defaults, not explicitly matched proxies.\n"
"# [default]\n"
+ "# no_proxy = *.exception.com, www.internal-site.org\n"
"# host = defaultproxy.whatever.com\n"
"# port = 7000\n"
"# username = defaultusername\n"
Modified: trunk/subversion/libsvn_ra_dav/session.c
==============================================================================
--- trunk/subversion/libsvn_ra_dav/session.c (original)
+++ trunk/subversion/libsvn_ra_dav/session.c Thu Mar 28 20:46:43 2002
@@ -131,44 +131,60 @@
};
+/* Return true iff STR matches any of the elements of LIST, a
+ * comma-separated list of one or more hostname-style strings,
+ * possibly using wildcards; else return false.
+ *
+ * Use POOL for temporary allocation.
+ *
+ * The following are all valid LISTs
+ *
+ * "svn.collab.net"
+ * "svn.collab.net, *.tigris.org"
+ * "*.tigris.org, *.collab.net, sp.red-bean.com"
+ *
+ * and the STR "svn.collab.net" would match all of them.
+ */
+static svn_boolean_t match_in_list(const char *str,
+ const char *list,
+ apr_pool_t *pool)
+{
+ apr_array_header_t *subvals = svn_cstring_split(list, ',', TRUE, pool);
+ int i;
+
+ for (i = 0; i < subvals->nelts; i++)
+ {
+ const char *this_pattern = APR_ARRAY_IDX(subvals, i, char *);
+ if (APR_STATUS_IS_SUCCESS(apr_fnmatch(this_pattern, str, 0)))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
/* This is an `svn_config_enumerator_t' function, and BATON is a
* `struct search_groups_baton *'.
*
+ * VALUE is in the same format as the LIST param of match_in_list().
* If an element of VALUE matches BATON->requested_host, then set
* BATON->proxy_group to a copy of NAME allocated in BATON->pool, and
- * return false (to end the enumeration).
- *
- * VALUE is a comma-separated list of one or more expressions to match
- * a host, possibly using wildcards. For example, these are all
- * valid VALUEs:
- *
- * "svn.collab.net"
- * "svn.collab.net, *.tigris.org"
- * "*.collab.net, *.tigris.org, sp.red-bean.com"
+ * return false, to end the enumeration.
*
- * If no match, return true (to continue enumerating).
+ * If no match, return true, to continue enumerating.
*/
static svn_boolean_t search_groups(const char *name,
const char *value,
void *baton)
{
struct search_groups_baton *b = baton;
- apr_array_header_t *subvals = svn_cstring_split(value, ',', TRUE, b->pool);
- int j;
- for (j = 0; j < subvals->nelts; j++)
+ if (match_in_list(b->requested_host, value, b->pool))
{
- const char *this_pattern = APR_ARRAY_IDX(subvals, j, char *);
- apr_status_t apr_err = apr_fnmatch(this_pattern, b->requested_host, 0);
-
- if (APR_STATUS_IS_SUCCESS(apr_err))
- {
- b->proxy_group = apr_pstrdup(b->pool, name);
- return FALSE;
- }
+ b->proxy_group = apr_pstrdup(b->pool, name);
+ return FALSE;
}
-
- return TRUE;
+ else
+ return TRUE;
}
@@ -188,15 +204,27 @@
{
struct search_groups_baton gb;
svn_config_t *cfg;
+ const char *exceptions;
const char *port_str;
+ /* If we find nothing, default to nulls. */
+ *proxy_host = NULL;
+ *proxy_port = -1;
+ *proxy_username = NULL;
+ *proxy_password = NULL;
+
SVN_ERR( svn_config_read_proxies(&cfg, pool) );
- /* Start out with defaults. */
- svn_config_get(cfg, proxy_host, "default", "host", NULL);
- svn_config_get(cfg, &port_str, "default", "port", NULL);
- svn_config_get(cfg, proxy_username, "default", "username", NULL);
- svn_config_get(cfg, proxy_password, "default", "password", NULL);
+ /* If there are defaults, use them, but only if the requested host
+ is not one of the exceptions to the defaults. */
+ svn_config_get(cfg, &exceptions, "default", "no_proxy", NULL);
+ if ((! exceptions) || (! match_in_list(requested_host, exceptions, pool)))
+ {
+ svn_config_get(cfg, proxy_host, "default", "host", NULL);
+ svn_config_get(cfg, &port_str, "default", "port", NULL);
+ svn_config_get(cfg, proxy_username, "default", "username", NULL);
+ svn_config_get(cfg, proxy_password, "default", "password", NULL);
+ }
/* Search for a proxy pattern specific to this host. */
gb.requested_host = requested_host;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic