httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lubomir Rintel <lkund...@v3.sk>
Subject [PATCH 56152 3/4] mod_proxy: Split the NoProxy parameter parsing away
Date Tue, 11 Mar 2014 14:00:38 GMT
From: Lubomir Rintel <lubo.rintel@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 e7c78ee..bd3bf82 100644
--- a/modules/proxy/mod_proxy.c
+++ b/modules/proxy/mod_proxy.c
@@ -1723,56 +1723,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;
@@ -1780,7 +1741,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;
 
@@ -1817,6 +1778,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


Mime
View raw message