You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Rodent of Unusual Size <Ke...@Golux.Com> on 1999/02/10 21:39:48 UTC

[PATCH] Merge RefererIgnore into mod_log_config

The attached patch should be quite low impact, but allow us to
get rid of mod_log_agent and mod_log_referer, since their other
capabilities are already available in mod_log_config.

I've been toying with the idea of adding a RefererIgnoreMatch
that uses ap_fnmatch() rather than a straight strcmp(), but I
wanted to float this one here first.
-- 
#ken    P-)}

Ken Coar                    <http://Web.Golux.Com/coar/>
Apache Group member         <http://www.apache.org/>
"Apache Server for Dummies" <http://Web.Golux.Com/coar/ASFD/>

Index: mod_log_config.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_log_config.c,v
retrieving revision 1.72
diff -u -r1.72 mod_log_config.c
--- mod_log_config.c	1999/02/02 16:21:20	1.72
+++ mod_log_config.c	1999/02/10 20:35:51
@@ -219,6 +219,8 @@
     array_header *config_logs;
     array_header *server_config_logs;
     table *formats;
+    int ignore_referers;
+    array_header *referer_list;
 } multi_log_state;
 
 /*
@@ -752,10 +754,27 @@
 static int multi_log_transaction(request_rec *r)
 {
     multi_log_state *mls = ap_get_module_config(r->server->module_config,
-                                             &config_log_module);
+						&config_log_module);
     config_log_state *clsarray;
     int i;
 
+    /*
+     * See if there are any Referer: values we're supposed to ignore.
+     */
+    if (mls->ignore_referers != 0) {
+	const char *referer = ap_table_get(r->headers_in, "Referer");
+	if (referer != NULL) {
+	    char **candidate = (char **) mls->referer_list->elts;
+	    for (i = 0; i < mls->referer_list->nelts; ++i) {
+		if (strcmp(referer, candidate[i]) == 0) {
+		    return OK;
+		}
+	    }
+	}
+    }
+    /*
+     * Continue and log this transaction..
+     */
     if (mls->config_logs->nelts) {
         clsarray = (config_log_state *) mls->config_logs->elts;
         for (i = 0; i < mls->config_logs->nelts; ++i) {
@@ -791,6 +810,8 @@
     mls->server_config_logs = NULL;
     mls->formats = ap_make_table(p, 4);
     ap_table_setn(mls->formats, "CLF", DEFAULT_LOG_FORMAT);
+    mls->ignore_referers = 0;
+    mls->referer_list = NULL;
 
     return mls;
 }
@@ -812,6 +833,10 @@
         add->default_format = base->default_format;
     }
     add->formats = ap_overlay_tables(p, base->formats, add->formats);
+    add->ignore_referers = (add->ignore_referers != 0)
+                           ? add->ignore_referers
+	                   : base->ignore_referers;
+    ap_array_cat(add->referer_list, base->referer_list);
 
     return add;
 }
@@ -844,6 +869,22 @@
     return err_string;
 }
 
+static const char *add_referer_ignore(cmd_parms *cmd, void *mconfig,
+				      char *word1)
+{
+    multi_log_state *mls = ap_get_module_config(cmd->server->module_config,
+						&config_log_module);
+    char **ignore_uri;
+
+    mls->ignore_referers++;
+    if (mls->referer_list == NULL) {
+	mls->referer_list = ap_make_array(cmd->pool, 4, sizeof(char *));
+    }
+    ignore_uri = (char **) ap_push_array(mls->referer_list);
+    *ignore_uri = ap_pstrdup(cmd->pool, word1);
+    return NULL;
+}
+
 static const char *add_custom_log(cmd_parms *cmd, void *dummy, char *fn,
                                   char *fmt)
 {
@@ -886,6 +927,8 @@
      "a log format string (see docs) and an optional format name"},
     {"CookieLog", set_cookie_log, NULL, RSRC_CONF, TAKE1,
      "the filename of the cookie log"},
+    {"RefererIgnore", add_referer_ignore, NULL, RSRC_CONF, ITERATE,
+     "referer URLs to ignore"},
     {NULL}
 };

