"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "internal/dnsforward/http.go" between
AdGuardHome-0.105.1.tar.gz and AdGuardHome-0.105.2.tar.gz

About: AdGuard Home is a network-wide ads & trackers blocking DNS server. It operates as a DNS server that re-routes tracking domains to a "black hole," thus preventing your devices from connecting to those servers.

http.go  (AdGuardHome-0.105.1):http.go  (AdGuardHome-0.105.2)
package dnsforward package dnsforward
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
"strconv" "strconv"
"strings" "strings"
"github.com/AdguardTeam/dnsproxy/proxy"
"github.com/AdguardTeam/dnsproxy/upstream" "github.com/AdguardTeam/dnsproxy/upstream"
"github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/log"
"github.com/AdguardTeam/golibs/utils" "github.com/AdguardTeam/golibs/utils"
"github.com/miekg/dns" "github.com/miekg/dns"
) )
func httpError(r *http.Request, w http.ResponseWriter, code int, format string, args ...interface{}) { func httpError(r *http.Request, w http.ResponseWriter, code int, format string, args ...interface{}) {
text := fmt.Sprintf(format, args...) text := fmt.Sprintf(format, args...)
log.Info("dns: %s %s: %s", r.Method, r.URL, text) log.Info("dns: %s %s: %s", r.Method, r.URL, text)
http.Error(w, text, code) http.Error(w, text, code)
skipping to change at line 152 skipping to change at line 153
func (req *dnsConfig) checkBootstrap() (string, error) { func (req *dnsConfig) checkBootstrap() (string, error) {
if req.Bootstraps == nil { if req.Bootstraps == nil {
return "", nil return "", nil
} }
for _, boot := range *req.Bootstraps { for _, boot := range *req.Bootstraps {
if boot == "" { if boot == "" {
return boot, fmt.Errorf("invalid bootstrap server address : empty") return boot, fmt.Errorf("invalid bootstrap server address : empty")
} }
if _, err := upstream.NewResolver(boot, 0); err != nil { if _, err := upstream.NewResolver(boot, upstream.Options{Timeout: 0}); err != nil {
return boot, fmt.Errorf("invalid bootstrap server address : %w", err) return boot, fmt.Errorf("invalid bootstrap server address : %w", err)
} }
} }
return "", nil return "", nil
} }
func (req *dnsConfig) checkCacheTTL() bool { func (req *dnsConfig) checkCacheTTL() bool {
if req.CacheMinTTL == nil && req.CacheMaxTTL == nil { if req.CacheMinTTL == nil && req.CacheMaxTTL == nil {
return true return true
skipping to change at line 317 skipping to change at line 318
// ValidateUpstreams validates each upstream and returns an error if any upstrea m is invalid or if there are no default upstreams specified // ValidateUpstreams validates each upstream and returns an error if any upstrea m is invalid or if there are no default upstreams specified
func ValidateUpstreams(upstreams []string) error { func ValidateUpstreams(upstreams []string) error {
// No need to validate comments // No need to validate comments
upstreams = filterOutComments(upstreams) upstreams = filterOutComments(upstreams)
// Consider this case valid because defaultDNS will be used // Consider this case valid because defaultDNS will be used
if len(upstreams) == 0 { if len(upstreams) == 0 {
return nil return nil
} }
_, err := proxy.ParseUpstreamsConfig(upstreams,
upstream.Options{
Bootstrap: []string{},
Timeout: DefaultTimeout,
},
)
if err != nil {
return err
}
var defaultUpstreamFound bool var defaultUpstreamFound bool
for _, u := range upstreams { for _, u := range upstreams {
d, err := validateUpstream(u) d, err := validateUpstream(u)
if err != nil { if err != nil {
return err return err
} }
// Check this flag until default upstream will not be found // Check this flag until default upstream will not be found
if !defaultUpstreamFound { if !defaultUpstreamFound {
defaultUpstreamFound = d defaultUpstreamFound = d
 End of changes. 3 change blocks. 
1 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)