Varnish 3.0.2 req.hash

Roberto O. Fernández Crisial roberto.fernandezcrisial at gmail.com
Sat Feb 11 22:27:46 CET 2012


If you're looking for the result of hash_data(), you should see what you're adding to default hash (url + uri). Nothing else ;)

Roberto
@rofc
-----Original Message-----
From: Hugues Alary <hugues.alary at gmail.com>
Date: Sat, 11 Feb 2012 13:24:34 
To: gau at gprj.net<gau at gprj.net>
Cc: Roberto O. Fernández Crisial<roberto.fernandezcrisial at gmail.com>; <varnish-misc at varnish-cache.org>
Subject: Re: Varnish 3.0.2 req.hash

Hi Syohey,

Thanks for your answer.

My final goal is to get the hash calculated by Varnish. In the
documentation of the 3.0.2 version it is written that req.hash contains
this hash. I guess they just forgot to remove it and that req.hash doesn't
exist anymore.

However, is there a mean to get the *final* hash calculated by varnish, the
result of hash_data()?

Here:
https://www.varnish-cache.org/docs/trunk/phk/varnish_does_not_hash.html it
is written:


"All the strings hash_data() are fed, are pushed through a cryptographic
hash algorithm called SHA256, which, as the name says, always spits out 256
bits (= 32 bytes), no matter how many bits you feed it."

And that's what I am looking for, the final value of the hash. I guess I
could do it myself with a bit of C, but I would think that it is possible
to get this value from somewhere since Varnish already does the calculation.

-Hugues

On Fri, Feb 10, 2012 at 5:22 PM, gau at gprj.net <gau at gprj.net> wrote:

> Hugues,
>
> req.hash is the original write-only.(If my memory serves me)
> and, VCL is a notation has changed Varnish3.
> req.hash is replaced to hash_data();
>
>
>  vcl:
>  sub vcl_hash {
>     hash_data(req.url);
>     set req.http.X-TEST = req.url; //add
>     if (req.http.host) {
>         hash_data(req.http.host);
>         set req.http.X-TEST = req.http.X-TEST + " + "  + req.http.host;
> //add
>     } else {
>        hash_data(server.ip);
>        set req.http.X-TEST = req.http.X-TEST + " + " + server.ip; //add
>     }
>     return (hash);
>  }
>
>
>  sub vcl_deliver{
>      set resp.http.X-TEST = req.http.X-TEST;
>  }
>
>  test:
>  wget  -d http://192.168.1.199:6081/test -O - > /dev/null
>
>  X-TEST: /test + 192.168.1.199:6081
>
> Is not a very smart.
> (Is not a hash, but understood what anything was used)
>
>
> Can not think only about making the other VMOD.
>
>
> --
> Syohei Tanaka(@xcir)
> http://xcir.net/
>
>
>
> 2012/2/11 Hugues Alary <hugues.alary at gmail.com>:
> > 2012/2/10 Roberto O. Fernández Crisial <
> roberto.fernandezcrisial at gmail.com>
> >>
> >> Hugues,
> >
> >
> > Hi Roberto,
> >
> > Thank you for your answer.
> >
> >>
> >>
> >> Try this:
> >>
> >> set req.http.X-TEST = req.hash;
> >> set req.http.TEST = req.http.X-TEST;
> >>
> >> It should work.
> >
> >
> >
> > Unfortunately the problem doesn't come from the syntax of "req.http.TEST"
> > but from req.hash. Here is the message:
> >
> > Message from VCC-compiler:
> > Symbol not found: 'req.hash' (expected type STRING_LIST):
> > ('input' Line 219 Pos 31)
> >         set req.http.X-TEST = req.hash;
> > ------------------------------########-
> >
> > Running VCC-compiler failed, exit 1
> >
> > VCL compilation failed
> >
> >
> > I also tried to put that in my configuration:
> >
> > set req.http.X-TEST = {""} + req.hash;
> >
> >
> > And, same error:
> >
> > Message from VCC-compiler:
> > Symbol not found: 'req.hash' (expected type STRING):
> > ('input' Line 219 Pos 38)
> >         set req.http.X-TEST = {""} + req.hash;
> > -------------------------------------########-
> >
> > Running VCC-compiler failed, exit 1
> >
> > VCL compilation failed
> >
> >
> > Do you have any other idea ?
> >
> >>
> >> Good  luck,
> >>
> >> Roberto (@rofc)
> >>
> >
> > Thanks!
> > -Hugues
> >
> > _______________________________________________
> > varnish-misc mailing list
> > varnish-misc at varnish-cache.org
> > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>



-- 
Hugues ALARY

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20120211/a6a44e3c/attachment-0001.html>


More information about the varnish-misc mailing list