Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishevent3
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
varnishevent3
Commits
cdd3b7bb
Commit
cdd3b7bb
authored
Feb 03, 2013
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
varnishevent - added formatter for %u
parent
dba10578
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
90 deletions
+39
-90
format.c
bin/varnishevent/format.c
+35
-87
varnishevent.c
bin/varnishevent/varnishevent.c
+2
-1
varnishevent.h
bin/varnishevent/varnishevent.h
+2
-2
No files found.
bin/varnishevent/format.c
View file @
cdd3b7bb
...
...
@@ -39,6 +39,7 @@
#include "vas.h"
#include "vsl.h"
#include "miniobj.h"
#include "base64.h"
#define C(spec) ((spec) & VSL_S_CLIENT)
#define B(spec) ((spec) & VSL_S_BACKEND)
...
...
@@ -230,28 +231,6 @@ format_q_##dir(logline_t *ll, char *name, enum VSL_tag_e tag, \
FORMAT_q
(
client
,
RxURL
)
FORMAT_q
(
backend
,
TxURL
)
#if 0
case 'r':
/*
* Fake "%r". This would be a lot easier if Varnish
* normalized the request URL.
*/
VSB_cat(os, lp->df_m ? lp->df_m : "-");
VSB_putc(os, ' ');
if (req_header(lp, "Host")) {
if (strncmp(req_header(lp, "Host"), "http://", 7) != 0)
VSB_cat(os, "http://");
VSB_cat(os, req_header(lp, "Host"));
} else {
VSB_cat(os, "http://localhost");
}
VSB_cat(os, lp->df_U ? lp->df_U : "-");
VSB_cat(os, lp->df_q ? lp->df_q : "");
VSB_putc(os, ' ');
VSB_cat(os, lp->df_H ? lp->df_H : "HTTP/1.0");
break;
#endif
#define FORMAT_r(dir, dx, hx) \
static void \
format_r_##dir(logline_t *ll, char *name, enum VSL_tag_e tag, \
...
...
@@ -338,28 +317,36 @@ format_U_##dir(logline_t *ll, char *name, enum VSL_tag_e tag, \
FORMAT_U
(
client
,
Rx
)
FORMAT_U
(
backend
,
Tx
)
#if 0
case 'u':
/* %u: decode authorization string */
if (lp->df_u != NULL) {
char *rubuf;
size_t rulen;
VB64_init();
rulen = ((strlen(lp->df_u) + 3) * 4) / 3;
rubuf = malloc(rulen);
assert(rubuf != NULL);
VB64_decode(rubuf, rulen, lp->df_u);
q = strchr(rubuf, ':');
if (q != NULL)
*q = '\0';
VSB_cat(os, rubuf);
free(rubuf);
} else {
VSB_putc(os, '-');
}
break;
#endif
#define FORMAT_u(dir, hx) \
static void \
format_u_##dir(logline_t *ll, char *name, enum VSL_tag_e tag, \
char **s, size_t *len) \
{ \
(void) name; \
(void) tag; \
record_t *rec; \
\
if ((rec = GET_HDR(ll, hx, "Authorization")) != NULL \
&& strncasecmp(rec->data + strlen("Authorization: "), "Basic", \
strlen("Basic")) == 0) { \
char *c, *auth = get_fld(rec, 3); \
VB64_init(); \
VB64_decode(scratch, config.max_reclen, auth); \
c = strchr(scratch, ':'); \
if (c != NULL) \
*c = '\0'; \
*s = scratch; \
*len = strlen(scratch); \
} \
else { \
strcpy(scratch, "-"); \
*s = scratch; \
*len = 1; \
} \
}
FORMAT_u
(
client
,
rx
)
FORMAT_u
(
backend
,
tx
)
#define FORMAT_Xio(dir, io, hx) \
static void \
...
...
@@ -591,28 +578,6 @@ compile_fmt(char *format, compiled_fmt_t *fmt, unsigned spec, char *err)
n
++
;
break
;
#if 0
case 'r':
/*
* Fake "%r". This would be a lot easier if Varnish
* normalized the request URL.
*/
VSB_cat(os, lp->df_m ? lp->df_m : "-");
VSB_putc(os, ' ');
if (req_header(lp, "Host")) {
if (strncmp(req_header(lp, "Host"), "http://", 7) != 0)
VSB_cat(os, "http://");
VSB_cat(os, req_header(lp, "Host"));
} else {
VSB_cat(os, "http://localhost");
}
VSB_cat(os, lp->df_U ? lp->df_U : "-");
VSB_cat(os, lp->df_q ? lp->df_q : "");
VSB_putc(os, ' ');
VSB_cat(os, lp->df_H ? lp->df_H : "HTTP/1.0");
break;
#endif
case
'r'
:
ADD_FMT
(
spec
,
fmt
,
os
,
n
,
format_r
,
NULL
,
0
);
ADD_CB_TAG
(
spec
,
fmt
->
tags
,
RxRequest
,
TxRequest
);
...
...
@@ -647,29 +612,12 @@ compile_fmt(char *format, compiled_fmt_t *fmt, unsigned spec, char *err)
n
++
;
break
;
#if 0
case
'u'
:
/* %u: decode authorization string */
if (lp->df_u != NULL) {
char *rubuf;
size_t rulen;
VB64_init();
rulen = ((strlen(lp->df_u) + 3) * 4) / 3;
rubuf = malloc(rulen);
assert(rubuf != NULL);
VB64_decode(rubuf, rulen, lp->df_u);
q = strchr(rubuf, ':');
if (q != NULL)
*q = '\0';
VSB_cat(os, rubuf);
free(rubuf);
} else {
VSB_putc(os, '-');
}
ADD_FMT
(
spec
,
fmt
,
os
,
n
,
format_u
,
NULL
,
0
);
ADD_CB_TAG
(
spec
,
fmt
->
tags
,
RxHeader
,
TxHeader
);
n
++
;
break
;
#endif
case
'{'
:
{
const
char
*
tmp
;
char
fname
[
100
],
type
;
...
...
bin/varnishevent/varnishevent.c
View file @
cdd3b7bb
...
...
@@ -263,7 +263,8 @@ collect(struct logline_t *lp, enum VSL_tag_e tag, unsigned spec,
}
else
rec
=
&
lp
->
tag
[
tag2idx
[
tag
]];
CHECK_OBJ_NOTNULL
(
rec
,
RECORD_MAGIC
);
memcpy
(
rec
->
data
,
ptr
,
len
);
rec
->
len
=
len
;
}
...
...
bin/varnishevent/varnishevent.h
View file @
cdd3b7bb
...
...
@@ -51,17 +51,17 @@
#define MAX_VSL_TAG 256
#if 0
#define DEFAULT_CFORMAT \
"%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\""
#define ALT_CFORMAT \
"%{X-Forwarded-For}i %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\""
#endif
#if 0
#define DEFAULT_CFORMAT \
"%h %l %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\""
#define ALT_CFORMAT \
"%{X-Forwarded-For}i %l %t %U %s %b \"%{Referer}i\" \"%{User-agent}i\""
#endif
typedef
enum
{
DATA_EMPTY
=
0
,
...
...
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