--------------------- PatchSet 11731 Date: 2007/11/06 22:36:20 Author: wessels Branch: HEAD Tag: (none) Log: Extended the Squid -> Rewriter interface with key=value pairs 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. Members: src/cf.data.pre:1.438->1.439 src/redirect.c:1.98->1.99 Index: squid/src/cf.data.pre =================================================================== RCS file: /cvsroot/squid/squid/src/cf.data.pre,v retrieving revision 1.438 retrieving revision 1.439 diff -u -r1.438 -r1.439 --- squid/src/cf.data.pre 16 Oct 2007 13:03:29 -0000 1.438 +++ squid/src/cf.data.pre 6 Nov 2007 22:36:20 -0000 1.439 @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.438 2007/10/16 13:03:29 amosjeffries Exp $ +# $Id: cf.data.pre,v 1.439 2007/11/06 22:36:20 wessels Exp $ # # SQUID Web Proxy Cache http://www.squid-cache.org/ # ---------------------------------------------------------- @@ -2558,7 +2558,13 @@ For each requested URL rewriter will receive on line with the format - URL client_ip "/" fqdn user method urlgroup + URL client_ip "/" fqdn user method urlgroup + [ kvpairs] + + 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: squid/src/redirect.c =================================================================== RCS file: /cvsroot/squid/squid/src/redirect.c,v retrieving revision 1.98 retrieving revision 1.99 diff -u -r1.98 -r1.99 --- squid/src/redirect.c 1 Feb 2007 09:30:19 -0000 1.98 +++ squid/src/redirect.c 6 Nov 2007 22:36:20 -0000 1.99 @@ -1,6 +1,6 @@ /* - * $Id: redirect.c,v 1.98 2007/02/01 09:30:19 serassio Exp $ + * $Id: redirect.c,v 1.99 2007/11/06 22:36:20 wessels Exp $ * * DEBUG: section 61 Redirector * AUTHOR: Duane Wessels @@ -98,6 +98,8 @@ const char *fqdn; char *urlgroup = conn->port->urlgroup; char buf[8192]; + char claddr[20]; + char myaddr[20]; assert(http); assert(handler); debug(61, 5) ("redirectStart: '%s'\n", http->uri); @@ -130,13 +132,17 @@ cbdataLock(r->data); if ((fqdn = fqdncache_gethostbyaddr(r->client_addr, 0)) == NULL) fqdn = dash_str; - snprintf(buf, 8191, "%s %s/%s %s %s %s", + xstrncpy(claddr, inet_ntoa(r->client_addr), 20); + xstrncpy(myaddr, inet_ntoa(http->request->my_addr), 20); + snprintf(buf, 8191, "%s %s/%s %s %s %s myip=%s myport=%d", r->orig_url, - inet_ntoa(r->client_addr), + claddr, fqdn, r->client_ident[0] ? rfc1738_escape(r->client_ident) : dash_str, r->method_s, - urlgroup ? urlgroup : "-"); + urlgroup ? urlgroup : "-", + myaddr, + http->request->my_port); debug(61, 6) ("redirectStart: sending '%s' to the helper\n", buf); strcat(buf, "\n"); helperSubmit(redirectors, buf, redirectHandleReply, r);