Commit 92acaacd authored by Geoff Simmons's avatar Geoff Simmons

the hosts.secret() method may not be called in vcl_init

parent 1c21f941
Pipeline #111 skipped
......@@ -34,6 +34,21 @@ client c1 {
expect resp.http.s1 == "foo"
} -run
# Usage
varnish v1 -errvcl {h.secret() may not be called in vcl_init} {
import hoailona from "${vmod_topbuild}/src/.libs/libvmod_hoailona.so";
import blobcode;
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new p = hoailona.policy(OPEN, 1h);
new h = hoailona.hosts();
if (blobcode.encode(blob=h.secret()) == "foo") {
return(fail);
}
}
}
varnish v1 -vcl {
import hoailona from "${vmod_topbuild}/src/.libs/libvmod_hoailona.so";
import blobcode;
......
......@@ -462,8 +462,6 @@ vmod_hosts_add(VRT_CTX, struct vmod_hoailona_hosts *hosts,
AZ(VRB_INSERT(assign_tree, &host->assignments, assign));
}
/* XXX the remaining methods are all illegal in init & fini (?) */
VCL_INT
vmod_hosts_policy(VRT_CTX, struct vmod_hoailona_hosts *hosts,
struct vmod_priv *priv_task, VCL_STRING hostname,
......@@ -682,6 +680,11 @@ vmod_hosts_secret(VRT_CTX, struct vmod_hoailona_hosts *hosts,
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(hosts, VMOD_HOAILONA_HOSTS_MAGIC);
if (INIT(ctx)) {
VERR(ctx, "%s.secret() may not be called in vcl_init",
hosts->vcl_name);
return NULL;
}
policy = get_policy(ctx, priv_task, hosts->vcl_name, "secret");
if (policy == NULL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment