Merge: fix #1587 + dns: new settings for cache
* commit '4303b3dd2f6c4e1f64e8cd8575070de35b3d6df7': + dns: new settings for cache
This commit is contained in:
commit
48f40d5f01
|
@ -894,6 +894,9 @@ Response:
|
||||||
"dnssec_enabled": true | false
|
"dnssec_enabled": true | false
|
||||||
"disable_ipv6": true | false,
|
"disable_ipv6": true | false,
|
||||||
"upstream_mode": "" | "parallel" | "fastest_addr"
|
"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
|
"dnssec_enabled": true | false
|
||||||
"disable_ipv6": true | false,
|
"disable_ipv6": true | false,
|
||||||
"upstream_mode": "" | "parallel" | "fastest_addr"
|
"upstream_mode": "" | "parallel" | "fastest_addr"
|
||||||
|
"cache_size": 1234, // in bytes
|
||||||
|
"cache_ttl_min": 1234, // in seconds
|
||||||
|
"cache_ttl_max": 1234, // in seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
Response:
|
Response:
|
||||||
|
|
|
@ -34,6 +34,9 @@ type dnsConfigJSON struct {
|
||||||
DNSSECEnabled bool `json:"dnssec_enabled"`
|
DNSSECEnabled bool `json:"dnssec_enabled"`
|
||||||
DisableIPv6 bool `json:"disable_ipv6"`
|
DisableIPv6 bool `json:"disable_ipv6"`
|
||||||
UpstreamMode string `json:"upstream_mode"`
|
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) {
|
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.EDNSCSEnabled = s.conf.EnableEDNSClientSubnet
|
||||||
resp.DNSSECEnabled = s.conf.EnableDNSSEC
|
resp.DNSSECEnabled = s.conf.EnableDNSSEC
|
||||||
resp.DisableIPv6 = s.conf.AAAADisabled
|
resp.DisableIPv6 = s.conf.AAAADisabled
|
||||||
|
resp.CacheSize = s.conf.CacheSize
|
||||||
|
resp.CacheMinTTL = s.conf.CacheMinTTL
|
||||||
|
resp.CacheMaxTTL = s.conf.CacheMaxTTL
|
||||||
if s.conf.FastestAddr {
|
if s.conf.FastestAddr {
|
||||||
resp.UpstreamMode = "fastest_addr"
|
resp.UpstreamMode = "fastest_addr"
|
||||||
} else if s.conf.AllServers {
|
} else if s.conf.AllServers {
|
||||||
|
@ -126,6 +132,11 @@ func (s *Server) handleSetConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
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
|
restart := false
|
||||||
s.Lock()
|
s.Lock()
|
||||||
|
|
||||||
|
@ -177,6 +188,21 @@ func (s *Server) handleSetConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
s.conf.AAAADisabled = req.DisableIPv6
|
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") {
|
if js.Exists("upstream_mode") {
|
||||||
s.conf.FastestAddr = false
|
s.conf.FastestAddr = false
|
||||||
s.conf.AllServers = false
|
s.conf.AllServers = false
|
||||||
|
|
|
@ -1016,6 +1016,12 @@ components:
|
||||||
type: boolean
|
type: boolean
|
||||||
dnssec_enabled:
|
dnssec_enabled:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
cache_size:
|
||||||
|
type: integer
|
||||||
|
cache_ttl_min:
|
||||||
|
type: integer
|
||||||
|
cache_ttl_max:
|
||||||
|
type: integer
|
||||||
upstream_mode:
|
upstream_mode:
|
||||||
enum:
|
enum:
|
||||||
- ""
|
- ""
|
||||||
|
|
Loading…
Reference in New Issue