+ dns: new settings for cache
Squashed commit of the following: commit e5b488249a4d972efd63c6e96830d9f30829aee1 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Jun 16 15:38:27 2020 +0300 + dns: new settings for cache
This commit is contained in:
parent
21dfb5ffe8
commit
4303b3dd2f
|
@ -894,6 +894,9 @@ Response:
|
|||
"dnssec_enabled": true | false
|
||||
"disable_ipv6": true | false,
|
||||
"upstream_mode": "" | "parallel" | "fastest_addr"
|
||||
"cache_size": 1234, // in bytes
|
||||
"cache_ttl_min": 1234, // in seconds
|
||||
"cache_ttl_max": 1234, // in seconds
|
||||
}
|
||||
|
||||
|
||||
|
@ -916,6 +919,9 @@ Request:
|
|||
"dnssec_enabled": true | false
|
||||
"disable_ipv6": true | false,
|
||||
"upstream_mode": "" | "parallel" | "fastest_addr"
|
||||
"cache_size": 1234, // in bytes
|
||||
"cache_ttl_min": 1234, // in seconds
|
||||
"cache_ttl_max": 1234, // in seconds
|
||||
}
|
||||
|
||||
Response:
|
||||
|
|
|
@ -34,6 +34,9 @@ type dnsConfigJSON struct {
|
|||
DNSSECEnabled bool `json:"dnssec_enabled"`
|
||||
DisableIPv6 bool `json:"disable_ipv6"`
|
||||
UpstreamMode string `json:"upstream_mode"`
|
||||
CacheSize uint32 `json:"cache_size"`
|
||||
CacheMinTTL uint32 `json:"cache_ttl_min"`
|
||||
CacheMaxTTL uint32 `json:"cache_ttl_max"`
|
||||
}
|
||||
|
||||
func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -50,6 +53,9 @@ func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) {
|
|||
resp.EDNSCSEnabled = s.conf.EnableEDNSClientSubnet
|
||||
resp.DNSSECEnabled = s.conf.EnableDNSSEC
|
||||
resp.DisableIPv6 = s.conf.AAAADisabled
|
||||
resp.CacheSize = s.conf.CacheSize
|
||||
resp.CacheMinTTL = s.conf.CacheMinTTL
|
||||
resp.CacheMaxTTL = s.conf.CacheMaxTTL
|
||||
if s.conf.FastestAddr {
|
||||
resp.UpstreamMode = "fastest_addr"
|
||||
} else if s.conf.AllServers {
|
||||
|
@ -126,6 +132,11 @@ func (s *Server) handleSetConfig(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
if req.CacheMinTTL > req.CacheMaxTTL {
|
||||
httpError(r, w, http.StatusBadRequest, "cache_ttl_min must be less or equal than cache_ttl_max")
|
||||
return
|
||||
}
|
||||
|
||||
restart := false
|
||||
s.Lock()
|
||||
|
||||
|
@ -177,6 +188,21 @@ func (s *Server) handleSetConfig(w http.ResponseWriter, r *http.Request) {
|
|||
s.conf.AAAADisabled = req.DisableIPv6
|
||||
}
|
||||
|
||||
if js.Exists("cache_size") {
|
||||
s.conf.CacheSize = req.CacheSize
|
||||
restart = true
|
||||
}
|
||||
|
||||
if js.Exists("cache_ttl_min") {
|
||||
s.conf.CacheMinTTL = req.CacheMinTTL
|
||||
restart = true
|
||||
}
|
||||
|
||||
if js.Exists("cache_ttl_max") {
|
||||
s.conf.CacheMaxTTL = req.CacheMaxTTL
|
||||
restart = true
|
||||
}
|
||||
|
||||
if js.Exists("upstream_mode") {
|
||||
s.conf.FastestAddr = false
|
||||
s.conf.AllServers = false
|
||||
|
|
|
@ -1016,6 +1016,12 @@ components:
|
|||
type: boolean
|
||||
dnssec_enabled:
|
||||
type: boolean
|
||||
cache_size:
|
||||
type: integer
|
||||
cache_ttl_min:
|
||||
type: integer
|
||||
cache_ttl_max:
|
||||
type: integer
|
||||
upstream_mode:
|
||||
enum:
|
||||
- ""
|
||||
|
|
Loading…
Reference in New Issue