Commit f118ecf1 authored by Tollef Fog Heen's avatar Tollef Fog Heen

Get rid of ban_url/ban.url

ban.url is confusing as it takes a regular expression rather than a
fixed string, so get rid of it in favour of people being explicit and
using ban req.url ~ /foo
parent 8c113ff6
......@@ -1058,21 +1058,6 @@ ccf_ban(struct cli *cli, const char * const *av, void *priv)
BAN_Insert(b);
}
static void
ccf_ban_url(struct cli *cli, const char * const *av, void *priv)
{
const char *aav[6];
(void)priv;
aav[0] = NULL;
aav[1] = "ban";
aav[2] = "req.url";
aav[3] = "~";
aav[4] = av[2];
aav[5] = NULL;
ccf_ban(cli, aav, priv);
}
static void
ban_render(struct cli *cli, const uint8_t *bs)
{
......@@ -1145,7 +1130,6 @@ ccf_ban_list(struct cli *cli, const char * const *av, void *priv)
}
static struct cli_proto ban_cmds[] = {
{ CLI_BAN_URL, "", ccf_ban_url },
{ CLI_BAN, "", ccf_ban },
{ CLI_BAN_LIST, "", ccf_ban_list },
{ NULL }
......
......@@ -683,7 +683,7 @@ static const struct parspec input_parspec[] = {
"Objects already cached will not be affected by changes "
"made until they are fetched from the backend again.\n"
"To force an immediate effect at the expense of a total "
"flush of the cache use \"ban.url .\"",
"flush of the cache use \"ban obj.http.date ~ .\"",
0,
"120", "seconds" },
{ "workspace_client",
......
......@@ -20,7 +20,7 @@ client c1 {
client c1 -run
varnish v1 -cli "ban.url foo"
varnish v1 -cli "ban req.url ~ foo"
client c1 {
txreq -url "/foo"
......
......@@ -13,7 +13,7 @@ server s1 {
varnish v1 -vcl+backend {} -start
varnish v1 -cliok "ban.url FOO"
varnish v1 -cliok "ban req.url ~ FOO"
# There is one "magic" ban from boot
varnish v1 -expect bans_added == 2
......@@ -35,7 +35,7 @@ varnish v1 -expect bans_tested == 0
varnish v1 -expect bans_tests_tested == 0
# Add another ban
varnish v1 -cliok "ban.url FOO"
varnish v1 -cliok "ban req.url ~ FOO"
varnish v1 -expect bans_added == 3
varnish v1 -cliok "ban.list"
......@@ -60,15 +60,15 @@ client c1 {
# Now add another two bans, Kilroy should not be hit
varnish v1 -cliok "ban.url KILROY"
varnish v1 -cliok "ban.url FOO"
varnish v1 -cliok "ban req.url ~ KILROY"
varnish v1 -cliok "ban req.url ~ FOO"
varnish v1 -expect bans_added == 5
# Enable dup removal of bans
varnish v1 -cliok "param.set ban_dups on"
# This should incapacitate the two previous FOO bans.
varnish v1 -cliok "ban.url FOO"
varnish v1 -cliok "ban req.url ~ FOO"
varnish v1 -expect bans_added == 6
varnish v1 -expect bans_dups == 3
varnish v1 -cliok "ban.list"
......@@ -87,4 +87,4 @@ varnish v1 -cliok "ban.list"
# Test a bogus regexp
varnish v1 -clierr 106 "ban.url [[["
varnish v1 -clierr 106 "ban req.url ~ [[["
......@@ -11,7 +11,7 @@ server s1 {
varnish v1 -vcl+backend {
sub vcl_recv {
if (req.request == "PURGE") {
ban_url("^/$");
ban("req.url ~ ^/$");
error 209 "foo";
}
}
......
......@@ -86,7 +86,7 @@ varnish v1 -errvcl {Only http header variables can be unset.} {
varnish v1 -errvcl {Unknown token 'if' when looking for STRING} {
backend b { .host = "127.0.0.1"; }
sub vcl_recv { ban_url (if); }
sub vcl_recv { ban (if); }
}
varnish v1 -errvcl {Expected an action, 'if', '{' or '}'} {
......@@ -96,7 +96,7 @@ varnish v1 -errvcl {Expected an action, 'if', '{' or '}'} {
varnish v1 -vcl {
backend b { .host = "127.0.0.1"; }
sub vcl_recv { ban_url ("foo"); }
sub vcl_recv { ban ("req.url ~ foo"); }
}
varnish v1 -errvcl {Expected an action, 'if', '{' or '}'} {
......
......@@ -118,13 +118,6 @@ ban.list
Then follows the actual ban it self.
ban.url regexp
Immediately invalidate all documents whose URL matches the
specified regular expression. Please note that the Host part of
the URL is ignored, so if you have several virtual hosts all of
them will be banned. Use *ban* to specify a complete ban if you
need to narrow it down.
help [command]
Display a list of available commands.
If the command is specified, display help for this command.
......
......@@ -327,9 +327,6 @@ regsuball(str, regex, sub)
ban(ban expression)
Bans all objects in cache that match the expression.
ban_url(regex)
Bans all objects in cache whose URLs match regex.
Subroutines
~~~~~~~~~~~
......@@ -574,7 +571,7 @@ Example:
sub vcl_recv {
if (client.ip ~ admin_network) {
if (req.http.Cache-Control ~ "no-cache") {
ban_url(req.url);
ban("req.url ~ " + req.url);
}
}
}
......
......@@ -58,13 +58,6 @@
"\tReturns the TTL, size and checksum of the object.", \
1, 1
#define CLI_BAN_URL \
"ban.url", \
"ban.url <regexp>", \
"\tAll objects where the urls matches regexp will be " \
"marked obsolete.", \
1, 1
#define CLI_BAN \
"ban", \
"ban <field> <operator> <arg> [&& <field> <oper> <arg>]...", \
......
......@@ -194,24 +194,6 @@ parse_ban(struct vcc *tl)
/*--------------------------------------------------------------------*/
static void
parse_ban_url(struct vcc *tl)
{
vcc_NextToken(tl);
ExpectErr(tl, '(');
vcc_NextToken(tl);
Fb(tl, 1, "VRT_ban(req, \"req.url\", \"~\", ");
vcc_Expr(tl, STRING);
ERRCHK(tl);
ExpectErr(tl, ')');
vcc_NextToken(tl);
Fb(tl, 0, ", 0);\n");
}
/*--------------------------------------------------------------------*/
static void
parse_new_syntax(struct vcc *tl)
{
......@@ -324,7 +306,6 @@ static struct action_table {
{ "call", parse_call },
{ "hash_data", parse_hash_data, VCL_MET_HASH },
{ "ban", parse_ban },
{ "ban_url", parse_ban_url },
{ "remove", parse_unset }, /* backward compatibility */
{ "return", parse_return },
{ "rollback", parse_rollback },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment