Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
4d562b77
Commit
4d562b77
authored
Oct 17, 2018
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Convert LogFragmentType to enum class
parent
e6225871
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
124 additions
and
123 deletions
+124
-123
genheaderfunc.py
genheaderfunc.py
+1
-1
genmethodfunc.py
genmethodfunc.py
+1
-1
gennghttpxfun.py
gennghttpxfun.py
+2
-2
gentokenlookup.py
gentokenlookup.py
+2
-2
src/shrpx_config.cc
src/shrpx_config.cc
+33
-33
src/shrpx_config_test.cc
src/shrpx_config_test.cc
+22
-22
src/shrpx_log.cc
src/shrpx_log.cc
+31
-30
src/shrpx_log.h
src/shrpx_log.h
+32
-32
No files found.
genheaderfunc.py
View file @
4d562b77
...
...
@@ -44,4 +44,4 @@ HEADERS = [
]
if
__name__
==
'__main__'
:
gentokenlookup
(
HEADERS
,
'HD'
)
gentokenlookup
(
HEADERS
,
'HD
_
'
)
genmethodfunc.py
View file @
4d562b77
...
...
@@ -50,4 +50,4 @@ if __name__ == '__main__':
continue
_
,
m
,
_
=
line
.
split
(
','
,
2
)
methods
.
append
(
m
.
strip
())
gentokenlookup
(
methods
,
'HTTP'
)
gentokenlookup
(
methods
,
'HTTP
_
'
)
gennghttpxfun.py
View file @
4d562b77
...
...
@@ -208,5 +208,5 @@ LOGVARS = [
]
if
__name__
==
'__main__'
:
gentokenlookup
(
OPTIONS
,
'SHRPX_OPTID'
,
value_type
=
'char'
,
comp_fun
=
'util::strieq_l'
)
gentokenlookup
(
LOGVARS
,
'
SHRPX_LOGF'
,
value_type
=
'char'
,
comp_fun
=
'util::strieq_l'
,
return_type
=
'LogFragmentType'
,
fail_value
=
'SHRPX_LOGF_
NONE'
)
gentokenlookup
(
OPTIONS
,
'SHRPX_OPTID
_
'
,
value_type
=
'char'
,
comp_fun
=
'util::strieq_l'
)
gentokenlookup
(
LOGVARS
,
'
LogFragmentType::'
,
value_type
=
'char'
,
comp_fun
=
'util::strieq_l'
,
return_type
=
'LogFragmentType'
,
fail_value
=
'LogFragmentType::
NONE'
)
gentokenlookup.py
View file @
4d562b77
#!/usr/bin/env python
def
to_enum_hd
(
k
,
prefix
):
res
=
prefix
+
'_'
res
=
prefix
for
c
in
k
.
upper
():
if
c
==
':'
or
c
==
'-'
:
res
+=
'_'
...
...
@@ -30,7 +30,7 @@ enum {'''
print
'''
\
{},'''
.
format
(
to_enum_hd
(
k
,
prefix
))
print
'''
\
{}
_
MAXIDX,
{}MAXIDX,
}};'''
.
format
(
prefix
)
def
gen_index_header
(
tokens
,
prefix
,
value_type
,
comp_fun
,
return_type
,
fail_value
):
...
...
src/shrpx_config.cc
View file @
4d562b77
...
...
@@ -379,7 +379,7 @@ LogFragmentType log_var_lookup_token(const char *name, size_t namelen) {
switch
(
name
[
2
])
{
case
'd'
:
if
(
util
::
strieq_l
(
"pi"
,
name
,
2
))
{
return
SHRPX_LOGF_
PID
;
return
LogFragmentType
::
PID
;
}
break
;
}
...
...
@@ -388,7 +388,7 @@ LogFragmentType log_var_lookup_token(const char *name, size_t namelen) {
switch
(
name
[
3
])
{
case
'n'
:
if
(
util
::
strieq_l
(
"alp"
,
name
,
3
))
{
return
SHRPX_LOGF_
ALPN
;
return
LogFragmentType
::
ALPN
;
}
break
;
}
...
...
@@ -397,7 +397,7 @@ LogFragmentType log_var_lookup_token(const char *name, size_t namelen) {
switch
(
name
[
5
])
{
case
's'
:
if
(
util
::
strieq_l
(
"statu"
,
name
,
5
))
{
return
SHRPX_LOGF_
STATUS
;
return
LogFragmentType
::
STATUS
;
}
break
;
}
...
...
@@ -406,12 +406,12 @@ LogFragmentType log_var_lookup_token(const char *name, size_t namelen) {
switch
(
name
[
6
])
{
case
'i'
:
if
(
util
::
strieq_l
(
"tls_sn"
,
name
,
6
))
{
return
SHRPX_LOGF_
TLS_SNI
;
return
LogFragmentType
::
TLS_SNI
;
}
break
;
case
't'
:
if
(
util
::
strieq_l
(
"reques"
,
name
,
6
))
{
return
SHRPX_LOGF_
REQUEST
;
return
LogFragmentType
::
REQUEST
;
}
break
;
}
...
...
@@ -420,15 +420,15 @@ LogFragmentType log_var_lookup_token(const char *name, size_t namelen) {
switch
(
name
[
9
])
{
case
'l'
:
if
(
util
::
strieq_l
(
"time_loca"
,
name
,
9
))
{
return
SHRPX_LOGF_
TIME_LOCAL
;
return
LogFragmentType
::
TIME_LOCAL
;
}
break
;
case
'r'
:
if
(
util
::
strieq_l
(
"ssl_ciphe"
,
name
,
9
))
{
return
SHRPX_LOGF_
SSL_CIPHER
;
return
LogFragmentType
::
SSL_CIPHER
;
}
if
(
util
::
strieq_l
(
"tls_ciphe"
,
name
,
9
))
{
return
SHRPX_LOGF_
TLS_CIPHER
;
return
LogFragmentType
::
TLS_CIPHER
;
}
break
;
}
...
...
@@ -437,15 +437,15 @@ LogFragmentType log_var_lookup_token(const char *name, size_t namelen) {
switch
(
name
[
10
])
{
case
'r'
:
if
(
util
::
strieq_l
(
"remote_add"
,
name
,
10
))
{
return
SHRPX_LOGF_
REMOTE_ADDR
;
return
LogFragmentType
::
REMOTE_ADDR
;
}
break
;
case
't'
:
if
(
util
::
strieq_l
(
"remote_por"
,
name
,
10
))
{
return
SHRPX_LOGF_
REMOTE_PORT
;
return
LogFragmentType
::
REMOTE_PORT
;
}
if
(
util
::
strieq_l
(
"server_por"
,
name
,
10
))
{
return
SHRPX_LOGF_
SERVER_PORT
;
return
LogFragmentType
::
SERVER_PORT
;
}
break
;
}
...
...
@@ -454,28 +454,28 @@ LogFragmentType log_var_lookup_token(const char *name, size_t namelen) {
switch
(
name
[
11
])
{
case
'1'
:
if
(
util
::
strieq_l
(
"time_iso860"
,
name
,
11
))
{
return
SHRPX_LOGF_
TIME_ISO8601
;
return
LogFragmentType
::
TIME_ISO8601
;
}
break
;
case
'e'
:
if
(
util
::
strieq_l
(
"request_tim"
,
name
,
11
))
{
return
SHRPX_LOGF_
REQUEST_TIME
;
return
LogFragmentType
::
REQUEST_TIME
;
}
break
;
case
'l'
:
if
(
util
::
strieq_l
(
"ssl_protoco"
,
name
,
11
))
{
return
SHRPX_LOGF_
SSL_PROTOCOL
;
return
LogFragmentType
::
SSL_PROTOCOL
;
}
if
(
util
::
strieq_l
(
"tls_protoco"
,
name
,
11
))
{
return
SHRPX_LOGF_
TLS_PROTOCOL
;
return
LogFragmentType
::
TLS_PROTOCOL
;
}
break
;
case
't'
:
if
(
util
::
strieq_l
(
"backend_hos"
,
name
,
11
))
{
return
SHRPX_LOGF_
BACKEND_HOST
;
return
LogFragmentType
::
BACKEND_HOST
;
}
if
(
util
::
strieq_l
(
"backend_por"
,
name
,
11
))
{
return
SHRPX_LOGF_
BACKEND_PORT
;
return
LogFragmentType
::
BACKEND_PORT
;
}
break
;
}
...
...
@@ -484,10 +484,10 @@ LogFragmentType log_var_lookup_token(const char *name, size_t namelen) {
switch
(
name
[
13
])
{
case
'd'
:
if
(
util
::
strieq_l
(
"ssl_session_i"
,
name
,
13
))
{
return
SHRPX_LOGF_
SSL_SESSION_ID
;
return
LogFragmentType
::
SSL_SESSION_ID
;
}
if
(
util
::
strieq_l
(
"tls_session_i"
,
name
,
13
))
{
return
SHRPX_LOGF_
TLS_SESSION_ID
;
return
LogFragmentType
::
TLS_SESSION_ID
;
}
break
;
}
...
...
@@ -496,7 +496,7 @@ LogFragmentType log_var_lookup_token(const char *name, size_t namelen) {
switch
(
name
[
14
])
{
case
't'
:
if
(
util
::
strieq_l
(
"body_bytes_sen"
,
name
,
14
))
{
return
SHRPX_LOGF_
BODY_BYTES_SENT
;
return
LogFragmentType
::
BODY_BYTES_SENT
;
}
break
;
}
...
...
@@ -505,7 +505,7 @@ LogFragmentType log_var_lookup_token(const char *name, size_t namelen) {
switch
(
name
[
16
])
{
case
'l'
:
if
(
util
::
strieq_l
(
"tls_client_seria"
,
name
,
16
))
{
return
SHRPX_LOGF_
TLS_CLIENT_SERIAL
;
return
LogFragmentType
::
TLS_CLIENT_SERIAL
;
}
break
;
}
...
...
@@ -514,10 +514,10 @@ LogFragmentType log_var_lookup_token(const char *name, size_t namelen) {
switch
(
name
[
17
])
{
case
'd'
:
if
(
util
::
strieq_l
(
"ssl_session_reuse"
,
name
,
17
))
{
return
SHRPX_LOGF_
SSL_SESSION_REUSED
;
return
LogFragmentType
::
SSL_SESSION_REUSED
;
}
if
(
util
::
strieq_l
(
"tls_session_reuse"
,
name
,
17
))
{
return
SHRPX_LOGF_
TLS_SESSION_REUSED
;
return
LogFragmentType
::
TLS_SESSION_REUSED
;
}
break
;
}
...
...
@@ -526,7 +526,7 @@ LogFragmentType log_var_lookup_token(const char *name, size_t namelen) {
switch
(
name
[
21
])
{
case
'e'
:
if
(
util
::
strieq_l
(
"tls_client_issuer_nam"
,
name
,
21
))
{
return
SHRPX_LOGF_
TLS_CLIENT_ISSUER_NAME
;
return
LogFragmentType
::
TLS_CLIENT_ISSUER_NAME
;
}
break
;
}
...
...
@@ -535,7 +535,7 @@ LogFragmentType log_var_lookup_token(const char *name, size_t namelen) {
switch
(
name
[
22
])
{
case
'e'
:
if
(
util
::
strieq_l
(
"tls_client_subject_nam"
,
name
,
22
))
{
return
SHRPX_LOGF_
TLS_CLIENT_SUBJECT_NAME
;
return
LogFragmentType
::
TLS_CLIENT_SUBJECT_NAME
;
}
break
;
}
...
...
@@ -544,7 +544,7 @@ LogFragmentType log_var_lookup_token(const char *name, size_t namelen) {
switch
(
name
[
26
])
{
case
'1'
:
if
(
util
::
strieq_l
(
"tls_client_fingerprint_sha"
,
name
,
26
))
{
return
SHRPX_LOGF_
TLS_CLIENT_FINGERPRINT_SHA1
;
return
LogFragmentType
::
TLS_CLIENT_FINGERPRINT_SHA1
;
}
break
;
}
...
...
@@ -553,13 +553,13 @@ LogFragmentType log_var_lookup_token(const char *name, size_t namelen) {
switch
(
name
[
28
])
{
case
'6'
:
if
(
util
::
strieq_l
(
"tls_client_fingerprint_sha25"
,
name
,
28
))
{
return
SHRPX_LOGF_
TLS_CLIENT_FINGERPRINT_SHA256
;
return
LogFragmentType
::
TLS_CLIENT_FINGERPRINT_SHA256
;
}
break
;
}
break
;
}
return
SHRPX_LOGF_
NONE
;
return
LogFragmentType
::
NONE
;
}
}
// namespace
...
...
@@ -613,16 +613,16 @@ std::vector<LogFragment> parse_log_format(BlockAllocator &balloc,
auto
type
=
log_var_lookup_token
(
var_name
,
var_namelen
);
if
(
type
==
SHRPX_LOGF_
NONE
)
{
if
(
type
==
LogFragmentType
::
NONE
)
{
if
(
util
::
istarts_with_l
(
StringRef
{
var_name
,
var_namelen
},
"http_"
))
{
if
(
util
::
streq_l
(
"host"
,
StringRef
{
var_name
+
str_size
(
"http_"
),
var_namelen
-
str_size
(
"http_"
)}))
{
// Special handling of host header field. We will use
// :authority header field if host header is missing. This
// is a typical case in HTTP/2.
type
=
SHRPX_LOGF_
AUTHORITY
;
type
=
LogFragmentType
::
AUTHORITY
;
}
else
{
type
=
SHRPX_LOGF_
HTTP
;
type
=
LogFragmentType
::
HTTP
;
value
=
var_name
+
str_size
(
"http_"
);
}
}
else
{
...
...
@@ -634,7 +634,7 @@ std::vector<LogFragment> parse_log_format(BlockAllocator &balloc,
if
(
literal_start
<
var_start
)
{
res
.
emplace_back
(
SHRPX_LOGF_
LITERAL
,
LogFragmentType
::
LITERAL
,
make_string_ref
(
balloc
,
StringRef
{
literal_start
,
var_start
}));
}
...
...
@@ -661,7 +661,7 @@ std::vector<LogFragment> parse_log_format(BlockAllocator &balloc,
}
if
(
literal_start
!=
eop
)
{
res
.
emplace_back
(
SHRPX_LOGF_
LITERAL
,
res
.
emplace_back
(
LogFragmentType
::
LITERAL
,
make_string_ref
(
balloc
,
StringRef
{
literal_start
,
eop
}));
}
...
...
src/shrpx_config_test.cc
View file @
4d562b77
...
...
@@ -79,84 +79,84 @@ void test_shrpx_config_parse_log_format(void) {
R"("${http_referer}" $http_host "$http_user_agent")"
));
CU_ASSERT
(
16
==
res
.
size
());
CU_ASSERT
(
SHRPX_LOGF_
REMOTE_ADDR
==
res
[
0
].
type
);
CU_ASSERT
(
LogFragmentType
::
REMOTE_ADDR
==
res
[
0
].
type
);
CU_ASSERT
(
SHRPX_LOGF_
LITERAL
==
res
[
1
].
type
);
CU_ASSERT
(
LogFragmentType
::
LITERAL
==
res
[
1
].
type
);
CU_ASSERT
(
" - $remote_user ["
==
res
[
1
].
value
);
CU_ASSERT
(
SHRPX_LOGF_
TIME_LOCAL
==
res
[
2
].
type
);
CU_ASSERT
(
LogFragmentType
::
TIME_LOCAL
==
res
[
2
].
type
);
CU_ASSERT
(
SHRPX_LOGF_
LITERAL
==
res
[
3
].
type
);
CU_ASSERT
(
LogFragmentType
::
LITERAL
==
res
[
3
].
type
);
CU_ASSERT
(
"]
\"
"
==
res
[
3
].
value
);
CU_ASSERT
(
SHRPX_LOGF_
REQUEST
==
res
[
4
].
type
);
CU_ASSERT
(
LogFragmentType
::
REQUEST
==
res
[
4
].
type
);
CU_ASSERT
(
SHRPX_LOGF_
LITERAL
==
res
[
5
].
type
);
CU_ASSERT
(
LogFragmentType
::
LITERAL
==
res
[
5
].
type
);
CU_ASSERT
(
"
\"
"
==
res
[
5
].
value
);
CU_ASSERT
(
SHRPX_LOGF_
STATUS
==
res
[
6
].
type
);
CU_ASSERT
(
LogFragmentType
::
STATUS
==
res
[
6
].
type
);
CU_ASSERT
(
SHRPX_LOGF_
LITERAL
==
res
[
7
].
type
);
CU_ASSERT
(
LogFragmentType
::
LITERAL
==
res
[
7
].
type
);
CU_ASSERT
(
" "
==
res
[
7
].
value
);
CU_ASSERT
(
SHRPX_LOGF_
BODY_BYTES_SENT
==
res
[
8
].
type
);
CU_ASSERT
(
LogFragmentType
::
BODY_BYTES_SENT
==
res
[
8
].
type
);
CU_ASSERT
(
SHRPX_LOGF_
LITERAL
==
res
[
9
].
type
);
CU_ASSERT
(
LogFragmentType
::
LITERAL
==
res
[
9
].
type
);
CU_ASSERT
(
"
\"
"
==
res
[
9
].
value
);
CU_ASSERT
(
SHRPX_LOGF_
HTTP
==
res
[
10
].
type
);
CU_ASSERT
(
LogFragmentType
::
HTTP
==
res
[
10
].
type
);
CU_ASSERT
(
"referer"
==
res
[
10
].
value
);
CU_ASSERT
(
SHRPX_LOGF_
LITERAL
==
res
[
11
].
type
);
CU_ASSERT
(
LogFragmentType
::
LITERAL
==
res
[
11
].
type
);
CU_ASSERT
(
"
\"
"
==
res
[
11
].
value
);
CU_ASSERT
(
SHRPX_LOGF_
AUTHORITY
==
res
[
12
].
type
);
CU_ASSERT
(
LogFragmentType
::
AUTHORITY
==
res
[
12
].
type
);
CU_ASSERT
(
SHRPX_LOGF_
LITERAL
==
res
[
13
].
type
);
CU_ASSERT
(
LogFragmentType
::
LITERAL
==
res
[
13
].
type
);
CU_ASSERT
(
"
\"
"
==
res
[
13
].
value
);
CU_ASSERT
(
SHRPX_LOGF_
HTTP
==
res
[
14
].
type
);
CU_ASSERT
(
LogFragmentType
::
HTTP
==
res
[
14
].
type
);
CU_ASSERT
(
"user-agent"
==
res
[
14
].
value
);
CU_ASSERT
(
SHRPX_LOGF_
LITERAL
==
res
[
15
].
type
);
CU_ASSERT
(
LogFragmentType
::
LITERAL
==
res
[
15
].
type
);
CU_ASSERT
(
"
\"
"
==
res
[
15
].
value
);
res
=
parse_log_format
(
balloc
,
StringRef
::
from_lit
(
"$"
));
CU_ASSERT
(
1
==
res
.
size
());
CU_ASSERT
(
SHRPX_LOGF_
LITERAL
==
res
[
0
].
type
);
CU_ASSERT
(
LogFragmentType
::
LITERAL
==
res
[
0
].
type
);
CU_ASSERT
(
"$"
==
res
[
0
].
value
);
res
=
parse_log_format
(
balloc
,
StringRef
::
from_lit
(
"${"
));
CU_ASSERT
(
1
==
res
.
size
());
CU_ASSERT
(
SHRPX_LOGF_
LITERAL
==
res
[
0
].
type
);
CU_ASSERT
(
LogFragmentType
::
LITERAL
==
res
[
0
].
type
);
CU_ASSERT
(
"${"
==
res
[
0
].
value
);
res
=
parse_log_format
(
balloc
,
StringRef
::
from_lit
(
"${a"
));
CU_ASSERT
(
1
==
res
.
size
());
CU_ASSERT
(
SHRPX_LOGF_
LITERAL
==
res
[
0
].
type
);
CU_ASSERT
(
LogFragmentType
::
LITERAL
==
res
[
0
].
type
);
CU_ASSERT
(
"${a"
==
res
[
0
].
value
);
res
=
parse_log_format
(
balloc
,
StringRef
::
from_lit
(
"${a "
));
CU_ASSERT
(
1
==
res
.
size
());
CU_ASSERT
(
SHRPX_LOGF_
LITERAL
==
res
[
0
].
type
);
CU_ASSERT
(
LogFragmentType
::
LITERAL
==
res
[
0
].
type
);
CU_ASSERT
(
"${a "
==
res
[
0
].
value
);
res
=
parse_log_format
(
balloc
,
StringRef
::
from_lit
(
"$$remote_addr"
));
CU_ASSERT
(
2
==
res
.
size
());
CU_ASSERT
(
SHRPX_LOGF_
LITERAL
==
res
[
0
].
type
);
CU_ASSERT
(
LogFragmentType
::
LITERAL
==
res
[
0
].
type
);
CU_ASSERT
(
"$"
==
res
[
0
].
value
);
CU_ASSERT
(
SHRPX_LOGF_
REMOTE_ADDR
==
res
[
1
].
type
);
CU_ASSERT
(
LogFragmentType
::
REMOTE_ADDR
==
res
[
1
].
type
);
CU_ASSERT
(
""
==
res
[
1
].
value
);
}
...
...
src/shrpx_log.cc
View file @
4d562b77
...
...
@@ -609,19 +609,19 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
for
(
auto
&
lf
:
lfv
)
{
switch
(
lf
.
type
)
{
case
SHRPX_LOGF_
LITERAL
:
case
LogFragmentType
:
:
LITERAL
:
std
::
tie
(
p
,
last
)
=
copy
(
lf
.
value
,
p
,
last
);
break
;
case
SHRPX_LOGF_
REMOTE_ADDR
:
case
LogFragmentType
:
:
REMOTE_ADDR
:
std
::
tie
(
p
,
last
)
=
copy
(
lgsp
.
remote_addr
,
p
,
last
);
break
;
case
SHRPX_LOGF_
TIME_LOCAL
:
case
LogFragmentType
:
:
TIME_LOCAL
:
std
::
tie
(
p
,
last
)
=
copy
(
tstamp
->
time_local
,
p
,
last
);
break
;
case
SHRPX_LOGF_
TIME_ISO8601
:
case
LogFragmentType
:
:
TIME_ISO8601
:
std
::
tie
(
p
,
last
)
=
copy
(
tstamp
->
time_iso8601
,
p
,
last
);
break
;
case
SHRPX_LOGF_
REQUEST
:
case
LogFragmentType
:
:
REQUEST
:
std
::
tie
(
p
,
last
)
=
copy
(
method
,
p
,
last
);
std
::
tie
(
p
,
last
)
=
copy
(
' '
,
p
,
last
);
std
::
tie
(
p
,
last
)
=
copy_escape
(
path
,
p
,
last
);
...
...
@@ -632,13 +632,13 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
std
::
tie
(
p
,
last
)
=
copy
(
req
.
http_minor
,
p
,
last
);
}
break
;
case
SHRPX_LOGF_
STATUS
:
case
LogFragmentType
:
:
STATUS
:
std
::
tie
(
p
,
last
)
=
copy
(
resp
.
http_status
,
p
,
last
);
break
;
case
SHRPX_LOGF_
BODY_BYTES_SENT
:
case
LogFragmentType
:
:
BODY_BYTES_SENT
:
std
::
tie
(
p
,
last
)
=
copy
(
downstream
->
response_sent_body_length
,
p
,
last
);
break
;
case
SHRPX_LOGF_
HTTP
:
{
case
LogFragmentType
:
:
HTTP
:
{
auto
hd
=
req
.
fs
.
header
(
lf
.
value
);
if
(
hd
)
{
std
::
tie
(
p
,
last
)
=
copy_escape
((
*
hd
).
value
,
p
,
last
);
...
...
@@ -649,7 +649,7 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
break
;
}
case
SHRPX_LOGF_
AUTHORITY
:
case
LogFragmentType
:
:
AUTHORITY
:
if
(
!
req
.
authority
.
empty
())
{
std
::
tie
(
p
,
last
)
=
copy
(
req
.
authority
,
p
,
last
);
break
;
...
...
@@ -658,13 +658,13 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
std
::
tie
(
p
,
last
)
=
copy
(
'-'
,
p
,
last
);
break
;
case
SHRPX_LOGF_
REMOTE_PORT
:
case
LogFragmentType
:
:
REMOTE_PORT
:
std
::
tie
(
p
,
last
)
=
copy
(
lgsp
.
remote_port
,
p
,
last
);
break
;
case
SHRPX_LOGF_
SERVER_PORT
:
case
LogFragmentType
:
:
SERVER_PORT
:
std
::
tie
(
p
,
last
)
=
copy
(
lgsp
.
server_port
,
p
,
last
);
break
;
case
SHRPX_LOGF_
REQUEST_TIME
:
{
case
LogFragmentType
:
:
REQUEST_TIME
:
{
auto
t
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
lgsp
.
request_end_time
-
downstream
->
get_request_start_time
())
.
count
();
...
...
@@ -678,20 +678,20 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
std
::
tie
(
p
,
last
)
=
copy
(
frac
,
p
,
last
);
break
;
}
case
SHRPX_LOGF_
PID
:
case
LogFragmentType
:
:
PID
:
std
::
tie
(
p
,
last
)
=
copy
(
lgsp
.
pid
,
p
,
last
);
break
;
case
SHRPX_LOGF_
ALPN
:
case
LogFragmentType
:
:
ALPN
:
std
::
tie
(
p
,
last
)
=
copy_escape
(
lgsp
.
alpn
,
p
,
last
);
break
;
case
SHRPX_LOGF_
TLS_CIPHER
:
case
LogFragmentType
:
:
TLS_CIPHER
:
if
(
!
lgsp
.
ssl
)
{
std
::
tie
(
p
,
last
)
=
copy
(
'-'
,
p
,
last
);
break
;
}
std
::
tie
(
p
,
last
)
=
copy
(
SSL_get_cipher_name
(
lgsp
.
ssl
),
p
,
last
);
break
;
case
SHRPX_LOGF_
TLS_PROTOCOL
:
case
LogFragmentType
:
:
TLS_PROTOCOL
:
if
(
!
lgsp
.
ssl
)
{
std
::
tie
(
p
,
last
)
=
copy
(
'-'
,
p
,
last
);
break
;
...
...
@@ -699,7 +699,7 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
std
::
tie
(
p
,
last
)
=
copy
(
nghttp2
::
tls
::
get_tls_protocol
(
lgsp
.
ssl
),
p
,
last
);
break
;
case
SHRPX_LOGF_
TLS_SESSION_ID
:
{
case
LogFragmentType
:
:
TLS_SESSION_ID
:
{
auto
session
=
SSL_get_session
(
lgsp
.
ssl
);
if
(
!
session
)
{
std
::
tie
(
p
,
last
)
=
copy
(
'-'
,
p
,
last
);
...
...
@@ -714,7 +714,7 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
std
::
tie
(
p
,
last
)
=
copy_hex_low
(
session_id
,
session_id_length
,
p
,
last
);
break
;
}
case
SHRPX_LOGF_
TLS_SESSION_REUSED
:
case
LogFragmentType
:
:
TLS_SESSION_REUSED
:
if
(
!
lgsp
.
ssl
)
{
std
::
tie
(
p
,
last
)
=
copy
(
'-'
,
p
,
last
);
break
;
...
...
@@ -722,15 +722,15 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
std
::
tie
(
p
,
last
)
=
copy
(
SSL_session_reused
(
lgsp
.
ssl
)
?
'r'
:
'.'
,
p
,
last
);
break
;
case
SHRPX_LOGF_
TLS_SNI
:
case
LogFragmentType
:
:
TLS_SNI
:
if
(
lgsp
.
sni
.
empty
())
{
std
::
tie
(
p
,
last
)
=
copy
(
'-'
,
p
,
last
);
break
;
}
std
::
tie
(
p
,
last
)
=
copy_escape
(
lgsp
.
sni
,
p
,
last
);
break
;
case
SHRPX_LOGF_
TLS_CLIENT_FINGERPRINT_SHA1
:
case
SHRPX_LOGF_
TLS_CLIENT_FINGERPRINT_SHA256
:
{
case
LogFragmentType
:
:
TLS_CLIENT_FINGERPRINT_SHA1
:
case
LogFragmentType
:
:
TLS_CLIENT_FINGERPRINT_SHA256
:
{
if
(
!
lgsp
.
ssl
)
{
std
::
tie
(
p
,
last
)
=
copy
(
'-'
,
p
,
last
);
break
;
...
...
@@ -743,8 +743,9 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
std
::
array
<
uint8_t
,
32
>
buf
;
auto
len
=
tls
::
get_x509_fingerprint
(
buf
.
data
(),
buf
.
size
(),
x
,
lf
.
type
==
SHRPX_LOGF_TLS_CLIENT_FINGERPRINT_SHA256
?
EVP_sha256
()
:
EVP_sha1
());
lf
.
type
==
LogFragmentType
::
TLS_CLIENT_FINGERPRINT_SHA256
?
EVP_sha256
()
:
EVP_sha1
());
X509_free
(
x
);
if
(
len
<=
0
)
{
std
::
tie
(
p
,
last
)
=
copy
(
'-'
,
p
,
last
);
...
...
@@ -753,8 +754,8 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
std
::
tie
(
p
,
last
)
=
copy_hex_low
(
buf
.
data
(),
len
,
p
,
last
);
break
;
}
case
SHRPX_LOGF_
TLS_CLIENT_ISSUER_NAME
:
case
SHRPX_LOGF_
TLS_CLIENT_SUBJECT_NAME
:
{
case
LogFragmentType
:
:
TLS_CLIENT_ISSUER_NAME
:
case
LogFragmentType
:
:
TLS_CLIENT_SUBJECT_NAME
:
{
if
(
!
lgsp
.
ssl
)
{
std
::
tie
(
p
,
last
)
=
copy
(
'-'
,
p
,
last
);
break
;
...
...
@@ -764,7 +765,7 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
std
::
tie
(
p
,
last
)
=
copy
(
'-'
,
p
,
last
);
break
;
}
auto
name
=
lf
.
type
==
SHRPX_LOGF_
TLS_CLIENT_ISSUER_NAME
auto
name
=
lf
.
type
==
LogFragmentType
::
TLS_CLIENT_ISSUER_NAME
?
tls
::
get_x509_issuer_name
(
balloc
,
x
)
:
tls
::
get_x509_subject_name
(
balloc
,
x
);
X509_free
(
x
);
...
...
@@ -775,7 +776,7 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
std
::
tie
(
p
,
last
)
=
copy
(
name
,
p
,
last
);
break
;
}
case
SHRPX_LOGF_
TLS_CLIENT_SERIAL
:
{
case
LogFragmentType
:
:
TLS_CLIENT_SERIAL
:
{
if
(
!
lgsp
.
ssl
)
{
std
::
tie
(
p
,
last
)
=
copy
(
'-'
,
p
,
last
);
break
;
...
...
@@ -794,21 +795,21 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
std
::
tie
(
p
,
last
)
=
copy
(
sn
,
p
,
last
);
break
;
}
case
SHRPX_LOGF_
BACKEND_HOST
:
case
LogFragmentType
:
:
BACKEND_HOST
:
if
(
!
downstream_addr
)
{
std
::
tie
(
p
,
last
)
=
copy
(
'-'
,
p
,
last
);
break
;
}
std
::
tie
(
p
,
last
)
=
copy
(
downstream_addr
->
host
,
p
,
last
);
break
;
case
SHRPX_LOGF_
BACKEND_PORT
:
case
LogFragmentType
:
:
BACKEND_PORT
:
if
(
!
downstream_addr
)
{
std
::
tie
(
p
,
last
)
=
copy
(
'-'
,
p
,
last
);
break
;
}
std
::
tie
(
p
,
last
)
=
copy
(
downstream_addr
->
port
,
p
,
last
);
break
;
case
SHRPX_LOGF_
NONE
:
case
LogFragmentType
:
:
NONE
:
break
;
default:
break
;
...
...
src/shrpx_log.h
View file @
4d562b77
...
...
@@ -215,38 +215,38 @@ void dec(Log &log);
#define TTY_HTTP_HD (log_config()->errorlog_tty ? "\033[1;34m" : "")
#define TTY_RST (log_config()->errorlog_tty ? "\033[0m" : "")
enum
LogFragmentType
{
SHRPX_LOGF_
NONE
,
SHRPX_LOGF_
LITERAL
,
SHRPX_LOGF_
REMOTE_ADDR
,
SHRPX_LOGF_
TIME_LOCAL
,
SHRPX_LOGF_
TIME_ISO8601
,
SHRPX_LOGF_
REQUEST
,
S
HRPX_LOGF_S
TATUS
,
SHRPX_LOGF_
BODY_BYTES_SENT
,
SHRPX_LOGF_
HTTP
,
SHRPX_LOGF_
AUTHORITY
,
SHRPX_LOGF_
REMOTE_PORT
,
S
HRPX_LOGF_S
ERVER_PORT
,
SHRPX_LOGF_
REQUEST_TIME
,
SHRPX_LOGF_
PID
,
SHRPX_LOGF_
ALPN
,
SHRPX_LOGF_
TLS_CIPHER
,
S
HRPX_LOGF_SSL_CIPHER
=
SHRPX_LOGF_
TLS_CIPHER
,
SHRPX_LOGF_
TLS_PROTOCOL
,
S
HRPX_LOGF_SSL_PROTOCOL
=
SHRPX_LOGF_
TLS_PROTOCOL
,
SHRPX_LOGF_
TLS_SESSION_ID
,
S
HRPX_LOGF_SSL_SESSION_ID
=
SHRPX_LOGF_
TLS_SESSION_ID
,
SHRPX_LOGF_
TLS_SESSION_REUSED
,
S
HRPX_LOGF_SSL_SESSION_REUSED
=
SHRPX_LOGF_
TLS_SESSION_REUSED
,
SHRPX_LOGF_
TLS_SNI
,
SHRPX_LOGF_
TLS_CLIENT_FINGERPRINT_SHA1
,
SHRPX_LOGF_
TLS_CLIENT_FINGERPRINT_SHA256
,
SHRPX_LOGF_
TLS_CLIENT_ISSUER_NAME
,
SHRPX_LOGF_
TLS_CLIENT_SERIAL
,
SHRPX_LOGF_
TLS_CLIENT_SUBJECT_NAME
,
SHRPX_LOGF_
BACKEND_HOST
,
SHRPX_LOGF_
BACKEND_PORT
,
enum
class
LogFragmentType
{
NONE
,
LITERAL
,
REMOTE_ADDR
,
TIME_LOCAL
,
TIME_ISO8601
,
REQUEST
,
STATUS
,
BODY_BYTES_SENT
,
HTTP
,
AUTHORITY
,
REMOTE_PORT
,
SERVER_PORT
,
REQUEST_TIME
,
PID
,
ALPN
,
TLS_CIPHER
,
S
SL_CIPHER
=
TLS_CIPHER
,
TLS_PROTOCOL
,
S
SL_PROTOCOL
=
TLS_PROTOCOL
,
TLS_SESSION_ID
,
S
SL_SESSION_ID
=
TLS_SESSION_ID
,
TLS_SESSION_REUSED
,
S
SL_SESSION_REUSED
=
TLS_SESSION_REUSED
,
TLS_SNI
,
TLS_CLIENT_FINGERPRINT_SHA1
,
TLS_CLIENT_FINGERPRINT_SHA256
,
TLS_CLIENT_ISSUER_NAME
,
TLS_CLIENT_SERIAL
,
TLS_CLIENT_SUBJECT_NAME
,
BACKEND_HOST
,
BACKEND_PORT
,
};
struct
LogFragment
{
...
...
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