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
b0eb68ee
Commit
b0eb68ee
authored
Oct 16, 2018
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Convert shrpx_forwarded_node_type to enum class
parent
e7b7b037
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
18 deletions
+18
-18
src/shrpx.cc
src/shrpx.cc
+1
-1
src/shrpx_client_handler.cc
src/shrpx_client_handler.cc
+3
-3
src/shrpx_config.cc
src/shrpx_config.cc
+9
-9
src/shrpx_config.h
src/shrpx_config.h
+5
-5
No files found.
src/shrpx.cc
View file @
b0eb68ee
...
...
@@ -3085,7 +3085,7 @@ int process_options(Config *config,
auto
&
fwdconf
=
config
->
http
.
forwarded
;
if
(
fwdconf
.
by_node_type
==
F
ORWARDED_NODE_
OBFUSCATED
&&
if
(
fwdconf
.
by_node_type
==
F
orwardedNode
::
OBFUSCATED
&&
fwdconf
.
by_obfuscated
.
empty
())
{
// 2 for '_' and terminal NULL
auto
iov
=
make_byte_ref
(
config
->
balloc
,
SHRPX_OBFUSCATED_NODE_LENGTH
+
2
);
...
...
src/shrpx_client_handler.cc
View file @
b0eb68ee
...
...
@@ -430,7 +430,7 @@ ClientHandler::ClientHandler(Worker *worker, int fd, SSL *ssl,
auto
&
fwdconf
=
config
->
http
.
forwarded
;
if
(
fwdconf
.
params
&
FORWARDED_FOR
)
{
if
(
fwdconf
.
for_node_type
==
F
ORWARDED_NODE_
OBFUSCATED
)
{
if
(
fwdconf
.
for_node_type
==
F
orwardedNode
::
OBFUSCATED
)
{
// 1 for '_'
auto
len
=
SHRPX_OBFUSCATED_NODE_LENGTH
+
1
;
// 1 for terminating NUL.
...
...
@@ -1490,7 +1490,7 @@ int ClientHandler::proxy_protocol_read() {
auto
&
fwdconf
=
config
->
http
.
forwarded
;
if
((
fwdconf
.
params
&
FORWARDED_FOR
)
&&
fwdconf
.
for_node_type
==
F
ORWARDED_NODE_
IP
)
{
fwdconf
.
for_node_type
==
F
orwardedNode
::
IP
)
{
init_forwarded_for
(
family
,
ipaddr_
);
}
...
...
@@ -1500,7 +1500,7 @@ int ClientHandler::proxy_protocol_read() {
StringRef
ClientHandler
::
get_forwarded_by
()
const
{
auto
&
fwdconf
=
get_config
()
->
http
.
forwarded
;
if
(
fwdconf
.
by_node_type
==
F
ORWARDED_NODE_
OBFUSCATED
)
{
if
(
fwdconf
.
by_node_type
==
F
orwardedNode
::
OBFUSCATED
)
{
return
fwdconf
.
by_obfuscated
;
}
...
...
src/shrpx_config.cc
View file @
b0eb68ee
...
...
@@ -1195,27 +1195,27 @@ int parse_mapping(Config *config, DownstreamAddrConfig &addr,
}
// namespace
namespace
{
int
parse_forwarded_node_type
(
const
StringRef
&
optarg
)
{
ForwardedNode
parse_forwarded_node_type
(
const
StringRef
&
optarg
)
{
if
(
util
::
strieq_l
(
"obfuscated"
,
optarg
))
{
return
F
ORWARDED_NODE_
OBFUSCATED
;
return
F
orwardedNode
::
OBFUSCATED
;
}
if
(
util
::
strieq_l
(
"ip"
,
optarg
))
{
return
F
ORWARDED_NODE_
IP
;
return
F
orwardedNode
::
IP
;
}
if
(
optarg
.
size
()
<
2
||
optarg
[
0
]
!=
'_'
)
{
return
-
1
;
return
static_cast
<
ForwardedNode
>
(
-
1
)
;
}
if
(
std
::
find_if_not
(
std
::
begin
(
optarg
),
std
::
end
(
optarg
),
[](
char
c
)
{
return
util
::
is_alpha
(
c
)
||
util
::
is_digit
(
c
)
||
c
==
'.'
||
c
==
'_'
||
c
==
'-'
;
})
!=
std
::
end
(
optarg
))
{
return
-
1
;
return
static_cast
<
ForwardedNode
>
(
-
1
)
;
}
return
F
ORWARDED_NODE_
OBFUSCATED
;
return
F
orwardedNode
::
OBFUSCATED
;
}
}
// namespace
...
...
@@ -3387,7 +3387,7 @@ int parse_config(Config *config, int optid, const StringRef &opt,
case
SHRPX_OPTID_FORWARDED_FOR
:
{
auto
type
=
parse_forwarded_node_type
(
optarg
);
if
(
type
==
-
1
||
if
(
type
==
static_cast
<
ForwardedNode
>
(
-
1
)
||
(
optid
==
SHRPX_OPTID_FORWARDED_FOR
&&
optarg
[
0
]
==
'_'
))
{
LOG
(
ERROR
)
<<
opt
<<
": unknown node type or illegal obfuscated string "
<<
optarg
;
...
...
@@ -3398,7 +3398,7 @@ int parse_config(Config *config, int optid, const StringRef &opt,
switch
(
optid
)
{
case
SHRPX_OPTID_FORWARDED_BY
:
fwdconf
.
by_node_type
=
static_cast
<
shrpx_forwarded_node_type
>
(
type
)
;
fwdconf
.
by_node_type
=
type
;
if
(
optarg
[
0
]
==
'_'
)
{
fwdconf
.
by_obfuscated
=
make_string_ref
(
config
->
balloc
,
optarg
);
}
else
{
...
...
@@ -3406,7 +3406,7 @@ int parse_config(Config *config, int optid, const StringRef &opt,
}
break
;
case
SHRPX_OPTID_FORWARDED_FOR
:
fwdconf
.
for_node_type
=
static_cast
<
shrpx_forwarded_node_type
>
(
type
)
;
fwdconf
.
for_node_type
=
type
;
break
;
}
...
...
src/shrpx_config.h
View file @
b0eb68ee
...
...
@@ -409,9 +409,9 @@ enum shrpx_forwarded_param {
FORWARDED_PROTO
=
0x8
,
};
enum
shrpx_forwarded_node_typ
e
{
FORWARDED_NODE_
OBFUSCATED
,
FORWARDED_NODE_
IP
,
enum
class
ForwardedNod
e
{
OBFUSCATED
,
IP
,
};
struct
AltSvc
{
...
...
@@ -704,10 +704,10 @@ struct HttpConfig {
uint32_t
params
;
// type of value recorded in "by" parameter of Forwarded header
// field.
shrpx_forwarded_node_typ
e
by_node_type
;
ForwardedNod
e
by_node_type
;
// type of value recorded in "for" parameter of Forwarded header
// field.
shrpx_forwarded_node_typ
e
for_node_type
;
ForwardedNod
e
for_node_type
;
bool
strip_incoming
;
}
forwarded
;
struct
{
...
...
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