- update to version 0.24

- add local IP exception patch [1]
  found on upstream (mod_limitipconn_local_IP_patch.diff)

PR:		ports/186281 [1]
Submitted by:	Tilghman Lesher <tlesher@mtadistributors.com>
Approved by:	Yuan-Chung Hsiao <ychsiao@gmail.com> (maintainer per PM)
This commit is contained in:
Olli Hauer 2014-02-02 15:57:13 +00:00
parent 2e1923da13
commit 137cfe65a7
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=342319
3 changed files with 96 additions and 5 deletions

View file

@ -2,8 +2,7 @@
# $FreeBSD$
PORTNAME= mod_limitipconn
PORTVERSION= 0.23
PORTREVISION= 3
PORTVERSION= 0.24
CATEGORIES= www
MASTER_SITES= http://dominia.org/djao/limit/
PKGNAMEPREFIX= ${APACHE_PKGNAMEPREFIX}
@ -15,7 +14,7 @@ COMMENT= Allows you to limit the number of simultaneous connexions
LICENSE= APACHE20
USE_APACHE= 22
USE_APACHE= 22+
USE_BZIP2= yes
AP_FAST_BUILD= yes

View file

@ -1,2 +1,2 @@
SHA256 (apache2/mod_limitipconn-0.23.tar.bz2) = eca35131e2d17b4499d7be13190cc0cdd5c82d83660b8bc96c79dc617defa6ec
SIZE (apache2/mod_limitipconn-0.23.tar.bz2) = 9851
SHA256 (apache2/mod_limitipconn-0.24.tar.bz2) = 69ca8fbf99d4e02db75e129df07d1604db771e9c10c1b199e2accaa96aec2a1f
SIZE (apache2/mod_limitipconn-0.24.tar.bz2) = 10150

View file

@ -0,0 +1,92 @@
--- ./mod_limitipconn.c.orig 2012-04-26 00:19:48.000000000 +0200
+++ ./mod_limitipconn.c 2014-02-02 16:47:28.000000000 +0100
@@ -42,6 +42,9 @@
/* array of MIME types to limit check; all other types are exempt */
apr_array_header_t *excl_limit;
+ apr_array_header_t *local_ip; /* array of local ip exempt from limit
+ checking */
+
} limitipconn_config;
static limitipconn_config *create_config(apr_pool_t *p)
@@ -53,6 +56,7 @@
cfg->limit = 0;
cfg->no_limit = apr_array_make(p, 0, sizeof(char *));
cfg->excl_limit = apr_array_make(p, 0, sizeof(char *));
+ cfg->local_ip = apr_array_make(p, 0, sizeof(char *));
return cfg;
}
@@ -75,6 +79,7 @@
/* convert Apache arrays to normal C arrays */
char **nolim = (char **) cfg->no_limit->elts;
char **exlim = (char **) cfg->excl_limit->elts;
+ char **localip = (char **) cfg->local_ip->elts;
const char *address;
@@ -112,7 +117,7 @@
/* Only check the MIME-type if we have MIME-type stuff in our config.
The extra subreq can be quite expensive. */
- if(cfg->no_limit->nelts > 0 || cfg->excl_limit->nelts > 0) {
+ if(cfg->no_limit->nelts > 0 || cfg->excl_limit->nelts > 0 || cfg->local_ip->nelts) {
/* Look up the Content-type of this request. We need a subrequest
* here since this module might be called before the URI has been
* translated into a MIME type. */
@@ -129,6 +134,20 @@
"mod_limitipconn: uri: %s Content-Type: %s",
r->uri, content_type);
+ /* Cycle through the local ip list; if the ip is local,
+ * return OK */
+
+ for (i = 0; i < cfg->local_ip->nelts; i++) {
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+ "mod_limitipconn: ip check: \"%s\" ? \"%s\"", address, localip[i]);
+ if ((ap_strcasecmp_match(address, localip[i]) == 0)
+ || (strncmp(localip[i], address, strlen(localip[i])) == 0)) {
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+ "mod_limitipconn: ip exempt: %s", address);
+ return DECLINED;
+ }
+ }
+
/* Cycle through the exempt list; if our content_type is exempt,
* return OK */
#if AP_MODULE_MAGIC_AT_LEAST(20090131, 0)
@@ -328,6 +347,24 @@
return NULL;
}
+/* Parse the LocalIP directive */
+static const char *local_ip_config_cmd(cmd_parms *parms, void *mconfig,
+ const char *arg)
+{
+ limitipconn_config *cfg = (limitipconn_config *) mconfig;
+ limitipconn_config *scfg = (limitipconn_config *)
+ ap_get_module_config(parms->server->module_config, &limitipconn_module);
+
+ if (parms->path != NULL) {
+ /* Per-directory context */
+ *(char **) apr_array_push(cfg->local_ip) = apr_pstrdup(parms->pool, arg);
+ } else {
+ /* global context */
+ *(char **) apr_array_push(scfg->local_ip) = apr_pstrdup(parms->pool, arg);
+ }
+ return NULL;
+}
+
/* Array describing structure of configuration directives */
static command_rec limitipconn_cmds[] = {
AP_INIT_TAKE1("MaxConnPerIP", limit_config_cmd, NULL, OR_LIMIT|RSRC_CONF,
@@ -336,6 +373,8 @@
"MIME types for which limit checking is disabled"),
AP_INIT_ITERATE("OnlyIPLimit", excl_limit_config_cmd, NULL,
OR_LIMIT|RSRC_CONF, "restrict limit checking to these MIME types only"),
+ AP_INIT_ITERATE("LocalIP", local_ip_config_cmd, NULL, OR_LIMIT|RSRC_CONF,
+ "no checking on local IP"),
{NULL},
};