Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/src/__locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"parallel_requests": "Parallel requests",
"load_balancing": "Load-balancing",
"load_balancing_desc": "Query one upstream server at a time.<br/>AdGuard Home uses a weighted random algorithm to select servers with the lowest number of failed lookups and the lowest average lookup time.",
"random": "Random",
"random_desc": "Query a random upstream server for every new query.",
"bootstrap_dns": "Bootstrap DNS servers",
"bootstrap_dns_desc": "IP addresses of DNS servers used to resolve IP addresses of the DoH/DoT resolvers you specify as upstreams. Comments are not permitted.",
"fallback_dns_title": "Fallback DNS servers",
Expand Down
1 change: 1 addition & 0 deletions client/src/helpers/constants.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand, more changes to the frontend are required?

Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ export const DNS_REQUEST_OPTIONS = {
PARALLEL: 'parallel',
FASTEST_ADDR: 'fastest_addr',
LOAD_BALANCING: 'load_balance',
RANDOM: 'random',
};

export const DHCP_FORM_NAMES = {
Expand Down
6 changes: 6 additions & 0 deletions internal/dnsforward/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ const (
jsonUpstreamModeLoadBalance jsonUpstreamMode = "load_balance"
jsonUpstreamModeParallel jsonUpstreamMode = "parallel"
jsonUpstreamModeFastestAddr jsonUpstreamMode = "fastest_addr"
jsonUpstreamModeRandom jsonUpstreamMode = "random"
)

func (s *Server) getDNSConfig() (c *jsonDNSConfig) {
Expand Down Expand Up @@ -180,6 +181,8 @@ func (s *Server) getDNSConfig() (c *jsonDNSConfig) {
upstreamMode = jsonUpstreamModeParallel
case UpstreamModeFastestAddr:
upstreamMode = jsonUpstreamModeFastestAddr
case UpstreamModeRandom:
upstreamMode = jsonUpstreamModeRandom
}

defPTRUps, err := s.defaultLocalPTRUpstreams()
Expand Down Expand Up @@ -265,6 +268,7 @@ func (req *jsonDNSConfig) checkUpstreamMode() (err error) {
jsonUpstreamModeLoadBalance,
jsonUpstreamModeParallel,
jsonUpstreamModeFastestAddr:
jsonUpstreamModeRandom:
return nil
default:
return fmt.Errorf("upstream_mode: incorrect value %q", um)
Expand Down Expand Up @@ -563,6 +567,8 @@ func mustParseUpstreamMode(mode jsonUpstreamMode) (um UpstreamMode) {
return UpstreamModeParallel
case jsonUpstreamModeFastestAddr:
return UpstreamModeFastestAddr
case jsonUpstreamModeRandom:
return UpstreamModeRandom
default:
// Should never happen, since the value should be validated.
panic(fmt.Errorf("unexpected upstream mode: %q", mode))
Expand Down
8 changes: 8 additions & 0 deletions internal/dnsforward/http_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ func TestDNSForwardHTTP_handleGetConfig(t *testing.T) {
return conf
},
name: "parallel",
}, {
conf: func() ServerConfig {
conf := defaultConf
conf.UpstreamMode = UpstreamModeRandom

return conf
},
name: "random",
}}

var data map[string]json.RawMessage
Expand Down
2 changes: 2 additions & 0 deletions internal/dnsforward/upstreams.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ func setProxyUpstreamMode(
switch upstreamMode {
case UpstreamModeParallel:
conf.UpstreamMode = proxy.UpstreamModeParallel
case UpstreamModeRandom:
conf.UpstreamMode = proxy.UpstreamModeRandom
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't build without go.mod modifications. You can set the dnsproxy version to the one from your branch, temporarily, via go get.

case UpstreamModeFastestAddr:
conf.UpstreamMode = proxy.UpstreamModeFastestAddr
conf.FastestPingTimeout = fastestTimeout
Expand Down
3 changes: 3 additions & 0 deletions openapi/next.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2510,10 +2510,13 @@
* `parallel`: Use parallel requests to speed up resolving by
simultaneously querying all upstream servers.
* `random`: Query a random upstream server for every new query.
'enum':
- 'fastest'
- 'load_balancing'
- 'parallel'
- 'random'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update both CHANGELOG.md (that one uses KeepAChangelog standard) and openapi/CHANGELOG.md adding this change.

'type': 'string'

'ErrorCode':
Expand Down