Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions bin/varnishd/cache/cache_ban.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "vcli_serve.h"
#include "vend.h"
#include "vmb.h"
#include "vtim.h"

/* cache_ban_build.c */
void BAN_Build_Init(void);
Expand Down Expand Up @@ -848,13 +849,16 @@ ban_render(struct cli *cli, const uint8_t *bs, int quote)
static void
ban_list(struct cli *cli, struct ban *bl)
{
char ts[VTIM_FORMAT_WEB_SIZE];
struct ban *b;
int64_t o;

VCLI_Out(cli, "Present bans:\n");
VTAILQ_FOREACH(b, &ban_head, list) {
o = bl == b ? 1 : 0;
VCLI_Out(cli, "%10.6f %5ju %s", ban_time(b->spec),
VTIM_format_web(ban_time(b->spec), ts);
VCLI_Out(cli, "%-*s %5ju %s",
(int)VTIM_FORMAT_WEB_SIZE, ts,
(intmax_t)(b->refcount - o),
b->flags & BANS_FLAG_COMPLETED ? "C" : "-");
if (DO_DEBUG(DBG_LURKER)) {
Expand All @@ -881,6 +885,7 @@ ban_list(struct cli *cli, struct ban *bl)
static void
ban_list_json(struct cli *cli, const char * const *av, struct ban *bl)
{
char ts[VTIM_FORMAT_WEB_SIZE];
struct ban *b;
int64_t o;
int n = 0;
Expand All @@ -894,7 +899,8 @@ ban_list_json(struct cli *cli, const char * const *av, struct ban *bl)
n++;
VCLI_Out(cli, "{\n");
VSB_indent(cli->sb, 2);
VCLI_Out(cli, "\"time\": %.6f,\n", ban_time(b->spec));
VTIM_format_web(ban_time(b->spec), ts);
VCLI_Out(cli, "\"time\": \"%s\",\n", ts);
VCLI_Out(cli, "\"refs\": %ju,\n", (intmax_t)(b->refcount - o));
VCLI_Out(cli, "\"completed\": %s,\n",
b->flags & BANS_FLAG_COMPLETED ? "true" : "false");
Expand Down
1 change: 1 addition & 0 deletions bin/varnishd/mgt/mgt_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ mgt_tests(void)
assert(VTIM_parse("Sun, 06 Nov 1994 08:49:37 GMT") == 784111777);
assert(VTIM_parse("Sunday, 06-Nov-94 08:49:37 GMT") == 784111777);
assert(VTIM_parse("Sun Nov 6 08:49:37 1994") == 784111777);
assert(VTIM_parse_web("1994-11-06T08:49:37.00Z") == 784111777);

/* Check that our VSHA256 works */
VSHA256_Test();
Expand Down
2 changes: 1 addition & 1 deletion bin/varnishtest/tests/c00019.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,5 @@ varnish v1 -clierr 106 "ban req.url ~ [[["
# Ban expression with quoting
varnish v1 -cliok {ban req.url ~ "BAR"}
shell {varnishadm -n ${tmpdir}/v1 ban 'obj.http.Host ~ \"Foo\"'}
varnish v1 -cliexpect {(?s)\d+\.\d+\s+\d+\s+-\s+\Qobj.http.Host ~ "Foo"\E} "ban.list"
varnish v1 -cliexpect {(?s)\S+\s+\d+\s+-\s+\Qobj.http.Host ~ "Foo"\E} "ban.list"
varnish v1 -clijson "ban.list -j"
5 changes: 4 additions & 1 deletion include/vtim.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@
/* from libvarnish/vtim.c */
extern unsigned VTIM_postel;
#define VTIM_FORMAT_SIZE 30
void VTIM_format(vtim_real t, char *p);
void VTIM_format(vtim_real t, char p[VTIM_FORMAT_SIZE]);
#define VTIM_FORMAT_WEB_SIZE (sizeof "2025-12-31T23:59:59.123456Z")
void VTIM_format_web(vtim_real t, char p[VTIM_FORMAT_WEB_SIZE]);
vtim_real VTIM_parse(const char *p);
vtim_real VTIM_parse_web(const char *p);
vtim_mono VTIM_mono(void);
vtim_real VTIM_real(void);
void VTIM_sleep(vtim_dur t);
Expand Down
Loading