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
bb1b526e
Commit
bb1b526e
authored
Sep 16, 2019
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the LOCAL,UTC options to dump_keys().
Also change the date outputs to include time zones.
parent
12c05ea6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
15 deletions
+41
-15
keys.c
src/keys.c
+8
-6
keys.h
src/keys.h
+6
-1
keys.vtc
src/tests/keys.vtc
+20
-5
vmod_ece.c
src/vmod_ece.c
+6
-2
vmod_ece.vcc
src/vmod_ece.vcc
+1
-1
No files found.
src/keys.c
View file @
bb1b526e
...
...
@@ -612,10 +612,10 @@ 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"))
#define TIMSZ (sizeof("YYYY-mm-ddTHH:MM:SS
+hh:mm
"))
void
KEY_Dump
(
VRT_CTX
)
KEY_Dump
(
VRT_CTX
,
enum
tz
tz
)
{
struct
key_tree
*
tree_h
;
struct
key
*
key
;
...
...
@@ -625,6 +625,8 @@ KEY_Dump(VRT_CTX)
char
tim_buf
[
TIMSZ
];
const
char
*
p
[
0
];
struct
strands
strands
=
{
1
,
p
};
struct
tm
*
(
*
time_r
[
2
])(
const
time_t
*
,
struct
tm
*
)
=
{
localtime_r
,
gmtime_r
};
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
...
...
@@ -641,13 +643,13 @@ KEY_Dump(VRT_CTX)
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
);
(
time_r
[
tz
])
(
&
tim
,
&
tm
);
strftime
(
tim_buf
,
TIMSZ
,
"%
FT%T%z
"
,
&
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
);
(
time_r
[
tz
])
(
&
tim
,
&
tm
);
strftime
(
tim_buf
,
TIMSZ
,
"%
FT%T%z
"
,
&
tm
);
VSB_printf
(
vsb
,
"%s
\n
"
,
tim_buf
);
}
KEY_Unlock
(
i
);
...
...
src/keys.h
View file @
bb1b526e
...
...
@@ -32,6 +32,11 @@
#include "vrt.h"
#endif
enum
tz
{
LOCAL
=
0
,
UTC
,
};
int
KEY_Init
(
VRT_CTX
);
void
KEY_Fini
(
void
);
void
KEY_Rdlock
(
uint8_t
idlen
);
...
...
@@ -45,4 +50,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
);
void
KEY_Dump
(
VRT_CTX
,
enum
tz
tz
);
src/tests/keys.vtc
View file @
bb1b526e
...
...
@@ -238,7 +238,12 @@ varnish v1 -vcl {
sub vcl_synth {
set resp.http.Content-Type = "text/csv";
ece.dump_keys();
if (req.url == "/3") {
ece.dump_keys(UTC);
}
else {
ece.dump_keys();
}
return (deliver);
}
}
...
...
@@ -255,10 +260,20 @@ client c1 {
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}$}
expect resp.body ~ {(?m)^foo,(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\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}[+-]\d{2}:?\d{2},?){2}$}
expect resp.body ~ {(?m)^baz,(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\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}[+-]\d{2}:?\d{2},?){2}$}
txreq -url /3
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}[+-]\d{2}:?\d{2},?){2}$}
expect resp.body ~ {(?m)^bar,(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\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}[+-]\d{2}:?\d{2},?){2}$}
expect resp.body ~ {(?m)^quux,(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{2}:?\d{2},?){2}$}
} -run
varnish v1 -vcl {
...
...
src/vmod_ece.c
View file @
bb1b526e
...
...
@@ -189,8 +189,10 @@ vmod_key_updated(VRT_CTX, VCL_STRING id)
}
VCL_VOID
vmod_dump_keys
(
VRT_CTX
)
vmod_dump_keys
(
VRT_CTX
,
VCL_ENUM
zone
)
{
enum
tz
tz
=
LOCAL
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
if
((
ctx
->
method
&
VCL_MET_SYNTH
)
==
0
)
{
...
...
@@ -198,7 +200,9 @@ vmod_dump_keys(VRT_CTX)
return
;
}
KEY_Dump
(
ctx
);
if
(
zone
==
VENUM
(
UTC
))
tz
=
UTC
;
KEY_Dump
(
ctx
,
tz
);
}
VCL_STRING
...
...
src/vmod_ece.vcc
View file @
bb1b526e
...
...
@@ -104,7 +104,7 @@ last updated.
XXX ...
$Function VOID dump_keys()
$Function VOID dump_keys(
ENUM {LOCAL, UTC} tz=LOCAL
)
Generate a synthetic client response body with information in CSV
format (comma-separated values) about all of the keys that are
...
...
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