Re: [PATCH] Merge RefererIgnore into mod_log_config

Posted by Brian Behlendorf <br...@hyperreal.org>.
On Wed, 10 Feb 1999, Rodent of Unusual Size wrote:
> As for RefererIgnore.. one of the points here is to get *rid* of
> mod_log_referer.  Which means making its exact functionality
> available elsewhere.  

Why do we want to get rid of them?  I don't compile them in, they don't
bother me, I don't bother them.  :)

	Brian




Re: [PATCH] Merge RefererIgnore into mod_log_config

Posted by Dean Gaudet <dg...@arctic.org>.
On Wed, 10 Feb 1999, Rodent of Unusual Size wrote:

> but I'll leave the RefererIgnore in as is; mod_rewrite is a
> lot of bloat if this is the only reason you want it.  (Again,
> it's a wash if you're already using mod_rewrite.)

mod_setenvif

Dean


Re: [PATCH] Merge RefererIgnore into mod_log_config

Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
Dean Gaudet wrote:
> 
> No my opinion hasn't changed, I have outstanding complaints with adding
> unneeded functionality to mod_log_config.  Piped logs solve this and all
> the other dozens of logging requests that keep recurring just fine.

And my opinion hasn't changed either.. :-) Piped logs are great for
this IFF you don't mind having another process hanging around just
to parse and throw away the stuff your server spent resources logging
unnecessarily.  For log splitting and transformations I agree 100%;
for log/don't log decisions, I think the server is the correct place.

> On Wed, 10 Feb 1999, Rodent of Unusual Size wrote:
> 
> > +    int ignore_referers;
> > +    array_header *referer_list;
> 
> You could test referer_list->nelts rather than keeping a separate
> ignore_referers member.

True.  I was thinking of memory, in terms of not creating the
array unnecessarily.  At potentially one array per server,
it's probably a wash.  With 500 vhosts, it's 500*sizeof(int)
versus 500*sizeof(array_header)+2000*sizeof(char *) total, plus
pointer fetching to check the field.  NBD.

> > +    {"RefererIgnore", add_referer_ignore, NULL, RSRC_CONF, ITERATE,
> > +     "referer URLs to ignore"},
> 
> Assuming that nobody is going to listen to my advocation of KISS I'd much
> rather see you test for the presence of a note or environment variable.
> There's no need to implement "RefererIgnore" and "RefererIgnoreMatch",
> mod_rewrite can set env variables just fine.

I think part of the issue is that not everyone agrees that your
answer is so S. :-)

As for RefererIgnore.. one of the points here is to get *rid* of
mod_log_referer.  Which means making its exact functionality
available elsewhere.  (These were the arguments that kept it
from being removed before.)  But I'd prefer the flexibility of
envariables myself.  So scratch the RefererIgnoreMatch idea,
but I'll leave the RefererIgnore in as is; mod_rewrite is a
lot of bloat if this is the only reason you want it.  (Again,
it's a wash if you're already using mod_rewrite.)
-- 
#ken    P-)}

Ken Coar                    <http://Web.Golux.Com/coar/>
Apache Group member         <http://www.apache.org/>
"Apache Server for Dummies" <http://Web.Golux.Com/coar/ASFD/>

Re: [PATCH] Merge RefererIgnore into mod_log_config

Posted by Dean Gaudet <dg...@arctic.org>.
No my opinion hasn't changed, I have outstanding complaints with adding
unneeded functionality to mod_log_config.  Piped logs solve this and all
the other dozens of logging requests that keep recurring just fine.

On Wed, 10 Feb 1999, Rodent of Unusual Size wrote:

> +    int ignore_referers;
> +    array_header *referer_list;

You could test referer_list->nelts rather than keeping a separate
ignore_referers member.

> +    {"RefererIgnore", add_referer_ignore, NULL, RSRC_CONF, ITERATE,
> +     "referer URLs to ignore"},

Assuming that nobody is going to listen to my advocation of KISS I'd much
rather see you test for the presence of a note or environment variable.
There's no need to implement "RefererIgnore" and "RefererIgnoreMatch",
mod_rewrite can set env variables just fine.

Dean