You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Lubomir Rintel <lk...@v3.sk> on 2014/03/19 11:04:16 UTC
[PATCH RESEND 3/4] mod_proxy: Split the NoProxy parameter parsing away
From: Lubomir Rintel <lu...@gooddata.com>
It is nice and could be reused by ProxyBlock.
---
modules/proxy/mod_proxy.c | 98 +++++++++++++++++++++++++----------------------
1 file changed, 53 insertions(+), 45 deletions(-)
diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c
index e027fd2..bfb48b5 100644
--- a/modules/proxy/mod_proxy.c
+++ b/modules/proxy/mod_proxy.c
@@ -1740,56 +1740,17 @@ static const char* cookie_domain(cmd_parms *cmd, void *dconf, const char *f,
return NULL;
}
-static const char *
- set_proxy_exclude(cmd_parms *parms, void *dummy, const char *arg)
-{
- server_rec *s = parms->server;
- proxy_server_conf *conf =
- ap_get_module_config(s->module_config, &proxy_module);
- struct noproxy_entry *new;
- struct noproxy_entry *list = (struct noproxy_entry *) conf->noproxies->elts;
- struct apr_sockaddr_t *addr;
- int found = 0;
- int i;
-
- /* Don't duplicate entries */
- for (i = 0; i < conf->noproxies->nelts; i++) {
- if (strcasecmp(arg, list[i].name) == 0) { /* ignore case for host names */
- found = 1;
- break;
- }
- }
-
- if (!found) {
- new = apr_array_push(conf->noproxies);
- new->name = arg;
- if (APR_SUCCESS == apr_sockaddr_info_get(&addr, new->name, APR_UNSPEC, 0, 0, parms->pool)) {
- new->addr = addr;
- }
- else {
- new->addr = NULL;
- }
- }
- return NULL;
-}
-
-
-/* Similar to set_proxy_exclude(), but defining directly connected hosts,
- * which should never be accessed via the configured ProxyRemote servers
- */
-static const char *
- set_proxy_dirconn(cmd_parms *parms, void *dummy, const char *arg)
+/* Add an entry to a NoProxy or ProxyBlock list */
+const char *
+ add_exclude_list(cmd_parms *parms, const char *arg, apr_array_header_t *array)
{
- server_rec *s = parms->server;
- proxy_server_conf *conf =
- ap_get_module_config(s->module_config, &proxy_module);
struct exclude_entry *New;
- struct exclude_entry *list = (struct exclude_entry *) conf->dirconn->elts;
+ struct exclude_entry *list = (struct exclude_entry *) array->elts;
int found = 0;
int i;
/* Don't duplicate entries */
- for (i = 0; i < conf->dirconn->nelts; i++) {
+ for (i = 0; i < array->nelts; i++) {
if (strcasecmp(arg, list[i].name) == 0) {
found = 1;
break;
@@ -1797,7 +1758,7 @@ static const char *
}
if (!found) {
- New = apr_array_push(conf->dirconn);
+ New = apr_array_push(array);
New->name = apr_pstrdup(parms->pool, arg);
New->hostaddr = NULL;
@@ -1834,6 +1795,53 @@ static const char *
}
static const char *
+ set_proxy_exclude(cmd_parms *parms, void *dummy, const char *arg)
+{
+ server_rec *s = parms->server;
+ proxy_server_conf *conf =
+ ap_get_module_config(s->module_config, &proxy_module);
+ struct noproxy_entry *new;
+ struct noproxy_entry *list = (struct noproxy_entry *) conf->noproxies->elts;
+ struct apr_sockaddr_t *addr;
+ int found = 0;
+ int i;
+
+ /* Don't duplicate entries */
+ for (i = 0; i < conf->noproxies->nelts; i++) {
+ if (strcasecmp(arg, list[i].name) == 0) { /* ignore case for host names */
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found) {
+ new = apr_array_push(conf->noproxies);
+ new->name = arg;
+ if (APR_SUCCESS == apr_sockaddr_info_get(&addr, new->name, APR_UNSPEC, 0, 0, parms->pool)) {
+ new->addr = addr;
+ }
+ else {
+ new->addr = NULL;
+ }
+ }
+ return NULL;
+}
+
+
+/* Similar to set_proxy_exclude(), but defining directly connected hosts,
+ * which should never be accessed via the configured ProxyRemote servers
+ */
+static const char *
+ set_proxy_dirconn(cmd_parms *parms, void *dummy, const char *arg)
+{
+ server_rec *s = parms->server;
+ proxy_server_conf *conf =
+ ap_get_module_config(s->module_config, &proxy_module);
+
+ return add_exclude_list(parms, arg, conf->dirconn);
+}
+
+static const char *
set_proxy_domain(cmd_parms *parms, void *dummy, const char *arg)
{
proxy_server_conf *psf =
--
1.8.3.1