varnish-cache
varnish-cache copied to clipboard
VCL_PRIV access from a filter
It is possible to parametrize filters through programmatic access to VRT_priv_task()
from vmod functions and the filter code.
But I see no way to access VCL_PRIVs from filter code. Can we add a way?
Can't you grab it at init time? https://github.com/varnishcache/varnish-cache/pull/3772
I would not see how, The VCL_PRIV can not be reached through the VRT_CTX, it is a static in the vcl object. One obvious possibility was to create an association (e.g. btree) between the vcl pointer (available as ctx->vcl) and the VCL_PRIV in the event function, and then use that to look up the vcl pointer later.
In the VMOD function where you set up your filter, grab the PRIV_VCL and put it in a dynamic PRIV_TASK that can be queried from a VRT_CTX from the init callback.
Yes, if that function exists. But the filter interface is designed that a simple
set resp.filters += " myfilter"
is sufficient. And there is no vmod function called for that.