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
6dfc5fcc
Commit
6dfc5fcc
authored
Sep 16, 2019
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add dump_keys().
parent
3f407ff8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
144 additions
and
0 deletions
+144
-0
keys.c
src/keys.c
+50
-0
keys.h
src/keys.h
+1
-0
keys.vtc
src/tests/keys.vtc
+71
-0
vmod_ece.c
src/vmod_ece.c
+14
-0
vmod_ece.vcc
src/vmod_ece.vcc
+8
-0
No files found.
src/keys.c
View file @
6dfc5fcc
...
...
@@ -38,6 +38,7 @@
#include "cache/cache.h"
#include "vtim.h"
#include "vsb.h"
#include "verrno.h"
/* XXX grr */
...
...
@@ -610,3 +611,52 @@ KEY_Updated(VRT_CTX, uint8_t *id, uint8_t idlen)
{
return
(
key_time
(
ctx
,
id
,
idlen
,
UPDATED
));
}
#define TIMSZ (sizeof("YYYY-mm-ddTHH:MM:SS"))
void
KEY_Dump
(
VRT_CTX
)
{
struct
key_tree
*
tree_h
;
struct
key
*
key
;
struct
vsb
*
vsb
=
VSB_new_auto
();
time_t
tim
;
struct
tm
tm
;
char
tim_buf
[
TIMSZ
];
const
char
*
p
[
0
];
struct
strands
strands
=
{
1
,
p
};
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
VSB_printf
(
vsb
,
"id,added,updated
\n
"
);
for
(
unsigned
i
=
0
;
i
<
UINT8_MAX
;
i
++
)
{
KEY_Rdlock
(
i
);
tree_h
=
&
key_tbl
[
i
].
tree
;
VRBT_FOREACH
(
key
,
key_tree
,
tree_h
)
{
CHECK_OBJ_NOTNULL
(
key
,
KEY_MAGIC
);
AN
(
key
->
id
);
AN
(
key
->
added
);
AN
(
key
->
updated
);
VSB_bcat
(
vsb
,
key
->
id
,
key
->
idlen
);
tim
=
(
time_t
)
key
->
added
;
localtime_r
(
&
tim
,
&
tm
);
strftime
(
tim_buf
,
TIMSZ
,
"%Y-%m-%dT%T"
,
&
tm
);
VSB_printf
(
vsb
,
",%s,"
,
tim_buf
);
tim
=
(
time_t
)
key
->
updated
;
localtime_r
(
&
tim
,
&
tm
);
strftime
(
tim_buf
,
TIMSZ
,
"%Y-%m-%dT%T"
,
&
tm
);
VSB_printf
(
vsb
,
"%s
\n
"
,
tim_buf
);
}
KEY_Unlock
(
i
);
}
VSB_finish
(
vsb
);
strands
.
n
=
1
;
strands
.
p
[
0
]
=
VSB_data
(
vsb
);
VRT_synth_page
(
ctx
,
&
strands
);
VSB_destroy
(
&
vsb
);
return
;
}
src/keys.h
View file @
6dfc5fcc
...
...
@@ -45,3 +45,4 @@ int KEY_Delete(VRT_CTX, uint8_t *id, uint8_t idlen);
VCL_BOOL
KEY_Exists
(
uint8_t
*
id
,
uint8_t
idlen
);
VCL_TIME
KEY_Added
(
VRT_CTX
,
uint8_t
*
id
,
uint8_t
idlen
);
VCL_TIME
KEY_Updated
(
VRT_CTX
,
uint8_t
*
id
,
uint8_t
idlen
);
void
KEY_Dump
(
VRT_CTX
);
src/tests/keys.vtc
View file @
6dfc5fcc
...
...
@@ -214,6 +214,77 @@ client c1 {
logexpect l1 -wait
varnish v1 -vcl {
import ${vmod_ece};
import blob;
backend b { .host="${bad_ip}"; }
sub vcl_recv {
if (ece.key_exists("")) {
ece.delete_key("");
}
if (req.url == "/2") {
ece.set_key("foo", blob.decode(BASE64,
encoded="H0JUi1Jb/WkAn5Ow0oyjCA=="));
ece.set_key("bar", blob.decode(BASE64,
encoded="/9InuRuPOTQOj/7dXZ/ZNw=="));
ece.set_key("baz", blob.decode(BASE64,
encoded="Wfhr2up4uvsVDo9ZLqweSw=="));
ece.set_key("quux", blob.decode(BASE64,
encoded="JfQd/wZAeH8swl8Fw92Vmw=="));
}
return (synth(200));
}
sub vcl_synth {
set resp.http.Content-Type = "text/csv";
ece.dump_keys();
return (deliver);
}
}
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.Content-Type == "text/csv"
expect resp.body ~ "^id,added,updated"
txreq -url /2
rxresp
expect resp.status == 200
expect resp.http.Content-Type == "text/csv"
expect resp.body ~ "^id,added,updated"
expect resp.body ~ {(?m)^foo,(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2},?){2}$}
expect resp.body ~ {(?m)^bar,(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2},?){2}$}
expect resp.body ~ {(?m)^baz,(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2},?){2}$}
expect resp.body ~ {(?m)^quux,(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2},?){2}$}
} -run
varnish v1 -vcl {
import ${vmod_ece};
backend b { .host="${bad_ip}"; }
sub vcl_recv {
ece.dump_keys();
}
}
logexpect l1 -v v1 -d 0 -g vxid -q "VCL_Error" {
expect 0 * Begin req
expect * = VCL_Error {^dump_keys\(\) may only be called in vcl_synth$}
expect * = End
} -start
client c1 {
txreq
rxresp
expect resp.status == 503
expect resp.reason == "VCL failed"
} -run
logexpect l1 -wait
varnish v1 -vcl {
import ${vmod_ece};
import blob;
...
...
src/vmod_ece.c
View file @
6dfc5fcc
...
...
@@ -33,6 +33,7 @@
#include <openssl/crypto.h>
#include "cache/cache.h"
#include "vcl.h"
#include "vcc_if.h"
...
...
@@ -187,6 +188,19 @@ vmod_key_updated(VRT_CTX, VCL_STRING id)
return
(
KEY_Updated
(
ctx
,
(
uint8_t
*
)
id
,
(
uint8_t
)
len
));
}
VCL_VOID
vmod_dump_keys
(
VRT_CTX
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
if
((
ctx
->
method
&
VCL_MET_SYNTH
)
==
0
)
{
VRT_fail
(
ctx
,
"dump_keys() may only be called in vcl_synth"
);
return
;
}
KEY_Dump
(
ctx
);
}
VCL_STRING
vmod_libcrypto_version
(
VRT_CTX
)
{
...
...
src/vmod_ece.vcc
View file @
6dfc5fcc
...
...
@@ -104,6 +104,14 @@ last updated.
XXX ...
$Function VOID dump_keys()
Generate a synthetic client response body with information in CSV
format (comma-separated values) about all of the keys that are
currently stored.
XXX ...
$Function STRING libcrypto_version()
Return the libcrypto version string.
...
...
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