From: wessels <> Date: Wed, 7 Nov 2007 04:19:30 +0000 (+0000) Subject: Extended the Squid -> Rewriter interface with key=value pairs X-Git-Tag: SQUID_3_0_STABLE1~53 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c71adec1a6c26854ec7bc0810ec65a1d8979c508;p=thirdparty%2Fsquid.git 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. --- diff --git a/src/cf.data.pre b/src/cf.data.pre index 800e1127c4..4a8de17b5e 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -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 client_ip "/" fqdn user method + URL client_ip "/" fqdn user method [ 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). diff --git a/src/redirect.cc b/src/redirect.cc index ca37bb45aa..f9142a303e 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -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); }