* DNS: remove /enable_protection and /disable_protection

This commit is contained in:
Simon Zolin 2019-11-15 11:36:47 +03:00 committed by Ildar Kamalov
parent 3b13c031a3
commit 87bb773d3e
3 changed files with 24 additions and 32 deletions

View File

@ -122,16 +122,6 @@ func (s *Server) handleSetConfig(w http.ResponseWriter, r *http.Request) {
} }
} }
func (s *Server) handleProtectionEnable(w http.ResponseWriter, r *http.Request) {
s.conf.ProtectionEnabled = true
s.conf.ConfigModified()
}
func (s *Server) handleProtectionDisable(w http.ResponseWriter, r *http.Request) {
s.conf.ProtectionEnabled = false
s.conf.ConfigModified()
}
type upstreamJSON struct { type upstreamJSON struct {
Upstreams []string `json:"upstream_dns"` // Upstreams Upstreams []string `json:"upstream_dns"` // Upstreams
BootstrapDNS []string `json:"bootstrap_dns"` // Bootstrap DNS BootstrapDNS []string `json:"bootstrap_dns"` // Bootstrap DNS
@ -376,8 +366,6 @@ func checkDNS(input string, bootstrap []string) error {
func (s *Server) registerHandlers() { func (s *Server) registerHandlers() {
s.conf.HTTPRegister("GET", "/control/dns_info", s.handleGetConfig) s.conf.HTTPRegister("GET", "/control/dns_info", s.handleGetConfig)
s.conf.HTTPRegister("POST", "/control/dns_config", s.handleSetConfig) s.conf.HTTPRegister("POST", "/control/dns_config", s.handleSetConfig)
s.conf.HTTPRegister("POST", "/control/enable_protection", s.handleProtectionEnable)
s.conf.HTTPRegister("POST", "/control/disable_protection", s.handleProtectionDisable)
s.conf.HTTPRegister("POST", "/control/set_upstreams_config", s.handleSetUpstreamConfig) s.conf.HTTPRegister("POST", "/control/set_upstreams_config", s.handleSetUpstreamConfig)
s.conf.HTTPRegister("POST", "/control/test_upstream_dns", s.handleTestUpstreamDNS) s.conf.HTTPRegister("POST", "/control/test_upstream_dns", s.handleTestUpstreamDNS)

View File

@ -147,6 +147,30 @@ Response:
} }
### Set DNS general settings: POST /control/dns_config
Replaces these API methods:
POST /control/enable_protection
POST /control/disable_protection
Request:
POST /control/dns_config
{
"protection_enabled": true | false,
"ratelimit": 1234,
"blocking_mode": "nxdomain" | "null_ip" | "custom_ip",
"blocking_ipv4": "1.2.3.4",
"blocking_ipv6": "1:2:3::4",
}
Response:
200 OK
## v0.99: incompatible API changes ## v0.99: incompatible API changes
* A note about web user authentication * A note about web user authentication

View File

@ -99,26 +99,6 @@ paths:
200: 200:
description: OK description: OK
/enable_protection:
post:
tags:
- global
operationId: enableProtection
summary: "Enable protection (turns on dnsfilter module in coredns)"
responses:
200:
description: OK
/disable_protection:
post:
tags:
- global
operationId: disableProtection
summary: "Disable protection (turns off filtering, sb, parental, safesearch temporarily by disabling dnsfilter module in coredns)"
responses:
200:
description: OK
/set_upstreams_config: /set_upstreams_config:
post: post:
tags: tags: