--- mod_limitipconn.c.org Wed Apr 30 14:57:33 2003 +++ mod_limitipconn.c Wed Apr 30 15:10:31 2003 @@ -44,6 +44,8 @@ checking */ array_header *excl_limit; /* array of MIME types to limit check; all other types are exempt */ + array_header *local_ip; /* array of local ip exempt from limit + checking */ } limitipconn_dir_config; static void *limitipconn_create_dir_config(pool *p, char *path) @@ -55,6 +57,7 @@ cfg->limit = 0; cfg->no_limit = ap_make_array(p, 0, sizeof(char *)); cfg->excl_limit = ap_make_array(p, 0, sizeof(char *)); + cfg->local_ip = ap_make_array(p, 0, sizeof(char *)); return (void *) cfg; } @@ -68,6 +71,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; @@ -109,6 +113,15 @@ return OK; } + /* Cycle through the local ip list; if the ip is local, + * return OK */ + for (i = 0; i < cfg->local_ip->nelts; i++) { + if ((ap_strcasecmp_match(address, localip[i]) == 0) + || (strncmp(localip[i], address, strlen(localip[i])) == 0)) { + return OK; + } + } + /* Cycle through the exempt list; if our content_type is exempt, * return OK */ for (i = 0; i < cfg->no_limit->nelts; i++) { @@ -219,6 +232,16 @@ return NULL; } +/* Parse the LocalIP directive */ +static const char *local_ip_config_cmd(cmd_parms *parms, void *mconfig, + const char *arg) +{ + limitipconn_dir_config *cfg = (limitipconn_dir_config *) mconfig; + + *(char **) ap_push_array(cfg->local_ip) = ap_pstrdup(parms->pool, arg); + return NULL; +} + /* Array describing structure of configuration directives */ static command_rec limitipconn_cmds[] = { {"MaxConnPerIP", limit_config_cmd, NULL, OR_LIMIT, TAKE1, @@ -227,6 +250,8 @@ "MIME types for which limit checking is disabled"}, {"OnlyIPLimit", excl_limit_config_cmd, NULL, OR_LIMIT, ITERATE, "restrict limit checking to these MIME types only"}, + {"LocalIP", local_ip_config_cmd, NULL, OR_LIMIT, ITERATE, + "no checking on local IP"}, {NULL}, };