Use $Restrict

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