Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-objvar
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
uplex-varnish
varnish-objvar
Commits
9c068644
Unverified
Commit
9c068644
authored
Jun 19, 2023
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use $Restrict
parent
b8d7bb72
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
413 additions
and
80 deletions
+413
-80
vmod_topvar.rst
src/vmod_topvar.rst
+376
-17
vmod_topvar.vcctpl
src/vmod_topvar.vcctpl
+7
-1
vmod_topvar.vtctpl
src/vtc/vmod_topvar.vtctpl
+30
-62
No files found.
src/vmod_topvar.rst
View file @
9c068644
This diff is collapsed.
Click to expand it.
src/vmod_topvar.vcctpl
View file @
9c068644
...
...
@@ -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
...
...
src/vtc/vmod_topvar.vtctpl
View file @
9c068644
...
...
@@ -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();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment