Use $Restrict

parent b8d7bb72
This diff is collapsed.
......@@ -62,18 +62,24 @@ will be initially undefined.\n \
$Method TYPE .get([TYPE fallback])\n \
Return the value of the topvar or the `fallback` argument\n \
if it is undefined. DEFDOC_ ## TYPE\n \
$Restrict client\n \
$Method VOID .set(TYPE)\n \
Set the value of the topvar.\n\n \
Triggers a vcl failure for protected variables.\n \
$Restrict client\n \
$Method VOID .undefine()\n \
Undefine the topvar.\n \
$Restrict client\n \
$Method BOOL .defined()\n \
Return whether the topvar is defined.\n \
$Restrict client\n \
$Method VOID .protect()\n \
Protect the topvar, so any future .set() calls on it\n \
trigger a vcl failure.\n \
$Restrict client\n \
$Method BOOL .protected()\n \
Return whether the topvar is protected.\n
Return whether the topvar is protected.\n \
$Restrict client\n
#include "tbl_types.h"
SEE ALSO
......
......@@ -37,9 +37,6 @@ varnish v1 \\
}
sub vcl_recv {
if (req.url ~ "^/backend/") {
return (pass);
}
#define VCC_TYPE(TYPE, type) \
if (req.http.what == #type) { \
set req.http.def1-x = x ## type %% .defined(); \
......@@ -58,30 +55,6 @@ varnish v1 \\
return (hash);
}
sub vcl_backend_fetch {
if (bereq.url !~ "^/backend/") {
return (fetch);
} else
if (bereq.url ~ "/get$") {
set bereq.http.foo = xint.get();
} else
if (bereq.url ~ "/set$") {
xint.set(5);
} else
if (bereq.url ~ "/undefine$") {
xint.undefine();
} else
if (bereq.url ~ "/defined$") {
set bereq.http.foo = xint.defined();
} else
if (bereq.url ~ "/protect$") {
xint.protect();
} else
if (bereq.url ~ "/protected$") {
set bereq.http.foo = xint.protected();
}
}
sub vcl_deliver {
set resp.http.def1-x = req.http.def1-x;
set resp.http.def1-xd = req.http.def1-xd;
......@@ -117,38 +90,33 @@ client c ## type {\n \
} -run
#include "../tbl_vtc.h"
client cget {
txreq -url "/backend/get"
rxresp
expect resp.status == 503
} -run
client cset {
txreq -url "/backend/set"
rxresp
expect resp.status == 503
} -run
client cundefine {
txreq -url "/backend/undefine"
rxresp
expect resp.status == 503
} -run
client cdefined {
txreq -url "/backend/defined"
rxresp
expect resp.status == 503
} -run
client cprotect {
txreq -url "/backend/protect"
rxresp
expect resp.status == 503
} -run
client cprotected {
txreq -url "/backend/protected"
rxresp
expect resp.status == 503
} -run
varnish v1 -errvcl {Not available in subroutine} {
import topvar;
backend none none;
sub vcl_init {
new xint = topvar.int();
}
sub vcl_backend_fetch {
if (bereq.url !~ "^/backend/") {
return (fetch);
} else
if (bereq.url ~ "/get$") {
set bereq.http.foo = xint.get();
} else
if (bereq.url ~ "/set$") {
xint.set(5);
} else
if (bereq.url ~ "/undefine$") {
xint.undefine();
} else
if (bereq.url ~ "/defined$") {
set bereq.http.foo = xint.defined();
} else
if (bereq.url ~ "/protect$") {
xint.protect();
} else
if (bereq.url ~ "/protected$") {
set bereq.http.foo = xint.protected();
}
}
}
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