Skip to content

Commit

Permalink
- dns: limit the number of active goroutines for incoming requests pr…
Browse files Browse the repository at this point in the history
…ocessing

Close #2015

Squashed commit of the following:

commit 90ba06f
Merge: 9494b29 473d881
Author: Simon Zolin <[email protected]>
Date:   Fri Aug 14 19:14:26 2020 +0300

    Merge remote-tracking branch 'origin/master' into max-go

commit 9494b29
Author: Simon Zolin <[email protected]>
Date:   Fri Aug 14 17:03:00 2020 +0300

    + max_goroutines setting

commit 87071a5
Author: Simon Zolin <[email protected]>
Date:   Fri Aug 14 15:29:00 2020 +0300

    - dns: limit the number of active goroutines for incoming requests processing
  • Loading branch information
szolin committed Aug 14, 2020
1 parent 473d881 commit 9e09dff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dnsforward/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type FilteringConfig struct {
AAAADisabled bool `yaml:"aaaa_disabled"` // Respond with an empty answer to all AAAA requests
EnableDNSSEC bool `yaml:"enable_dnssec"` // Set DNSSEC flag in outcoming DNS request
EnableEDNSClientSubnet bool `yaml:"edns_client_subnet"` // Enable EDNS Client Subnet option
MaxGoroutines uint32 `yaml:"max_goroutines"` // Max. number of parallel goroutines for processing incoming requests
}

// TLSConfig is the TLS configuration for HTTPS, DNS-over-HTTPS, and DNS-over-TLS
Expand Down Expand Up @@ -144,6 +145,7 @@ func (s *Server) createProxyConfig() (proxy.Config, error) {
BeforeRequestHandler: s.beforeRequestHandler,
RequestHandler: s.handleDNSRequest,
EnableEDNSClientSubnet: s.conf.EnableEDNSClientSubnet,
MaxGoroutines: int(s.conf.MaxGoroutines),
}

if s.conf.CacheSize != 0 {
Expand Down
3 changes: 3 additions & 0 deletions dnsforward/dnsforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ func (s *Server) Prepare(config *ServerConfig) error {
return fmt.Errorf("DNS: invalid custom blocking IP address specified")
}
}
if s.conf.MaxGoroutines == 0 {
s.conf.MaxGoroutines = 50
}
}

// 2. Set default values in the case if nothing is configured
Expand Down

0 comments on commit 9e09dff

Please sign in to comment.