r1663 - in trunk/varnish-cache: bin/varnishd include lib/libvcl
phk at projects.linpro.no
phk at projects.linpro.no
Tue Jul 10 21:59:39 CEST 2007
Author: phk
Date: 2007-07-10 21:59:39 +0200 (Tue, 10 Jul 2007)
New Revision: 1663
Modified:
trunk/varnish-cache/bin/varnishd/cache_vrt.c
trunk/varnish-cache/include/vrt.h
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
trunk/varnish-cache/lib/libvcl/vcc_string.c
Log:
Add conversion from IP to string format to allow things like:
set bereq.http.HeyYou = client.ip " asked for " req.url;
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-07-10 19:46:16 UTC (rev 1662)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-07-10 19:59:39 UTC (rev 1663)
@@ -472,3 +472,19 @@
clock_gettime(CLOCK_MONOTONIC, &now);
return (now.tv_sec - sp->obj->lru_stamp);
}
+
+/*--------------------------------------------------------------------*/
+
+char *
+VRT_IP_string(struct sess *sp, struct sockaddr *sa)
+{
+ char h[64], p[8], *q;
+
+ TCP_name(sa, sa->sa_len, h, sizeof h, p, sizeof p);
+ q = WS_Alloc(sp->http->ws, strlen(h) + strlen(p) + 2);
+ AN(q);
+ strcpy(q, h);
+ strcat(q, ":");
+ strcat(q, p);
+ return (q);
+}
Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h 2007-07-10 19:46:16 UTC (rev 1662)
+++ trunk/varnish-cache/include/vrt.h 2007-07-10 19:59:39 UTC (rev 1663)
@@ -85,6 +85,7 @@
void VRT_free_backends(struct VCL_conf *cp);
void VRT_fini_backend(struct backend *be);
+char *VRT_IP_string(struct sess *sp, struct sockaddr *sa);
#define VRT_done(sp, hand) \
do { \
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-07-10 19:46:16 UTC (rev 1662)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-07-10 19:59:39 UTC (rev 1663)
@@ -441,6 +441,7 @@
vsb_cat(sb, "void VRT_free_backends(struct VCL_conf *cp);\n");
vsb_cat(sb, "void VRT_fini_backend(struct backend *be);\n");
vsb_cat(sb, "\n");
+ vsb_cat(sb, "char *VRT_IP_string(struct sess *sp, struct sockaddr *sa);\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "#define VRT_done(sp, hand) \\\n");
vsb_cat(sb, " do { \\\n");
Modified: trunk/varnish-cache/lib/libvcl/vcc_string.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_string.c 2007-07-10 19:46:16 UTC (rev 1662)
+++ trunk/varnish-cache/lib/libvcl/vcc_string.c 2007-07-10 19:59:39 UTC (rev 1663)
@@ -66,6 +66,9 @@
case STRING:
Fb(tl, 0, "%s", vp->rname);
break;
+ case IP:
+ Fb(tl, 0, "VRT_IP_string(sp, %s)", vp->rname);
+ break;
default:
vsb_printf(tl->sb,
"String representation of '%s' not implemented yet.\n",
More information about the varnish-commit
mailing list