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
a06a8c36
Commit
a06a8c36
authored
Dec 11, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Add --dns-lookup-timeout and --dns-max-try options
parent
0967ee9c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
1 deletion
+63
-1
gennghttpxfun.py
gennghttpxfun.py
+2
-0
src/shrpx.cc
src/shrpx.cc
+24
-0
src/shrpx_config.cc
src/shrpx_config.cc
+22
-0
src/shrpx_config.h
src/shrpx_config.h
+9
-0
src/shrpx_dns_resolver.cc
src/shrpx_dns_resolver.cc
+6
-1
No files found.
gennghttpxfun.py
View file @
a06a8c36
...
...
@@ -150,6 +150,8 @@ OPTIONS = [
"tls-sct-dir"
,
"backend-connect-timeout"
,
"dns-cache-timeout"
,
"dns-lookup-timeout"
,
"dns-max-try"
,
]
LOGVARS
=
[
...
...
src/shrpx.cc
View file @
a06a8c36
...
...
@@ -1491,7 +1491,9 @@ void fill_default_config(Config *config) {
{
auto
&
timeoutconf
=
dnsconf
.
timeout
;
timeoutconf
.
cache
=
10
_s
;
timeoutconf
.
lookup
=
5
_s
;
}
dnsconf
.
max_try
=
2
;
}
}
// namespace
...
...
@@ -2388,6 +2390,18 @@ DNS:
that nghttpx caches the unsuccessful results as well.
Default: )"
<<
util
::
duration_str
(
config
->
dns
.
timeout
.
cache
)
<<
R"(
--dns-lookup-timeout=<DURATION>
Set timeout that DNS server is given to respond to the
initial DNS query. For the 2nd and later queries,
server is given time based on this timeout, and it is
scaled linearly.
Default: )"
<<
util
::
duration_str
(
config
->
dns
.
timeout
.
lookup
)
<<
R"(
--dns-max-try=<N>
Set the number of DNS query before nghttpx gives up name
lookup.
Default: )"
<<
config
->
dns
.
max_try
<<
R"(
Debug:
--frontend-http2-dump-request-header=<PATH>
...
...
@@ -3049,6 +3063,8 @@ int main(int argc, char **argv) {
{
SHRPX_OPT_BACKEND_CONNECT_TIMEOUT
.
c_str
(),
required_argument
,
&
flag
,
142
},
{
SHRPX_OPT_DNS_CACHE_TIMEOUT
.
c_str
(),
required_argument
,
&
flag
,
143
},
{
SHRPX_OPT_DNS_LOOKUP_TIMEOUT
.
c_str
(),
required_argument
,
&
flag
,
144
},
{
SHRPX_OPT_DNS_MAX_TRY
.
c_str
(),
required_argument
,
&
flag
,
145
},
{
nullptr
,
0
,
nullptr
,
0
}};
int
option_index
=
0
;
...
...
@@ -3726,6 +3742,14 @@ int main(int argc, char **argv) {
// --dns-cache-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_DNS_CACHE_TIMEOUT
,
StringRef
{
optarg
});
break
;
case
144
:
// --dns-lookup-timeou
cmdcfgs
.
emplace_back
(
SHRPX_OPT_DNS_LOOKUP_TIMEOUT
,
StringRef
{
optarg
});
break
;
case
145
:
// --dns-max-try
cmdcfgs
.
emplace_back
(
SHRPX_OPT_DNS_MAX_TRY
,
StringRef
{
optarg
});
break
;
default:
break
;
}
...
...
src/shrpx_config.cc
View file @
a06a8c36
...
...
@@ -1370,6 +1370,9 @@ int option_lookup_token(const char *name, size_t namelen) {
}
break
;
case
'y'
:
if
(
util
::
strieq_l
(
"dns-max-tr"
,
name
,
10
))
{
return
SHRPX_OPTID_DNS_MAX_TRY
;
}
if
(
util
::
strieq_l
(
"http2-prox"
,
name
,
10
))
{
return
SHRPX_OPTID_HTTP2_PROXY
;
}
...
...
@@ -1548,6 +1551,9 @@ int option_lookup_token(const char *name, size_t namelen) {
}
break
;
case
't'
:
if
(
util
::
strieq_l
(
"dns-lookup-timeou"
,
name
,
17
))
{
return
SHRPX_OPTID_DNS_LOOKUP_TIMEOUT
;
}
if
(
util
::
strieq_l
(
"worker-write-burs"
,
name
,
17
))
{
return
SHRPX_OPTID_WORKER_WRITE_BURST
;
}
...
...
@@ -3104,6 +3110,22 @@ int parse_config(Config *config, int optid, const StringRef &opt,
#endif // !(!LIBRESSL_IN_USE && OPENSSL_VERSION_NUMBER >= 0x10002000L)
case
SHRPX_OPTID_DNS_CACHE_TIMEOUT
:
return
parse_duration
(
&
config
->
dns
.
timeout
.
cache
,
opt
,
optarg
);
case
SHRPX_OPTID_DNS_LOOKUP_TIMEOUT
:
return
parse_duration
(
&
config
->
dns
.
timeout
.
lookup
,
opt
,
optarg
);
case
SHRPX_OPTID_DNS_MAX_TRY
:
{
int
n
;
if
(
parse_uint
(
&
n
,
opt
,
optarg
)
!=
0
)
{
return
-
1
;
}
if
(
n
>
5
)
{
LOG
(
ERROR
)
<<
opt
<<
": must be smaller than or equal to 5"
;
return
-
1
;
}
config
->
dns
.
max_try
=
n
;
return
0
;
}
case
SHRPX_OPTID_CONF
:
LOG
(
WARN
)
<<
"conf: ignored"
;
...
...
src/shrpx_config.h
View file @
a06a8c36
...
...
@@ -314,6 +314,9 @@ constexpr auto SHRPX_OPT_BACKEND_CONNECT_TIMEOUT =
StringRef
::
from_lit
(
"backend-connect-timeout"
);
constexpr
auto
SHRPX_OPT_DNS_CACHE_TIMEOUT
=
StringRef
::
from_lit
(
"dns-cache-timeout"
);
constexpr
auto
SHRPX_OPT_DNS_LOOKUP_TIMEOUT
=
StringRef
::
from_lit
(
"dns-lookup-timeout"
);
constexpr
auto
SHRPX_OPT_DNS_MAX_TRY
=
StringRef
::
from_lit
(
"dns-max-try"
);
constexpr
size_t
SHRPX_OBFUSCATED_NODE_LENGTH
=
8
;
...
...
@@ -785,7 +788,11 @@ struct APIConfig {
struct
DNSConfig
{
struct
{
ev_tstamp
cache
;
ev_tstamp
lookup
;
}
timeout
;
// The number of tries name resolver makes before abandoning
// request.
size_t
max_try
;
}
;
struct
Config
{
...
...
@@ -905,6 +912,8 @@ enum {
SHRPX_OPTID_DAEMON
,
SHRPX_OPTID_DH_PARAM_FILE
,
SHRPX_OPTID_DNS_CACHE_TIMEOUT
,
SHRPX_OPTID_DNS_LOOKUP_TIMEOUT
,
SHRPX_OPTID_DNS_MAX_TRY
,
SHRPX_OPTID_ECDH_CURVES
,
SHRPX_OPTID_ERROR_PAGE
,
SHRPX_OPTID_ERRORLOG_FILE
,
...
...
src/shrpx_dns_resolver.cc
View file @
a06a8c36
...
...
@@ -29,6 +29,7 @@
#include "shrpx_log.h"
#include "shrpx_connection.h"
#include "shrpx_config.h"
namespace
shrpx
{
...
...
@@ -145,11 +146,15 @@ int DNSResolver::resolve(const StringRef &name, int family) {
int
rv
;
auto
&
dnsconf
=
get_config
()
->
dns
;
ares_options
opts
{};
opts
.
sock_state_cb
=
sock_state_cb
;
opts
.
sock_state_cb_data
=
this
;
opts
.
timeout
=
static_cast
<
int
>
(
dnsconf
.
timeout
.
lookup
*
1000
);
opts
.
tries
=
dnsconf
.
max_try
;
auto
optmask
=
ARES_OPT_SOCK_STATE_CB
;
auto
optmask
=
ARES_OPT_SOCK_STATE_CB
|
ARES_OPT_TIMEOUTMS
|
ARES_OPT_TRIES
;
ares_channel
chan
;
rv
=
ares_init_options
(
&
chan
,
&
opts
,
optmask
);
...
...
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