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
baf2dc3d
Commit
baf2dc3d
authored
Nov 23, 2012
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shrpx: Add --backend-ipv4 and --backend-ipv6 options.
parent
df7023bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
1 deletion
+39
-1
src/shrpx.cc
src/shrpx.cc
+29
-1
src/shrpx_config.cc
src/shrpx_config.cc
+6
-0
src/shrpx_config.h
src/shrpx_config.h
+4
-0
No files found.
src/shrpx.cc
View file @
baf2dc3d
...
...
@@ -82,7 +82,13 @@ int cache_downstream_host_address()
snprintf
(
service
,
sizeof
(
service
),
"%u"
,
get_config
()
->
downstream_port
);
memset
(
&
hints
,
0
,
sizeof
(
addrinfo
));
hints
.
ai_family
=
AF_UNSPEC
;
if
(
get_config
()
->
backend_ipv4
)
{
hints
.
ai_family
=
AF_INET
;
}
else
if
(
get_config
()
->
backend_ipv6
)
{
hints
.
ai_family
=
AF_INET6
;
}
else
{
hints
.
ai_family
=
AF_UNSPEC
;
}
hints
.
ai_socktype
=
SOCK_STREAM
;
#ifdef AI_ADDRCONFIG
hints
.
ai_flags
|=
AI_ADDRCONFIG
;
...
...
@@ -360,6 +366,8 @@ void fill_default_config()
mod_config
()
->
pid_file
=
0
;
mod_config
()
->
uid
=
0
;
mod_config
()
->
gid
=
0
;
mod_config
()
->
backend_ipv4
=
false
;
mod_config
()
->
backend_ipv6
=
false
;
}
}
// namespace
...
...
@@ -407,6 +415,10 @@ void print_help(std::ostream& out)
<<
" --backlog=<NUM> Set listen backlog size.
\n
"
<<
" Default: "
<<
get_config
()
->
backlog
<<
"
\n
"
<<
" --backend-ipv4 Resolve backend hostname to IPv4 address
\n
"
<<
" only.
\n
"
<<
" --backend-ipv6 Resolve backend hostname to IPv6 address
\n
"
<<
" only.
\n
"
<<
"
\n
"
<<
" Performance:
\n
"
<<
" -n, --workers=<CORES>
\n
"
...
...
@@ -552,6 +564,8 @@ int main(int argc, char **argv)
{
"client"
,
no_argument
,
&
flag
,
17
},
{
"backend-spdy-window-bits"
,
required_argument
,
&
flag
,
18
},
{
"cacert"
,
required_argument
,
&
flag
,
19
},
{
"backend-ipv4"
,
no_argument
,
&
flag
,
20
},
{
"backend-ipv6"
,
no_argument
,
&
flag
,
21
},
{
0
,
0
,
0
,
0
}
};
int
option_index
=
0
;
...
...
@@ -681,6 +695,14 @@ int main(int argc, char **argv)
// --cacert
cmdcfgs
.
push_back
(
std
::
make_pair
(
SHRPX_OPT_CACERT
,
optarg
));
break
;
case
20
:
// --backend-ipv4
cmdcfgs
.
push_back
(
std
::
make_pair
(
SHRPX_OPT_BACKEND_IPV4
,
"yes"
));
break
;
case
21
:
// --backend-ipv6
cmdcfgs
.
push_back
(
std
::
make_pair
(
SHRPX_OPT_BACKEND_IPV6
,
"yes"
));
break
;
default:
break
;
}
...
...
@@ -712,6 +734,12 @@ int main(int argc, char **argv)
}
}
if
(
get_config
()
->
backend_ipv4
&&
get_config
()
->
backend_ipv6
)
{
LOG
(
FATAL
)
<<
"--backend-ipv4 and --backend-ipv6 cannot be used at the "
<<
"same time."
;
exit
(
EXIT_FAILURE
);
}
int
mode
=
get_config
()
->
spdy_proxy
|
(
get_config
()
->
client_proxy
<<
1
)
|
(
get_config
()
->
client
<<
2
);
if
(
mode
!=
0
&&
mode
!=
1
&&
mode
!=
2
&&
mode
!=
4
)
{
...
...
src/shrpx_config.cc
View file @
baf2dc3d
...
...
@@ -73,6 +73,8 @@ const char SHRPX_OPT_CIPHERS[] = "ciphers";
const
char
SHRPX_OPT_CLIENT
[]
=
"client"
;
const
char
SHRPX_OPT_INSECURE
[]
=
"insecure"
;
const
char
SHRPX_OPT_CACERT
[]
=
"cacert"
;
const
char
SHRPX_OPT_BACKEND_IPV4
[]
=
"backend-ipv4"
;
const
char
SHRPX_OPT_BACKEND_IPV6
[]
=
"backend-ipv6"
;
namespace
{
Config
*
config
=
0
;
...
...
@@ -240,6 +242,10 @@ int parse_config(const char *opt, const char *optarg)
mod_config
()
->
insecure
=
util
::
strieq
(
optarg
,
"yes"
);
}
else
if
(
util
::
strieq
(
opt
,
SHRPX_OPT_CACERT
))
{
set_config_str
(
&
mod_config
()
->
cacert
,
optarg
);
}
else
if
(
util
::
strieq
(
opt
,
SHRPX_OPT_BACKEND_IPV4
))
{
mod_config
()
->
backend_ipv4
=
util
::
strieq
(
optarg
,
"yes"
);
}
else
if
(
util
::
strieq
(
opt
,
SHRPX_OPT_BACKEND_IPV6
))
{
mod_config
()
->
backend_ipv6
=
util
::
strieq
(
optarg
,
"yes"
);
}
else
if
(
util
::
strieq
(
opt
,
"conf"
))
{
LOG
(
WARNING
)
<<
"conf is ignored"
;
}
else
{
...
...
src/shrpx_config.h
View file @
baf2dc3d
...
...
@@ -65,6 +65,8 @@ extern const char SHRPX_OPT_CIPHERS[];
extern
const
char
SHRPX_OPT_CLIENT
[];
extern
const
char
SHRPX_OPT_INSECURE
[];
extern
const
char
SHRPX_OPT_CACERT
[];
extern
const
char
SHRPX_OPT_BACKEND_IPV4
[];
extern
const
char
SHRPX_OPT_BACKEND_IPV6
[];
union
sockaddr_union
{
sockaddr
sa
;
...
...
@@ -116,6 +118,8 @@ struct Config {
bool
client_mode
;
bool
insecure
;
char
*
cacert
;
bool
backend_ipv4
;
bool
backend_ipv6
;
};
const
Config
*
get_config
();
...
...
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