From 87bb773d3e087c1d0b21ce7e98045091fd99e105 Mon Sep 17 00:00:00 2001
From: Simon Zolin <s.zolin@adguard.com>
Date: Fri, 15 Nov 2019 11:36:47 +0300
Subject: [PATCH] * DNS: remove /enable_protection and /disable_protection

---
 dnsforward/dnsforward_http.go | 12 ------------
 openapi/CHANGELOG.md          | 24 ++++++++++++++++++++++++
 openapi/openapi.yaml          | 20 --------------------
 3 files changed, 24 insertions(+), 32 deletions(-)

diff --git a/dnsforward/dnsforward_http.go b/dnsforward/dnsforward_http.go
index 25a2aae3..680f5c2b 100644
--- a/dnsforward/dnsforward_http.go
+++ b/dnsforward/dnsforward_http.go
@@ -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 {
 	Upstreams    []string `json:"upstream_dns"`  // Upstreams
 	BootstrapDNS []string `json:"bootstrap_dns"` // Bootstrap DNS
@@ -376,8 +366,6 @@ func checkDNS(input string, bootstrap []string) error {
 func (s *Server) registerHandlers() {
 	s.conf.HTTPRegister("GET", "/control/dns_info", s.handleGetConfig)
 	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/test_upstream_dns", s.handleTestUpstreamDNS)
 
diff --git a/openapi/CHANGELOG.md b/openapi/CHANGELOG.md
index c6e79b8a..d611cb27 100644
--- a/openapi/CHANGELOG.md
+++ b/openapi/CHANGELOG.md
@@ -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
 
 * A note about web user authentication
diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml
index f8b9bdb8..410e668d 100644
--- a/openapi/openapi.yaml
+++ b/openapi/openapi.yaml
@@ -99,26 +99,6 @@ paths:
                 200:
                     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:
         post:
             tags: