Skip to content

Commit

Permalink
dnsforward: imp code, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Dec 19, 2023
1 parent db0356c commit b6f9bd5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ NOTE: Add new changes BELOW THIS COMMENT.

### Fixed

- Load balancing algorithm ([#6480]).
- Load balancing algorithm stuck on a single server ([#6480]).
- Names defined in the `/etc/hosts` for a single address family wrongly
considered undefined for another family ([#6541]).
- Omitted CNAME records in safe search results, which can cause YouTube to not
Expand Down
4 changes: 2 additions & 2 deletions internal/dnsforward/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ type Config struct {

// MaxGoroutines is the max number of parallel goroutines for processing
// incoming requests.
MaxGoroutines uint32 `yaml:"max_goroutines"`
MaxGoroutines uint `yaml:"max_goroutines"`

// HandleDDR, if true, handle DDR requests
HandleDDR bool `yaml:"handle_ddr"`
Expand Down Expand Up @@ -313,7 +313,7 @@ func (s *Server) newProxyConfig() (conf *proxy.Config, err error) {
RequestHandler: s.handleDNSRequest,
HTTPSServerName: aghhttp.UserAgent(),
EnableEDNSClientSubnet: srvConf.EDNSClientSubnet.Enabled,
MaxGoroutines: uint(srvConf.MaxGoroutines),
MaxGoroutines: srvConf.MaxGoroutines,
UseDNS64: srvConf.UseDNS64,
DNS64Prefs: srvConf.DNS64Prefixes,
}
Expand Down
15 changes: 8 additions & 7 deletions internal/dnsforward/dnsforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,11 @@ func (s *Server) startLocked() error {
return err
}

// prepareUpstreamSettings initializes the local upstreams configuration using b
// as bootstrap. It assumes that s.serverLock is locked or the Server not
// running.
func (s *Server) prepareLocalResolvers(b upstream.Resolver) (uc *proxy.UpstreamConfig, err error) {
// prepareLocalResolvers initializes the local upstreams configuration using
// boot as bootstrap. It assumes that s.serverLock is locked or s not running.
func (s *Server) prepareLocalResolvers(
boot upstream.Resolver,
) (uc *proxy.UpstreamConfig, err error) {
set, err := s.conf.ourAddrsSet()
if err != nil {
// Don't wrap the error because it's informative enough as is.
Expand All @@ -495,7 +496,7 @@ func (s *Server) prepareLocalResolvers(b upstream.Resolver) (uc *proxy.UpstreamC
log.Debug("dnsforward: upstreams to resolve ptr for local addresses: %v", resolvers)

uc, err = s.prepareUpstreamConfig(resolvers, nil, &upstream.Options{
Bootstrap: b,
Bootstrap: boot,
Timeout: defaultLocalTimeout,
// TODO(e.burkov): Should we verify server's certificates?
PreferIPv6: s.conf.BootstrapPreferIPv6,
Expand All @@ -515,7 +516,7 @@ func (s *Server) prepareLocalResolvers(b upstream.Resolver) (uc *proxy.UpstreamC
}

// setupLocalResolvers initializes and sets the resolvers for local addresses.
// It assumes s.serverLock is locked or the Server not running.
// It assumes s.serverLock is locked or s not running.
func (s *Server) setupLocalResolvers(boot upstream.Resolver) (err error) {
uc, err := s.prepareLocalResolvers(boot)
if err != nil {
Expand Down Expand Up @@ -719,7 +720,7 @@ func (s *Server) prepareInternalProxy() (err error) {
CacheEnabled: true,
CacheSizeBytes: 4096,
UpstreamConfig: srvConf.UpstreamConfig,
MaxGoroutines: uint(s.conf.MaxGoroutines),
MaxGoroutines: s.conf.MaxGoroutines,
}

setProxyUpstreamMode(
Expand Down

0 comments on commit b6f9bd5

Please sign in to comment.