docstring_tokens
stringlengths
0
76.5k
code_tokens
stringlengths
75
1.81M
label_window
sequencelengths
4
2.12k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
cType := w.Header().Get(aghhttp.HdrNameContentType) assert.Equal(t, aghhttp.HdrValApplicationJSON, cType)
<mask> <mask> s.conf = tc.conf() <mask> s.handleGetConfig(w, nil) <mask> <mask> assert.Equal(t, "application/json", w.Header().Get("Content-Type")) <mask> assert.JSONEq(t, string(caseWant), w.Body.String()) <mask> }) <mask> } <mask> } <mask> </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove if err != http.ErrServerClosed { </s> add if !errors.Is(err, http.ErrServerClosed) { </s> remove log.Fatal(err) </s> add log.Fatalf("web: https: %s", err) </s> remove if err != nil { const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } </s> add if err == nil { return } const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } } // shutdownSrv3 shuts srv down and prints error messages to the log. // // TODO(a.garipov): Think of a good way to merge with [shutdownSrv]. func shutdownSrv3(srv *http3.Server) { defer log.OnPanic("") if srv == nil { return } err := srv.Close() if err == nil { return } const msgFmt = "shutting down http/3 server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/dnsforward/http_test.go
Bootstrap: config.DNS.BootstrapDNS, Timeout: config.DNS.UpstreamTimeout.Duration, HTTPVersions: dnsforward.UpstreamHTTPVersions(config.DNS.UseHTTP3Upstreams),
<mask> var conf *proxy.UpstreamConfig <mask> conf, err = proxy.ParseUpstreamsConfig( <mask> upstreams, <mask> &upstream.Options{ <mask> Bootstrap: config.DNS.BootstrapDNS, <mask> Timeout: config.DNS.UpstreamTimeout.Duration, <mask> }, <mask> ) <mask> if err != nil { <mask> return nil, err <mask> } </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove &upstream.Options{Bootstrap: []string{}, Timeout: DefaultTimeout}, </s> add &upstream.Options{ Bootstrap: []string{}, Timeout: DefaultTimeout, }, </s> remove Bootstrap: s.conf.BootstrapDNS, Timeout: s.conf.UpstreamTimeout, </s> add Bootstrap: s.conf.BootstrapDNS, Timeout: s.conf.UpstreamTimeout, HTTPVersions: httpVersions, </s> remove Bootstrap: s.conf.BootstrapDNS, Timeout: s.conf.UpstreamTimeout, </s> add Bootstrap: s.conf.BootstrapDNS, Timeout: s.conf.UpstreamTimeout, HTTPVersions: httpVersions, </s> remove jsonVal, err := json.Marshal(result) if err != nil { aghhttp.Error( r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err, ) return } w.Header().Set("Content-Type", "application/json") _, err = w.Write(jsonVal) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't write body: %s", err) } </s> add _ = aghhttp.WriteJSONResponse(w, r, result)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/clients.go
// ServeHTTP3 defines if HTTP/3 is be allowed for incoming requests. // // TODO(a.garipov): Add to the UI when HTTP/3 support is no longer // experimental. ServeHTTP3 bool `yaml:"serve_http3"` // UseHTTP3Upstreams defines if HTTP/3 is be allowed for DNS-over-HTTPS // upstreams. // // TODO(a.garipov): Add to the UI when HTTP/3 support is no longer // experimental. UseHTTP3Upstreams bool `yaml:"use_http3_upstreams"`
<mask> // LocalPTRResolvers is the slice of addresses to be used as upstreams <mask> // for PTR queries for locally-served networks. <mask> LocalPTRResolvers []string `yaml:"local_ptr_upstreams"` <mask> } <mask> <mask> type tlsConfigSettings struct { <mask> Enabled bool `yaml:"enabled" json:"enabled"` // Enabled is the encryption (DoT/DoH/HTTPS) status <mask> ServerName string `yaml:"server_name" json:"server_name,omitempty"` // ServerName is the hostname of your HTTPS/TLS server <mask> ForceHTTPS bool `yaml:"force_https" json:"force_https"` // ForceHTTPS: if true, forces HTTP->HTTPS redirect </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove // LocalPTRResolvers is a slice of addresses to be used as upstreams for // resolving PTR queries for local addresses. LocalPTRResolvers []string </s> add // ServeHTTP3 defines if HTTP/3 is be allowed for incoming requests. ServeHTTP3 bool // UseHTTP3Upstreams defines if HTTP/3 is be allowed for DNS-over-HTTPS // upstreams. UseHTTP3Upstreams bool </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond condLock sync.Mutex shutdown bool // if TRUE, don't restart the server enabled bool cert tls.Certificate </s> add // httpsServer contains the data for the HTTPS server. type httpsServer struct { // server is the pre-HTTP/3 HTTPS server. server *http.Server // server3 is the HTTP/3 HTTPS server. If it is not nil, // [httpsServer.server] must also be non-nil. server3 *http3.Server // TODO(a.garipov): Why is there a *sync.Cond here? Remove. cond *sync.Cond condLock sync.Mutex cert tls.Certificate inShutdown bool enabled bool </s> remove conf *webConfig forceHTTPS bool httpServer *http.Server // HTTP module httpsServer HTTPSServer // HTTPS module </s> add conf *webConfig // TODO(a.garipov): Refactor all these servers. httpServer *http.Server // httpServerBeta is a server for new client. httpServerBeta *http.Server
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/config.go
<mask> package home <mask> <mask> import ( <mask> "encoding/json" <mask> "fmt" <mask> "net" <mask> "net/http" <mask> "net/url" <mask> "runtime" </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove github.com/AdguardTeam/dnsproxy v0.44.0 </s> add github.com/AdguardTeam/dnsproxy v0.45.2 </s> remove github.com/lucas-clemente/quic-go v0.29.0 </s> add github.com/lucas-clemente/quic-go v0.29.1 </s> remove // LocalPTRResolvers is a slice of addresses to be used as upstreams for // resolving PTR queries for local addresses. LocalPTRResolvers []string </s> add // ServeHTTP3 defines if HTTP/3 is be allowed for incoming requests. ServeHTTP3 bool // UseHTTP3Upstreams defines if HTTP/3 is be allowed for DNS-over-HTTPS // upstreams. UseHTTP3Upstreams bool </s> remove Bootstrap: config.DNS.BootstrapDNS, Timeout: config.DNS.UpstreamTimeout.Duration, </s> add Bootstrap: config.DNS.BootstrapDNS, Timeout: config.DNS.UpstreamTimeout.Duration, HTTPVersions: dnsforward.UpstreamHTTPVersions(config.DNS.UseHTTP3Upstreams),
[ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/control.go
<mask> Name string `json:"name"` <mask> } <mask> <mask> func handleGetProfile(w http.ResponseWriter, r *http.Request) { <mask> pj := profileJSON{} <mask> u := Context.auth.getCurrentUser(r) <mask> <mask> pj.Name = u.Name <mask> <mask> data, err := json.Marshal(pj) </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove pj.Name = u.Name data, err := json.Marshal(pj) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Marshal: %s", err) return </s> add resp := &profileJSON{ Name: u.Name, </s> remove j := s.accessListJSON() w.Header().Set("Content-Type", "application/json") err := json.NewEncoder(w).Encode(j) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "encoding response: %s", err) return } </s> add _ = aghhttp.WriteJSONResponse(w, r, s.accessListJSON()) </s> remove if err != http.ErrServerClosed { </s> add if !errors.Is(err, http.ErrServerClosed) { </s> remove log.Fatal(err) </s> add log.Fatalf("web: https: %s", err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/control.go
resp := &profileJSON{ Name: u.Name,
<mask> <mask> func handleGetProfile(w http.ResponseWriter, r *http.Request) { <mask> pj := profileJSON{} <mask> u := Context.auth.getCurrentUser(r) <mask> <mask> pj.Name = u.Name <mask> <mask> data, err := json.Marshal(pj) <mask> if err != nil { <mask> aghhttp.Error(r, w, http.StatusInternalServerError, "json.Marshal: %s", err) <mask> <mask> return <mask> } <mask> <mask> _, _ = w.Write(data) <mask> } <mask> </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove pj := profileJSON{} </s> add </s> remove jsonVal, err := json.Marshal(result) if err != nil { aghhttp.Error( r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err, ) return } w.Header().Set("Content-Type", "application/json") _, err = w.Write(jsonVal) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't write body: %s", err) } </s> add _ = aghhttp.WriteJSONResponse(w, r, result) </s> remove j := s.accessListJSON() w.Header().Set("Content-Type", "application/json") err := json.NewEncoder(w).Encode(j) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "encoding response: %s", err) return } </s> add _ = aghhttp.WriteJSONResponse(w, r, s.accessListJSON()) </s> remove w.Header().Set("Content-Type", "application/json") if err = json.NewEncoder(w).Encode(resp); err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Encoder: %s", err) return } </s> add _ = aghhttp.WriteJSONResponse(w, r, resp) </s> remove aghhttp.Error( r, w, http.StatusBadRequest, "Failed to encode 'check_config' JSON data: %s", err, ) </s> add aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/control.go
_ = aghhttp.WriteJSONResponse(w, r, resp)
<mask> <mask> return <mask> } <mask> <mask> _, _ = w.Write(data) <mask> } <mask> <mask> // ------------------------ <mask> // registration of handlers <mask> // ------------------------ </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove pj.Name = u.Name data, err := json.Marshal(pj) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Marshal: %s", err) return </s> add resp := &profileJSON{ Name: u.Name, </s> remove jsonVal, err := json.Marshal(result) if err != nil { aghhttp.Error( r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err, ) return } w.Header().Set("Content-Type", "application/json") _, err = w.Write(jsonVal) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't write body: %s", err) } </s> add _ = aghhttp.WriteJSONResponse(w, r, result) </s> remove w.Header().Set("Content-Type", "application/json") if err = json.NewEncoder(w).Encode(resp); err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Encoder: %s", err) return } </s> add _ = aghhttp.WriteJSONResponse(w, r, resp) </s> remove if err != nil { const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } </s> add if err == nil { return } const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } } // shutdownSrv3 shuts srv down and prints error messages to the log. // // TODO(a.garipov): Think of a good way to merge with [shutdownSrv]. func shutdownSrv3(srv *http3.Server) { defer log.OnPanic("") if srv == nil { return } err := srv.Close() if err == nil { return } const msgFmt = "shutting down http/3 server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/control.go
"github.com/lucas-clemente/quic-go/http3"
<mask> "github.com/AdguardTeam/golibs/errors" <mask> "github.com/AdguardTeam/golibs/log" <mask> ) <mask> <mask> // getAddrsResponse is the response for /install/get_addresses endpoint. <mask> type getAddrsResponse struct { <mask> Interfaces map[string]*aghnet.NetInterface `json:"interfaces"` <mask> </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond condLock sync.Mutex shutdown bool // if TRUE, don't restart the server enabled bool cert tls.Certificate </s> add // httpsServer contains the data for the HTTPS server. type httpsServer struct { // server is the pre-HTTP/3 HTTPS server. server *http.Server // server3 is the HTTP/3 HTTPS server. If it is not nil, // [httpsServer.server] must also be non-nil. server3 *http3.Server // TODO(a.garipov): Why is there a *sync.Cond here? Remove. cond *sync.Cond condLock sync.Mutex cert tls.Certificate inShutdown bool enabled bool </s> remove conf *webConfig forceHTTPS bool httpServer *http.Server // HTTP module httpsServer HTTPSServer // HTTPS module </s> add conf *webConfig // TODO(a.garipov): Refactor all these servers. httpServer *http.Server // httpServerBeta is a server for new client. httpServerBeta *http.Server </s> remove // Web - module object </s> add // Web is the web UI and API server.
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/controlinstall.go
// shutdownSrv shuts srv down and prints error messages to the log.
<mask> <mask> // shutdownTimeout is the timeout for shutting HTTP server down operation. <mask> const shutdownTimeout = 5 * time.Second <mask> <mask> func shutdownSrv(ctx context.Context, srv *http.Server) { <mask> defer log.OnPanic("") <mask> <mask> if srv == nil { <mask> return <mask> } </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove if err != nil { const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } </s> add if err == nil { return } const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } } // shutdownSrv3 shuts srv down and prints error messages to the log. // // TODO(a.garipov): Think of a good way to merge with [shutdownSrv]. func shutdownSrv3(srv *http3.Server) { defer log.OnPanic("") if srv == nil { return } err := srv.Close() if err == nil { return } const msgFmt = "shutting down http/3 server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) </s> remove // WebCheckPortAvailable - check if port is available // BUT: if we are already using this port, no need func WebCheckPortAvailable(port int) bool { </s> add // webCheckPortAvailable checks if port, which is considered an HTTPS port, is // available, unless the HTTPS server isn't active. // // TODO(a.garipov): Adapt for HTTP/3. func webCheckPortAvailable(port int) (ok bool) { </s> remove w.Header().Set("Content-Type", "application/json") if err = json.NewEncoder(w).Encode(resp); err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Encoder: %s", err) return } </s> add _ = aghhttp.WriteJSONResponse(w, r, resp) </s> remove conf *webConfig forceHTTPS bool httpServer *http.Server // HTTP module httpsServer HTTPSServer // HTTPS module </s> add conf *webConfig // TODO(a.garipov): Refactor all these servers. httpServer *http.Server // httpServerBeta is a server for new client. httpServerBeta *http.Server
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/controlinstall.go
if err == nil { return } const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } } // shutdownSrv3 shuts srv down and prints error messages to the log. // // TODO(a.garipov): Think of a good way to merge with [shutdownSrv]. func shutdownSrv3(srv *http3.Server) { defer log.OnPanic("") if srv == nil { return } err := srv.Close() if err == nil { return } const msgFmt = "shutting down http/3 server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err)
<mask> return <mask> } <mask> <mask> err := srv.Shutdown(ctx) <mask> if err != nil { <mask> const msgFmt = "shutting down http server %q: %s" <mask> if errors.Is(err, context.Canceled) { <mask> log.Debug(msgFmt, srv.Addr, err) <mask> } else { <mask> log.Error(msgFmt, srv.Addr, err) <mask> } <mask> } <mask> } <mask> <mask> // PasswordMinRunes is the minimum length of user's password in runes. <mask> const PasswordMinRunes = 8 </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove log.Fatal(err) </s> add log.Fatalf("web: https: %s", err) </s> remove jsonVal, err := json.Marshal(result) if err != nil { aghhttp.Error( r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err, ) return } w.Header().Set("Content-Type", "application/json") _, err = w.Write(jsonVal) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't write body: %s", err) } </s> add _ = aghhttp.WriteJSONResponse(w, r, result) </s> remove w.Header().Set("Content-Type", "application/json") if err = json.NewEncoder(w).Encode(resp); err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Encoder: %s", err) return } </s> add _ = aghhttp.WriteJSONResponse(w, r, resp) </s> remove pj.Name = u.Name data, err := json.Marshal(pj) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Marshal: %s", err) return </s> add resp := &profileJSON{ Name: u.Name,
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/controlinstall.go
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
<mask> nonBetaReqBody := &strings.Builder{} <mask> <mask> err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData) <mask> if err != nil { <mask> aghhttp.Error( <mask> r, <mask> w, <mask> http.StatusBadRequest, <mask> "Failed to encode 'check_config' JSON data: %s", <mask> err, <mask> ) <mask> <mask> return <mask> } <mask> body := nonBetaReqBody.String() <mask> r.Body = io.NopCloser(strings.NewReader(body)) </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove aghhttp.Error( r, w, http.StatusBadRequest, "Failed to encode 'check_config' JSON data: %s", err, ) </s> add aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err) </s> remove jsonVal, err := json.Marshal(result) if err != nil { aghhttp.Error( r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err, ) return } w.Header().Set("Content-Type", "application/json") _, err = w.Write(jsonVal) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't write body: %s", err) } </s> add _ = aghhttp.WriteJSONResponse(w, r, result) </s> remove w.Header().Set("Content-Type", "application/json") if err = json.NewEncoder(w).Encode(resp); err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Encoder: %s", err) return } </s> add _ = aghhttp.WriteJSONResponse(w, r, resp) </s> remove pj.Name = u.Name data, err := json.Marshal(pj) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Marshal: %s", err) return </s> add resp := &profileJSON{ Name: u.Name, </s> remove if !WebCheckPortAvailable(setts.PortHTTPS) { </s> add if !webCheckPortAvailable(setts.PortHTTPS) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/controlinstall.go
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
<mask> nonBetaReqBody := &strings.Builder{} <mask> <mask> err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData) <mask> if err != nil { <mask> aghhttp.Error( <mask> r, <mask> w, <mask> http.StatusBadRequest, <mask> "Failed to encode 'check_config' JSON data: %s", <mask> err, <mask> ) <mask> <mask> return <mask> } <mask> body := nonBetaReqBody.String() <mask> r.Body = io.NopCloser(strings.NewReader(body)) </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove aghhttp.Error( r, w, http.StatusBadRequest, "Failed to encode 'check_config' JSON data: %s", err, ) </s> add aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err) </s> remove jsonVal, err := json.Marshal(result) if err != nil { aghhttp.Error( r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err, ) return } w.Header().Set("Content-Type", "application/json") _, err = w.Write(jsonVal) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't write body: %s", err) } </s> add _ = aghhttp.WriteJSONResponse(w, r, result) </s> remove w.Header().Set("Content-Type", "application/json") if err = json.NewEncoder(w).Encode(resp); err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Encoder: %s", err) return } </s> add _ = aghhttp.WriteJSONResponse(w, r, resp) </s> remove pj.Name = u.Name data, err := json.Marshal(pj) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Marshal: %s", err) return </s> add resp := &profileJSON{ Name: u.Name, </s> remove if !WebCheckPortAvailable(setts.PortHTTPS) { </s> add if !webCheckPortAvailable(setts.PortHTTPS) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/controlinstall.go
<mask> <mask> newConf.FilterHandler = applyAdditionalFiltering <mask> newConf.GetCustomUpstreamByClient = Context.clients.findUpstreams <mask> <mask> newConf.ResolveClients = config.Clients.Sources.RDNS <mask> newConf.UsePrivateRDNS = dnsConf.UsePrivateRDNS <mask> newConf.LocalPTRResolvers = dnsConf.LocalPTRResolvers <mask> newConf.UpstreamTimeout = dnsConf.UpstreamTimeout.Duration <mask> <mask> return newConf, nil <mask> } </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove web = CreateWeb(&webConf) </s> add web = newWeb(&webConf) </s> remove w.Header().Set("Content-Type", "application/json") if err = json.NewEncoder(w).Encode(resp); err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Encoder: %s", err) return } </s> add _ = aghhttp.WriteJSONResponse(w, r, resp) </s> remove if err != nil { const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } </s> add if err == nil { return } const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } } // shutdownSrv3 shuts srv down and prints error messages to the log. // // TODO(a.garipov): Think of a good way to merge with [shutdownSrv]. func shutdownSrv3(srv *http3.Server) { defer log.OnPanic("") if srv == nil { return } err := srv.Close() if err == nil { return } const msgFmt = "shutting down http/3 server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) </s> remove jsonVal, err := json.Marshal(result) if err != nil { aghhttp.Error( r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err, ) return } w.Header().Set("Content-Type", "application/json") _, err = w.Write(jsonVal) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't write body: %s", err) } </s> add _ = aghhttp.WriteJSONResponse(w, r, result)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/dns.go
newConf.ResolveClients = config.Clients.Sources.RDNS newConf.UsePrivateRDNS = dnsConf.UsePrivateRDNS newConf.ServeHTTP3 = dnsConf.ServeHTTP3 newConf.UseHTTP3Upstreams = dnsConf.UseHTTP3Upstreams
<mask> <mask> newConf.LocalPTRResolvers = dnsConf.LocalPTRResolvers <mask> newConf.UpstreamTimeout = dnsConf.UpstreamTimeout.Duration <mask> <mask> return newConf, nil <mask> } <mask> <mask> func newDNSCrypt(hosts []net.IP, tlsConf tlsConfigSettings) (dnscc dnsforward.DNSCryptConfig, err error) { <mask> if tlsConf.DNSCryptConfigFile == "" { </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove newConf.ResolveClients = config.Clients.Sources.RDNS newConf.UsePrivateRDNS = dnsConf.UsePrivateRDNS </s> add </s> remove w.Header().Set("Content-Type", "application/json") if err = json.NewEncoder(w).Encode(resp); err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Encoder: %s", err) return } </s> add _ = aghhttp.WriteJSONResponse(w, r, resp) </s> remove if err != nil { const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } </s> add if err == nil { return } const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } } // shutdownSrv3 shuts srv down and prints error messages to the log. // // TODO(a.garipov): Think of a good way to merge with [shutdownSrv]. func shutdownSrv3(srv *http3.Server) { defer log.OnPanic("") if srv == nil { return } err := srv.Close() if err == nil { return } const msgFmt = "shutting down http/3 server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) </s> remove &upstream.Options{Bootstrap: []string{}, Timeout: DefaultTimeout}, </s> add &upstream.Options{ Bootstrap: []string{}, Timeout: DefaultTimeout, }, </s> remove web = CreateWeb(&webConf) </s> add web = newWeb(&webConf)
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/dns.go
serveHTTP3: config.DNS.ServeHTTP3,
<mask> WriteTimeout: writeTimeout, <mask> <mask> clientFS: clientFS, <mask> clientBetaFS: clientBetaFS, <mask> } <mask> <mask> web = newWeb(&webConf) <mask> if web == nil { </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove web = CreateWeb(&webConf) </s> add web = newWeb(&webConf) </s> remove // CreateWeb - create module func CreateWeb(conf *webConfig) *Web { log.Info("Initialize web module") </s> add // newWeb creates a new instance of the web UI and API server. func newWeb(conf *webConfig) (w *Web) { log.Info("web: initializing") </s> remove w.Header().Set("Content-Type", "application/json") if err = json.NewEncoder(w).Encode(resp); err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Encoder: %s", err) return } </s> add _ = aghhttp.WriteJSONResponse(w, r, resp) </s> remove if err != nil { const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } </s> add if err == nil { return } const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } } // shutdownSrv3 shuts srv down and prints error messages to the log. // // TODO(a.garipov): Think of a good way to merge with [shutdownSrv]. func shutdownSrv3(srv *http3.Server) { defer log.OnPanic("") if srv == nil { return } err := srv.Close() if err == nil { return } const msgFmt = "shutting down http/3 server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err)
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/home.go
web = newWeb(&webConf)
<mask> clientFS: clientFS, <mask> clientBetaFS: clientBetaFS, <mask> } <mask> <mask> web = CreateWeb(&webConf) <mask> if web == nil { <mask> return nil, fmt.Errorf("initializing web: %w", err) <mask> } <mask> <mask> return web, nil </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove &upstream.Options{Bootstrap: []string{}, Timeout: DefaultTimeout}, </s> add &upstream.Options{ Bootstrap: []string{}, Timeout: DefaultTimeout, }, </s> remove w.Header().Set("Content-Type", "application/json") if err = json.NewEncoder(w).Encode(resp); err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Encoder: %s", err) return } </s> add _ = aghhttp.WriteJSONResponse(w, r, resp) </s> remove if err != nil { const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } </s> add if err == nil { return } const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } } // shutdownSrv3 shuts srv down and prints error messages to the log. // // TODO(a.garipov): Think of a good way to merge with [shutdownSrv]. func shutdownSrv3(srv *http3.Server) { defer log.OnPanic("") if srv == nil { return } err := srv.Close() if err == nil { return } const msgFmt = "shutting down http/3 server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) </s> remove Bootstrap: s.conf.BootstrapDNS, Timeout: s.conf.UpstreamTimeout, </s> add Bootstrap: s.conf.BootstrapDNS, Timeout: s.conf.UpstreamTimeout, HTTPVersions: httpVersions,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/home.go
if !webCheckPortAvailable(setts.PortHTTPS) {
<mask> return <mask> } <mask> } <mask> <mask> if !WebCheckPortAvailable(setts.PortHTTPS) { <mask> aghhttp.Error( <mask> r, <mask> w, <mask> http.StatusBadRequest, <mask> "port %d is not available, cannot enable HTTPS on it", </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove if !WebCheckPortAvailable(data.PortHTTPS) { </s> add if !webCheckPortAvailable(data.PortHTTPS) { </s> remove aghhttp.Error( r, w, http.StatusBadRequest, "Failed to encode 'check_config' JSON data: %s", err, ) </s> add aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err) </s> remove aghhttp.Error( r, w, http.StatusBadRequest, "Failed to encode 'check_config' JSON data: %s", err, ) </s> add aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err) </s> remove jsonVal, err := json.Marshal(result) if err != nil { aghhttp.Error( r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err, ) return } w.Header().Set("Content-Type", "application/json") _, err = w.Write(jsonVal) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't write body: %s", err) } </s> add _ = aghhttp.WriteJSONResponse(w, r, result)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/tls.go
if !webCheckPortAvailable(data.PortHTTPS) {
<mask> } <mask> } <mask> <mask> // TODO(e.burkov): Investigate and perhaps check other ports. <mask> if !WebCheckPortAvailable(data.PortHTTPS) { <mask> aghhttp.Error( <mask> r, <mask> w, <mask> http.StatusBadRequest, <mask> "port %d is not available, cannot enable HTTPS on it", </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove if !WebCheckPortAvailable(setts.PortHTTPS) { </s> add if !webCheckPortAvailable(setts.PortHTTPS) { </s> remove aghhttp.Error( r, w, http.StatusBadRequest, "Failed to encode 'check_config' JSON data: %s", err, ) </s> add aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err) </s> remove aghhttp.Error( r, w, http.StatusBadRequest, "Failed to encode 'check_config' JSON data: %s", err, ) </s> add aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err) </s> remove jsonVal, err := json.Marshal(result) if err != nil { aghhttp.Error( r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err, ) return } w.Header().Set("Content-Type", "application/json") _, err = w.Write(jsonVal) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't write body: %s", err) } </s> add _ = aghhttp.WriteJSONResponse(w, r, result) </s> remove // WebCheckPortAvailable - check if port is available // BUT: if we are already using this port, no need func WebCheckPortAvailable(port int) bool { </s> add // webCheckPortAvailable checks if port, which is considered an HTTPS port, is // available, unless the HTTPS server isn't active. // // TODO(a.garipov): Adapt for HTTP/3. func webCheckPortAvailable(port int) (ok bool) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/tls.go
"github.com/lucas-clemente/quic-go" "github.com/lucas-clemente/quic-go/http3"
<mask> "github.com/AdguardTeam/golibs/errors" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/AdguardTeam/golibs/netutil" <mask> "github.com/NYTimes/gziphandler" <mask> "golang.org/x/net/http2" <mask> "golang.org/x/net/http2/h2c" <mask> ) <mask> </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove Bootstrap: config.DNS.BootstrapDNS, Timeout: config.DNS.UpstreamTimeout.Duration, </s> add Bootstrap: config.DNS.BootstrapDNS, Timeout: config.DNS.UpstreamTimeout.Duration, HTTPVersions: dnsforward.UpstreamHTTPVersions(config.DNS.UseHTTP3Upstreams), </s> remove golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 golang.org/x/exp v0.0.0-20220827204233-334a2380cb91 golang.org/x/net v0.0.0-20220906165146-f3363e06e74c golang.org/x/sys v0.0.0-20220906135438-9e1f76180b77 </s> add golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be golang.org/x/exp v0.0.0-20220929160808-de9c53c655b9 golang.org/x/net v0.0.0-20220927171203-f486391704dc golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec </s> remove Bootstrap: s.conf.BootstrapDNS, Timeout: s.conf.UpstreamTimeout, </s> add Bootstrap: s.conf.BootstrapDNS, Timeout: s.conf.UpstreamTimeout, HTTPVersions: httpVersions,
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
serveHTTP3 bool
<mask> // appropriate field. <mask> WriteTimeout time.Duration <mask> <mask> firstRun bool <mask> } <mask> <mask> // httpsServer contains the data for the HTTPS server. <mask> type httpsServer struct { <mask> // server is the pre-HTTP/3 HTTPS server. </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond condLock sync.Mutex shutdown bool // if TRUE, don't restart the server enabled bool cert tls.Certificate </s> add // httpsServer contains the data for the HTTPS server. type httpsServer struct { // server is the pre-HTTP/3 HTTPS server. server *http.Server // server3 is the HTTP/3 HTTPS server. If it is not nil, // [httpsServer.server] must also be non-nil. server3 *http3.Server // TODO(a.garipov): Why is there a *sync.Cond here? Remove. cond *sync.Cond condLock sync.Mutex cert tls.Certificate inShutdown bool enabled bool </s> remove // Web - module object </s> add // Web is the web UI and API server. </s> remove // httpServerBeta is a server for new client. httpServerBeta *http.Server </s> add // httpsServer is the server that handles HTTPS traffic. If it is not nil, // [Web.http3Server] must also not be nil. httpsServer httpsServer forceHTTPS bool </s> remove conf *webConfig forceHTTPS bool httpServer *http.Server // HTTP module httpsServer HTTPSServer // HTTPS module </s> add conf *webConfig // TODO(a.garipov): Refactor all these servers. httpServer *http.Server // httpServerBeta is a server for new client. httpServerBeta *http.Server </s> remove // WebCheckPortAvailable - check if port is available // BUT: if we are already using this port, no need func WebCheckPortAvailable(port int) bool { </s> add // webCheckPortAvailable checks if port, which is considered an HTTPS port, is // available, unless the HTTPS server isn't active. // // TODO(a.garipov): Adapt for HTTP/3. func webCheckPortAvailable(port int) (ok bool) {
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
// httpsServer contains the data for the HTTPS server. type httpsServer struct { // server is the pre-HTTP/3 HTTPS server. server *http.Server // server3 is the HTTP/3 HTTPS server. If it is not nil, // [httpsServer.server] must also be non-nil. server3 *http3.Server // TODO(a.garipov): Why is there a *sync.Cond here? Remove. cond *sync.Cond condLock sync.Mutex cert tls.Certificate inShutdown bool enabled bool
<mask> <mask> firstRun bool <mask> } <mask> <mask> // HTTPSServer - HTTPS Server <mask> type HTTPSServer struct { <mask> server *http.Server <mask> cond *sync.Cond <mask> condLock sync.Mutex <mask> shutdown bool // if TRUE, don't restart the server <mask> enabled bool <mask> cert tls.Certificate <mask> } <mask> <mask> // Web - module object <mask> type Web struct { <mask> conf *webConfig </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove // Web - module object </s> add // Web is the web UI and API server. </s> remove conf *webConfig forceHTTPS bool httpServer *http.Server // HTTP module httpsServer HTTPSServer // HTTPS module </s> add conf *webConfig // TODO(a.garipov): Refactor all these servers. httpServer *http.Server // httpServerBeta is a server for new client. httpServerBeta *http.Server </s> remove // httpServerBeta is a server for new client. httpServerBeta *http.Server </s> add // httpsServer is the server that handles HTTPS traffic. If it is not nil, // [Web.http3Server] must also not be nil. httpsServer httpsServer forceHTTPS bool
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
// Web is the web UI and API server.
<mask> enabled bool <mask> cert tls.Certificate <mask> } <mask> <mask> // Web - module object <mask> type Web struct { <mask> conf *webConfig <mask> forceHTTPS bool <mask> httpServer *http.Server // HTTP module <mask> httpsServer HTTPSServer // HTTPS module </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove conf *webConfig forceHTTPS bool httpServer *http.Server // HTTP module httpsServer HTTPSServer // HTTPS module </s> add conf *webConfig // TODO(a.garipov): Refactor all these servers. httpServer *http.Server // httpServerBeta is a server for new client. httpServerBeta *http.Server </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond condLock sync.Mutex shutdown bool // if TRUE, don't restart the server enabled bool cert tls.Certificate </s> add // httpsServer contains the data for the HTTPS server. type httpsServer struct { // server is the pre-HTTP/3 HTTPS server. server *http.Server // server3 is the HTTP/3 HTTPS server. If it is not nil, // [httpsServer.server] must also be non-nil. server3 *http3.Server // TODO(a.garipov): Why is there a *sync.Cond here? Remove. cond *sync.Cond condLock sync.Mutex cert tls.Certificate inShutdown bool enabled bool </s> remove // httpServerBeta is a server for new client. httpServerBeta *http.Server </s> add // httpsServer is the server that handles HTTPS traffic. If it is not nil, // [Web.http3Server] must also not be nil. httpsServer httpsServer forceHTTPS bool </s> remove // CreateWeb - create module func CreateWeb(conf *webConfig) *Web { log.Info("Initialize web module") </s> add // newWeb creates a new instance of the web UI and API server. func newWeb(conf *webConfig) (w *Web) { log.Info("web: initializing")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
conf *webConfig // TODO(a.garipov): Refactor all these servers. httpServer *http.Server // httpServerBeta is a server for new client. httpServerBeta *http.Server
<mask> } <mask> <mask> // Web - module object <mask> type Web struct { <mask> conf *webConfig <mask> forceHTTPS bool <mask> httpServer *http.Server // HTTP module <mask> httpsServer HTTPSServer // HTTPS module <mask> <mask> // handlerBeta is the handler for new client. <mask> handlerBeta http.Handler <mask> // installerBeta is the pre-install handler for new client. <mask> installerBeta http.Handler </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove // httpServerBeta is a server for new client. httpServerBeta *http.Server </s> add // httpsServer is the server that handles HTTPS traffic. If it is not nil, // [Web.http3Server] must also not be nil. httpsServer httpsServer forceHTTPS bool </s> remove // Web - module object </s> add // Web is the web UI and API server. </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond condLock sync.Mutex shutdown bool // if TRUE, don't restart the server enabled bool cert tls.Certificate </s> add // httpsServer contains the data for the HTTPS server. type httpsServer struct { // server is the pre-HTTP/3 HTTPS server. server *http.Server // server3 is the HTTP/3 HTTPS server. If it is not nil, // [httpsServer.server] must also be non-nil. server3 *http3.Server // TODO(a.garipov): Why is there a *sync.Cond here? Remove. cond *sync.Cond condLock sync.Mutex cert tls.Certificate inShutdown bool enabled bool </s> remove // CreateWeb - create module func CreateWeb(conf *webConfig) *Web { log.Info("Initialize web module") </s> add // newWeb creates a new instance of the web UI and API server. func newWeb(conf *webConfig) (w *Web) { log.Info("web: initializing")
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
// httpsServer is the server that handles HTTPS traffic. If it is not nil, // [Web.http3Server] must also not be nil. httpsServer httpsServer forceHTTPS bool
<mask> handlerBeta http.Handler <mask> // installerBeta is the pre-install handler for new client. <mask> installerBeta http.Handler <mask> <mask> // httpServerBeta is a server for new client. <mask> httpServerBeta *http.Server <mask> } <mask> <mask> // CreateWeb - create module <mask> func CreateWeb(conf *webConfig) *Web { <mask> log.Info("Initialize web module") </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove conf *webConfig forceHTTPS bool httpServer *http.Server // HTTP module httpsServer HTTPSServer // HTTPS module </s> add conf *webConfig // TODO(a.garipov): Refactor all these servers. httpServer *http.Server // httpServerBeta is a server for new client. httpServerBeta *http.Server </s> remove // CreateWeb - create module func CreateWeb(conf *webConfig) *Web { log.Info("Initialize web module") </s> add // newWeb creates a new instance of the web UI and API server. func newWeb(conf *webConfig) (w *Web) { log.Info("web: initializing") </s> remove w := Web{} w.conf = conf </s> add w = &Web{ conf: conf, } </s> remove // Web - module object </s> add // Web is the web UI and API server. </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond condLock sync.Mutex shutdown bool // if TRUE, don't restart the server enabled bool cert tls.Certificate </s> add // httpsServer contains the data for the HTTPS server. type httpsServer struct { // server is the pre-HTTP/3 HTTPS server. server *http.Server // server3 is the HTTP/3 HTTPS server. If it is not nil, // [httpsServer.server] must also be non-nil. server3 *http3.Server // TODO(a.garipov): Why is there a *sync.Cond here? Remove. cond *sync.Cond condLock sync.Mutex cert tls.Certificate inShutdown bool enabled bool
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
// newWeb creates a new instance of the web UI and API server. func newWeb(conf *webConfig) (w *Web) { log.Info("web: initializing")
<mask> // httpServerBeta is a server for new client. <mask> httpServerBeta *http.Server <mask> } <mask> <mask> // CreateWeb - create module <mask> func CreateWeb(conf *webConfig) *Web { <mask> log.Info("Initialize web module") <mask> <mask> w := Web{} <mask> w.conf = conf <mask> <mask> clientFS := http.FileServer(http.FS(conf.clientFS)) </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove w := Web{} w.conf = conf </s> add w = &Web{ conf: conf, } </s> remove // httpServerBeta is a server for new client. httpServerBeta *http.Server </s> add // httpsServer is the server that handles HTTPS traffic. If it is not nil, // [Web.http3Server] must also not be nil. httpsServer httpsServer forceHTTPS bool </s> remove conf *webConfig forceHTTPS bool httpServer *http.Server // HTTP module httpsServer HTTPSServer // HTTPS module </s> add conf *webConfig // TODO(a.garipov): Refactor all these servers. httpServer *http.Server // httpServerBeta is a server for new client. httpServerBeta *http.Server </s> remove // Web - module object </s> add // Web is the web UI and API server. </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond condLock sync.Mutex shutdown bool // if TRUE, don't restart the server enabled bool cert tls.Certificate </s> add // httpsServer contains the data for the HTTPS server. type httpsServer struct { // server is the pre-HTTP/3 HTTPS server. server *http.Server // server3 is the HTTP/3 HTTPS server. If it is not nil, // [httpsServer.server] must also be non-nil. server3 *http3.Server // TODO(a.garipov): Why is there a *sync.Cond here? Remove. cond *sync.Cond condLock sync.Mutex cert tls.Certificate inShutdown bool enabled bool
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
w = &Web{ conf: conf, }
<mask> // CreateWeb - create module <mask> func CreateWeb(conf *webConfig) *Web { <mask> log.Info("Initialize web module") <mask> <mask> w := Web{} <mask> w.conf = conf <mask> <mask> clientFS := http.FileServer(http.FS(conf.clientFS)) <mask> betaClientFS := http.FileServer(http.FS(conf.clientBetaFS)) <mask> <mask> // if not configured, redirect / to /install.html, otherwise redirect /install.html to / </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove // CreateWeb - create module func CreateWeb(conf *webConfig) *Web { log.Info("Initialize web module") </s> add // newWeb creates a new instance of the web UI and API server. func newWeb(conf *webConfig) (w *Web) { log.Info("web: initializing") </s> remove // httpServerBeta is a server for new client. httpServerBeta *http.Server </s> add // httpsServer is the server that handles HTTPS traffic. If it is not nil, // [Web.http3Server] must also not be nil. httpsServer httpsServer forceHTTPS bool </s> remove // Web - module object </s> add // Web is the web UI and API server. </s> remove for !web.httpsServer.shutdown { </s> add for !web.httpsServer.inShutdown { </s> remove conf *webConfig forceHTTPS bool httpServer *http.Server // HTTP module httpsServer HTTPSServer // HTTPS module </s> add conf *webConfig // TODO(a.garipov): Refactor all these servers. httpServer *http.Server // httpServerBeta is a server for new client. httpServerBeta *http.Server
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
return w
<mask> registerControlHandlers() <mask> } <mask> <mask> w.httpsServer.cond = sync.NewCond(&w.httpsServer.condLock) <mask> return &w <mask> } <mask> <mask> // WebCheckPortAvailable - check if port is available <mask> // BUT: if we are already using this port, no need <mask> func WebCheckPortAvailable(port int) bool { </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove // WebCheckPortAvailable - check if port is available // BUT: if we are already using this port, no need func WebCheckPortAvailable(port int) bool { </s> add // webCheckPortAvailable checks if port, which is considered an HTTPS port, is // available, unless the HTTPS server isn't active. // // TODO(a.garipov): Adapt for HTTP/3. func webCheckPortAvailable(port int) (ok bool) { </s> remove if web.httpsServer.shutdown { </s> add if web.httpsServer.inShutdown { </s> remove if web.httpsServer.shutdown { </s> add if web.httpsServer.inShutdown { </s> remove for !web.httpsServer.shutdown { </s> add for !web.httpsServer.inShutdown { </s> remove if !WebCheckPortAvailable(data.PortHTTPS) { </s> add if !webCheckPortAvailable(data.PortHTTPS) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
// webCheckPortAvailable checks if port, which is considered an HTTPS port, is // available, unless the HTTPS server isn't active. // // TODO(a.garipov): Adapt for HTTP/3. func webCheckPortAvailable(port int) (ok bool) {
<mask> w.httpsServer.cond = sync.NewCond(&w.httpsServer.condLock) <mask> return &w <mask> } <mask> <mask> // WebCheckPortAvailable - check if port is available <mask> // BUT: if we are already using this port, no need <mask> func WebCheckPortAvailable(port int) bool { <mask> return Context.web.httpsServer.server != nil || <mask> aghnet.CheckPort("tcp", config.BindHost, port) == nil <mask> } <mask> <mask> // TLSConfigChanged updates the TLS configuration and restarts the HTTPS server </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove return &w </s> add return w </s> remove log.Debug("Web: applying new TLS configuration") </s> add log.Debug("web: applying new tls configuration") </s> remove if err != nil { const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } </s> add if err == nil { return } const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } } // shutdownSrv3 shuts srv down and prints error messages to the log. // // TODO(a.garipov): Think of a good way to merge with [shutdownSrv]. func shutdownSrv3(srv *http3.Server) { defer log.OnPanic("") if srv == nil { return } err := srv.Close() if err == nil { return } const msgFmt = "shutting down http/3 server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
log.Debug("web: applying new tls configuration")
<mask> <mask> // TLSConfigChanged updates the TLS configuration and restarts the HTTPS server <mask> // if necessary. <mask> func (web *Web) TLSConfigChanged(ctx context.Context, tlsConf tlsConfigSettings) { <mask> log.Debug("Web: applying new TLS configuration") <mask> web.conf.PortHTTPS = tlsConf.PortHTTPS <mask> web.forceHTTPS = (tlsConf.ForceHTTPS && tlsConf.Enabled && tlsConf.PortHTTPS != 0) <mask> <mask> enabled := tlsConf.Enabled && <mask> tlsConf.PortHTTPS != 0 && </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove // WebCheckPortAvailable - check if port is available // BUT: if we are already using this port, no need func WebCheckPortAvailable(port int) bool { </s> add // webCheckPortAvailable checks if port, which is considered an HTTPS port, is // available, unless the HTTPS server isn't active. // // TODO(a.garipov): Adapt for HTTP/3. func webCheckPortAvailable(port int) (ok bool) { </s> remove // CreateWeb - create module func CreateWeb(conf *webConfig) *Web { log.Info("Initialize web module") </s> add // newWeb creates a new instance of the web UI and API server. func newWeb(conf *webConfig) (w *Web) { log.Info("web: initializing") </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond condLock sync.Mutex shutdown bool // if TRUE, don't restart the server enabled bool cert tls.Certificate </s> add // httpsServer contains the data for the HTTPS server. type httpsServer struct { // server is the pre-HTTP/3 HTTPS server. server *http.Server // server3 is the HTTP/3 HTTPS server. If it is not nil, // [httpsServer.server] must also be non-nil. server3 *http3.Server // TODO(a.garipov): Why is there a *sync.Cond here? Remove. cond *sync.Cond condLock sync.Mutex cert tls.Certificate inShutdown bool enabled bool
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
shutdownSrv3(web.httpsServer.server3)
<mask> var cancel context.CancelFunc <mask> ctx, cancel = context.WithTimeout(ctx, shutdownTimeout) <mask> shutdownSrv(ctx, web.httpsServer.server) <mask> cancel() <mask> } <mask> <mask> web.httpsServer.enabled = enabled <mask> web.httpsServer.cert = cert </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove web.httpsServer.shutdown = true </s> add web.httpsServer.inShutdown = true </s> remove // Web - module object </s> add // Web is the web UI and API server. </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond condLock sync.Mutex shutdown bool // if TRUE, don't restart the server enabled bool cert tls.Certificate </s> add // httpsServer contains the data for the HTTPS server. type httpsServer struct { // server is the pre-HTTP/3 HTTPS server. server *http.Server // server3 is the HTTP/3 HTTPS server. If it is not nil, // [httpsServer.server] must also be non-nil. server3 *http3.Server // TODO(a.garipov): Why is there a *sync.Cond here? Remove. cond *sync.Cond condLock sync.Mutex cert tls.Certificate inShutdown bool enabled bool </s> remove var protocols = []string{"udp://", "tcp://", "tls://", "https://", "sdns://", "quic://"} </s> add var protocols = []string{ "h3://", "https://", "quic://", "sdns://", "tcp://", "tls://", "udp://", }
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
for !web.httpsServer.inShutdown {
<mask> // for https, we have a separate goroutine loop <mask> go web.tlsServerLoop() <mask> <mask> // this loop is used as an ability to change listening host and/or port <mask> for !web.httpsServer.shutdown { <mask> printHTTPAddresses(aghhttp.SchemeHTTP) <mask> errs := make(chan error, 2) <mask> <mask> // Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies. <mask> hdlr := h2c.NewHandler(withMiddlewares(Context.mux, limitRequestBody), &http2.Server{}) </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove j := s.accessListJSON() w.Header().Set("Content-Type", "application/json") err := json.NewEncoder(w).Encode(j) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "encoding response: %s", err) return } </s> add _ = aghhttp.WriteJSONResponse(w, r, s.accessListJSON()) </s> remove // LocalPTRResolvers is a slice of addresses to be used as upstreams for // resolving PTR queries for local addresses. LocalPTRResolvers []string </s> add // ServeHTTP3 defines if HTTP/3 is be allowed for incoming requests. ServeHTTP3 bool // UseHTTP3Upstreams defines if HTTP/3 is be allowed for DNS-over-HTTPS // upstreams. UseHTTP3Upstreams bool </s> remove // WebCheckPortAvailable - check if port is available // BUT: if we are already using this port, no need func WebCheckPortAvailable(port int) bool { </s> add // webCheckPortAvailable checks if port, which is considered an HTTPS port, is // available, unless the HTTPS server isn't active. // // TODO(a.garipov): Adapt for HTTP/3. func webCheckPortAvailable(port int) (ok bool) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
web.httpsServer.inShutdown = true
<mask> func (web *Web) Close(ctx context.Context) { <mask> log.Info("stopping http server...") <mask> <mask> web.httpsServer.cond.L.Lock() <mask> web.httpsServer.shutdown = true <mask> web.httpsServer.cond.L.Unlock() <mask> <mask> var cancel context.CancelFunc <mask> ctx, cancel = context.WithTimeout(ctx, shutdownTimeout) <mask> defer cancel() </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove if web.httpsServer.shutdown { </s> add if web.httpsServer.inShutdown { </s> remove if web.httpsServer.shutdown { </s> add if web.httpsServer.inShutdown { </s> remove log.Debug("Web: applying new TLS configuration") </s> add log.Debug("web: applying new tls configuration")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
shutdownSrv3(web.httpsServer.server3)
<mask> defer cancel() <mask> <mask> shutdownSrv(ctx, web.httpsServer.server) <mask> shutdownSrv(ctx, web.httpServer) <mask> shutdownSrv(ctx, web.httpServerBeta) <mask> <mask> log.Info("stopped http server") <mask> } <mask> </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove web.httpsServer.shutdown = true </s> add web.httpsServer.inShutdown = true </s> remove if err != nil { const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } </s> add if err == nil { return } const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } } // shutdownSrv3 shuts srv down and prints error messages to the log. // // TODO(a.garipov): Think of a good way to merge with [shutdownSrv]. func shutdownSrv3(srv *http3.Server) { defer log.OnPanic("") if srv == nil { return } err := srv.Close() if err == nil { return } const msgFmt = "shutting down http/3 server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err)
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
if web.httpsServer.inShutdown {
<mask> <mask> func (web *Web) tlsServerLoop() { <mask> for { <mask> web.httpsServer.cond.L.Lock() <mask> if web.httpsServer.shutdown { <mask> web.httpsServer.cond.L.Unlock() <mask> break <mask> } <mask> <mask> // this mechanism doesn't let us through until all conditions are met </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove if web.httpsServer.shutdown { </s> add if web.httpsServer.inShutdown { </s> remove web.httpsServer.shutdown = true </s> add web.httpsServer.inShutdown = true </s> remove return &w </s> add return w </s> remove // WebCheckPortAvailable - check if port is available // BUT: if we are already using this port, no need func WebCheckPortAvailable(port int) bool { </s> add // webCheckPortAvailable checks if port, which is considered an HTTPS port, is // available, unless the HTTPS server isn't active. // // TODO(a.garipov): Adapt for HTTP/3. func webCheckPortAvailable(port int) (ok bool) { </s> remove // CreateWeb - create module func CreateWeb(conf *webConfig) *Web { log.Info("Initialize web module") </s> add // newWeb creates a new instance of the web UI and API server. func newWeb(conf *webConfig) (w *Web) { log.Info("web: initializing")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
if web.httpsServer.inShutdown {
<mask> <mask> // this mechanism doesn't let us through until all conditions are met <mask> for !web.httpsServer.enabled { // sleep until necessary data is supplied <mask> web.httpsServer.cond.Wait() <mask> if web.httpsServer.shutdown { <mask> web.httpsServer.cond.L.Unlock() <mask> return <mask> } <mask> } <mask> </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove if web.httpsServer.shutdown { </s> add if web.httpsServer.inShutdown { </s> remove return &w </s> add return w </s> remove // WebCheckPortAvailable - check if port is available // BUT: if we are already using this port, no need func WebCheckPortAvailable(port int) bool { </s> add // webCheckPortAvailable checks if port, which is considered an HTTPS port, is // available, unless the HTTPS server isn't active. // // TODO(a.garipov): Adapt for HTTP/3. func webCheckPortAvailable(port int) (ok bool) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
addr := netutil.JoinHostPort(web.conf.BindHost.String(), web.conf.PortHTTPS)
<mask> } <mask> <mask> web.httpsServer.cond.L.Unlock() <mask> <mask> // prepare HTTPS server <mask> address := netutil.JoinHostPort(web.conf.BindHost.String(), web.conf.PortHTTPS) <mask> web.httpsServer.server = &http.Server{ <mask> ErrorLog: log.StdLog("web: https", log.DEBUG), <mask> Addr: address, <mask> TLSConfig: &tls.Config{ <mask> Certificates: []tls.Certificate{web.httpsServer.cert}, </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove Addr: address, </s> add Addr: addr, </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond condLock sync.Mutex shutdown bool // if TRUE, don't restart the server enabled bool cert tls.Certificate </s> add // httpsServer contains the data for the HTTPS server. type httpsServer struct { // server is the pre-HTTP/3 HTTPS server. server *http.Server // server3 is the HTTP/3 HTTPS server. If it is not nil, // [httpsServer.server] must also be non-nil. server3 *http3.Server // TODO(a.garipov): Why is there a *sync.Cond here? Remove. cond *sync.Cond condLock sync.Mutex cert tls.Certificate inShutdown bool enabled bool </s> remove // WebCheckPortAvailable - check if port is available // BUT: if we are already using this port, no need func WebCheckPortAvailable(port int) bool { </s> add // webCheckPortAvailable checks if port, which is considered an HTTPS port, is // available, unless the HTTPS server isn't active. // // TODO(a.garipov): Adapt for HTTP/3. func webCheckPortAvailable(port int) (ok bool) { </s> remove if web.httpsServer.shutdown { </s> add if web.httpsServer.inShutdown {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
Addr: addr,
<mask> // prepare HTTPS server <mask> address := netutil.JoinHostPort(web.conf.BindHost.String(), web.conf.PortHTTPS) <mask> web.httpsServer.server = &http.Server{ <mask> ErrorLog: log.StdLog("web: https", log.DEBUG), <mask> Addr: address, <mask> TLSConfig: &tls.Config{ <mask> Certificates: []tls.Certificate{web.httpsServer.cert}, <mask> RootCAs: Context.tlsRoots, <mask> CipherSuites: aghtls.SaferCipherSuites(), <mask> MinVersion: tls.VersionTLS12, </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove // prepare HTTPS server address := netutil.JoinHostPort(web.conf.BindHost.String(), web.conf.PortHTTPS) </s> add addr := netutil.JoinHostPort(web.conf.BindHost.String(), web.conf.PortHTTPS) </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond condLock sync.Mutex shutdown bool // if TRUE, don't restart the server enabled bool cert tls.Certificate </s> add // httpsServer contains the data for the HTTPS server. type httpsServer struct { // server is the pre-HTTP/3 HTTPS server. server *http.Server // server3 is the HTTP/3 HTTPS server. If it is not nil, // [httpsServer.server] must also be non-nil. server3 *http3.Server // TODO(a.garipov): Why is there a *sync.Cond here? Remove. cond *sync.Cond condLock sync.Mutex cert tls.Certificate inShutdown bool enabled bool </s> remove // WebCheckPortAvailable - check if port is available // BUT: if we are already using this port, no need func WebCheckPortAvailable(port int) bool { </s> add // webCheckPortAvailable checks if port, which is considered an HTTPS port, is // available, unless the HTTPS server isn't active. // // TODO(a.garipov): Adapt for HTTP/3. func webCheckPortAvailable(port int) (ok bool) { </s> remove log.Debug("Web: applying new TLS configuration") </s> add log.Debug("web: applying new tls configuration")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
if web.conf.serveHTTP3 { go web.mustStartHTTP3(addr) } log.Debug("web: starting https server")
<mask> WriteTimeout: web.conf.WriteTimeout, <mask> } <mask> <mask> printHTTPAddresses(aghhttp.SchemeHTTPS) <mask> err := web.httpsServer.server.ListenAndServeTLS("", "") <mask> if !errors.Is(err, http.ErrServerClosed) { <mask> cleanupAlways() <mask> log.Fatalf("web: https: %s", err) <mask> } <mask> } </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove log.Fatal(err) </s> add log.Fatalf("web: https: %s", err) </s> remove if err != http.ErrServerClosed { </s> add if !errors.Is(err, http.ErrServerClosed) { </s> remove pj.Name = u.Name data, err := json.Marshal(pj) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Marshal: %s", err) return </s> add resp := &profileJSON{ Name: u.Name, </s> remove jsonVal, err := json.Marshal(result) if err != nil { aghhttp.Error( r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err, ) return } w.Header().Set("Content-Type", "application/json") _, err = w.Write(jsonVal) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't write body: %s", err) } </s> add _ = aghhttp.WriteJSONResponse(w, r, result) </s> remove aghhttp.Error( r, w, http.StatusBadRequest, "Failed to encode 'check_config' JSON data: %s", err, ) </s> add aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
if !errors.Is(err, http.ErrServerClosed) {
<mask> } <mask> <mask> printHTTPAddresses(aghhttp.SchemeHTTPS) <mask> err := web.httpsServer.server.ListenAndServeTLS("", "") <mask> if err != http.ErrServerClosed { <mask> cleanupAlways() <mask> log.Fatal(err) <mask> } <mask> } <mask> } </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove log.Fatal(err) </s> add log.Fatalf("web: https: %s", err) </s> remove jsonVal, err := json.Marshal(result) if err != nil { aghhttp.Error( r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err, ) return } w.Header().Set("Content-Type", "application/json") _, err = w.Write(jsonVal) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't write body: %s", err) } </s> add _ = aghhttp.WriteJSONResponse(w, r, result) </s> remove pj.Name = u.Name data, err := json.Marshal(pj) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Marshal: %s", err) return </s> add resp := &profileJSON{ Name: u.Name, </s> remove if err != nil { const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } </s> add if err == nil { return } const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } } // shutdownSrv3 shuts srv down and prints error messages to the log. // // TODO(a.garipov): Think of a good way to merge with [shutdownSrv]. func shutdownSrv3(srv *http3.Server) { defer log.OnPanic("") if srv == nil { return } err := srv.Close() if err == nil { return } const msgFmt = "shutting down http/3 server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
log.Fatalf("web: https: %s", err)
<mask> printHTTPAddresses(aghhttp.SchemeHTTPS) <mask> err := web.httpsServer.server.ListenAndServeTLS("", "") <mask> if err != http.ErrServerClosed { <mask> cleanupAlways() <mask> log.Fatal(err) <mask> } <mask> } <mask> } </s> Pull request: 3955-doh3 Updates #3955. Squashed commit of the following: commit acfd5ccc29ff03dfae1e51e52649acdf05042d9f Merge: caeac6e5 61bd217e Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 18:00:37 2022 +0300 Merge branch 'master' into 3955-doh3 commit caeac6e5401bcaa95bba8d2b84a943b6c9a5898a Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:54:16 2022 +0300 all: fix server closing; imp docs commit 87396141ff49d48ae54b4184559070e7885bccc7 Author: Ainar Garipov <[email protected]> Date: Mon Oct 3 17:33:39 2022 +0300 all: add doh3 support </s> remove if err != http.ErrServerClosed { </s> add if !errors.Is(err, http.ErrServerClosed) { </s> remove jsonVal, err := json.Marshal(result) if err != nil { aghhttp.Error( r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err, ) return } w.Header().Set("Content-Type", "application/json") _, err = w.Write(jsonVal) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't write body: %s", err) } </s> add _ = aghhttp.WriteJSONResponse(w, r, result) </s> remove pj.Name = u.Name data, err := json.Marshal(pj) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json.Marshal: %s", err) return </s> add resp := &profileJSON{ Name: u.Name, </s> remove if err != nil { const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } </s> add if err == nil { return } const msgFmt = "shutting down http server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err) } } // shutdownSrv3 shuts srv down and prints error messages to the log. // // TODO(a.garipov): Think of a good way to merge with [shutdownSrv]. func shutdownSrv3(srv *http3.Server) { defer log.OnPanic("") if srv == nil { return } err := srv.Close() if err == nil { return } const msgFmt = "shutting down http/3 server %q: %s" if errors.Is(err, context.Canceled) { log.Debug(msgFmt, srv.Addr, err) } else { log.Error(msgFmt, srv.Addr, err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cce420261b1e207e558f884d6c73cbec9d55f60
internal/home/web.go
delete(clients.list, old.Name)
<mask> // update Name index <mask> if old.Name != c.Name { <mask> clients.list[c.Name] = old <mask> } <mask> <mask> // update upstreams cache <mask> if old.Name != c.Name { </s> Merge: - clients: fix rename Close #1340 Squashed commit of the following: commit 95f0291c681f98c29f4014b651c159d387301af4 Author: Simon Zolin <[email protected]> Date: Thu Jan 9 18:56:23 2020 +0300 add test commit 293be277e245ff2f430e8c1e9ee3e82dc7da0995 Author: Simon Zolin <[email protected]> Date: Thu Jan 9 16:04:36 2020 +0300 - clients: fix rename </s> remove delete(clients.upstreamsCache, name) delete(clients.upstreamsCache, old.Name) </s> add if old.Name != c.Name { delete(clients.upstreamsCache, old.Name) } else { delete(clients.upstreamsCache, c.Name) }
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cd25cf598096505f9b77c4d0a64bd1bbf08d6fe
home/clients.go
if old.Name != c.Name { delete(clients.upstreamsCache, old.Name) } else { delete(clients.upstreamsCache, c.Name) }
<mask> clients.list[c.Name] = old <mask> } <mask> <mask> // update upstreams cache <mask> delete(clients.upstreamsCache, name) <mask> delete(clients.upstreamsCache, old.Name) <mask> <mask> *old = c <mask> return nil <mask> } <mask> </s> Merge: - clients: fix rename Close #1340 Squashed commit of the following: commit 95f0291c681f98c29f4014b651c159d387301af4 Author: Simon Zolin <[email protected]> Date: Thu Jan 9 18:56:23 2020 +0300 add test commit 293be277e245ff2f430e8c1e9ee3e82dc7da0995 Author: Simon Zolin <[email protected]> Date: Thu Jan 9 16:04:36 2020 +0300 - clients: fix rename
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cd25cf598096505f9b77c4d0a64bd1bbf08d6fe
home/clients.go
assert.True(t, clients.list["client1"] == nil)
<mask> c = Client{} <mask> c, b = clients.Find("1.1.1.2") <mask> assert.True(t, b && c.Name == "client1-renamed" && c.IDs[0] == "1.1.1.2" && c.UseOwnSettings) <mask> <mask> // failed remove - no such name <mask> if clients.Del("client3") { <mask> t.Fatalf("Del - no such name") <mask> } <mask> </s> Merge: - clients: fix rename Close #1340 Squashed commit of the following: commit 95f0291c681f98c29f4014b651c159d387301af4 Author: Simon Zolin <[email protected]> Date: Thu Jan 9 18:56:23 2020 +0300 add test commit 293be277e245ff2f430e8c1e9ee3e82dc7da0995 Author: Simon Zolin <[email protected]> Date: Thu Jan 9 16:04:36 2020 +0300 - clients: fix rename </s> remove delete(clients.upstreamsCache, name) delete(clients.upstreamsCache, old.Name) </s> add if old.Name != c.Name { delete(clients.upstreamsCache, old.Name) } else { delete(clients.upstreamsCache, c.Name) }
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cd25cf598096505f9b77c4d0a64bd1bbf08d6fe
home/clients_test.go
s.queryLog.Add(msg, d.Res, res, elapsed, getIP(d.Addr), upstreamAddr)
<mask> upstreamAddr := "" <mask> if d.Upstream != nil { <mask> upstreamAddr = d.Upstream.Address() <mask> } <mask> s.queryLog.Add(msg, d.Res, res, elapsed, d.Addr, upstreamAddr) <mask> } <mask> <mask> s.updateStats(d, elapsed, *res) <mask> s.RUnlock() <mask> </s> * QueryLog.Add() now receives net.IP, not net.Addr </s> remove IP: ip, </s> add IP: ip.String(), </s> remove ip := getIPString(addr) </s> add </s> remove // getIPString is a helper function that extracts IP address from net.Addr func getIPString(addr net.Addr) string { switch addr := addr.(type) { case *net.UDPAddr: return addr.IP.String() case *net.TCPAddr: return addr.IP.String() } return "" } func (l *queryLog) Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, addr net.Addr, upstream string) { </s> add func (l *queryLog) Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, ip net.IP, upstream string) { </s> remove Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, addr net.Addr, upstream string) </s> add Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, ip net.IP, upstream string)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cd6781a9a94bbb0cf1d0bd310fc50d665da4674
dnsforward/dnsforward.go
// Get IP address from net.Addr func getIP(addr net.Addr) net.IP { switch addr := addr.(type) { case *net.UDPAddr: return addr.IP case *net.TCPAddr: return addr.IP } return nil }
<mask> } <mask> <mask> func (s *Server) updateStats(d *proxy.DNSContext, elapsed time.Duration, res dnsfilter.Result) { <mask> if s.stats == nil { <mask> return <mask> } <mask> <mask> e := stats.Entry{} </s> * QueryLog.Add() now receives net.IP, not net.Addr </s> remove // getIPString is a helper function that extracts IP address from net.Addr func getIPString(addr net.Addr) string { switch addr := addr.(type) { case *net.UDPAddr: return addr.IP.String() case *net.TCPAddr: return addr.IP.String() } return "" } func (l *queryLog) Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, addr net.Addr, upstream string) { </s> add func (l *queryLog) Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, ip net.IP, upstream string) { </s> remove ip := getIPString(addr) </s> add </s> remove s.queryLog.Add(msg, d.Res, res, elapsed, d.Addr, upstreamAddr) </s> add s.queryLog.Add(msg, d.Res, res, elapsed, getIP(d.Addr), upstreamAddr) </s> remove IP: ip, </s> add IP: ip.String(), </s> remove Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, addr net.Addr, upstream string) </s> add Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, ip net.IP, upstream string)
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cd6781a9a94bbb0cf1d0bd310fc50d665da4674
dnsforward/dnsforward.go
func (l *queryLog) Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, ip net.IP, upstream string) {
<mask> Elapsed time.Duration <mask> Upstream string `json:",omitempty"` // if empty, means it was cached <mask> } <mask> <mask> // getIPString is a helper function that extracts IP address from net.Addr <mask> func getIPString(addr net.Addr) string { <mask> switch addr := addr.(type) { <mask> case *net.UDPAddr: <mask> return addr.IP.String() <mask> case *net.TCPAddr: <mask> return addr.IP.String() <mask> } <mask> return "" <mask> } <mask> <mask> func (l *queryLog) Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, addr net.Addr, upstream string) { <mask> if !l.conf.Enabled { <mask> return <mask> } <mask> <mask> if question == nil || len(question.Question) != 1 || len(question.Question[0].Name) == 0 || </s> * QueryLog.Add() now receives net.IP, not net.Addr </s> remove Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, addr net.Addr, upstream string) </s> add Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, ip net.IP, upstream string) </s> remove s.queryLog.Add(msg, d.Res, res, elapsed, d.Addr, upstreamAddr) </s> add s.queryLog.Add(msg, d.Res, res, elapsed, getIP(d.Addr), upstreamAddr) </s> remove ip := getIPString(addr) </s> add </s> remove IP: ip, </s> add IP: ip.String(),
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cd6781a9a94bbb0cf1d0bd310fc50d665da4674
querylog/qlog.go
<mask> } <mask> <mask> var a []byte <mask> var err error <mask> ip := getIPString(addr) <mask> <mask> if answer != nil { <mask> a, err = answer.Pack() <mask> if err != nil { <mask> log.Printf("failed to pack answer for querylog: %s", err) </s> * QueryLog.Add() now receives net.IP, not net.Addr </s> remove s.queryLog.Add(msg, d.Res, res, elapsed, d.Addr, upstreamAddr) </s> add s.queryLog.Add(msg, d.Res, res, elapsed, getIP(d.Addr), upstreamAddr) </s> remove // getIPString is a helper function that extracts IP address from net.Addr func getIPString(addr net.Addr) string { switch addr := addr.(type) { case *net.UDPAddr: return addr.IP.String() case *net.TCPAddr: return addr.IP.String() } return "" } func (l *queryLog) Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, addr net.Addr, upstream string) { </s> add func (l *queryLog) Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, ip net.IP, upstream string) { </s> remove IP: ip, </s> add IP: ip.String(), </s> remove Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, addr net.Addr, upstream string) </s> add Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, ip net.IP, upstream string)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cd6781a9a94bbb0cf1d0bd310fc50d665da4674
querylog/qlog.go
IP: ip.String(),
<mask> } <mask> <mask> now := time.Now() <mask> entry := logEntry{ <mask> IP: ip, <mask> Time: now, <mask> <mask> Answer: a, <mask> Result: *result, <mask> Elapsed: elapsed, </s> * QueryLog.Add() now receives net.IP, not net.Addr </s> remove s.queryLog.Add(msg, d.Res, res, elapsed, d.Addr, upstreamAddr) </s> add s.queryLog.Add(msg, d.Res, res, elapsed, getIP(d.Addr), upstreamAddr) </s> remove ip := getIPString(addr) </s> add </s> remove Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, addr net.Addr, upstream string) </s> add Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, ip net.IP, upstream string) </s> remove // getIPString is a helper function that extracts IP address from net.Addr func getIPString(addr net.Addr) string { switch addr := addr.(type) { case *net.UDPAddr: return addr.IP.String() case *net.TCPAddr: return addr.IP.String() } return "" } func (l *queryLog) Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, addr net.Addr, upstream string) { </s> add func (l *queryLog) Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, ip net.IP, upstream string) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cd6781a9a94bbb0cf1d0bd310fc50d665da4674
querylog/qlog.go
Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, ip net.IP, upstream string)
<mask> // Close query log object <mask> Close() <mask> <mask> // Add a log entry <mask> Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, addr net.Addr, upstream string) <mask> <mask> // WriteDiskConfig - write configuration <mask> WriteDiskConfig(dc *DiskConfig) <mask> } <mask> </s> * QueryLog.Add() now receives net.IP, not net.Addr </s> remove // getIPString is a helper function that extracts IP address from net.Addr func getIPString(addr net.Addr) string { switch addr := addr.(type) { case *net.UDPAddr: return addr.IP.String() case *net.TCPAddr: return addr.IP.String() } return "" } func (l *queryLog) Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, addr net.Addr, upstream string) { </s> add func (l *queryLog) Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, elapsed time.Duration, ip net.IP, upstream string) { </s> remove IP: ip, </s> add IP: ip.String(), </s> remove s.queryLog.Add(msg, d.Res, res, elapsed, d.Addr, upstreamAddr) </s> add s.queryLog.Add(msg, d.Res, res, elapsed, getIP(d.Addr), upstreamAddr) </s> remove ip := getIPString(addr) </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0cd6781a9a94bbb0cf1d0bd310fc50d665da4674
querylog/querylog.go
"context"
<mask> // Package dnsfilter implements a DNS request and response filter. <mask> package dnsfilter <mask> <mask> import ( <mask> "fmt" <mask> "io/ioutil" <mask> "net" <mask> "net/http" </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove func TestCheckHostSafeSearchGoogle(t *testing.T) { d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() // Slice of google domains googleDomains := []string{"www.google.com", "www.google.im", "www.google.co.in", "www.google.iq", "www.google.is", "www.google.it", "www.google.je"} </s> add // testResolver is a Resolver for tests. type testResolver struct{} // LookupIP implements Resolver interface for *testResolver. func (r *testResolver) LookupIPAddr(_ context.Context, host string) (ips []net.IPAddr, err error) { hash := sha256.Sum256([]byte(host)) addrs := []net.IPAddr{{ IP: net.IP(hash[:4]), Zone: "somezone", }, { IP: net.IP(hash[4:20]), Zone: "somezone", }} return addrs, nil }
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter.go
// Resolver is the interface for net.Resolver to simplify testing. type Resolver interface { // TODO(e.burkov): Replace with LookupIP after upgrading go to v1.15. LookupIPAddr(ctx context.Context, host string) (ips []net.IPAddr, err error) }
<mask> blockFilters []Filter <mask> } <mask> <mask> // DNSFilter matches hostnames and DNS requests against filtering rules. <mask> type DNSFilter struct { <mask> rulesStorage *filterlist.RuleStorage <mask> filteringEngine *urlfilter.DNSEngine <mask> rulesStorageAllow *filterlist.RuleStorage </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove var r Result filters := []Filter{{ ID: 0, Data: []byte("||example.org^\n"), </s> add d := newForTest( &Config{ ParentalEnabled: true, SafeBrowsingEnabled: false, }, []Filter{{ ID: 0, Data: []byte("||example.org^\n"), }}, ) t.Cleanup(d.Close) d.parentalUpstream = &testSbUpstream{ hostname: "pornhub.com", block: true, } d.safeBrowsingUpstream = &testSbUpstream{ hostname: "wmconvirus.narod.ru", block: true, } type testCase struct { name string host string before bool wantReason Reason } testCases := []testCase{{ name: "filters", host: "example.org", before: true, wantReason: FilteredBlockList, }, { name: "parental", host: "pornhub.com", before: true, wantReason: FilteredParental, }, { name: "safebrowsing", host: "wmconvirus.narod.ru", before: false, wantReason: FilteredSafeBrowsing, }, { name: "additional_rules", host: "facebook.com", before: false, wantReason: FilteredBlockedService, </s> remove // not blocked r, _ = d.CheckHost("facebook.com", dns.TypeA, &setts) assert.False(t, r.IsFiltered) // override client settings: </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter.go
// resolver only looks up the IP address of the host while safe search. // // TODO(e.burkov): Use upstream that configured in dnsforward instead. resolver Resolver
<mask> <mask> // Channel for passing data to filters-initializer goroutine <mask> filtersInitializerChan chan filtersInitializerParams <mask> filtersInitializerLock sync.Mutex <mask> } <mask> <mask> // Filter represents a filter list <mask> type Filter struct { <mask> ID int64 // auto-assigned when filter is added (see nextFilterID) </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove func TestCheckHostSafeSearchGoogle(t *testing.T) { d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() // Slice of google domains googleDomains := []string{"www.google.com", "www.google.im", "www.google.co.in", "www.google.iq", "www.google.is", "www.google.it", "www.google.je"} </s> add // testResolver is a Resolver for tests. type testResolver struct{} // LookupIP implements Resolver interface for *testResolver. func (r *testResolver) LookupIPAddr(_ context.Context, host string) (ips []net.IPAddr, err error) { hash := sha256.Sum256([]byte(host)) addrs := []net.IPAddr{{ IP: net.IP(hash[:4]), Zone: "somezone", }, { IP: net.IP(hash[4:20]), Zone: "somezone", }} return addrs, nil } </s> remove // not matched by white filter, but matched by block filter </s> add // Not matched by white filter, but matched by block filter. </s> remove // matched by white filter </s> add // Matched by white filter.
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter.go
d := &DNSFilter{ resolver: net.DefaultResolver, }
<mask> gctx.parentalCache = cache.New(cacheConf) <mask> } <mask> } <mask> <mask> d := new(DNSFilter) <mask> <mask> err := d.initSecurityServices() <mask> if err != nil { <mask> log.Error("dnsfilter: initialize services: %s", err) <mask> return nil </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove if gctx.safebrowsingCache != nil { gctx.safebrowsingCache.Clear() } if gctx.parentalCache != nil { gctx.parentalCache.Clear() } if gctx.safeSearchCache != nil { gctx.safeSearchCache.Clear() </s> add for _, c := range []cache.Cache{ gctx.safebrowsingCache, gctx.parentalCache, gctx.safeSearchCache, } { if c != nil { c.Clear() } </s> remove ip := ips[0] for _, i := range ips { if i.To4() != nil { ip = i </s> add ip := ipAddrs[0].IP for _, ipAddr := range ipAddrs { if ipAddr.IP.To4() != nil { ip = ipAddr.IP </s> remove // TODO this address should be resolved with upstream that was configured in dnsforward ips, err := net.LookupIP(safeHost) </s> add ipAddrs, err := d.resolver.LookupIPAddr(context.Background(), safeHost) </s> remove for _, ip := range ips { if ipv4 := ip.To4(); ipv4 != nil { </s> add for _, ipAddr := range ipAddrs { if ipv4 := ipAddr.IP.To4(); ipv4 != nil { </s> remove ips, err := net.LookupIP(safeDomain) </s> add ipAddrs, err := resolver.LookupIPAddr(context.Background(), safeDomain)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter.go
"context" "crypto/sha256"
<mask> package dnsfilter <mask> <mask> import ( <mask> "bytes" <mask> "fmt" <mask> "net" <mask> "testing" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/testutil" </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // FILTERING const nl = "\n" const ( blockingRules = `||example.org^` + nl allowlistRules = `||example.org^` + nl + `@@||test.example.org` + nl importantRules = `@@||example.org^` + nl + `||test.example.org^$important` + nl regexRules = `/example\.org/` + nl + `@@||test.example.org^` + nl maskRules = `test*.example.org^` + nl + `exam*.com` + nl dnstypeRules = `||example.org^$dnstype=AAAA` + nl + `@@||test.example.org^` + nl ) var tests = []struct { testname string rules string hostname string isFiltered bool reason Reason dnsType uint16 }{ {"sanity", "||doubleclick.net^", "www.doubleclick.net", true, FilteredBlockList, dns.TypeA}, {"sanity", "||doubleclick.net^", "nodoubleclick.net", false, NotFilteredNotFound, dns.TypeA}, {"sanity", "||doubleclick.net^", "doubleclick.net.ru", false, NotFilteredNotFound, dns.TypeA}, {"sanity", "||doubleclick.net^", "wmconvirus.narod.ru", false, NotFilteredNotFound, dns.TypeA}, {"blocking", blockingRules, "example.org", true, FilteredBlockList, dns.TypeA}, {"blocking", blockingRules, "test.example.org", true, FilteredBlockList, dns.TypeA}, {"blocking", blockingRules, "test.test.example.org", true, FilteredBlockList, dns.TypeA}, {"blocking", blockingRules, "testexample.org", false, NotFilteredNotFound, dns.TypeA}, {"blocking", blockingRules, "onemoreexample.org", false, NotFilteredNotFound, dns.TypeA}, {"allowlist", allowlistRules, "example.org", true, FilteredBlockList, dns.TypeA}, {"allowlist", allowlistRules, "test.example.org", false, NotFilteredAllowList, dns.TypeA}, {"allowlist", allowlistRules, "test.test.example.org", false, NotFilteredAllowList, dns.TypeA}, {"allowlist", allowlistRules, "testexample.org", false, NotFilteredNotFound, dns.TypeA}, {"allowlist", allowlistRules, "onemoreexample.org", false, NotFilteredNotFound, dns.TypeA}, {"important", importantRules, "example.org", false, NotFilteredAllowList, dns.TypeA}, {"important", importantRules, "test.example.org", true, FilteredBlockList, dns.TypeA}, {"important", importantRules, "test.test.example.org", true, FilteredBlockList, dns.TypeA}, {"important", importantRules, "testexample.org", false, NotFilteredNotFound, dns.TypeA}, {"important", importantRules, "onemoreexample.org", false, NotFilteredNotFound, dns.TypeA}, {"regex", regexRules, "example.org", true, FilteredBlockList, dns.TypeA}, {"regex", regexRules, "test.example.org", false, NotFilteredAllowList, dns.TypeA}, {"regex", regexRules, "test.test.example.org", false, NotFilteredAllowList, dns.TypeA}, {"regex", regexRules, "testexample.org", true, FilteredBlockList, dns.TypeA}, {"regex", regexRules, "onemoreexample.org", true, FilteredBlockList, dns.TypeA}, {"mask", maskRules, "test.example.org", true, FilteredBlockList, dns.TypeA}, {"mask", maskRules, "test2.example.org", true, FilteredBlockList, dns.TypeA}, {"mask", maskRules, "example.com", true, FilteredBlockList, dns.TypeA}, {"mask", maskRules, "exampleeee.com", true, FilteredBlockList, dns.TypeA}, {"mask", maskRules, "onemoreexamsite.com", true, FilteredBlockList, dns.TypeA}, {"mask", maskRules, "example.org", false, NotFilteredNotFound, dns.TypeA}, {"mask", maskRules, "testexample.org", false, NotFilteredNotFound, dns.TypeA}, {"mask", maskRules, "example.co.uk", false, NotFilteredNotFound, dns.TypeA}, {"dnstype", dnstypeRules, "onemoreexample.org", false, NotFilteredNotFound, dns.TypeA}, {"dnstype", dnstypeRules, "example.org", false, NotFilteredNotFound, dns.TypeA}, {"dnstype", dnstypeRules, "example.org", true, FilteredBlockList, dns.TypeAAAA}, {"dnstype", dnstypeRules, "test.example.org", false, NotFilteredAllowList, dns.TypeA}, {"dnstype", dnstypeRules, "test.example.org", false, NotFilteredAllowList, dns.TypeAAAA}, } </s> add // Filtering.
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
"github.com/AdguardTeam/golibs/cache"
<mask> "testing" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/testutil" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/AdguardTeam/urlfilter/rules" <mask> "github.com/miekg/dns" <mask> "github.com/stretchr/testify/assert" </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove d := DNSFilter{} </s> add d := newForTest(nil, nil) t.Cleanup(d.Close) </s> remove for _, ip := range ips { if ipv4 := ip.To4(); ipv4 != nil { </s> add for _, ipAddr := range ipAddrs { if ipv4 := ipAddr.IP.To4(); ipv4 != nil { </s> remove d.checkMatch(t, "test.wmconvirus.narod.ru") </s> add d.checkMatch(t, "test."+matching)
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
// Helpers.
<mask> } <mask> <mask> var setts RequestFilteringSettings <mask> <mask> // HELPERS <mask> // SAFE BROWSING <mask> // SAFE SEARCH <mask> // PARENTAL <mask> // FILTERING <mask> // BENCHMARKS <mask> <mask> // HELPERS <mask> <mask> func purgeCaches() { <mask> if gctx.safebrowsingCache != nil { <mask> gctx.safebrowsingCache.Clear() <mask> } </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove if gctx.safebrowsingCache != nil { gctx.safebrowsingCache.Clear() } if gctx.parentalCache != nil { gctx.parentalCache.Clear() } if gctx.safeSearchCache != nil { gctx.safeSearchCache.Clear() </s> add for _, c := range []cache.Cache{ gctx.safebrowsingCache, gctx.parentalCache, gctx.safeSearchCache, } { if c != nil { c.Clear() } </s> remove // SAFE BROWSING </s> add // Safe Browsing. </s> remove // SAFE SEARCH </s> add // Safe Search. </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) </s> remove loopback6 := net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1} assert.Equal(t, res.Rules[0].IP, loopback6) </s> add assert.Equal(t, res.Rules[0].IP, net.IPv6loopback)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
for _, c := range []cache.Cache{ gctx.safebrowsingCache, gctx.parentalCache, gctx.safeSearchCache, } { if c != nil { c.Clear() }
<mask> <mask> // HELPERS <mask> <mask> func purgeCaches() { <mask> if gctx.safebrowsingCache != nil { <mask> gctx.safebrowsingCache.Clear() <mask> } <mask> if gctx.parentalCache != nil { <mask> gctx.parentalCache.Clear() <mask> } <mask> if gctx.safeSearchCache != nil { <mask> gctx.safeSearchCache.Clear() <mask> } <mask> } <mask> <mask> func NewForTest(c *Config, filters []Filter) *DNSFilter { <mask> setts = RequestFilteringSettings{} </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove func NewForTest(c *Config, filters []Filter) *DNSFilter { </s> add func newForTest(c *Config, filters []Filter) *DNSFilter { </s> remove // HELPERS // SAFE BROWSING // SAFE SEARCH // PARENTAL // FILTERING // BENCHMARKS // HELPERS </s> add // Helpers. </s> remove d := new(DNSFilter) </s> add d := &DNSFilter{ resolver: net.DefaultResolver, } </s> remove ip := ips[0] for _, i := range ips { if i.To4() != nil { ip = i </s> add ip := ipAddrs[0].IP for _, ipAddr := range ipAddrs { if ipAddr.IP.To4() != nil { ip = ipAddr.IP </s> remove // blocked by parental r, _ = d.CheckHost("pornhub.com", dns.TypeA, &setts) if !r.IsFiltered || r.Reason != FilteredParental { t.Fatalf("CheckHost FilteredParental") </s> add makeTester := func(tc testCase, before bool) func(t *testing.T) { return func(t *testing.T) { r, _ := d.CheckHost(tc.host, dns.TypeA, &setts) if before { assert.True(t, r.IsFiltered) assert.Equal(t, tc.wantReason, r.Reason) } else { assert.False(t, r.IsFiltered) } }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
func newForTest(c *Config, filters []Filter) *DNSFilter {
<mask> gctx.safeSearchCache.Clear() <mask> } <mask> } <mask> <mask> func NewForTest(c *Config, filters []Filter) *DNSFilter { <mask> setts = RequestFilteringSettings{} <mask> setts.FilteringEnabled = true <mask> if c != nil { <mask> c.SafeBrowsingCacheSize = 10000 <mask> c.ParentalCacheSize = 10000 </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove if gctx.safebrowsingCache != nil { gctx.safebrowsingCache.Clear() } if gctx.parentalCache != nil { gctx.parentalCache.Clear() } if gctx.safeSearchCache != nil { gctx.safeSearchCache.Clear() </s> add for _, c := range []cache.Cache{ gctx.safebrowsingCache, gctx.parentalCache, gctx.safeSearchCache, } { if c != nil { c.Clear() } </s> remove // CLIENT SETTINGS </s> add // Client Settings. </s> remove ip := ips[0] for _, i := range ips { if i.To4() != nil { ip = i </s> add ip := ipAddrs[0].IP for _, ipAddr := range ipAddrs { if ipAddr.IP.To4() != nil { ip = ipAddr.IP </s> remove d := NewForTest(&Config{ParentalEnabled: true, SafeBrowsingEnabled: false}, filters) defer d.Close() // no client settings: // blocked by filters r, _ = d.CheckHost("example.org", dns.TypeA, &setts) if !r.IsFiltered || r.Reason != FilteredBlockList { t.Fatalf("CheckHost FilteredBlockList") } </s> add </s> remove d := new(DNSFilter) </s> add d := &DNSFilter{ resolver: net.DefaultResolver, }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err) assert.Truef(t, res.IsFiltered, "Expected hostname %s to match", hostname)
<mask> <mask> func (d *DNSFilter) checkMatch(t *testing.T, hostname string) { <mask> t.Helper() <mask> res, err := d.CheckHost(hostname, dns.TypeA, &setts) <mask> if err != nil { <mask> t.Errorf("Error while matching host %s: %s", hostname, err) <mask> } <mask> if !res.IsFiltered { <mask> t.Errorf("Expected hostname %s to match", hostname) <mask> } <mask> } <mask> <mask> func (d *DNSFilter) checkMatchIP(t *testing.T, hostname, ip string, qtype uint16) { <mask> t.Helper() <mask> </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove if err != nil { t.Errorf("Error while matching host %s: %s", hostname, err) } if !res.IsFiltered { t.Errorf("Expected hostname %s to match", hostname) } if len(res.Rules) == 0 { t.Errorf("Expected result to have rules") return } r := res.Rules[0] if r.IP == nil || r.IP.String() != ip { t.Errorf("Expected ip %s to match, actual: %v", ip, r.IP) </s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err) assert.Truef(t, res.IsFiltered, "Expected hostname %s to match", hostname) if assert.NotEmpty(t, res.Rules, "Expected result to have rules") { r := res.Rules[0] assert.NotNilf(t, r.IP, "Expected ip %s to match, actual: %v", ip, r.IP) assert.Equalf(t, ip, r.IP.String(), "Expected ip %s to match, actual: %v", ip, r.IP) </s> remove if err != nil { t.Errorf("Error while matching host %s: %s", hostname, err) } if res.IsFiltered { t.Errorf("Expected hostname %s to not match", hostname) } </s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err) assert.Falsef(t, res.IsFiltered, "Expected hostname %s to not match", hostname) </s> remove hostname := "wmconvirus.narod.ru" res, err := d.CheckHost(hostname, dns.TypeA, &setts) if err != nil { b.Errorf("Error while matching host %s: %s", hostname, err) } if !res.IsFiltered { b.Errorf("Expected hostname %s to match", hostname) } </s> add res, err := d.CheckHost(blocked, dns.TypeA, &setts) assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err) assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) </s> remove hostname := "wmconvirus.narod.ru" res, err := d.CheckHost(hostname, dns.TypeA, &setts) if err != nil { b.Errorf("Error while matching host %s: %s", hostname, err) } if !res.IsFiltered { b.Errorf("Expected hostname %s to match", hostname) } </s> add res, err := d.CheckHost(blocked, dns.TypeA, &setts) assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err) assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil) defer d.Close() </s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil) b.Cleanup(d.Close) blocked := "wmconvirus.narod.ru" d.safeBrowsingUpstream = &testSbUpstream{ hostname: blocked, block: true, }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err) assert.Truef(t, res.IsFiltered, "Expected hostname %s to match", hostname) if assert.NotEmpty(t, res.Rules, "Expected result to have rules") { r := res.Rules[0] assert.NotNilf(t, r.IP, "Expected ip %s to match, actual: %v", ip, r.IP) assert.Equalf(t, ip, r.IP.String(), "Expected ip %s to match, actual: %v", ip, r.IP)
<mask> func (d *DNSFilter) checkMatchIP(t *testing.T, hostname, ip string, qtype uint16) { <mask> t.Helper() <mask> <mask> res, err := d.CheckHost(hostname, qtype, &setts) <mask> if err != nil { <mask> t.Errorf("Error while matching host %s: %s", hostname, err) <mask> } <mask> <mask> if !res.IsFiltered { <mask> t.Errorf("Expected hostname %s to match", hostname) <mask> } <mask> <mask> if len(res.Rules) == 0 { <mask> t.Errorf("Expected result to have rules") <mask> <mask> return <mask> } <mask> <mask> r := res.Rules[0] <mask> if r.IP == nil || r.IP.String() != ip { <mask> t.Errorf("Expected ip %s to match, actual: %v", ip, r.IP) <mask> } <mask> } <mask> <mask> func (d *DNSFilter) checkMatchEmpty(t *testing.T, hostname string) { <mask> t.Helper() </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove if err != nil { t.Errorf("Error while matching host %s: %s", hostname, err) } if !res.IsFiltered { t.Errorf("Expected hostname %s to match", hostname) } </s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err) assert.Truef(t, res.IsFiltered, "Expected hostname %s to match", hostname) </s> remove if err != nil { t.Errorf("Error while matching host %s: %s", hostname, err) } if res.IsFiltered { t.Errorf("Expected hostname %s to not match", hostname) } </s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err) assert.Falsef(t, res.IsFiltered, "Expected hostname %s to not match", hostname) </s> remove hostname := "wmconvirus.narod.ru" res, err := d.CheckHost(hostname, dns.TypeA, &setts) if err != nil { b.Errorf("Error while matching host %s: %s", hostname, err) } if !res.IsFiltered { b.Errorf("Expected hostname %s to match", hostname) } </s> add res, err := d.CheckHost(blocked, dns.TypeA, &setts) assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err) assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) </s> remove hostname := "wmconvirus.narod.ru" res, err := d.CheckHost(hostname, dns.TypeA, &setts) if err != nil { b.Errorf("Error while matching host %s: %s", hostname, err) } if !res.IsFiltered { b.Errorf("Expected hostname %s to match", hostname) } </s> add res, err := d.CheckHost(blocked, dns.TypeA, &setts) assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err) assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) </s> remove ip := ips[0] for _, i := range ips { if i.To4() != nil { ip = i </s> add ip := ipAddrs[0].IP for _, ipAddr := range ipAddrs { if ipAddr.IP.To4() != nil { ip = ipAddr.IP
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err) assert.Falsef(t, res.IsFiltered, "Expected hostname %s to not match", hostname)
<mask> <mask> func (d *DNSFilter) checkMatchEmpty(t *testing.T, hostname string) { <mask> t.Helper() <mask> res, err := d.CheckHost(hostname, dns.TypeA, &setts) <mask> if err != nil { <mask> t.Errorf("Error while matching host %s: %s", hostname, err) <mask> } <mask> if res.IsFiltered { <mask> t.Errorf("Expected hostname %s to not match", hostname) <mask> } <mask> } <mask> <mask> func TestEtcHostsMatching(t *testing.T) { <mask> addr := "216.239.38.120" <mask> addr6 := "::1" </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove if err != nil { t.Errorf("Error while matching host %s: %s", hostname, err) } if !res.IsFiltered { t.Errorf("Expected hostname %s to match", hostname) } </s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err) assert.Truef(t, res.IsFiltered, "Expected hostname %s to match", hostname) </s> remove if err != nil { t.Errorf("Error while matching host %s: %s", hostname, err) } if !res.IsFiltered { t.Errorf("Expected hostname %s to match", hostname) } if len(res.Rules) == 0 { t.Errorf("Expected result to have rules") return } r := res.Rules[0] if r.IP == nil || r.IP.String() != ip { t.Errorf("Expected ip %s to match, actual: %v", ip, r.IP) </s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err) assert.Truef(t, res.IsFiltered, "Expected hostname %s to match", hostname) if assert.NotEmpty(t, res.Rules, "Expected result to have rules") { r := res.Rules[0] assert.NotNilf(t, r.IP, "Expected ip %s to match, actual: %v", ip, r.IP) assert.Equalf(t, ip, r.IP.String(), "Expected ip %s to match, actual: %v", ip, r.IP) </s> remove hostname := "wmconvirus.narod.ru" res, err := d.CheckHost(hostname, dns.TypeA, &setts) if err != nil { b.Errorf("Error while matching host %s: %s", hostname, err) } if !res.IsFiltered { b.Errorf("Expected hostname %s to match", hostname) } </s> add res, err := d.CheckHost(blocked, dns.TypeA, &setts) assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err) assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) </s> remove hostname := "wmconvirus.narod.ru" res, err := d.CheckHost(hostname, dns.TypeA, &setts) if err != nil { b.Errorf("Error while matching host %s: %s", hostname, err) } if !res.IsFiltered { b.Errorf("Expected hostname %s to match", hostname) } </s> add res, err := d.CheckHost(blocked, dns.TypeA, &setts) assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err) assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil) defer d.Close() </s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil) b.Cleanup(d.Close) blocked := "wmconvirus.narod.ru" d.safeBrowsingUpstream = &testSbUpstream{ hostname: blocked, block: true, }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
d := newForTest(nil, filters) t.Cleanup(d.Close)
<mask> addr, addr6) <mask> filters := []Filter{{ <mask> ID: 0, Data: []byte(text), <mask> }} <mask> d := NewForTest(nil, filters) <mask> defer d.Close() <mask> <mask> d.checkMatchIP(t, "google.com", addr, dns.TypeA) <mask> d.checkMatchIP(t, "www.google.com", addr, dns.TypeA) <mask> d.checkMatchEmpty(t, "subdomain.google.com") <mask> d.checkMatchEmpty(t, "example.org") </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // IPv4 </s> add // IPv4 match. </s> remove d := NewForTest(nil, filters) </s> add d := newForTest(nil, filters) </s> remove defer d.Close() </s> add t.Cleanup(d.Close) </s> remove d := NewForTest(&Config{ParentalEnabled: true, SafeBrowsingEnabled: false}, filters) defer d.Close() // no client settings: // blocked by filters r, _ = d.CheckHost("example.org", dns.TypeA, &setts) if !r.IsFiltered || r.Reason != FilteredBlockList { t.Fatalf("CheckHost FilteredBlockList") } </s> add </s> remove // Check behaviour without any per-client settings, // then apply per-client settings and check behaviour once again </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
// IPv4 match.
<mask> d.checkMatchIP(t, "www.google.com", addr, dns.TypeA) <mask> d.checkMatchEmpty(t, "subdomain.google.com") <mask> d.checkMatchEmpty(t, "example.org") <mask> <mask> // IPv4 <mask> d.checkMatchIP(t, "block.com", "0.0.0.0", dns.TypeA) <mask> <mask> // ...but empty IPv6 <mask> res, err := d.CheckHost("block.com", dns.TypeAAAA, &setts) <mask> assert.Nil(t, err) </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // ...but empty IPv6 </s> add // Empty IPv6. </s> remove d := NewForTest(nil, filters) defer d.Close() </s> add d := newForTest(nil, filters) t.Cleanup(d.Close) </s> remove // IPv6 </s> add // IPv6 match. </s> remove // ...but empty IPv4 </s> add // Empty IPv4. </s> remove loopback4 := net.IP{0, 0, 0, 1} assert.Equal(t, res.Rules[0].IP, loopback4) </s> add assert.Equal(t, res.Rules[0].IP, net.IP{0, 0, 0, 1})
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
// Empty IPv6.
<mask> <mask> // IPv4 <mask> d.checkMatchIP(t, "block.com", "0.0.0.0", dns.TypeA) <mask> <mask> // ...but empty IPv6 <mask> res, err := d.CheckHost("block.com", dns.TypeAAAA, &setts) <mask> assert.Nil(t, err) <mask> assert.True(t, res.IsFiltered) <mask> if assert.Len(t, res.Rules, 1) { <mask> assert.Equal(t, "0.0.0.0 block.com", res.Rules[0].Text) </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // IPv4 </s> add // IPv4 match. </s> remove // ...but empty IPv4 </s> add // Empty IPv4. </s> remove // IPv6 </s> add // IPv6 match. </s> remove loopback4 := net.IP{0, 0, 0, 1} assert.Equal(t, res.Rules[0].IP, loopback4) </s> add assert.Equal(t, res.Rules[0].IP, net.IP{0, 0, 0, 1}) </s> remove // 2 IPv4 (return only the first one) </s> add // Two IPv4, the first one returned.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
// IPv6 match.
<mask> assert.Equal(t, "0.0.0.0 block.com", res.Rules[0].Text) <mask> assert.Empty(t, res.Rules[0].IP) <mask> } <mask> <mask> // IPv6 <mask> d.checkMatchIP(t, "ipv6.com", addr6, dns.TypeAAAA) <mask> <mask> // ...but empty IPv4 <mask> res, err = d.CheckHost("ipv6.com", dns.TypeA, &setts) <mask> assert.Nil(t, err) </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // ...but empty IPv4 </s> add // Empty IPv4. </s> remove // ...but empty IPv6 </s> add // Empty IPv6. </s> remove // IPv4 </s> add // IPv4 match. </s> remove // 2 IPv4 (return only the first one) </s> add // Two IPv4, the first one returned. </s> remove loopback4 := net.IP{0, 0, 0, 1} assert.Equal(t, res.Rules[0].IP, loopback4) </s> add assert.Equal(t, res.Rules[0].IP, net.IP{0, 0, 0, 1})
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
// Empty IPv4.
<mask> <mask> // IPv6 <mask> d.checkMatchIP(t, "ipv6.com", addr6, dns.TypeAAAA) <mask> <mask> // ...but empty IPv4 <mask> res, err = d.CheckHost("ipv6.com", dns.TypeA, &setts) <mask> assert.Nil(t, err) <mask> assert.True(t, res.IsFiltered) <mask> if assert.Len(t, res.Rules, 1) { <mask> assert.Equal(t, "::1 ipv6.com", res.Rules[0].Text) </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // IPv6 </s> add // IPv6 match. </s> remove // ...but empty IPv6 </s> add // Empty IPv6. </s> remove // 2 IPv4 (return only the first one) </s> add // Two IPv4, the first one returned. </s> remove // IPv4 </s> add // IPv4 match. </s> remove // not matched by white filter, but matched by block filter </s> add // Not matched by white filter, but matched by block filter.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
// Two IPv4, the first one returned.
<mask> assert.Equal(t, "::1 ipv6.com", res.Rules[0].Text) <mask> assert.Empty(t, res.Rules[0].IP) <mask> } <mask> <mask> // 2 IPv4 (return only the first one) <mask> res, err = d.CheckHost("host2", dns.TypeA, &setts) <mask> assert.Nil(t, err) <mask> assert.True(t, res.IsFiltered) <mask> if assert.Len(t, res.Rules, 1) { <mask> loopback4 := net.IP{0, 0, 0, 1} </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove loopback4 := net.IP{0, 0, 0, 1} assert.Equal(t, res.Rules[0].IP, loopback4) </s> add assert.Equal(t, res.Rules[0].IP, net.IP{0, 0, 0, 1}) </s> remove // ...and 1 IPv6 address </s> add // One IPv6 address. </s> remove loopback6 := net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1} assert.Equal(t, res.Rules[0].IP, loopback6) </s> add assert.Equal(t, res.Rules[0].IP, net.IPv6loopback) </s> remove // ...but empty IPv4 </s> add // Empty IPv4. </s> remove // not matched by white filter, but matched by block filter </s> add // Not matched by white filter, but matched by block filter.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
assert.Equal(t, res.Rules[0].IP, net.IP{0, 0, 0, 1})
<mask> res, err = d.CheckHost("host2", dns.TypeA, &setts) <mask> assert.Nil(t, err) <mask> assert.True(t, res.IsFiltered) <mask> if assert.Len(t, res.Rules, 1) { <mask> loopback4 := net.IP{0, 0, 0, 1} <mask> assert.Equal(t, res.Rules[0].IP, loopback4) <mask> } <mask> <mask> // ...and 1 IPv6 address <mask> res, err = d.CheckHost("host2", dns.TypeAAAA, &setts) <mask> assert.Nil(t, err) </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // ...and 1 IPv6 address </s> add // One IPv6 address. </s> remove loopback6 := net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1} assert.Equal(t, res.Rules[0].IP, loopback6) </s> add assert.Equal(t, res.Rules[0].IP, net.IPv6loopback) </s> remove // 2 IPv4 (return only the first one) </s> add // Two IPv4, the first one returned. </s> remove // not matched by white filter, but matched by block filter </s> add // Not matched by white filter, but matched by block filter. </s> remove // ...but empty IPv6 </s> add // Empty IPv6.
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
// One IPv6 address.
<mask> loopback4 := net.IP{0, 0, 0, 1} <mask> assert.Equal(t, res.Rules[0].IP, loopback4) <mask> } <mask> <mask> // ...and 1 IPv6 address <mask> res, err = d.CheckHost("host2", dns.TypeAAAA, &setts) <mask> assert.Nil(t, err) <mask> assert.True(t, res.IsFiltered) <mask> if assert.Len(t, res.Rules, 1) { <mask> loopback6 := net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1} </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove loopback4 := net.IP{0, 0, 0, 1} assert.Equal(t, res.Rules[0].IP, loopback4) </s> add assert.Equal(t, res.Rules[0].IP, net.IP{0, 0, 0, 1}) </s> remove loopback6 := net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1} assert.Equal(t, res.Rules[0].IP, loopback6) </s> add assert.Equal(t, res.Rules[0].IP, net.IPv6loopback) </s> remove // 2 IPv4 (return only the first one) </s> add // Two IPv4, the first one returned. </s> remove f := NewForTest(nil, []Filter{{ID: 0, Data: []byte(text)}}) </s> add f := newForTest(nil, []Filter{{ID: 0, Data: []byte(text)}}) </s> remove d := DNSFilter{} </s> add d := newForTest(nil, nil) t.Cleanup(d.Close)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
assert.Equal(t, res.Rules[0].IP, net.IPv6loopback)
<mask> res, err = d.CheckHost("host2", dns.TypeAAAA, &setts) <mask> assert.Nil(t, err) <mask> assert.True(t, res.IsFiltered) <mask> if assert.Len(t, res.Rules, 1) { <mask> loopback6 := net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1} <mask> assert.Equal(t, res.Rules[0].IP, loopback6) <mask> } <mask> } <mask> <mask> // SAFE BROWSING <mask> </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // ...and 1 IPv6 address </s> add // One IPv6 address. </s> remove loopback4 := net.IP{0, 0, 0, 1} assert.Equal(t, res.Rules[0].IP, loopback4) </s> add assert.Equal(t, res.Rules[0].IP, net.IP{0, 0, 0, 1}) </s> remove // 2 IPv4 (return only the first one) </s> add // Two IPv4, the first one returned. </s> remove f := NewForTest(nil, []Filter{{ID: 0, Data: []byte(text)}}) </s> add f := newForTest(nil, []Filter{{ID: 0, Data: []byte(text)}}) </s> remove d := DNSFilter{} </s> add d := newForTest(nil, nil) t.Cleanup(d.Close)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
// Safe Browsing.
<mask> assert.Equal(t, res.Rules[0].IP, loopback6) <mask> } <mask> } <mask> <mask> // SAFE BROWSING <mask> <mask> func TestSafeBrowsing(t *testing.T) { <mask> logOutput := &bytes.Buffer{} <mask> testutil.ReplaceLogWriter(t, logOutput) <mask> testutil.ReplaceLogLevel(t, log.DEBUG) </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // PARENTAL </s> add // Parental. </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil) defer d.Close() d.checkMatch(t, "wmconvirus.narod.ru") </s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil) t.Cleanup(d.Close) matching := "wmconvirus.narod.ru" d.safeBrowsingUpstream = &testSbUpstream{ hostname: matching, block: true, } d.checkMatch(t, matching) </s> remove loopback6 := net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1} assert.Equal(t, res.Rules[0].IP, loopback6) </s> add assert.Equal(t, res.Rules[0].IP, net.IPv6loopback) </s> remove d := NewForTest(&Config{ParentalEnabled: true}, nil) defer d.Close() d.checkMatch(t, "pornhub.com") assert.Contains(t, logOutput.String(), "Parental lookup for pornhub.com") d.checkMatch(t, "www.pornhub.com") </s> add d := newForTest(&Config{ParentalEnabled: true}, nil) t.Cleanup(d.Close) matching := "pornhub.com" d.parentalUpstream = &testSbUpstream{ hostname: matching, block: true, } d.checkMatch(t, matching) assert.Contains(t, logOutput.String(), "Parental lookup for "+matching) d.checkMatch(t, "www."+matching) </s> remove // HELPERS // SAFE BROWSING // SAFE SEARCH // PARENTAL // FILTERING // BENCHMARKS // HELPERS </s> add // Helpers.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
d := newForTest(&Config{SafeBrowsingEnabled: true}, nil) t.Cleanup(d.Close) matching := "wmconvirus.narod.ru" d.safeBrowsingUpstream = &testSbUpstream{ hostname: matching, block: true, } d.checkMatch(t, matching)
<mask> logOutput := &bytes.Buffer{} <mask> testutil.ReplaceLogWriter(t, logOutput) <mask> testutil.ReplaceLogLevel(t, log.DEBUG) <mask> <mask> d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil) <mask> defer d.Close() <mask> d.checkMatch(t, "wmconvirus.narod.ru") <mask> <mask> assert.Contains(t, logOutput.String(), "SafeBrowsing lookup for wmconvirus.narod.ru") <mask> <mask> d.checkMatch(t, "test.wmconvirus.narod.ru") <mask> d.checkMatchEmpty(t, "yandex.ru") </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove assert.Contains(t, logOutput.String(), "SafeBrowsing lookup for wmconvirus.narod.ru") </s> add assert.Contains(t, logOutput.String(), "SafeBrowsing lookup for "+matching) </s> remove d := NewForTest(&Config{ParentalEnabled: true}, nil) defer d.Close() d.checkMatch(t, "pornhub.com") assert.Contains(t, logOutput.String(), "Parental lookup for pornhub.com") d.checkMatch(t, "www.pornhub.com") </s> add d := newForTest(&Config{ParentalEnabled: true}, nil) t.Cleanup(d.Close) matching := "pornhub.com" d.parentalUpstream = &testSbUpstream{ hostname: matching, block: true, } d.checkMatch(t, matching) assert.Contains(t, logOutput.String(), "Parental lookup for "+matching) d.checkMatch(t, "www."+matching) </s> remove d.checkMatch(t, "test.wmconvirus.narod.ru") </s> add d.checkMatch(t, "test."+matching) </s> remove // PARENTAL </s> add // Parental. </s> remove // SAFE BROWSING </s> add // Safe Browsing.
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
assert.Contains(t, logOutput.String(), "SafeBrowsing lookup for "+matching)
<mask> d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil) <mask> defer d.Close() <mask> d.checkMatch(t, "wmconvirus.narod.ru") <mask> <mask> assert.Contains(t, logOutput.String(), "SafeBrowsing lookup for wmconvirus.narod.ru") <mask> <mask> d.checkMatch(t, "test.wmconvirus.narod.ru") <mask> d.checkMatchEmpty(t, "yandex.ru") <mask> d.checkMatchEmpty(t, "pornhub.com") <mask> </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove d.checkMatch(t, "test.wmconvirus.narod.ru") </s> add d.checkMatch(t, "test."+matching) </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil) defer d.Close() d.checkMatch(t, "wmconvirus.narod.ru") </s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil) t.Cleanup(d.Close) matching := "wmconvirus.narod.ru" d.safeBrowsingUpstream = &testSbUpstream{ hostname: matching, block: true, } d.checkMatch(t, matching) </s> remove d := NewForTest(&Config{ParentalEnabled: true}, nil) defer d.Close() d.checkMatch(t, "pornhub.com") assert.Contains(t, logOutput.String(), "Parental lookup for pornhub.com") d.checkMatch(t, "www.pornhub.com") </s> add d := newForTest(&Config{ParentalEnabled: true}, nil) t.Cleanup(d.Close) matching := "pornhub.com" d.parentalUpstream = &testSbUpstream{ hostname: matching, block: true, } d.checkMatch(t, matching) assert.Contains(t, logOutput.String(), "Parental lookup for "+matching) d.checkMatch(t, "www."+matching) </s> remove // test cached result </s> add // Cached result. </s> remove d.checkMatch(t, "wmconvirus.narod.ru") d.checkMatch(t, "test.wmconvirus.narod.ru") </s> add d.checkMatch(t, matching) d.checkMatch(t, "test."+matching)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
d.checkMatch(t, "test."+matching)
<mask> d.checkMatch(t, "wmconvirus.narod.ru") <mask> <mask> assert.Contains(t, logOutput.String(), "SafeBrowsing lookup for wmconvirus.narod.ru") <mask> <mask> d.checkMatch(t, "test.wmconvirus.narod.ru") <mask> d.checkMatchEmpty(t, "yandex.ru") <mask> d.checkMatchEmpty(t, "pornhub.com") <mask> <mask> // test cached result <mask> d.safeBrowsingServer = "127.0.0.1" </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // test cached result </s> add // Cached result. </s> remove assert.Contains(t, logOutput.String(), "SafeBrowsing lookup for wmconvirus.narod.ru") </s> add assert.Contains(t, logOutput.String(), "SafeBrowsing lookup for "+matching) </s> remove d.checkMatch(t, "wmconvirus.narod.ru") </s> add d.checkMatch(t, matching) </s> remove d := NewForTest(&Config{ParentalEnabled: true}, nil) defer d.Close() d.checkMatch(t, "pornhub.com") assert.Contains(t, logOutput.String(), "Parental lookup for pornhub.com") d.checkMatch(t, "www.pornhub.com") </s> add d := newForTest(&Config{ParentalEnabled: true}, nil) t.Cleanup(d.Close) matching := "pornhub.com" d.parentalUpstream = &testSbUpstream{ hostname: matching, block: true, } d.checkMatch(t, matching) assert.Contains(t, logOutput.String(), "Parental lookup for "+matching) d.checkMatch(t, "www."+matching) </s> remove d.checkMatch(t, "pornhub.com") </s> add d.checkMatch(t, matching)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
// Cached result.
<mask> d.checkMatch(t, "test.wmconvirus.narod.ru") <mask> d.checkMatchEmpty(t, "yandex.ru") <mask> d.checkMatchEmpty(t, "pornhub.com") <mask> <mask> // test cached result <mask> d.safeBrowsingServer = "127.0.0.1" <mask> d.checkMatch(t, "wmconvirus.narod.ru") <mask> d.checkMatchEmpty(t, "pornhub.com") <mask> d.safeBrowsingServer = defaultSafebrowsingServer <mask> } </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove d.checkMatch(t, "wmconvirus.narod.ru") </s> add d.checkMatch(t, matching) </s> remove d.checkMatch(t, "test.wmconvirus.narod.ru") </s> add d.checkMatch(t, "test."+matching) </s> remove d.checkMatch(t, "pornhub.com") </s> add d.checkMatch(t, matching) </s> remove d.checkMatch(t, "wmconvirus.narod.ru") d.checkMatch(t, "test.wmconvirus.narod.ru") </s> add d.checkMatch(t, matching) d.checkMatch(t, "test."+matching) </s> remove d := NewForTest(&Config{ParentalEnabled: true}, nil) defer d.Close() d.checkMatch(t, "pornhub.com") assert.Contains(t, logOutput.String(), "Parental lookup for pornhub.com") d.checkMatch(t, "www.pornhub.com") </s> add d := newForTest(&Config{ParentalEnabled: true}, nil) t.Cleanup(d.Close) matching := "pornhub.com" d.parentalUpstream = &testSbUpstream{ hostname: matching, block: true, } d.checkMatch(t, matching) assert.Contains(t, logOutput.String(), "Parental lookup for "+matching) d.checkMatch(t, "www."+matching)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
d.checkMatch(t, matching)
<mask> d.checkMatchEmpty(t, "pornhub.com") <mask> <mask> // test cached result <mask> d.safeBrowsingServer = "127.0.0.1" <mask> d.checkMatch(t, "wmconvirus.narod.ru") <mask> d.checkMatchEmpty(t, "pornhub.com") <mask> d.safeBrowsingServer = defaultSafebrowsingServer <mask> } <mask> <mask> func TestParallelSB(t *testing.T) { </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // test cached result </s> add // Cached result. </s> remove d.checkMatch(t, "test.wmconvirus.narod.ru") </s> add d.checkMatch(t, "test."+matching) </s> remove d.checkMatch(t, "pornhub.com") </s> add d.checkMatch(t, matching) </s> remove d := NewForTest(&Config{ParentalEnabled: true}, nil) defer d.Close() d.checkMatch(t, "pornhub.com") assert.Contains(t, logOutput.String(), "Parental lookup for pornhub.com") d.checkMatch(t, "www.pornhub.com") </s> add d := newForTest(&Config{ParentalEnabled: true}, nil) t.Cleanup(d.Close) matching := "pornhub.com" d.parentalUpstream = &testSbUpstream{ hostname: matching, block: true, } d.checkMatch(t, matching) assert.Contains(t, logOutput.String(), "Parental lookup for "+matching) d.checkMatch(t, "www."+matching) </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil) defer d.Close() </s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil) t.Cleanup(d.Close) matching := "wmconvirus.narod.ru" d.safeBrowsingUpstream = &testSbUpstream{ hostname: matching, block: true, }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
d := newForTest(&Config{SafeBrowsingEnabled: true}, nil) t.Cleanup(d.Close) matching := "wmconvirus.narod.ru" d.safeBrowsingUpstream = &testSbUpstream{ hostname: matching, block: true, }
<mask> d.safeBrowsingServer = defaultSafebrowsingServer <mask> } <mask> <mask> func TestParallelSB(t *testing.T) { <mask> d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil) <mask> defer d.Close() <mask> t.Run("group", func(t *testing.T) { <mask> for i := 0; i < 100; i++ { <mask> t.Run(fmt.Sprintf("aaa%d", i), func(t *testing.T) { <mask> t.Parallel() <mask> d.checkMatch(t, "wmconvirus.narod.ru") </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove d.checkMatch(t, "wmconvirus.narod.ru") d.checkMatch(t, "test.wmconvirus.narod.ru") </s> add d.checkMatch(t, matching) d.checkMatch(t, "test."+matching) </s> remove d.checkMatch(t, "wmconvirus.narod.ru") </s> add d.checkMatch(t, matching) </s> remove ip := ips[0] for _, i := range ips { if i.To4() != nil { ip = i </s> add ip := ipAddrs[0].IP for _, ipAddr := range ipAddrs { if ipAddr.IP.To4() != nil { ip = ipAddr.IP </s> remove // BENCHMARKS </s> add // Benchmarks. </s> remove // blocked by parental r, _ = d.CheckHost("pornhub.com", dns.TypeA, &setts) if !r.IsFiltered || r.Reason != FilteredParental { t.Fatalf("CheckHost FilteredParental") </s> add makeTester := func(tc testCase, before bool) func(t *testing.T) { return func(t *testing.T) { r, _ := d.CheckHost(tc.host, dns.TypeA, &setts) if before { assert.True(t, r.IsFiltered) assert.Equal(t, tc.wantReason, r.Reason) } else { assert.False(t, r.IsFiltered) } }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
d.checkMatch(t, matching) d.checkMatch(t, "test."+matching)
<mask> t.Run("group", func(t *testing.T) { <mask> for i := 0; i < 100; i++ { <mask> t.Run(fmt.Sprintf("aaa%d", i), func(t *testing.T) { <mask> t.Parallel() <mask> d.checkMatch(t, "wmconvirus.narod.ru") <mask> d.checkMatch(t, "test.wmconvirus.narod.ru") <mask> d.checkMatchEmpty(t, "yandex.ru") <mask> d.checkMatchEmpty(t, "pornhub.com") <mask> }) <mask> } <mask> }) </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil) defer d.Close() </s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil) t.Cleanup(d.Close) matching := "wmconvirus.narod.ru" d.safeBrowsingUpstream = &testSbUpstream{ hostname: matching, block: true, } </s> remove // test cached result </s> add // Cached result. </s> remove d.checkMatch(t, "test.wmconvirus.narod.ru") </s> add d.checkMatch(t, "test."+matching) </s> remove d.checkMatch(t, "wmconvirus.narod.ru") </s> add d.checkMatch(t, matching) </s> remove assert.Contains(t, logOutput.String(), "SafeBrowsing lookup for wmconvirus.narod.ru") </s> add assert.Contains(t, logOutput.String(), "SafeBrowsing lookup for "+matching)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
// Safe Search.
<mask> } <mask> }) <mask> } <mask> <mask> // SAFE SEARCH <mask> <mask> func TestSafeSearch(t *testing.T) { <mask> d := NewForTest(&Config{SafeSearchEnabled: true}, nil) <mask> defer d.Close() <mask> val, ok := d.SafeSearchDomain("www.google.com") </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) </s> remove if !ok { t.Errorf("Expected safesearch to find result for www.google.com") } if val != "forcesafesearch.google.com" { t.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com") } </s> add assert.True(t, ok, "Expected safesearch to find result for www.google.com") assert.Equal(t, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil) b.Cleanup(d.Close) </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil) b.Cleanup(d.Close) </s> remove if !ok { b.Errorf("Expected safesearch to find result for www.google.com") } if val != "forcesafesearch.google.com" { b.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com") } </s> add assert.True(b, ok, "Expected safesearch to find result for www.google.com") assert.Equal(b, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close)
<mask> <mask> // SAFE SEARCH <mask> <mask> func TestSafeSearch(t *testing.T) { <mask> d := NewForTest(&Config{SafeSearchEnabled: true}, nil) <mask> defer d.Close() <mask> val, ok := d.SafeSearchDomain("www.google.com") <mask> if !ok { <mask> t.Errorf("Expected safesearch to find result for www.google.com") <mask> } <mask> if val != "forcesafesearch.google.com" { </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove if !ok { t.Errorf("Expected safesearch to find result for www.google.com") } if val != "forcesafesearch.google.com" { t.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com") } </s> add assert.True(t, ok, "Expected safesearch to find result for www.google.com") assert.Equal(t, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove if !ok { b.Errorf("Expected safesearch to find result for www.google.com") } if val != "forcesafesearch.google.com" { b.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com") } </s> add assert.True(b, ok, "Expected safesearch to find result for www.google.com") assert.Equal(b, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove if !ok { b.Errorf("Expected safesearch to find result for www.google.com") } if val != "forcesafesearch.google.com" { b.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com") } </s> add assert.True(b, ok, "Expected safesearch to find result for www.google.com") assert.Equal(b, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil) b.Cleanup(d.Close) </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil) b.Cleanup(d.Close)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
assert.True(t, ok, "Expected safesearch to find result for www.google.com") assert.Equal(t, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com")
<mask> func TestSafeSearch(t *testing.T) { <mask> d := NewForTest(&Config{SafeSearchEnabled: true}, nil) <mask> defer d.Close() <mask> val, ok := d.SafeSearchDomain("www.google.com") <mask> if !ok { <mask> t.Errorf("Expected safesearch to find result for www.google.com") <mask> } <mask> if val != "forcesafesearch.google.com" { <mask> t.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com") <mask> } <mask> } <mask> <mask> func TestCheckHostSafeSearchYandex(t *testing.T) { <mask> d := NewForTest(&Config{SafeSearchEnabled: true}, nil) <mask> defer d.Close() </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove if !ok { b.Errorf("Expected safesearch to find result for www.google.com") } if val != "forcesafesearch.google.com" { b.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com") } </s> add assert.True(b, ok, "Expected safesearch to find result for www.google.com") assert.Equal(b, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) </s> remove if !ok { b.Errorf("Expected safesearch to find result for www.google.com") } if val != "forcesafesearch.google.com" { b.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com") } </s> add assert.True(b, ok, "Expected safesearch to find result for www.google.com") assert.Equal(b, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil) b.Cleanup(d.Close) </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil) b.Cleanup(d.Close)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) // Check host for each domain. for _, host := range []string{ "yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com", } {
<mask> } <mask> } <mask> <mask> func TestCheckHostSafeSearchYandex(t *testing.T) { <mask> d := NewForTest(&Config{SafeSearchEnabled: true}, nil) <mask> defer d.Close() <mask> <mask> // Slice of yandex domains <mask> yandex := []string{"yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com"} <mask> <mask> // Check host for each domain <mask> for _, host := range yandex { <mask> res, err := d.CheckHost(host, dns.TypeA, &setts) <mask> assert.Nil(t, err) <mask> assert.True(t, res.IsFiltered) <mask> if assert.Len(t, res.Rules, 1) { <mask> assert.Equal(t, res.Rules[0].IP.String(), "213.180.193.56") </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // Check host for each domain for _, host := range googleDomains { res, err := d.CheckHost(host, dns.TypeA, &setts) assert.Nil(t, err) assert.True(t, res.IsFiltered) if assert.Len(t, res.Rules, 1) { assert.NotEqual(t, res.Rules[0].IP.String(), "0.0.0.0") } </s> add func TestCheckHostSafeSearchGoogle(t *testing.T) { d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) d.resolver = &testResolver{} // Check host for each domain. for _, host := range []string{ "www.google.com", "www.google.im", "www.google.co.in", "www.google.iq", "www.google.is", "www.google.it", "www.google.je", } { t.Run(host, func(t *testing.T) { res, err := d.CheckHost(host, dns.TypeA, &setts) assert.Nil(t, err) assert.True(t, res.IsFiltered) assert.Len(t, res.Rules, 1) }) </s> remove func TestCheckHostSafeSearchGoogle(t *testing.T) { d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() // Slice of google domains googleDomains := []string{"www.google.com", "www.google.im", "www.google.co.in", "www.google.iq", "www.google.is", "www.google.it", "www.google.je"} </s> add // testResolver is a Resolver for tests. type testResolver struct{} // LookupIP implements Resolver interface for *testResolver. func (r *testResolver) LookupIPAddr(_ context.Context, host string) (ips []net.IPAddr, err error) { hash := sha256.Sum256([]byte(host)) addrs := []net.IPAddr{{ IP: net.IP(hash[:4]), Zone: "somezone", }, { IP: net.IP(hash[4:20]), Zone: "somezone", }} return addrs, nil } </s> remove // For yandex we already know valid ip. </s> add // For yandex we already know valid IP. </s> remove assert.Equal(t, res.Rules[0].IP.String(), "213.180.193.56") </s> add assert.Equal(t, res.Rules[0].IP, net.IPv4(213, 180, 193, 56)) </s> remove assert.Equal(t, res.Rules[0].IP.String(), "213.180.193.56") </s> add assert.Equal(t, res.Rules[0].IP, net.IPv4(213, 180, 193, 56))
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
assert.Equal(t, res.Rules[0].IP, net.IPv4(213, 180, 193, 56))
<mask> res, err := d.CheckHost(host, dns.TypeA, &setts) <mask> assert.Nil(t, err) <mask> assert.True(t, res.IsFiltered) <mask> if assert.Len(t, res.Rules, 1) { <mask> assert.Equal(t, res.Rules[0].IP.String(), "213.180.193.56") <mask> } <mask> } <mask> } <mask> <mask> func TestCheckHostSafeSearchGoogle(t *testing.T) { </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // Check host for each domain for _, host := range googleDomains { res, err := d.CheckHost(host, dns.TypeA, &setts) assert.Nil(t, err) assert.True(t, res.IsFiltered) if assert.Len(t, res.Rules, 1) { assert.NotEqual(t, res.Rules[0].IP.String(), "0.0.0.0") } </s> add func TestCheckHostSafeSearchGoogle(t *testing.T) { d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) d.resolver = &testResolver{} // Check host for each domain. for _, host := range []string{ "www.google.com", "www.google.im", "www.google.co.in", "www.google.iq", "www.google.is", "www.google.it", "www.google.je", } { t.Run(host, func(t *testing.T) { res, err := d.CheckHost(host, dns.TypeA, &setts) assert.Nil(t, err) assert.True(t, res.IsFiltered) assert.Len(t, res.Rules, 1) }) </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() // Slice of yandex domains yandex := []string{"yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com"} // Check host for each domain for _, host := range yandex { </s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) // Check host for each domain. for _, host := range []string{ "yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com", } { </s> remove assert.Equal(t, res.Rules[0].IP.String(), "213.180.193.56") </s> add assert.Equal(t, res.Rules[0].IP, net.IPv4(213, 180, 193, 56)) </s> remove loopback4 := net.IP{0, 0, 0, 1} assert.Equal(t, res.Rules[0].IP, loopback4) </s> add assert.Equal(t, res.Rules[0].IP, net.IP{0, 0, 0, 1}) </s> remove // not matched by white filter, but matched by block filter </s> add // Not matched by white filter, but matched by block filter.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
// testResolver is a Resolver for tests. type testResolver struct{} // LookupIP implements Resolver interface for *testResolver. func (r *testResolver) LookupIPAddr(_ context.Context, host string) (ips []net.IPAddr, err error) { hash := sha256.Sum256([]byte(host)) addrs := []net.IPAddr{{ IP: net.IP(hash[:4]), Zone: "somezone", }, { IP: net.IP(hash[4:20]), Zone: "somezone", }} return addrs, nil }
<mask> } <mask> } <mask> } <mask> <mask> func TestCheckHostSafeSearchGoogle(t *testing.T) { <mask> d := NewForTest(&Config{SafeSearchEnabled: true}, nil) <mask> defer d.Close() <mask> <mask> // Slice of google domains <mask> googleDomains := []string{"www.google.com", "www.google.im", "www.google.co.in", "www.google.iq", "www.google.is", "www.google.it", "www.google.je"} <mask> <mask> // Check host for each domain <mask> for _, host := range googleDomains { <mask> res, err := d.CheckHost(host, dns.TypeA, &setts) <mask> assert.Nil(t, err) </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // Check host for each domain for _, host := range googleDomains { res, err := d.CheckHost(host, dns.TypeA, &setts) assert.Nil(t, err) assert.True(t, res.IsFiltered) if assert.Len(t, res.Rules, 1) { assert.NotEqual(t, res.Rules[0].IP.String(), "0.0.0.0") } </s> add func TestCheckHostSafeSearchGoogle(t *testing.T) { d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) d.resolver = &testResolver{} // Check host for each domain. for _, host := range []string{ "www.google.com", "www.google.im", "www.google.co.in", "www.google.iq", "www.google.is", "www.google.it", "www.google.je", } { t.Run(host, func(t *testing.T) { res, err := d.CheckHost(host, dns.TypeA, &setts) assert.Nil(t, err) assert.True(t, res.IsFiltered) assert.Len(t, res.Rules, 1) }) </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() // Slice of yandex domains yandex := []string{"yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com"} // Check host for each domain for _, host := range yandex { </s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) // Check host for each domain. for _, host := range []string{ "yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com", } { </s> remove d := NewForTest(nil, nil) defer d.Close() </s> add d := newForTest(nil, nil) t.Cleanup(d.Close) </s> remove assert.Equal(t, res.Rules[0].IP.String(), "213.180.193.56") </s> add assert.Equal(t, res.Rules[0].IP, net.IPv4(213, 180, 193, 56)) </s> remove hostname := "wmconvirus.narod.ru" res, err := d.CheckHost(hostname, dns.TypeA, &setts) if err != nil { b.Errorf("Error while matching host %s: %s", hostname, err) } if !res.IsFiltered { b.Errorf("Expected hostname %s to match", hostname) } </s> add res, err := d.CheckHost(blocked, dns.TypeA, &setts) assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err) assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
func TestCheckHostSafeSearchGoogle(t *testing.T) { d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) d.resolver = &testResolver{} // Check host for each domain. for _, host := range []string{ "www.google.com", "www.google.im", "www.google.co.in", "www.google.iq", "www.google.is", "www.google.it", "www.google.je", } { t.Run(host, func(t *testing.T) { res, err := d.CheckHost(host, dns.TypeA, &setts) assert.Nil(t, err) assert.True(t, res.IsFiltered) assert.Len(t, res.Rules, 1) })
<mask> <mask> // Slice of google domains <mask> googleDomains := []string{"www.google.com", "www.google.im", "www.google.co.in", "www.google.iq", "www.google.is", "www.google.it", "www.google.je"} <mask> <mask> // Check host for each domain <mask> for _, host := range googleDomains { <mask> res, err := d.CheckHost(host, dns.TypeA, &setts) <mask> assert.Nil(t, err) <mask> assert.True(t, res.IsFiltered) <mask> if assert.Len(t, res.Rules, 1) { <mask> assert.NotEqual(t, res.Rules[0].IP.String(), "0.0.0.0") <mask> } <mask> } <mask> } <mask> <mask> func TestSafeSearchCacheYandex(t *testing.T) { <mask> d := NewForTest(nil, nil) </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove func TestCheckHostSafeSearchGoogle(t *testing.T) { d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() // Slice of google domains googleDomains := []string{"www.google.com", "www.google.im", "www.google.co.in", "www.google.iq", "www.google.is", "www.google.it", "www.google.je"} </s> add // testResolver is a Resolver for tests. type testResolver struct{} // LookupIP implements Resolver interface for *testResolver. func (r *testResolver) LookupIPAddr(_ context.Context, host string) (ips []net.IPAddr, err error) { hash := sha256.Sum256([]byte(host)) addrs := []net.IPAddr{{ IP: net.IP(hash[:4]), Zone: "somezone", }, { IP: net.IP(hash[4:20]), Zone: "somezone", }} return addrs, nil } </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() // Slice of yandex domains yandex := []string{"yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com"} // Check host for each domain for _, host := range yandex { </s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) // Check host for each domain. for _, host := range []string{ "yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com", } { </s> remove d := NewForTest(nil, nil) defer d.Close() </s> add d := newForTest(nil, nil) t.Cleanup(d.Close) </s> remove assert.Equal(t, res.Rules[0].IP.String(), "213.180.193.56") </s> add assert.Equal(t, res.Rules[0].IP, net.IPv4(213, 180, 193, 56)) </s> remove assert.Equal(t, cachedValue.Rules[0].IP.String(), "213.180.193.56") </s> add assert.Equal(t, cachedValue.Rules[0].IP, net.IPv4(213, 180, 193, 56))
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
d := newForTest(nil, nil) t.Cleanup(d.Close)
<mask> } <mask> } <mask> <mask> func TestSafeSearchCacheYandex(t *testing.T) { <mask> d := NewForTest(nil, nil) <mask> defer d.Close() <mask> domain := "yandex.ru" <mask> <mask> // Check host with disabled safesearch. <mask> res, err := d.CheckHost(domain, dns.TypeA, &setts) <mask> assert.Nil(t, err) </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // Check host for each domain for _, host := range googleDomains { res, err := d.CheckHost(host, dns.TypeA, &setts) assert.Nil(t, err) assert.True(t, res.IsFiltered) if assert.Len(t, res.Rules, 1) { assert.NotEqual(t, res.Rules[0].IP.String(), "0.0.0.0") } </s> add func TestCheckHostSafeSearchGoogle(t *testing.T) { d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) d.resolver = &testResolver{} // Check host for each domain. for _, host := range []string{ "www.google.com", "www.google.im", "www.google.co.in", "www.google.iq", "www.google.is", "www.google.it", "www.google.je", } { t.Run(host, func(t *testing.T) { res, err := d.CheckHost(host, dns.TypeA, &setts) assert.Nil(t, err) assert.True(t, res.IsFiltered) assert.Len(t, res.Rules, 1) }) </s> remove d := NewForTest(nil, nil) defer d.Close() </s> add d := newForTest(nil, nil) t.Cleanup(d.Close) resolver := &testResolver{} d.resolver = resolver </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() // Slice of yandex domains yandex := []string{"yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com"} // Check host for each domain for _, host := range yandex { </s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) // Check host for each domain. for _, host := range []string{ "yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com", } { </s> remove func TestCheckHostSafeSearchGoogle(t *testing.T) { d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() // Slice of google domains googleDomains := []string{"www.google.com", "www.google.im", "www.google.co.in", "www.google.iq", "www.google.is", "www.google.it", "www.google.je"} </s> add // testResolver is a Resolver for tests. type testResolver struct{} // LookupIP implements Resolver interface for *testResolver. func (r *testResolver) LookupIPAddr(_ context.Context, host string) (ips []net.IPAddr, err error) { hash := sha256.Sum256([]byte(host)) addrs := []net.IPAddr{{ IP: net.IP(hash[:4]), Zone: "somezone", }, { IP: net.IP(hash[4:20]), Zone: "somezone", }} return addrs, nil } </s> remove hostname := "wmconvirus.narod.ru" res, err := d.CheckHost(hostname, dns.TypeA, &setts) if err != nil { b.Errorf("Error while matching host %s: %s", hostname, err) } if !res.IsFiltered { b.Errorf("Expected hostname %s to match", hostname) } </s> add res, err := d.CheckHost(blocked, dns.TypeA, &setts) assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err) assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
d = newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close)
<mask> assert.Nil(t, err) <mask> assert.False(t, res.IsFiltered) <mask> assert.Empty(t, res.Rules) <mask> <mask> d = NewForTest(&Config{SafeSearchEnabled: true}, nil) <mask> defer d.Close() <mask> <mask> res, err = d.CheckHost(domain, dns.TypeA, &setts) <mask> if err != nil { <mask> t.Fatalf("CheckHost for safesearh domain %s failed cause %s", domain, err) <mask> } </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove if err != nil { t.Fatalf("CheckHost for safesearh domain %s failed cause %s", domain, err) } </s> add assert.Nilf(t, err, "CheckHost for safesearh domain %s failed cause %s", domain, err) </s> remove // For yandex we already know valid ip. </s> add // For yandex we already know valid IP. </s> remove d := NewForTest(nil, nil) defer d.Close() </s> add d := newForTest(nil, nil) t.Cleanup(d.Close) resolver := &testResolver{} d.resolver = resolver </s> remove d = NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d = newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) d.resolver = resolver </s> remove // TODO this address should be resolved with upstream that was configured in dnsforward ips, err := net.LookupIP(safeHost) </s> add ipAddrs, err := d.resolver.LookupIPAddr(context.Background(), safeHost)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
assert.Nilf(t, err, "CheckHost for safesearh domain %s failed cause %s", domain, err)
<mask> d = NewForTest(&Config{SafeSearchEnabled: true}, nil) <mask> defer d.Close() <mask> <mask> res, err = d.CheckHost(domain, dns.TypeA, &setts) <mask> if err != nil { <mask> t.Fatalf("CheckHost for safesearh domain %s failed cause %s", domain, err) <mask> } <mask> <mask> // For yandex we already know valid ip. <mask> if assert.Len(t, res.Rules, 1) { <mask> assert.Equal(t, res.Rules[0].IP.String(), "213.180.193.56") <mask> } </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // For yandex we already know valid ip. </s> add // For yandex we already know valid IP. </s> remove assert.Equal(t, res.Rules[0].IP.String(), "213.180.193.56") </s> add assert.Equal(t, res.Rules[0].IP, net.IPv4(213, 180, 193, 56)) </s> remove d = NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d = newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() // Slice of yandex domains yandex := []string{"yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com"} // Check host for each domain for _, host := range yandex { </s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) // Check host for each domain. for _, host := range []string{ "yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com", } { </s> remove assert.Equal(t, res.Rules[0].IP.String(), "213.180.193.56") </s> add assert.Equal(t, res.Rules[0].IP, net.IPv4(213, 180, 193, 56))
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
// For yandex we already know valid IP.
<mask> if err != nil { <mask> t.Fatalf("CheckHost for safesearh domain %s failed cause %s", domain, err) <mask> } <mask> <mask> // For yandex we already know valid ip. <mask> if assert.Len(t, res.Rules, 1) { <mask> assert.Equal(t, res.Rules[0].IP.String(), "213.180.193.56") <mask> } <mask> <mask> // Check cache. </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove if err != nil { t.Fatalf("CheckHost for safesearh domain %s failed cause %s", domain, err) } </s> add assert.Nilf(t, err, "CheckHost for safesearh domain %s failed cause %s", domain, err) </s> remove assert.Equal(t, res.Rules[0].IP.String(), "213.180.193.56") </s> add assert.Equal(t, res.Rules[0].IP, net.IPv4(213, 180, 193, 56)) </s> remove d = NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d = newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() // Slice of yandex domains yandex := []string{"yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com"} // Check host for each domain for _, host := range yandex { </s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) // Check host for each domain. for _, host := range []string{ "yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com", } { </s> remove assert.Equal(t, cachedValue.Rules[0].IP.String(), "213.180.193.56") </s> add assert.Equal(t, cachedValue.Rules[0].IP, net.IPv4(213, 180, 193, 56))
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
assert.Equal(t, res.Rules[0].IP, net.IPv4(213, 180, 193, 56))
<mask> } <mask> <mask> // For yandex we already know valid ip. <mask> if assert.Len(t, res.Rules, 1) { <mask> assert.Equal(t, res.Rules[0].IP.String(), "213.180.193.56") <mask> } <mask> <mask> // Check cache. <mask> cachedValue, isFound := getCachedResult(gctx.safeSearchCache, domain) <mask> assert.True(t, isFound) </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // For yandex we already know valid ip. </s> add // For yandex we already know valid IP. </s> remove assert.Equal(t, cachedValue.Rules[0].IP.String(), "213.180.193.56") </s> add assert.Equal(t, cachedValue.Rules[0].IP, net.IPv4(213, 180, 193, 56)) </s> remove if err != nil { t.Fatalf("CheckHost for safesearh domain %s failed cause %s", domain, err) } </s> add assert.Nilf(t, err, "CheckHost for safesearh domain %s failed cause %s", domain, err) </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() // Slice of yandex domains yandex := []string{"yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com"} // Check host for each domain for _, host := range yandex { </s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) // Check host for each domain. for _, host := range []string{ "yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com", } { </s> remove assert.Equal(t, res.Rules[0].IP.String(), "213.180.193.56") </s> add assert.Equal(t, res.Rules[0].IP, net.IPv4(213, 180, 193, 56))
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
assert.Equal(t, cachedValue.Rules[0].IP, net.IPv4(213, 180, 193, 56))
<mask> // Check cache. <mask> cachedValue, isFound := getCachedResult(gctx.safeSearchCache, domain) <mask> assert.True(t, isFound) <mask> if assert.Len(t, cachedValue.Rules, 1) { <mask> assert.Equal(t, cachedValue.Rules[0].IP.String(), "213.180.193.56") <mask> } <mask> } <mask> <mask> func TestSafeSearchCacheGoogle(t *testing.T) { <mask> d := NewForTest(nil, nil) </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove assert.Equal(t, res.Rules[0].IP.String(), "213.180.193.56") </s> add assert.Equal(t, res.Rules[0].IP, net.IPv4(213, 180, 193, 56)) </s> remove // For yandex we already know valid ip. </s> add // For yandex we already know valid IP. </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() // Slice of yandex domains yandex := []string{"yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com"} // Check host for each domain for _, host := range yandex { </s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) // Check host for each domain. for _, host := range []string{ "yAndeX.ru", "YANdex.COM", "yandex.ua", "yandex.by", "yandex.kz", "www.yandex.com", } { </s> remove // Check host for each domain for _, host := range googleDomains { res, err := d.CheckHost(host, dns.TypeA, &setts) assert.Nil(t, err) assert.True(t, res.IsFiltered) if assert.Len(t, res.Rules, 1) { assert.NotEqual(t, res.Rules[0].IP.String(), "0.0.0.0") } </s> add func TestCheckHostSafeSearchGoogle(t *testing.T) { d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) d.resolver = &testResolver{} // Check host for each domain. for _, host := range []string{ "www.google.com", "www.google.im", "www.google.co.in", "www.google.iq", "www.google.is", "www.google.it", "www.google.je", } { t.Run(host, func(t *testing.T) { res, err := d.CheckHost(host, dns.TypeA, &setts) assert.Nil(t, err) assert.True(t, res.IsFiltered) assert.Len(t, res.Rules, 1) }) </s> remove assert.Equal(t, res.Rules[0].IP.String(), "213.180.193.56") </s> add assert.Equal(t, res.Rules[0].IP, net.IPv4(213, 180, 193, 56))
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
d := newForTest(nil, nil) t.Cleanup(d.Close) resolver := &testResolver{} d.resolver = resolver
<mask> } <mask> } <mask> <mask> func TestSafeSearchCacheGoogle(t *testing.T) { <mask> d := NewForTest(nil, nil) <mask> defer d.Close() <mask> domain := "www.google.ru" <mask> res, err := d.CheckHost(domain, dns.TypeA, &setts) <mask> assert.Nil(t, err) <mask> assert.False(t, res.IsFiltered) <mask> assert.Empty(t, res.Rules) </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove d = NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d = newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) </s> remove d := NewForTest(nil, nil) defer d.Close() </s> add d := newForTest(nil, nil) t.Cleanup(d.Close) </s> remove d = NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d = newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) d.resolver = resolver </s> remove // Check host for each domain for _, host := range googleDomains { res, err := d.CheckHost(host, dns.TypeA, &setts) assert.Nil(t, err) assert.True(t, res.IsFiltered) if assert.Len(t, res.Rules, 1) { assert.NotEqual(t, res.Rules[0].IP.String(), "0.0.0.0") } </s> add func TestCheckHostSafeSearchGoogle(t *testing.T) { d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) d.resolver = &testResolver{} // Check host for each domain. for _, host := range []string{ "www.google.com", "www.google.im", "www.google.co.in", "www.google.iq", "www.google.is", "www.google.it", "www.google.je", } { t.Run(host, func(t *testing.T) { res, err := d.CheckHost(host, dns.TypeA, &setts) assert.Nil(t, err) assert.True(t, res.IsFiltered) assert.Len(t, res.Rules, 1) }) </s> remove defer d.Close() </s> add t.Cleanup(d.Close)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
d = newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) d.resolver = resolver
<mask> assert.Nil(t, err) <mask> assert.False(t, res.IsFiltered) <mask> assert.Empty(t, res.Rules) <mask> <mask> d = NewForTest(&Config{SafeSearchEnabled: true}, nil) <mask> defer d.Close() <mask> <mask> // Let's lookup for safesearch domain <mask> safeDomain, ok := d.SafeSearchDomain(domain) <mask> if !ok { <mask> t.Fatalf("Failed to get safesearch domain for %s", domain) </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // Let's lookup for safesearch domain </s> add // Lookup for safesearch domain. </s> remove if !ok { t.Fatalf("Failed to get safesearch domain for %s", domain) } </s> add assert.Truef(t, ok, "Failed to get safesearch domain for %s", domain) </s> remove ips, err := net.LookupIP(safeDomain) </s> add ipAddrs, err := resolver.LookupIPAddr(context.Background(), safeDomain) </s> remove d = NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d = newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) </s> remove d := NewForTest(nil, nil) defer d.Close() </s> add d := newForTest(nil, nil) t.Cleanup(d.Close) resolver := &testResolver{} d.resolver = resolver
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
// Lookup for safesearch domain.
<mask> <mask> d = NewForTest(&Config{SafeSearchEnabled: true}, nil) <mask> defer d.Close() <mask> <mask> // Let's lookup for safesearch domain <mask> safeDomain, ok := d.SafeSearchDomain(domain) <mask> if !ok { <mask> t.Fatalf("Failed to get safesearch domain for %s", domain) <mask> } <mask> </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove if !ok { t.Fatalf("Failed to get safesearch domain for %s", domain) } </s> add assert.Truef(t, ok, "Failed to get safesearch domain for %s", domain) </s> remove d = NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d = newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) d.resolver = resolver </s> remove ips, err := net.LookupIP(safeDomain) </s> add ipAddrs, err := resolver.LookupIPAddr(context.Background(), safeDomain) </s> remove if !ok { t.Errorf("Expected safesearch to find result for www.google.com") } if val != "forcesafesearch.google.com" { t.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com") } </s> add assert.True(t, ok, "Expected safesearch to find result for www.google.com") assert.Equal(t, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove if !ok { b.Errorf("Expected safesearch to find result for www.google.com") } if val != "forcesafesearch.google.com" { b.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com") } </s> add assert.True(b, ok, "Expected safesearch to find result for www.google.com") assert.Equal(b, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
assert.Truef(t, ok, "Failed to get safesearch domain for %s", domain)
<mask> defer d.Close() <mask> <mask> // Let's lookup for safesearch domain <mask> safeDomain, ok := d.SafeSearchDomain(domain) <mask> if !ok { <mask> t.Fatalf("Failed to get safesearch domain for %s", domain) <mask> } <mask> <mask> ips, err := net.LookupIP(safeDomain) <mask> if err != nil { <mask> t.Fatalf("Failed to lookup for %s", safeDomain) <mask> } </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove ips, err := net.LookupIP(safeDomain) </s> add ipAddrs, err := resolver.LookupIPAddr(context.Background(), safeDomain) </s> remove // Let's lookup for safesearch domain </s> add // Lookup for safesearch domain. </s> remove d = NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d = newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) d.resolver = resolver </s> remove ip := ips[0] for _, i := range ips { if i.To4() != nil { ip = i </s> add ip := ipAddrs[0].IP for _, ipAddr := range ipAddrs { if ipAddr.IP.To4() != nil { ip = ipAddr.IP </s> remove if !ok { b.Errorf("Expected safesearch to find result for www.google.com") } if val != "forcesafesearch.google.com" { b.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com") } </s> add assert.True(b, ok, "Expected safesearch to find result for www.google.com") assert.Equal(b, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com")
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
ipAddrs, err := resolver.LookupIPAddr(context.Background(), safeDomain)
<mask> if !ok { <mask> t.Fatalf("Failed to get safesearch domain for %s", domain) <mask> } <mask> <mask> ips, err := net.LookupIP(safeDomain) <mask> if err != nil { <mask> t.Fatalf("Failed to lookup for %s", safeDomain) <mask> } <mask> <mask> ip := ips[0] </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove if !ok { t.Fatalf("Failed to get safesearch domain for %s", domain) } </s> add assert.Truef(t, ok, "Failed to get safesearch domain for %s", domain) </s> remove ip := ips[0] for _, i := range ips { if i.To4() != nil { ip = i </s> add ip := ipAddrs[0].IP for _, ipAddr := range ipAddrs { if ipAddr.IP.To4() != nil { ip = ipAddr.IP </s> remove // Let's lookup for safesearch domain </s> add // Lookup for safesearch domain. </s> remove d = NewForTest(&Config{SafeSearchEnabled: true}, nil) defer d.Close() </s> add d = newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) d.resolver = resolver </s> remove if err != nil { t.Errorf("Error while matching host %s: %s", hostname, err) } if !res.IsFiltered { t.Errorf("Expected hostname %s to match", hostname) } if len(res.Rules) == 0 { t.Errorf("Expected result to have rules") return } r := res.Rules[0] if r.IP == nil || r.IP.String() != ip { t.Errorf("Expected ip %s to match, actual: %v", ip, r.IP) </s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err) assert.Truef(t, res.IsFiltered, "Expected hostname %s to match", hostname) if assert.NotEmpty(t, res.Rules, "Expected result to have rules") { r := res.Rules[0] assert.NotNilf(t, r.IP, "Expected ip %s to match, actual: %v", ip, r.IP) assert.Equalf(t, ip, r.IP.String(), "Expected ip %s to match, actual: %v", ip, r.IP)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
ip := ipAddrs[0].IP for _, ipAddr := range ipAddrs { if ipAddr.IP.To4() != nil { ip = ipAddr.IP
<mask> if err != nil { <mask> t.Fatalf("Failed to lookup for %s", safeDomain) <mask> } <mask> <mask> ip := ips[0] <mask> for _, i := range ips { <mask> if i.To4() != nil { <mask> ip = i <mask> break <mask> } <mask> } <mask> <mask> res, err = d.CheckHost(domain, dns.TypeA, &setts) </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove ips, err := net.LookupIP(safeDomain) </s> add ipAddrs, err := resolver.LookupIPAddr(context.Background(), safeDomain) </s> remove for _, ip := range ips { if ipv4 := ip.To4(); ipv4 != nil { </s> add for _, ipAddr := range ipAddrs { if ipv4 := ipAddr.IP.To4(); ipv4 != nil { </s> remove if !ok { t.Fatalf("Failed to get safesearch domain for %s", domain) } </s> add assert.Truef(t, ok, "Failed to get safesearch domain for %s", domain) </s> remove if err != nil { t.Errorf("Error while matching host %s: %s", hostname, err) } if !res.IsFiltered { t.Errorf("Expected hostname %s to match", hostname) } if len(res.Rules) == 0 { t.Errorf("Expected result to have rules") return } r := res.Rules[0] if r.IP == nil || r.IP.String() != ip { t.Errorf("Expected ip %s to match, actual: %v", ip, r.IP) </s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err) assert.Truef(t, res.IsFiltered, "Expected hostname %s to match", hostname) if assert.NotEmpty(t, res.Rules, "Expected result to have rules") { r := res.Rules[0] assert.NotNilf(t, r.IP, "Expected ip %s to match, actual: %v", ip, r.IP) assert.Equalf(t, ip, r.IP.String(), "Expected ip %s to match, actual: %v", ip, r.IP) </s> remove if gctx.safebrowsingCache != nil { gctx.safebrowsingCache.Clear() } if gctx.parentalCache != nil { gctx.parentalCache.Clear() } if gctx.safeSearchCache != nil { gctx.safeSearchCache.Clear() </s> add for _, c := range []cache.Cache{ gctx.safebrowsingCache, gctx.parentalCache, gctx.safeSearchCache, } { if c != nil { c.Clear() }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
// Parental.
<mask> assert.True(t, cachedValue.Rules[0].IP.Equal(ip)) <mask> } <mask> } <mask> <mask> // PARENTAL <mask> <mask> func TestParentalControl(t *testing.T) { <mask> logOutput := &bytes.Buffer{} <mask> testutil.ReplaceLogWriter(t, logOutput) <mask> testutil.ReplaceLogLevel(t, log.DEBUG) </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // SAFE BROWSING </s> add // Safe Browsing. </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil) defer d.Close() d.checkMatch(t, "wmconvirus.narod.ru") </s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil) t.Cleanup(d.Close) matching := "wmconvirus.narod.ru" d.safeBrowsingUpstream = &testSbUpstream{ hostname: matching, block: true, } d.checkMatch(t, matching) </s> remove d := NewForTest(&Config{ParentalEnabled: true}, nil) defer d.Close() d.checkMatch(t, "pornhub.com") assert.Contains(t, logOutput.String(), "Parental lookup for pornhub.com") d.checkMatch(t, "www.pornhub.com") </s> add d := newForTest(&Config{ParentalEnabled: true}, nil) t.Cleanup(d.Close) matching := "pornhub.com" d.parentalUpstream = &testSbUpstream{ hostname: matching, block: true, } d.checkMatch(t, matching) assert.Contains(t, logOutput.String(), "Parental lookup for "+matching) d.checkMatch(t, "www."+matching) </s> remove // HELPERS // SAFE BROWSING // SAFE SEARCH // PARENTAL // FILTERING // BENCHMARKS // HELPERS </s> add // Helpers. </s> remove // Check host for each domain for _, host := range googleDomains { res, err := d.CheckHost(host, dns.TypeA, &setts) assert.Nil(t, err) assert.True(t, res.IsFiltered) if assert.Len(t, res.Rules, 1) { assert.NotEqual(t, res.Rules[0].IP.String(), "0.0.0.0") } </s> add func TestCheckHostSafeSearchGoogle(t *testing.T) { d := newForTest(&Config{SafeSearchEnabled: true}, nil) t.Cleanup(d.Close) d.resolver = &testResolver{} // Check host for each domain. for _, host := range []string{ "www.google.com", "www.google.im", "www.google.co.in", "www.google.iq", "www.google.is", "www.google.it", "www.google.je", } { t.Run(host, func(t *testing.T) { res, err := d.CheckHost(host, dns.TypeA, &setts) assert.Nil(t, err) assert.True(t, res.IsFiltered) assert.Len(t, res.Rules, 1) })
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
d := newForTest(&Config{ParentalEnabled: true}, nil) t.Cleanup(d.Close) matching := "pornhub.com" d.parentalUpstream = &testSbUpstream{ hostname: matching, block: true, } d.checkMatch(t, matching) assert.Contains(t, logOutput.String(), "Parental lookup for "+matching) d.checkMatch(t, "www."+matching)
<mask> logOutput := &bytes.Buffer{} <mask> testutil.ReplaceLogWriter(t, logOutput) <mask> testutil.ReplaceLogLevel(t, log.DEBUG) <mask> <mask> d := NewForTest(&Config{ParentalEnabled: true}, nil) <mask> defer d.Close() <mask> d.checkMatch(t, "pornhub.com") <mask> assert.Contains(t, logOutput.String(), "Parental lookup for pornhub.com") <mask> d.checkMatch(t, "www.pornhub.com") <mask> d.checkMatchEmpty(t, "www.yandex.ru") <mask> d.checkMatchEmpty(t, "yandex.ru") <mask> d.checkMatchEmpty(t, "api.jquery.com") <mask> <mask> // test cached result </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil) defer d.Close() d.checkMatch(t, "wmconvirus.narod.ru") </s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil) t.Cleanup(d.Close) matching := "wmconvirus.narod.ru" d.safeBrowsingUpstream = &testSbUpstream{ hostname: matching, block: true, } d.checkMatch(t, matching) </s> remove d.checkMatch(t, "test.wmconvirus.narod.ru") </s> add d.checkMatch(t, "test."+matching) </s> remove assert.Contains(t, logOutput.String(), "SafeBrowsing lookup for wmconvirus.narod.ru") </s> add assert.Contains(t, logOutput.String(), "SafeBrowsing lookup for "+matching) </s> remove d.checkMatch(t, "pornhub.com") </s> add d.checkMatch(t, matching) </s> remove // test cached result </s> add // Cached result.
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go
d.checkMatch(t, matching)
<mask> d.checkMatchEmpty(t, "api.jquery.com") <mask> <mask> // test cached result <mask> d.parentalServer = "127.0.0.1" <mask> d.checkMatch(t, "pornhub.com") <mask> d.checkMatchEmpty(t, "yandex.ru") <mask> d.parentalServer = defaultParentalServer <mask> } <mask> <mask> // FILTERING </s> Pull request: 2574 external tests vol.1 Merge in DNS/adguard-home from 2574-external-tests to master Updates #2574. Squashed commit of the following: commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29 Merge: 2a073431 eeeb0383 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:43:41 2021 +0300 Merge branch 'master' into 2574-external-tests commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 15:16:40 2021 +0300 dnsfilter: imp docs commit 49aff871282e2739d27fcbceefdf1bd005c21174 Author: Eugene Burkov <[email protected]> Date: Fri Jan 29 14:10:56 2021 +0300 dnsfilter: imp docs commit 11be89a5378c0e451f1b88dc48a2e8827ba38358 Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 21:20:55 2021 +0300 dnsfilter: fix go version trouble commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc Author: Eugene Burkov <[email protected]> Date: Thu Jan 28 17:42:29 2021 +0300 dnsfilter: imp tests </s> remove // test cached result </s> add // Cached result. </s> remove d.checkMatch(t, "test.wmconvirus.narod.ru") </s> add d.checkMatch(t, "test."+matching) </s> remove d.checkMatch(t, "wmconvirus.narod.ru") </s> add d.checkMatch(t, matching) </s> remove d := NewForTest(&Config{ParentalEnabled: true}, nil) defer d.Close() d.checkMatch(t, "pornhub.com") assert.Contains(t, logOutput.String(), "Parental lookup for pornhub.com") d.checkMatch(t, "www.pornhub.com") </s> add d := newForTest(&Config{ParentalEnabled: true}, nil) t.Cleanup(d.Close) matching := "pornhub.com" d.parentalUpstream = &testSbUpstream{ hostname: matching, block: true, } d.checkMatch(t, matching) assert.Contains(t, logOutput.String(), "Parental lookup for "+matching) d.checkMatch(t, "www."+matching) </s> remove d.checkMatch(t, "wmconvirus.narod.ru") d.checkMatch(t, "test.wmconvirus.narod.ru") </s> add d.checkMatch(t, matching) d.checkMatch(t, "test."+matching)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc
internal/dnsfilter/dnsfilter_test.go