mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-15 03:02:07 +03:00
* DNS API: new setting "upstream_mode"; remove "fastest_addr", "parallel_requests"
* use dnsproxy v0.29.0
Squashed commit of the following:
commit f18b7231f3f3f84446c0d837855af342f3c971b4
Merge: 501a4e06 dae275e6
Author: Simon Zolin <s.zolin@adguard.com>
Date: Wed Jun 10 15:24:15 2020 +0300
Merge remote-tracking branch 'origin/master' into update-dnsproxy
commit 501a4e06ab350e46ff78656141d925de9f2e4996
Author: Simon Zolin <s.zolin@adguard.com>
Date: Fri Jun 5 12:47:13 2020 +0300
openapi
commit 3930bd196572924f164ed011629356a0ac0ec631
Author: Simon Zolin <s.zolin@adguard.com>
Date: Fri Jun 5 12:21:32 2020 +0300
* DNS API: new setting "upstream_mode"; remove "fastest_addr", "parallel_requests"
* use dnsproxy v0.29.0
This commit is contained in:
parent
dae275e6f9
commit
a869ec4cbb
@ -893,8 +893,7 @@ Response:
|
||||
"edns_cs_enabled": true | false,
|
||||
"dnssec_enabled": true | false
|
||||
"disable_ipv6": true | false,
|
||||
"fastest_addr": true | false, // use Fastest Address algorithm
|
||||
"parallel_requests": true | false, // send DNS requests to all upstream servers at once
|
||||
"upstream_mode": "" | "parallel" | "fastest_addr"
|
||||
}
|
||||
|
||||
|
||||
@ -916,8 +915,7 @@ Request:
|
||||
"edns_cs_enabled": true | false,
|
||||
"dnssec_enabled": true | false
|
||||
"disable_ipv6": true | false,
|
||||
"fastest_addr": true | false, // use Fastest Address algorithm
|
||||
"parallel_requests": true | false, // send DNS requests to all upstream servers at once
|
||||
"upstream_mode": "" | "parallel" | "fastest_addr"
|
||||
}
|
||||
|
||||
Response:
|
||||
|
@ -145,9 +145,14 @@ func (s *Server) createProxyConfig() (proxy.Config, error) {
|
||||
UpstreamConfig: s.conf.UpstreamConfig,
|
||||
BeforeRequestHandler: s.beforeRequestHandler,
|
||||
RequestHandler: s.handleDNSRequest,
|
||||
AllServers: s.conf.AllServers,
|
||||
EnableEDNSClientSubnet: s.conf.EnableEDNSClientSubnet,
|
||||
FindFastestAddr: s.conf.FastestAddr,
|
||||
}
|
||||
|
||||
proxyConfig.UpstreamMode = proxy.UModeLoadBalance
|
||||
if s.conf.AllServers {
|
||||
proxyConfig.UpstreamMode = proxy.UModeParallel
|
||||
} else if s.conf.FastestAddr {
|
||||
proxyConfig.UpstreamMode = proxy.UModeFastestAddr
|
||||
}
|
||||
|
||||
if len(s.conf.BogusNXDomain) > 0 {
|
||||
|
@ -33,8 +33,7 @@ type dnsConfigJSON struct {
|
||||
EDNSCSEnabled bool `json:"edns_cs_enabled"`
|
||||
DNSSECEnabled bool `json:"dnssec_enabled"`
|
||||
DisableIPv6 bool `json:"disable_ipv6"`
|
||||
FastestAddr bool `json:"fastest_addr"`
|
||||
ParallelRequests bool `json:"parallel_requests"`
|
||||
UpstreamMode string `json:"upstream_mode"`
|
||||
}
|
||||
|
||||
func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) {
|
||||
@ -51,8 +50,11 @@ 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.FastestAddr = s.conf.FastestAddr
|
||||
resp.ParallelRequests = s.conf.AllServers
|
||||
if s.conf.FastestAddr {
|
||||
resp.UpstreamMode = "fastest_addr"
|
||||
} else if s.conf.AllServers {
|
||||
resp.UpstreamMode = "parallel"
|
||||
}
|
||||
s.RUnlock()
|
||||
|
||||
js, err := json.Marshal(resp)
|
||||
@ -118,6 +120,12 @@ func (s *Server) handleSetConfig(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if js.Exists("upstream_mode") &&
|
||||
!(req.UpstreamMode == "" || req.UpstreamMode == "fastest_addr" || req.UpstreamMode == "parallel") {
|
||||
httpError(r, w, http.StatusBadRequest, "upstream_mode: incorrect value")
|
||||
return
|
||||
}
|
||||
|
||||
restart := false
|
||||
s.Lock()
|
||||
|
||||
@ -169,12 +177,19 @@ func (s *Server) handleSetConfig(w http.ResponseWriter, r *http.Request) {
|
||||
s.conf.AAAADisabled = req.DisableIPv6
|
||||
}
|
||||
|
||||
if js.Exists("fastest_addr") {
|
||||
s.conf.FastestAddr = req.FastestAddr
|
||||
}
|
||||
if js.Exists("upstream_mode") {
|
||||
s.conf.FastestAddr = false
|
||||
s.conf.AllServers = false
|
||||
switch req.UpstreamMode {
|
||||
case "":
|
||||
//
|
||||
|
||||
if js.Exists("parallel_requests") {
|
||||
s.conf.AllServers = req.ParallelRequests
|
||||
case "parallel":
|
||||
s.conf.AllServers = true
|
||||
|
||||
case "fastest_addr":
|
||||
s.conf.FastestAddr = true
|
||||
}
|
||||
}
|
||||
|
||||
s.Unlock()
|
||||
|
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module github.com/AdguardTeam/AdGuardHome
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/AdguardTeam/dnsproxy v0.28.1
|
||||
github.com/AdguardTeam/dnsproxy v0.29.0
|
||||
github.com/AdguardTeam/golibs v0.4.2
|
||||
github.com/AdguardTeam/urlfilter v0.10.1
|
||||
github.com/NYTimes/gziphandler v1.1.1
|
||||
|
4
go.sum
4
go.sum
@ -1,5 +1,5 @@
|
||||
github.com/AdguardTeam/dnsproxy v0.28.1 h1:WkLjrUcVf/njbTLyL7bNt6e18zQjF2ZYv/HWwL9cMmU=
|
||||
github.com/AdguardTeam/dnsproxy v0.28.1/go.mod h1:hOYFV9TW+pd5XKYz7KZf2FFD8SvSPqjyGTxUae86s58=
|
||||
github.com/AdguardTeam/dnsproxy v0.29.0 h1:cHurldpiipPBAH+kgytcg9pkeYjG43KWiVYPbN3rAw4=
|
||||
github.com/AdguardTeam/dnsproxy v0.29.0/go.mod h1:hOYFV9TW+pd5XKYz7KZf2FFD8SvSPqjyGTxUae86s58=
|
||||
github.com/AdguardTeam/golibs v0.4.0 h1:4VX6LoOqFe9p9Gf55BeD8BvJD6M6RDYmgEiHrENE9KU=
|
||||
github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
|
||||
github.com/AdguardTeam/golibs v0.4.2 h1:7M28oTZFoFwNmp8eGPb3ImmYbxGaJLyQXeIFVHjME0o=
|
||||
|
@ -1019,12 +1019,11 @@ components:
|
||||
type: boolean
|
||||
dnssec_enabled:
|
||||
type: boolean
|
||||
fastest_addr:
|
||||
type: boolean
|
||||
parallel_requests:
|
||||
type: boolean
|
||||
description: If true, parallel queries to all configured upstream servers are
|
||||
enabled
|
||||
upstream_mode:
|
||||
enum:
|
||||
- ""
|
||||
- parallel
|
||||
- fastest_addr
|
||||
UpstreamsConfig:
|
||||
type: object
|
||||
description: Upstreams configuration
|
||||
|
Loading…
Reference in New Issue
Block a user