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
d66377d4
Commit
d66377d4
authored
Dec 10, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Add dns-cache-timeout option
This option controls how long cached DNS entries remain valid.
parent
77a324fa
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
6 deletions
+42
-6
gennghttpxfun.py
gennghttpxfun.py
+1
-0
src/shrpx.cc
src/shrpx.cc
+18
-0
src/shrpx_config.cc
src/shrpx_config.cc
+5
-0
src/shrpx_config.h
src/shrpx_config.h
+11
-0
src/shrpx_dns_tracker.cc
src/shrpx_dns_tracker.cc
+7
-6
No files found.
gennghttpxfun.py
View file @
d66377d4
...
...
@@ -149,6 +149,7 @@ OPTIONS = [
"ecdh-curves"
,
"tls-sct-dir"
,
"backend-connect-timeout"
,
"dns-cache-timeout"
,
]
LOGVARS
=
[
...
...
src/shrpx.cc
View file @
d66377d4
...
...
@@ -1486,6 +1486,12 @@ void fill_default_config(Config *config) {
auto
&
apiconf
=
config
->
api
;
apiconf
.
max_request_body
=
16
_k
;
auto
&
dnsconf
=
config
->
dns
;
{
auto
&
timeoutconf
=
dnsconf
.
timeout
;
timeoutconf
.
cache
=
10
_s
;
}
}
}
// namespace
...
...
@@ -2376,6 +2382,13 @@ API:
Default: )"
<<
util
::
utos_unit
(
config
->
api
.
max_request_body
)
<<
R"(
DNS:
--dns-cache-timeout=<DURATION>
Set duration that cached DNS results remain valid. Note
that nghttpx caches the unsuccessful results as well.
Default: )"
<<
util
::
duration_str
(
config
->
dns
.
timeout
.
cache
)
<<
R"(
Debug:
--frontend-http2-dump-request-header=<PATH>
Dumps request headers received by HTTP/2 frontend to the
...
...
@@ -3035,6 +3048,7 @@ int main(int argc, char **argv) {
{
SHRPX_OPT_TLS_SCT_DIR
.
c_str
(),
required_argument
,
&
flag
,
141
},
{
SHRPX_OPT_BACKEND_CONNECT_TIMEOUT
.
c_str
(),
required_argument
,
&
flag
,
142
},
{
SHRPX_OPT_DNS_CACHE_TIMEOUT
.
c_str
(),
required_argument
,
&
flag
,
143
},
{
nullptr
,
0
,
nullptr
,
0
}};
int
option_index
=
0
;
...
...
@@ -3708,6 +3722,10 @@ int main(int argc, char **argv) {
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_CONNECT_TIMEOUT
,
StringRef
{
optarg
});
break
;
case
143
:
// --dns-cache-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_DNS_CACHE_TIMEOUT
,
StringRef
{
optarg
});
break
;
default:
break
;
}
...
...
src/shrpx_config.cc
View file @
d66377d4
...
...
@@ -1531,6 +1531,9 @@ int option_lookup_token(const char *name, size_t namelen) {
}
break
;
case
't'
:
if
(
util
::
strieq_l
(
"dns-cache-timeou"
,
name
,
16
))
{
return
SHRPX_OPTID_DNS_CACHE_TIMEOUT
;
}
if
(
util
::
strieq_l
(
"worker-read-burs"
,
name
,
16
))
{
return
SHRPX_OPTID_WORKER_READ_BURST
;
}
...
...
@@ -3099,6 +3102,8 @@ int parse_config(Config *config, int optid, const StringRef &opt,
LOG
(
WARN
)
<<
opt
<<
": This option requires OpenSSL >= 1.0.2"
;
return
0
;
#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_CONF
:
LOG
(
WARN
)
<<
"conf: ignored"
;
...
...
src/shrpx_config.h
View file @
d66377d4
...
...
@@ -312,6 +312,8 @@ constexpr auto SHRPX_OPT_ECDH_CURVES = StringRef::from_lit("ecdh-curves");
constexpr
auto
SHRPX_OPT_TLS_SCT_DIR
=
StringRef
::
from_lit
(
"tls-sct-dir"
);
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
size_t
SHRPX_OBFUSCATED_NODE_LENGTH
=
8
;
...
...
@@ -780,6 +782,12 @@ struct APIConfig {
bool
enabled
;
};
struct
DNSConfig
{
struct
{
ev_tstamp
cache
;
}
timeout
;
}
;
struct
Config
{
Config
()
:
balloc
(
4096
,
4096
),
...
...
@@ -790,6 +798,7 @@ struct Config {
logging
{},
conn
{},
api
{},
dns
{},
num_worker
{
0
},
padding
{
0
},
rlimit_nofile
{
0
},
...
...
@@ -818,6 +827,7 @@ struct Config {
LoggingConfig
logging
;
ConnectionConfig
conn
;
APIConfig
api
;
DNSConfig
dns
;
StringRef
pid_file
;
StringRef
conf_path
;
StringRef
user
;
...
...
@@ -894,6 +904,7 @@ enum {
SHRPX_OPTID_CONF
,
SHRPX_OPTID_DAEMON
,
SHRPX_OPTID_DH_PARAM_FILE
,
SHRPX_OPTID_DNS_CACHE_TIMEOUT
,
SHRPX_OPTID_ECDH_CURVES
,
SHRPX_OPTID_ERROR_PAGE
,
SHRPX_OPTID_ERRORLOG_FILE
,
...
...
src/shrpx_dns_tracker.cc
View file @
d66377d4
...
...
@@ -23,6 +23,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "shrpx_dns_tracker.h"
#include "shrpx_config.h"
#include "util.h"
namespace
shrpx
{
...
...
@@ -43,18 +44,16 @@ DNSTracker::~DNSTracker() {
}
}
namespace
{
constexpr
auto
DNS_TTL
=
30
_s
;
}
// namespace
ResolverEntry
DNSTracker
::
make_entry
(
std
::
unique_ptr
<
DualDNSResolver
>
resolv
,
ImmutableString
host
,
int
status
,
const
Address
*
result
)
{
auto
&
dnsconf
=
get_config
()
->
dns
;
auto
ent
=
ResolverEntry
{};
ent
.
resolv
=
std
::
move
(
resolv
);
ent
.
host
=
std
::
move
(
host
);
ent
.
status
=
status
;
ent
.
expiry
=
ev_now
(
loop_
)
+
DNS_TTL
;
ent
.
expiry
=
ev_now
(
loop_
)
+
dnsconf
.
timeout
.
cache
;
if
(
result
)
{
ent
.
result
=
*
result
;
}
...
...
@@ -233,9 +232,11 @@ void DNSTracker::add_to_qlist(ResolverEntry &ent, DNSQuery *dnsq) {
cb
(
status
,
result
);
}
auto
&
dnsconf
=
get_config
()
->
dns
;
ent
.
resolv
.
reset
();
ent
.
status
=
status
;
ent
.
expiry
=
ev_now
(
loop
)
+
DNS_TTL
;
ent
.
expiry
=
ev_now
(
loop
)
+
dnsconf
.
timeout
.
cache
;
if
(
ent
.
status
==
DNS_STATUS_OK
)
{
ent
.
result
=
*
result
;
}
...
...
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