Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-ece
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-ece
Commits
766d3b42
Commit
766d3b42
authored
Sep 19, 2019
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add encrypter.create_stats().
parent
935128b7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
3 deletions
+73
-3
encrypter.vtc
src/tests/encrypter.vtc
+18
-2
roundtrip.vtc
src/tests/roundtrip.vtc
+17
-1
vmod_ece.c
src/vmod_ece.c
+29
-0
vmod_ece.vcc
src/vmod_ece.vcc
+9
-0
No files found.
src/tests/encrypter.vtc
View file @
766d3b42
...
...
@@ -13,7 +13,9 @@ server s1 -repeat 3 {
txresp -body {I am the walrus}
} -start
varnish v1 -arg "-p vsl_mask=+VfpAcct" -vcl+backend {
# Debug param vclrel causes VCLs to be released without delay, tests
# object finalization and the DISCARD event.
varnish v1 -arg "-p vsl_mask=+VfpAcct -p debug=+vclrel" -vcl+backend {
import ${vmod_ece};
import blob;
...
...
@@ -21,6 +23,7 @@ varnish v1 -arg "-p vsl_mask=+VfpAcct" -vcl+backend {
# With all params set to defaults, the encrypter is
# just like the default ece_encrypt VFP.
new default_dup = ece.encrypter("default_dup");
default_dup.create_stats();
ece.set_key("", blob.decode(BASE64URLNOPAD,
encoded="yqdlZ-tYemfogSmv7Ws5PQ"));
}
...
...
@@ -42,6 +45,10 @@ client c1 {
expect resp.bodylen == 53
} -run
varnish v1 -expect ECE.vfp.vcl1.default_dup.ops == 1
varnish v1 -expect ECE.vfp.vcl1.default_dup.in == 15
varnish v1 -expect ECE.vfp.vcl1.default_dup.out == 53
# The only way is to verify the result is to manually inspect the log file.
# See the comment in encrypt.vtc. The same log excerpt shown there should
# appear for this test as well.
...
...
@@ -58,6 +65,7 @@ varnish v1 -vcl+backend {
sub vcl_init {
# Custom encrypter that uses another header to set the key.
new hdr = ece.encrypter("hdr", key_hdr="X-Set-Key-ID");
hdr.create_stats();
}
sub vcl_backend_response {
...
...
@@ -84,6 +92,10 @@ client c1 {
logexpect l1 -wait
varnish v1 -expect ECE.vfp.vcl2.hdr.ops == 1
varnish v1 -expect ECE.vfp.vcl2.hdr.in == 15
varnish v1 -expect ECE.vfp.vcl2.hdr.out == 53
# Fetch fails if the wrong key header is used.
logexpect l1 -v v1 -d 0 -g vxid -q "FetchError" {
expect 0 * Begin bereq
...
...
@@ -100,6 +112,10 @@ client c1 {
logexpect l1 -wait
# Tests object finalization and DISCARD event.
varnish v1 -expect ECE.vfp.vcl2.hdr.ops == 2
varnish v1 -expect ECE.vfp.vcl2.hdr.in == 15
varnish v1 -expect ECE.vfp.vcl2.hdr.out == 53
# Tests the DISCARD event.
varnish v1 -cli "vcl.discard vcl1"
varnish v1 -cli "vcl.list"
src/tests/roundtrip.vtc
View file @
766d3b42
...
...
@@ -44,7 +44,9 @@ Enim per accumsan, augue id maecenas bibendum ullamcorper in fermentum, platea f
chunkedlen 0
} -start
varnish v1 -arg "-p vsl_mask=+VfpAcct" -vcl+backend {
# Debug param vclrel causes VCLs to be released without delay, tests
# object finalization and the DISCARD event.
varnish v1 -arg "-p vsl_mask=+VfpAcct -p debug=+vclrel" -vcl+backend {
import ${vmod_ece};
import blob;
...
...
@@ -165,6 +167,7 @@ varnish v1 -vcl+backend {
sub vcl_init {
# Encrypter uses 128 byte record size.
new rs128 = ece.encrypter("rs128", rs=128B);
rs128.create_stats();
# Decrypter uses 8k chunk size.
new chunk8k = ece.decrypter("chunk8k", chunksz=8k);
}
...
...
@@ -223,11 +226,16 @@ client c1 -run
logexpect l1 -wait
varnish v1 -expect ECE.vfp.vcl2.rs128.ops == 6
varnish v1 -expect ECE.vfp.vcl2.rs128.in == 199975
varnish v1 -expect ECE.vfp.vcl2.rs128.out > 199975
varnish v1 -vcl+backend {
import ${vmod_ece};
sub vcl_init {
new rs815 = ece.encrypter("rs815", rs=815B);
rs815.create_stats();
new chunk4711 = ece.decrypter("chunk4711", chunksz=4711B);
}
...
...
@@ -284,3 +292,11 @@ logexpect l1 -v v1 -d 0 -g vxid -q "VfpAcct" {
client c1 -run
logexpect l1 -wait
varnish v1 -expect ECE.vfp.vcl3.rs815.ops == 6
varnish v1 -expect ECE.vfp.vcl3.rs815.in == 199975
varnish v1 -expect ECE.vfp.vcl3.rs815.out > 199975
varnish v1 -cli "vcl.discard vcl1"
varnish v1 -cli "vcl.discard vcl2"
varnish v1 -cli "vcl.list"
src/vmod_ece.c
View file @
766d3b42
...
...
@@ -256,6 +256,28 @@ crypter_init(VRT_CTX, const char *vcl_name, struct vmod_priv *priv,
return
(
0
);
}
static
void
create_stats
(
VRT_CTX
,
const
struct
vfp
*
vfp
,
const
char
*
vcl_name
)
{
struct
vfp_cfg
*
cfg
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
AN
(
vcl_name
);
if
((
ctx
->
method
&
VCL_MET_INIT
)
==
0
)
{
VFAIL
(
ctx
,
"%s.create_stats() may only be called in vcl_init"
,
vcl_name
);
return
;
}
AN
(
vfp
);
CAST_OBJ_NOTNULL
(
cfg
,
TRUST_ME
(
vfp
->
priv1
),
VFP_CFG_MAGIC
);
cfg
->
stats
=
VSC_ece_New
(
NULL
,
&
cfg
->
vsc_seg
,
"vfp.%s.%s"
,
VCL_Name
(
ctx
->
vcl
),
vcl_name
);
AN
(
cfg
->
stats
);
memset
(
cfg
->
stats
,
0
,
sizeof
(
*
cfg
->
stats
));
}
/* Object encrypter */
VCL_VOID
...
...
@@ -370,6 +392,13 @@ vmod_encrypter__fini(struct VPFX(ece_encrypter) **encp)
FREE_OBJ
(
enc
);
}
VCL_VOID
vmod_encrypter_create_stats
(
VRT_CTX
,
struct
VPFX
(
ece_encrypter
)
*
enc
)
{
CHECK_OBJ_NOTNULL
(
enc
,
ECE_ENCRYPTER_MAGIC
);
create_stats
(
ctx
,
enc
->
vfp
,
enc
->
vcl_name
);
}
/* Object decrypter */
VCL_VOID
...
...
src/vmod_ece.vcc
View file @
766d3b42
...
...
@@ -63,6 +63,15 @@ Create an encryption filter named ``name`` with custom parameters.
XXX ...
$Method VOID .create_stats()
Create statistics, observable with a tool like ``varnishstat(1)``, for
the custom encryption filter. These are the same as the counters
created for the standard ``"ece_encrypt"`` filter. See `STATISTICS`_
below for details.
XXX ...
$Object decrypter(PRIV_VCL, STRING name, BYTES chunksz=16384,
BYTES max_rs=1048576)
...
...
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