]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Extended the Squid -> Rewriter interface with key=value pairs
authorwessels <>
Wed, 7 Nov 2007 04:19:30 +0000 (04:19 +0000)
committerwessels <>
Wed, 7 Nov 2007 04:19:30 +0000 (04:19 +0000)
Our customer wants to use a redirector (rewriter) but needs additional
fields.  We think that new fields should be of the form "key=value"
so that, in the future, the user can choose which fields to send
to the rewriter.

src/cf.data.pre
src/redirect.cc

index 800e1127c46da9baf41ce76c196c1ec33e546d95..4a8de17b5e2fe8b83e6a0701883457570110163a 100644 (file)
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.485 2007/10/31 10:34:36 amosjeffries Exp $
+# $Id: cf.data.pre,v 1.486 2007/11/06 21:19:30 wessels Exp $
 #
 # SQUID Web Proxy Cache                http://www.squid-cache.org/
 # ----------------------------------------------------------
@@ -2364,7 +2364,12 @@ DOC_START
 
        For each requested URL rewriter will receive on line with the format
 
-       URL <SP> client_ip "/" fqdn <SP> user <SP> method <NL>
+       URL <SP> client_ip "/" fqdn <SP> user <SP> method [<SP> kvpairs]<NL>
+
+       In the future, the rewriter interface will be extended with
+       key=value pairs ("kvpairs" shown above).  Rewriter programs
+       should be prepared to receive and possibly ignore additional
+       whitespace-separated tokens on each input line.
 
        And the rewriter may return a rewritten URL. The other components of
        the request line does not need to be returned (ignored if they are).
index ca37bb45aa8dee3ce1a590c76aa741b461555ad8..f9142a303e954d25fb7d08f4eb61c44c9c4f2fc3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: redirect.cc,v 1.121 2007/09/27 23:58:06 amosjeffries Exp $
+ * $Id: redirect.cc,v 1.122 2007/11/06 21:19:31 wessels Exp $
  *
  * DEBUG: section 61    Redirector
  * AUTHOR: Duane Wessels
@@ -117,6 +117,8 @@ redirectStart(ClientHttpRequest * http, RH * handler, void *data)
     redirectStateData *r = NULL;
     const char *fqdn;
     char buf[8192];
+    char claddr[20];
+    char myaddr[20];
     assert(http);
     assert(handler);
     debugs(61, 5, "redirectStart: '" << http->uri << "'");
@@ -161,12 +163,16 @@ redirectStart(ClientHttpRequest * http, RH * handler, void *data)
     if ((fqdn = fqdncache_gethostbyaddr(r->client_addr, 0)) == NULL)
         fqdn = dash_str;
 
-    snprintf(buf, 8192, "%s %s/%s %s %s\n",
+    xstrncpy(claddr, inet_ntoa(r->client_addr), 20);
+    xstrncpy(myaddr, inet_ntoa(http->request->my_addr), 20);
+    snprintf(buf, 8192, "%s %s/%s %s %s myip=%s myport=%d\n",
              r->orig_url,
-             inet_ntoa(r->client_addr),
+             claddr,
              fqdn,
              r->client_ident[0] ? rfc1738_escape(r->client_ident) : dash_str,
-             r->method_s);
+             r->method_s,
+            myaddr,
+            http->request->my_port);
 
     helperSubmit(redirectors, buf, redirectHandleReply, r);
 }