Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
b0080ea4
Commit
b0080ea4
authored
Sep 25, 2013
by
Martin Blix Grydeland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable record prefix filtering for operations
parent
ad7153be
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
5 deletions
+49
-5
l00001.vtc
bin/varnishtest/tests/l00001.vtc
+7
-0
generate.py
lib/libvarnishapi/generate.py
+1
-1
vsl_query.c
lib/libvarnishapi/vsl_query.c
+12
-0
vxp.h
lib/libvarnishapi/vxp.h
+2
-0
vxp_parse.c
lib/libvarnishapi/vxp_parse.c
+27
-4
No files found.
bin/varnishtest/tests/l00001.vtc
View file @
b0080ea4
...
...
@@ -179,3 +179,10 @@ logexpect l1 -d 1 -g vxid -q "Debug,Resp* == 200" {
expect * = ReqEnd
expect * = End
} -run
# Test record prefix
logexpect l1 -d 1 -g vxid -q "Resp*:x-test eq '123 321'" {
expect 0 * Begin req
expect * = ReqEnd
expect * = End
} -run
lib/libvarnishapi/generate.py
View file @
b0080ea4
...
...
@@ -63,7 +63,7 @@ tokens = {
"T_NOT"
:
"not"
,
# Miscellaneous
None
:
"<>~[]{}()"
,
None
:
"<>~[]{}()
:
"
,
# These have handwritten recognizers
"VAL"
:
None
,
...
...
lib/libvarnishapi/vsl_query.c
View file @
b0080ea4
...
...
@@ -86,6 +86,18 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
b
=
VSL_CDATA
(
rec
->
ptr
);
e
=
b
+
VSL_LEN
(
rec
->
ptr
)
-
1
;
/* Prefix */
if
(
vex
->
lhs
->
prefix
!=
NULL
)
{
if
(
strncasecmp
(
b
,
vex
->
lhs
->
prefix
,
vex
->
lhs
->
prefixlen
))
return
(
0
);
if
(
b
[
vex
->
lhs
->
prefixlen
]
!=
':'
)
return
(
0
);
b
+=
vex
->
lhs
->
prefixlen
+
1
;
/* Skip ws */
while
(
*
b
&&
isspace
(
*
b
))
b
++
;
}
/* Field */
if
(
vex
->
lhs
->
field
>
0
)
{
for
(
e
=
b
,
i
=
0
;
*
e
&&
i
<
vex
->
lhs
->
field
;
i
++
)
{
...
...
lib/libvarnishapi/vxp.h
View file @
b0080ea4
...
...
@@ -83,6 +83,8 @@ struct vex_lhs {
unsigned
magic
;
#define VEX_LHS_MAGIC 0x1AD3D78D
struct
vbitmap
*
tags
;
char
*
prefix
;
int
prefixlen
;
int
field
;
int
level_min
;
int
level_max
;
...
...
lib/libvarnishapi/vxp_parse.c
View file @
b0080ea4
...
...
@@ -85,6 +85,22 @@ vxp_expr_lhs(struct vxp *vxp, struct vex_lhs **plhs)
assert
(
i
>
0
);
vxp_NextToken
(
vxp
);
if
(
vxp
->
t
->
tok
==
':'
)
{
/* Record prefix */
vxp_NextToken
(
vxp
);
if
(
vxp
->
t
->
tok
!=
VAL
)
{
VSB_printf
(
vxp
->
sb
,
"Expected string got '%.*s' "
,
PF
(
vxp
->
t
));
vxp_ErrWhere
(
vxp
,
vxp
->
t
,
-
1
);
return
;
}
AN
(
vxp
->
t
->
dec
);
(
*
plhs
)
->
prefix
=
strdup
(
vxp
->
t
->
dec
);
AN
((
*
plhs
)
->
prefix
);
(
*
plhs
)
->
prefixlen
=
strlen
((
*
plhs
)
->
prefix
);
vxp_NextToken
(
vxp
);
}
if
(
vxp
->
t
->
tok
==
'['
)
{
/* LHS field [] */
vxp_NextToken
(
vxp
);
...
...
@@ -434,6 +450,8 @@ vex_Free(struct vex **pvex)
if
((
*
pvex
)
->
lhs
!=
NULL
)
{
if
((
*
pvex
)
->
lhs
->
tags
!=
NULL
)
vbit_destroy
((
*
pvex
)
->
lhs
->
tags
);
if
((
*
pvex
)
->
lhs
->
prefix
!=
NULL
)
free
((
*
pvex
)
->
lhs
->
prefix
);
FREE_OBJ
((
*
pvex
)
->
lhs
);
}
if
((
*
pvex
)
->
rhs
!=
NULL
)
{
...
...
@@ -462,21 +480,22 @@ vex_print_rhs(const struct vex_rhs *rhs)
{
CHECK_OBJ_NOTNULL
(
rhs
,
VEX_RHS_MAGIC
);
fprintf
(
stderr
,
"rhs="
);
switch
(
rhs
->
type
)
{
case
VEX_INT
:
fprintf
(
stderr
,
"INT
=%jd
"
,
(
intmax_t
)
rhs
->
val_int
);
fprintf
(
stderr
,
"INT
(%jd)
"
,
(
intmax_t
)
rhs
->
val_int
);
break
;
case
VEX_FLOAT
:
fprintf
(
stderr
,
"FLOAT
=%f
"
,
rhs
->
val_float
);
fprintf
(
stderr
,
"FLOAT
(%f)
"
,
rhs
->
val_float
);
break
;
case
VEX_STRING
:
AN
(
rhs
->
val_string
);
fprintf
(
stderr
,
"STRING
='%s'
"
,
rhs
->
val_string
);
fprintf
(
stderr
,
"STRING
(%s)
"
,
rhs
->
val_string
);
break
;
case
VEX_REGEX
:
AN
(
rhs
->
val_string
);
AN
(
rhs
->
val_regex
);
fprintf
(
stderr
,
"REGEX
='%s'
"
,
rhs
->
val_string
);
fprintf
(
stderr
,
"REGEX
(%s)
"
,
rhs
->
val_string
);
break
;
default:
WRONG
(
"rhs type"
);
...
...
@@ -515,6 +534,10 @@ vex_print(const struct vex *vex, int indent)
fprintf
(
stderr
,
" lhs=("
);
vex_print_tags
(
vex
->
lhs
->
tags
);
fprintf
(
stderr
,
")"
);
if
(
vex
->
lhs
->
prefix
)
{
assert
(
vex
->
lhs
->
prefixlen
==
strlen
(
vex
->
lhs
->
prefix
));
fprintf
(
stderr
,
":%s"
,
vex
->
lhs
->
prefix
);
}
if
(
vex
->
lhs
->
field
>=
0
)
fprintf
(
stderr
,
"[%d]"
,
vex
->
lhs
->
field
);
}
...
...
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