]> err.no Git - varnish/commitdiff
Add conversion from IP to string format to allow things like:
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 10 Jul 2007 19:59:39 +0000 (19:59 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 10 Jul 2007 19:59:39 +0000 (19:59 +0000)
set bereq.http.HeyYou = client.ip " asked for  " req.url;

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1663 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_vrt.c
varnish-cache/include/vrt.h
varnish-cache/lib/libvcl/vcc_fixed_token.c
varnish-cache/lib/libvcl/vcc_string.c

index 4edcbea8d5c57a28e2474a3e5cfd8c8d17c4db98..9e56ccb37c5d597546f6c8803b9d176acb9484e5 100644 (file)
@@ -472,3 +472,19 @@ VRT_r_obj_lastuse(struct sess *sp)
        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);
+}
index 7f284681fb58cf91ce841537aad02d1ceca5d6a5..7f559a4902f5f75075d6a9f052c95d4cacaab990 100644 (file)
@@ -85,6 +85,7 @@ void VRT_alloc_backends(struct VCL_conf *cp);
 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 {                                    \
index 0625384ef112dce26c0b58185d35285149eaa736..ad67b89572b4f8370b594ca0333f1000330f820b 100644 (file)
@@ -441,6 +441,7 @@ vcl_output_lang_h(struct vsb *sb)
        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");
index bc8914371fe0baa17a9216726e36b3c55d090af1..ec7723d4a16c7169c286b99c3eae35a51f296101 100644 (file)
@@ -66,6 +66,9 @@ vcc_StringVal(struct tokenlist *tl)
                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",