docstring_tokens
stringlengths
18
16.9k
code_tokens
stringlengths
75
1.81M
html_url
stringlengths
74
116
file_name
stringlengths
3
311
keep keep replace keep keep keep keep replace
<mask> Filter: filtering.Filter{ID: 1}, <mask> Enabled: true, <mask> URL: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt", <mask> Name: "AdGuard DNS filter", <mask> }, { <mask> Filter: filtering.Filter{ID: 2}, <mask> Enabled: false, <mask> URL: "https://adaway.org/hosts.txt", </s> Pull request: 5238-default-filter-urls Updates #5238. Squashed commit of the following: commit 6a1b58bfa0f0bb8cc924e294485e8f650ce7f7aa Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Dec 8 14:18:54 2022 +0300 all: upd go in github actions commit 98366880dc32290258dfae152be069cb84ed86c6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Dec 8 14:08:36 2022 +0300 home: sync default filter urls </s> add // NOTE: Keep these parameters in sync with the one put into // client/src/helpers/filters/filters.js by scripts/vetted-filters. // // TODO(a.garipov): Think of a way to make scripts/vetted-filters update // these as well if necessary. </s> remove 'GO_VERSION': '1.18.8' </s> add 'GO_VERSION': '1.18.9' </s> remove 'GO_VERSION': '1.18.8' </s> add 'GO_VERSION': '1.18.9'
https://github.com/AdguardTeam/AdGuardHome/commit/8d453e75a457bd0f6048e7e01ce7ca6f73779a0b
internal/home/config.go
keep add keep keep keep keep keep
<mask> "net/http" <mask> "os" <mask> "sort" <mask> "strconv" <mask> "strings" <mask> "sync" <mask> "time" </s> + control: /install/check_config: Check and deactivate DNSStubListener </s> add "syscall" </s> add if errorIsAddrInUse(err) { canAutofix := checkDNSStubListener() if canAutofix && reqData.DNS.Autofix { err = disableDNSStubListener() if err != nil { log.Error("Couldn't disable DNSStubListener: %s", err) } err = checkPacketPortAvailable(reqData.DNS.IP, reqData.DNS.Port) canAutofix = false } respData.DNS.CanAutofix = canAutofix } </s> remove if reqData.DNS.Port != 0 && reqData.DNS.Port != config.DNS.Port { </s> add if reqData.DNS.Port != 0 {
https://github.com/AdguardTeam/AdGuardHome/commit/8d936b5756cb93741a4162edb778b86ac1f78e72
control.go
keep keep keep keep replace keep keep keep keep keep
<mask> respData.Web.Status = fmt.Sprintf("%v", err) <mask> } <mask> } <mask> <mask> if reqData.DNS.Port != 0 && reqData.DNS.Port != config.DNS.Port { <mask> err = checkPacketPortAvailable(reqData.DNS.IP, reqData.DNS.Port) <mask> if err != nil { <mask> respData.DNS.Status = fmt.Sprintf("%v", err) <mask> } <mask> } </s> + control: /install/check_config: Check and deactivate DNSStubListener </s> add "syscall" </s> add if errorIsAddrInUse(err) { canAutofix := checkDNSStubListener() if canAutofix && reqData.DNS.Autofix { err = disableDNSStubListener() if err != nil { log.Error("Couldn't disable DNSStubListener: %s", err) } err = checkPacketPortAvailable(reqData.DNS.IP, reqData.DNS.Port) canAutofix = false } respData.DNS.CanAutofix = canAutofix } </s> add "os/exec"
https://github.com/AdguardTeam/AdGuardHome/commit/8d936b5756cb93741a4162edb778b86ac1f78e72
control.go
keep keep add keep keep keep keep
<mask> <mask> if reqData.DNS.Port != 0 { <mask> err = checkPacketPortAvailable(reqData.DNS.IP, reqData.DNS.Port) <mask> if err != nil { <mask> respData.DNS.Status = fmt.Sprintf("%v", err) <mask> } <mask> } </s> + control: /install/check_config: Check and deactivate DNSStubListener </s> add "syscall" </s> remove if reqData.DNS.Port != 0 && reqData.DNS.Port != config.DNS.Port { </s> add if reqData.DNS.Port != 0 { </s> add "os/exec"
https://github.com/AdguardTeam/AdGuardHome/commit/8d936b5756cb93741a4162edb778b86ac1f78e72
control.go
keep keep keep add keep keep keep keep keep
<mask> "path/filepath" <mask> "runtime" <mask> "strconv" <mask> "strings" <mask> "time" <mask> <mask> "github.com/AdguardTeam/dnsproxy/upstream" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/joomcode/errorx" </s> + control: /install/check_config: Check and deactivate DNSStubListener </s> add if errorIsAddrInUse(err) { canAutofix := checkDNSStubListener() if canAutofix && reqData.DNS.Autofix { err = disableDNSStubListener() if err != nil { log.Error("Couldn't disable DNSStubListener: %s", err) } err = checkPacketPortAvailable(reqData.DNS.IP, reqData.DNS.Port) canAutofix = false } respData.DNS.CanAutofix = canAutofix } </s> remove if reqData.DNS.Port != 0 && reqData.DNS.Port != config.DNS.Port { </s> add if reqData.DNS.Port != 0 { </s> add "os/exec"
https://github.com/AdguardTeam/AdGuardHome/commit/8d936b5756cb93741a4162edb778b86ac1f78e72
helpers.go
keep keep keep keep replace keep keep keep keep keep
<mask> package home <mask> <mask> import ( <mask> "io/ioutil" <mask> "net/http" <mask> "os" <mask> "path/filepath" <mask> "sync" <mask> "time" <mask> </s> * move HTTP server code </s> remove "github.com/NYTimes/gziphandler" "github.com/gobuffalo/packr" </s> add </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove stopHTTPServer() </s> add if Context.web != nil { Context.web.Close() Context.web = nil } if Context.auth != nil { Context.auth.Close() Context.auth = nil } </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove startWeb() </s> add Context.web.Start() </s> remove err = initWeb() if err != nil { log.Fatalf("%s", err) </s> add sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { log.Fatalf("Couldn't initialize Auth module") } config.Users = nil webConf := WebConfig{ firstRun: Context.firstRun, BindHost: config.BindHost, BindPort: config.BindPort, TLS: config.TLS, } Context.web = CreateWeb(&webConf) if Context.web == nil { log.Fatalf("Can't initialize Web module")
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/config.go
keep keep keep keep replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> LogFile string `yaml:"log_file"` // Path to the log file. If empty, write to stdout. If "syslog", writes to syslog <mask> Verbose bool `yaml:"verbose"` // If true, verbose logging is enabled <mask> } <mask> <mask> // HTTPSServer - HTTPS Server <mask> type HTTPSServer struct { <mask> server *http.Server <mask> cond *sync.Cond // reacts to config.TLS.Enabled, PortHTTPS, CertificateChain and PrivateKey <mask> sync.Mutex // protects config.TLS <mask> shutdown bool // if TRUE, don't restart the server <mask> } <mask> <mask> // configuration is loaded from YAML <mask> // field ordering is important -- yaml fields will mirror ordering from here <mask> type configuration struct { <mask> // Raw file data to avoid re-reading of configuration file <mask> // It's reset after config is parsed </s> * move HTTP server code </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove clients clientsContainer // per-client-settings module stats stats.Stats // statistics module queryLog querylog.QueryLog // query log module dnsServer *dnsforward.Server // DNS module rdns *RDNS // rDNS module whois *Whois // WHOIS module dnsFilter *dnsfilter.Dnsfilter // DNS filtering module dhcpServer *dhcpd.Server // DHCP module auth *Auth // HTTP authentication module httpServer *http.Server // HTTP module httpsServer HTTPSServer // HTTPS module filters Filtering </s> add clients clientsContainer // per-client-settings module stats stats.Stats // statistics module queryLog querylog.QueryLog // query log module dnsServer *dnsforward.Server // DNS module rdns *RDNS // rDNS module whois *Whois // WHOIS module dnsFilter *dnsfilter.Dnsfilter // DNS filtering module dhcpServer *dhcpd.Server // DHCP module auth *Auth // HTTP authentication module filters Filtering web *Web </s> remove Context.httpsServer.cond.L.Lock() Context.httpsServer.cond.Broadcast() if Context.httpsServer.server != nil { Context.httpsServer.server.Shutdown(context.TODO()) </s> add Context.web.httpsServer.cond.L.Lock() Context.web.httpsServer.cond.Broadcast() if Context.web.httpsServer.server != nil { Context.web.httpsServer.server.Shutdown(context.TODO()) </s> remove _ = Context.httpServer.Shutdown(context.TODO()) </s> add _ = Context.web.httpServer.Shutdown(context.TODO()) </s> remove if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.httpsServer.server != nil { </s> add if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.web.httpsServer.server != nil { </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil {
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/config.go
keep keep keep keep replace keep keep keep keep keep
<mask> return <mask> } <mask> <mask> // enforce https? <mask> if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.httpsServer.server != nil { <mask> // yes, and we want host from host:port <mask> host, _, err := net.SplitHostPort(r.Host) <mask> if err != nil { <mask> // no port in host <mask> host = r.Host </s> * move HTTP server code </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove err = initWeb() if err != nil { log.Fatalf("%s", err) </s> add sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { log.Fatalf("Couldn't initialize Auth module") } config.Users = nil webConf := WebConfig{ firstRun: Context.firstRun, BindHost: config.BindHost, BindPort: config.BindPort, TLS: config.TLS, } Context.web = CreateWeb(&webConf) if Context.web == nil { log.Fatalf("Can't initialize Web module") </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove stopHTTPServer() </s> add if Context.web != nil { Context.web.Close() Context.web = nil } if Context.auth != nil { Context.auth.Close() Context.auth = nil }
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/control.go
keep keep keep keep replace keep keep keep keep keep
<mask> // this needs to be done in a goroutine because Shutdown() is a blocking call, and it will block <mask> // until all requests are finished, and _we_ are inside a request right now, so it will block indefinitely <mask> if restartHTTP { <mask> go func() { <mask> _ = Context.httpServer.Shutdown(context.TODO()) <mask> }() <mask> } <mask> <mask> returnOK(w) <mask> } </s> * move HTTP server code </s> remove Context.httpsServer.cond.L.Lock() Context.httpsServer.cond.Broadcast() if Context.httpsServer.server != nil { Context.httpsServer.server.Shutdown(context.TODO()) </s> add Context.web.httpsServer.cond.L.Lock() Context.web.httpsServer.cond.Broadcast() if Context.web.httpsServer.server != nil { Context.web.httpsServer.server.Shutdown(context.TODO()) </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond // reacts to config.TLS.Enabled, PortHTTPS, CertificateChain and PrivateKey sync.Mutex // protects config.TLS shutdown bool // if TRUE, don't restart the server } </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/control_install.go
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> // check if port is available <mask> // BUT: if we are already using this port, no need <mask> alreadyRunning := false <mask> if Context.httpsServer.server != nil { <mask> alreadyRunning = true <mask> } <mask> if !alreadyRunning { <mask> err = util.CheckPortAvailable(config.BindHost, data.PortHTTPS) <mask> if err != nil { </s> * move HTTP server code </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.httpsServer.server != nil { </s> add if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.web.httpsServer.server != nil { </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove err = initWeb() if err != nil { log.Fatalf("%s", err) </s> add sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { log.Fatalf("Couldn't initialize Auth module") } config.Users = nil webConf := WebConfig{ firstRun: Context.firstRun, BindHost: config.BindHost, BindPort: config.BindPort, TLS: config.TLS, } Context.web = CreateWeb(&webConf) if Context.web == nil { log.Fatalf("Can't initialize Web module") </s> remove stopHTTPServer() </s> add if Context.web != nil { Context.web.Close() Context.web = nil } if Context.auth != nil { Context.auth.Close() Context.auth = nil }
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/control_tls.go
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> // check if port is available <mask> // BUT: if we are already using this port, no need <mask> alreadyRunning := false <mask> if Context.httpsServer.server != nil { <mask> alreadyRunning = true <mask> } <mask> if !alreadyRunning { <mask> err = util.CheckPortAvailable(config.BindHost, data.PortHTTPS) <mask> if err != nil { </s> * move HTTP server code
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/control_tls.go
keep keep keep replace replace replace replace keep replace keep keep keep
<mask> if restartHTTPS { <mask> go func() { <mask> time.Sleep(time.Second) // TODO: could not find a way to reliably know that data was fully sent to client by https server, so we wait a bit to let response through before closing the server <mask> Context.httpsServer.cond.L.Lock() <mask> Context.httpsServer.cond.Broadcast() <mask> if Context.httpsServer.server != nil { <mask> Context.httpsServer.server.Shutdown(context.TODO()) <mask> } <mask> Context.httpsServer.cond.L.Unlock() <mask> }() <mask> } <mask> } </s> * move HTTP server code </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove _ = Context.httpServer.Shutdown(context.TODO()) </s> add _ = Context.web.httpServer.Shutdown(context.TODO()) </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil {
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/control_tls.go
keep keep keep keep replace replace keep keep keep keep keep
<mask> "github.com/AdguardTeam/AdGuardHome/dnsforward" <mask> "github.com/AdguardTeam/AdGuardHome/querylog" <mask> "github.com/AdguardTeam/AdGuardHome/stats" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/NYTimes/gziphandler" <mask> "github.com/gobuffalo/packr" <mask> ) <mask> <mask> const ( <mask> // Used in config to indicate that syslog or eventlog (win) should be used for logger output <mask> configSyslog = "syslog" </s> * move HTTP server code </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond // reacts to config.TLS.Enabled, PortHTTPS, CertificateChain and PrivateKey sync.Mutex // protects config.TLS shutdown bool // if TRUE, don't restart the server } </s> add </s> remove _ = Context.httpServer.Shutdown(context.TODO()) </s> add _ = Context.web.httpServer.Shutdown(context.TODO()) </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove "net/http" </s> add </s> remove if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.httpsServer.server != nil { </s> add if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.web.httpsServer.server != nil {
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/home.go
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> type homeContext struct { <mask> // Modules <mask> // -- <mask> <mask> clients clientsContainer // per-client-settings module <mask> stats stats.Stats // statistics module <mask> queryLog querylog.QueryLog // query log module <mask> dnsServer *dnsforward.Server // DNS module <mask> rdns *RDNS // rDNS module <mask> whois *Whois // WHOIS module <mask> dnsFilter *dnsfilter.Dnsfilter // DNS filtering module <mask> dhcpServer *dhcpd.Server // DHCP module <mask> auth *Auth // HTTP authentication module <mask> httpServer *http.Server // HTTP module <mask> httpsServer HTTPSServer // HTTPS module <mask> filters Filtering <mask> <mask> // Runtime properties <mask> // -- <mask> <mask> configFilename string // Config filename (can be overridden via the command line arguments) </s> * move HTTP server code </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond // reacts to config.TLS.Enabled, PortHTTPS, CertificateChain and PrivateKey sync.Mutex // protects config.TLS shutdown bool // if TRUE, don't restart the server } </s> add </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.httpsServer.server != nil { </s> add if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.web.httpsServer.server != nil { </s> remove _ = Context.httpServer.Shutdown(context.TODO()) </s> add _ = Context.web.httpServer.Shutdown(context.TODO()) </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil {
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/home.go
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> if err != nil { <mask> log.Fatalf("Cannot create DNS data dir at %s: %s", Context.getDataDir(), err) <mask> } <mask> <mask> err = initWeb() <mask> if err != nil { <mask> log.Fatalf("%s", err) <mask> } <mask> <mask> if !Context.firstRun { <mask> err := initDNSServer() <mask> if err != nil { </s> * move HTTP server code </s> remove stopHTTPServer() </s> add if Context.web != nil { Context.web.Close() Context.web = nil } if Context.auth != nil { Context.auth.Close() Context.auth = nil } </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.httpsServer.server != nil { </s> add if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.web.httpsServer.server != nil { </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/home.go
keep keep keep keep replace keep keep keep keep keep
<mask> log.Fatal(err) <mask> } <mask> } <mask> <mask> startWeb() <mask> <mask> // wait indefinitely for other go-routines to complete their job <mask> select {} <mask> } <mask> </s> * move HTTP server code </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove Context.httpsServer.cond.L.Lock() Context.httpsServer.cond.Broadcast() if Context.httpsServer.server != nil { Context.httpsServer.server.Shutdown(context.TODO()) </s> add Context.web.httpsServer.cond.L.Lock() Context.web.httpsServer.cond.Broadcast() if Context.web.httpsServer.server != nil { Context.web.httpsServer.server.Shutdown(context.TODO()) </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove _ = Context.httpServer.Shutdown(context.TODO()) </s> add _ = Context.web.httpServer.Shutdown(context.TODO()) </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond // reacts to config.TLS.Enabled, PortHTTPS, CertificateChain and PrivateKey sync.Mutex // protects config.TLS shutdown bool // if TRUE, don't restart the server } </s> add </s> remove Context.httpsServer.cond.L.Unlock() </s> add Context.web.httpsServer.cond.L.Unlock()
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/home.go
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> // wait indefinitely for other go-routines to complete their job <mask> select {} <mask> } <mask> <mask> // Initialize Web modules <mask> func initWeb() error { <mask> sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") <mask> Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) <mask> if Context.auth == nil { <mask> return fmt.Errorf("Couldn't initialize Auth module") <mask> } <mask> config.Users = nil <mask> <mask> // Initialize and run the admin Web interface <mask> box := packr.NewBox("../build/static") <mask> <mask> // if not configured, redirect / to /install.html, otherwise redirect /install.html to / <mask> http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) <mask> <mask> // add handlers for /install paths, we only need them when we're not configured yet <mask> if Context.firstRun { <mask> log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") <mask> http.Handle("/install.html", preInstallHandler(http.FileServer(box))) <mask> registerInstallHandlers() <mask> } else { <mask> registerControlHandlers() <mask> } <mask> <mask> Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) <mask> return nil <mask> } <mask> <mask> func startWeb() { <mask> // for https, we have a separate goroutine loop <mask> go httpServerLoop() <mask> <mask> // this loop is used as an ability to change listening host and/or port <mask> for !Context.httpsServer.shutdown { <mask> printHTTPAddresses("http") <mask> <mask> // we need to have new instance, because after Shutdown() the Server is not usable <mask> address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) <mask> Context.httpServer = &http.Server{ <mask> Addr: address, <mask> } <mask> err := Context.httpServer.ListenAndServe() <mask> if err != http.ErrServerClosed { <mask> cleanupAlways() <mask> log.Fatal(err) <mask> } <mask> // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop <mask> } <mask> } <mask> <mask> func httpServerLoop() { <mask> for !Context.httpsServer.shutdown { <mask> Context.httpsServer.cond.L.Lock() <mask> // this mechanism doesn't let us through until all conditions are met <mask> for config.TLS.Enabled == false || <mask> config.TLS.PortHTTPS == 0 || <mask> len(config.TLS.PrivateKeyData) == 0 || <mask> len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied <mask> Context.httpsServer.cond.Wait() <mask> } <mask> address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) <mask> // validate current TLS config and update warnings (it could have been loaded from file) <mask> data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) <mask> if !data.ValidPair { <mask> cleanupAlways() <mask> log.Fatal(data.WarningValidation) <mask> } <mask> config.Lock() <mask> config.TLS.tlsConfigStatus = data // update warnings <mask> config.Unlock() <mask> <mask> // prepare certs for HTTPS server <mask> // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests <mask> certchain := make([]byte, len(config.TLS.CertificateChainData)) <mask> copy(certchain, config.TLS.CertificateChainData) <mask> privatekey := make([]byte, len(config.TLS.PrivateKeyData)) <mask> copy(privatekey, config.TLS.PrivateKeyData) <mask> cert, err := tls.X509KeyPair(certchain, privatekey) <mask> if err != nil { <mask> cleanupAlways() <mask> log.Fatal(err) <mask> } <mask> Context.httpsServer.cond.L.Unlock() <mask> <mask> // prepare HTTPS server <mask> Context.httpsServer.server = &http.Server{ <mask> Addr: address, <mask> TLSConfig: &tls.Config{ <mask> Certificates: []tls.Certificate{cert}, <mask> MinVersion: tls.VersionTLS12, <mask> RootCAs: Context.tlsRoots, <mask> }, <mask> } <mask> <mask> printHTTPAddresses("https") <mask> err = Context.httpsServer.server.ListenAndServeTLS("", "") <mask> if err != http.ErrServerClosed { <mask> cleanupAlways() <mask> log.Fatal(err) <mask> } <mask> } <mask> } <mask> <mask> // Check if the current user has root (administrator) rights <mask> // and if not, ask and try to run as root <mask> func requireAdminRights() { <mask> admin, _ := util.HaveAdminRights() <mask> if //noinspection ALL </s> * move HTTP server code </s> remove Context.httpsServer.cond.L.Lock() Context.httpsServer.cond.Broadcast() if Context.httpsServer.server != nil { Context.httpsServer.server.Shutdown(context.TODO()) </s> add Context.web.httpsServer.cond.L.Lock() Context.web.httpsServer.cond.Broadcast() if Context.web.httpsServer.server != nil { Context.web.httpsServer.server.Shutdown(context.TODO()) </s> remove if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.httpsServer.server != nil { </s> add if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.web.httpsServer.server != nil { </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove err = initWeb() if err != nil { log.Fatalf("%s", err) </s> add sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { log.Fatalf("Couldn't initialize Auth module") } config.Users = nil webConf := WebConfig{ firstRun: Context.firstRun, BindHost: config.BindHost, BindPort: config.BindPort, TLS: config.TLS, } Context.web = CreateWeb(&webConf) if Context.web == nil { log.Fatalf("Can't initialize Web module") </s> remove _ = Context.httpServer.Shutdown(context.TODO()) </s> add _ = Context.web.httpServer.Shutdown(context.TODO()) </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil {
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/home.go
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> func cleanup() { <mask> log.Info("Stopping AdGuard Home") <mask> <mask> stopHTTPServer() <mask> <mask> err := stopDNSServer() <mask> if err != nil { <mask> log.Error("Couldn't stop DNS server: %s", err) <mask> } </s> * move HTTP server code </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove err = initWeb() if err != nil { log.Fatalf("%s", err) </s> add sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { log.Fatalf("Couldn't initialize Auth module") } config.Users = nil webConf := WebConfig{ firstRun: Context.firstRun, BindHost: config.BindHost, BindPort: config.BindPort, TLS: config.TLS, } Context.web = CreateWeb(&webConf) if Context.web == nil { log.Fatalf("Can't initialize Web module") </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.httpsServer.server != nil { </s> add if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.web.httpsServer.server != nil {
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/home.go
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> log.Error("Couldn't stop DHCP server: %s", err) <mask> } <mask> } <mask> <mask> // Stop HTTP server, possibly waiting for all active connections to be closed <mask> func stopHTTPServer() { <mask> log.Info("Stopping HTTP server...") <mask> Context.httpsServer.shutdown = true <mask> if Context.httpsServer.server != nil { <mask> _ = Context.httpsServer.server.Shutdown(context.TODO()) <mask> } <mask> if Context.httpServer != nil { <mask> _ = Context.httpServer.Shutdown(context.TODO()) <mask> } <mask> <mask> if Context.auth != nil { <mask> Context.auth.Close() <mask> Context.auth = nil <mask> } <mask> <mask> log.Info("Stopped HTTP server") <mask> } <mask> <mask> // This function is called before application exits <mask> func cleanupAlways() { <mask> if len(Context.pidFileName) != 0 { <mask> _ = os.Remove(Context.pidFileName) <mask> } </s> * move HTTP server code </s> remove stopHTTPServer() </s> add if Context.web != nil { Context.web.Close() Context.web = nil } if Context.auth != nil { Context.auth.Close() Context.auth = nil } </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove err = initWeb() if err != nil { log.Fatalf("%s", err) </s> add sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { log.Fatalf("Couldn't initialize Auth module") } config.Users = nil webConf := WebConfig{ firstRun: Context.firstRun, BindHost: config.BindHost, BindPort: config.BindPort, TLS: config.TLS, } Context.web = CreateWeb(&webConf) if Context.web == nil { log.Fatalf("Can't initialize Web module") </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove _ = Context.httpServer.Shutdown(context.TODO()) </s> add _ = Context.web.httpServer.Shutdown(context.TODO())
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/home.go
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> .modal-body--medium { <mask> max-height: 20rem; <mask> overflow-y: scroll; <mask> } <mask> <mask> .modal-body__item:not(:first-child) { <mask> padding-top: 1.5rem; <mask> } </s> Pull request: 3395 fix table scroll styles Closes #3395 Squashed commit of the following: commit 63fd4593977cd2ac6595344f681df499dc62abb1 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Aug 16 11:58:26 2021 +0300 client: fix table scroll styles </s> remove overflow-y: scroll; </s> add overflow-y: auto; </s> remove overflow-y: scroll; </s> add overflow-y: auto;
https://github.com/AdguardTeam/AdGuardHome/commit/8e667d3cc4551cec2438b4f0f4fdf7749d4a7ed3
client/src/components/App/index.css
keep keep keep keep replace keep keep keep keep keep
<mask> border-radius: 4px !important; <mask> pointer-events: auto !important; <mask> background-color: var(--white); <mask> z-index: 102; <mask> overflow-y: scroll; <mask> max-height: 100%; <mask> } <mask> <mask> .white-space--nowrap { <mask> white-space: nowrap !important; </s> Pull request: 3395 fix table scroll styles Closes #3395 Squashed commit of the following: commit 63fd4593977cd2ac6595344f681df499dc62abb1 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Aug 16 11:58:26 2021 +0300 client: fix table scroll styles </s> remove overflow-y: scroll; </s> add overflow-y: auto; </s> remove overflow-y: scroll; </s> add overflow-y: auto;
https://github.com/AdguardTeam/AdGuardHome/commit/8e667d3cc4551cec2438b4f0f4fdf7749d4a7ed3
client/src/components/Logs/Cells/IconTooltip.css
keep keep keep keep replace keep keep keep keep keep
<mask> width: 100%; <mask> border-collapse: collapse; <mask> contain: layout; <mask> overflow-x: hidden; <mask> overflow-y: scroll; <mask> will-change: scroll-position; <mask> } <mask> <mask> .logs__table .logs__cell--response, <mask> .logs__table .logs__cell--client { </s> Pull request: 3395 fix table scroll styles Closes #3395 Squashed commit of the following: commit 63fd4593977cd2ac6595344f681df499dc62abb1 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Aug 16 11:58:26 2021 +0300 client: fix table scroll styles </s> remove overflow-y: scroll; </s> add overflow-y: auto; </s> remove overflow-y: scroll; </s> add overflow-y: auto;
https://github.com/AdguardTeam/AdGuardHome/commit/8e667d3cc4551cec2438b4f0f4fdf7749d4a7ed3
client/src/components/Logs/Logs.css
keep keep keep keep replace keep
<mask> "use_saved_key": "Use the previously saved key", <mask> "parental_control": "Parental Control", <mask> "safe_browsing": "Safe Browsing", <mask> "served_from_cache": "{{value}} <i>(served from cache)</i>", <mask> "form_error_password_length": "Password must be at least {{value}} characters long" <mask> } </s> Pull request: 4913 IP anonymizer notification Updates #4913 Squashed commit of the following: commit baa63c647bdecf10a2c5e91568231864c423c4c3 Merge: 70de6540 9ffe0787 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Sep 19 18:53:24 2022 +0300 Merge branch 'master' into 4913-anonymizer-notification commit 70de65405fa34ba764408ce1331f90ec0ef7aec2 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Sep 19 18:03:52 2022 +0300 client: fix text commit e6d8db0086903fe61b0aa511807e97dd12bd571c Author: Ildar Kamalov <ik@adguard.com> Date: Fri Sep 16 20:37:42 2022 +0300 client: IP anonymizer notification </s> add anonymize_client_ip: anonymizeClientIp, </s> add import AnonymizerNotification from './AnonymizerNotification'; </s> remove return <> {enabled && processingGetConfig && <Loading />} {enabled && !processingGetConfig && renderPage()} {!enabled && !processingGetConfig && <Disabled />} </>; </s> add return ( <> {enabled && ( <> {processingGetConfig && <Loading />} {anonymizeClientIp && <AnonymizerNotification />} {!processingGetConfig && renderPage()} </> )} {!enabled && !processingGetConfig && <Disabled />} </> );
https://github.com/AdguardTeam/AdGuardHome/commit/8e89cc129cb5b7327975af31dbfaa41f9d7d0dfe
client/src/__locales/en.json
keep keep add keep keep keep keep keep
<mask> import InfiniteTable from './InfiniteTable'; <mask> import './Logs.css'; <mask> import { BUTTON_PREFIX } from './Cells/helpers'; <mask> <mask> const processContent = (data) => Object.entries(data) <mask> .map(([key, value]) => { <mask> if (!value) { <mask> return null; </s> Pull request: 4913 IP anonymizer notification Updates #4913 Squashed commit of the following: commit baa63c647bdecf10a2c5e91568231864c423c4c3 Merge: 70de6540 9ffe0787 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Sep 19 18:53:24 2022 +0300 Merge branch 'master' into 4913-anonymizer-notification commit 70de65405fa34ba764408ce1331f90ec0ef7aec2 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Sep 19 18:03:52 2022 +0300 client: fix text commit e6d8db0086903fe61b0aa511807e97dd12bd571c Author: Ildar Kamalov <ik@adguard.com> Date: Fri Sep 16 20:37:42 2022 +0300 client: IP anonymizer notification </s> add anonymize_client_ip: anonymizeClientIp, </s> remove "form_error_password_length": "Password must be at least {{value}} characters long" </s> add "form_error_password_length": "Password must be at least {{value}} characters long", "anonymizer_notification": "<0>Note:</0> IP anonymization is enabled. You can disable it in <1>General settings</1>." </s> remove return <> {enabled && processingGetConfig && <Loading />} {enabled && !processingGetConfig && renderPage()} {!enabled && !processingGetConfig && <Disabled />} </>; </s> add return ( <> {enabled && ( <> {processingGetConfig && <Loading />} {anonymizeClientIp && <AnonymizerNotification />} {!processingGetConfig && renderPage()} </> )} {!enabled && !processingGetConfig && <Disabled />} </> );
https://github.com/AdguardTeam/AdGuardHome/commit/8e89cc129cb5b7327975af31dbfaa41f9d7d0dfe
client/src/components/Logs/index.js
keep keep add keep keep keep keep
<mask> processingGetConfig, <mask> processingAdditionalLogs, <mask> processingGetLogs, <mask> } = useSelector((state) => state.queryLogs, shallowEqual); <mask> const filter = useSelector((state) => state.queryLogs.filter, shallowEqual); <mask> const logs = useSelector((state) => state.queryLogs.logs, shallowEqual); <mask> </s> Pull request: 4913 IP anonymizer notification Updates #4913 Squashed commit of the following: commit baa63c647bdecf10a2c5e91568231864c423c4c3 Merge: 70de6540 9ffe0787 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Sep 19 18:53:24 2022 +0300 Merge branch 'master' into 4913-anonymizer-notification commit 70de65405fa34ba764408ce1331f90ec0ef7aec2 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Sep 19 18:03:52 2022 +0300 client: fix text commit e6d8db0086903fe61b0aa511807e97dd12bd571c Author: Ildar Kamalov <ik@adguard.com> Date: Fri Sep 16 20:37:42 2022 +0300 client: IP anonymizer notification </s> add import AnonymizerNotification from './AnonymizerNotification'; </s> remove "form_error_password_length": "Password must be at least {{value}} characters long" </s> add "form_error_password_length": "Password must be at least {{value}} characters long", "anonymizer_notification": "<0>Note:</0> IP anonymization is enabled. You can disable it in <1>General settings</1>." </s> remove return <> {enabled && processingGetConfig && <Loading />} {enabled && !processingGetConfig && renderPage()} {!enabled && !processingGetConfig && <Disabled />} </>; </s> add return ( <> {enabled && ( <> {processingGetConfig && <Loading />} {anonymizeClientIp && <AnonymizerNotification />} {!processingGetConfig && renderPage()} </> )} {!enabled && !processingGetConfig && <Disabled />} </> );
https://github.com/AdguardTeam/AdGuardHome/commit/8e89cc129cb5b7327975af31dbfaa41f9d7d0dfe
client/src/components/Logs/index.js
keep keep keep keep replace replace replace replace replace keep keep keep
<mask> {processContent(detailedDataCurrent, buttonType)} <mask> </Modal> <mask> </>; <mask> <mask> return <> <mask> {enabled && processingGetConfig && <Loading />} <mask> {enabled && !processingGetConfig && renderPage()} <mask> {!enabled && !processingGetConfig && <Disabled />} <mask> </>; <mask> }; <mask> <mask> export default Logs; </s> Pull request: 4913 IP anonymizer notification Updates #4913 Squashed commit of the following: commit baa63c647bdecf10a2c5e91568231864c423c4c3 Merge: 70de6540 9ffe0787 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Sep 19 18:53:24 2022 +0300 Merge branch 'master' into 4913-anonymizer-notification commit 70de65405fa34ba764408ce1331f90ec0ef7aec2 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Sep 19 18:03:52 2022 +0300 client: fix text commit e6d8db0086903fe61b0aa511807e97dd12bd571c Author: Ildar Kamalov <ik@adguard.com> Date: Fri Sep 16 20:37:42 2022 +0300 client: IP anonymizer notification </s> add anonymize_client_ip: anonymizeClientIp, </s> add import AnonymizerNotification from './AnonymizerNotification'; </s> remove "form_error_password_length": "Password must be at least {{value}} characters long" </s> add "form_error_password_length": "Password must be at least {{value}} characters long", "anonymizer_notification": "<0>Note:</0> IP anonymization is enabled. You can disable it in <1>General settings</1>."
https://github.com/AdguardTeam/AdGuardHome/commit/8e89cc129cb5b7327975af31dbfaa41f9d7d0dfe
client/src/components/Logs/index.js
keep keep add keep keep keep keep
<mask> log.Fatal(data.WarningValidation) <mask> os.Exit(1) <mask> } <mask> config.TLS = data // update warnings <mask> config.Unlock() <mask> <mask> // prepare certs for HTTPS server </s> Fix data races found by race detector. </s> add config.Unlock() </s> add httpsServer.cond.L.Lock() </s> add httpsServer.cond.L.Unlock()
https://github.com/AdguardTeam/AdGuardHome/commit/8e993cd788d7e5ec4e085e58799b76aa45a393b5
app.go
keep add keep keep keep keep keep
<mask> config.Lock() <mask> config.TLS = data // update warnings <mask> <mask> // prepare certs for HTTPS server <mask> // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests <mask> certchain := make([]byte, len(config.TLS.CertificateChain)) <mask> copy(certchain, []byte(config.TLS.CertificateChain)) </s> Fix data races found by race detector. </s> add config.Lock() </s> add httpsServer.cond.L.Lock() </s> add httpsServer.cond.L.Unlock()
https://github.com/AdguardTeam/AdGuardHome/commit/8e993cd788d7e5ec4e085e58799b76aa45a393b5
app.go
keep add keep keep keep keep keep keep
<mask> go func() { <mask> time.Sleep(time.Second) // TODO: could not find a way to reliably know that data was fully sent to client by https server, so we wait a bit to let response through before closing the server <mask> httpsServer.cond.Broadcast() <mask> if httpsServer.server != nil { <mask> httpsServer.server.Shutdown(context.TODO()) <mask> } <mask> httpsServer.cond.L.Unlock() <mask> }() </s> Fix data races found by race detector. </s> add config.Lock() </s> add config.Unlock() </s> add httpsServer.cond.L.Unlock()
https://github.com/AdguardTeam/AdGuardHome/commit/8e993cd788d7e5ec4e085e58799b76aa45a393b5
control.go
keep add keep keep keep keep keep
<mask> httpsServer.server.Shutdown(context.TODO()) <mask> } <mask> }() <mask> } <mask> } <mask> <mask> func validateCertificates(data tlsConfig) tlsConfig { </s> Fix data races found by race detector. </s> add config.Lock() </s> add httpsServer.cond.L.Lock() </s> add config.Unlock()
https://github.com/AdguardTeam/AdGuardHome/commit/8e993cd788d7e5ec4e085e58799b76aa45a393b5
control.go
keep keep replace keep replace replace keep keep keep keep
<mask> }) => { <mask> const dispatch = useDispatch(); <mask> const [t] = useTranslation(); <mask> const upstream_dns = useSelector((store) => store.form[FORM_NAME.UPSTREAM].values.upstream_dns); <mask> const bootstrap_dns = useSelector((store) => store.form[FORM_NAME.UPSTREAM] <mask> .values.bootstrap_dns); <mask> <mask> const handleUpstreamTest = () => dispatch(testUpstream({ <mask> upstream_dns, <mask> bootstrap_dns, </s> - client: Fix DNS settings </s> remove } = ((state) => state.dnsConfig, shallowEqual); </s> add } = useSelector((state) => state.dnsConfig, shallowEqual); </s> remove import { shallowEqual, useDispatch } from 'react-redux'; </s> add import { shallowEqual, useDispatch, useSelector } from 'react-redux'; </s> remove return ( <Card title={t('upstream_dns')} subtitle={t('upstream_dns_hint')} bodyType="card-body box-body--settings" > <div className="row"> <div className="col"> <Form initialValues={{ upstream_dns, bootstrap_dns, upstream_mode, }} onSubmit={handleSubmit} processingTestUpstream={processingTestUpstream} processingSetConfig={processingSetConfig} /> </div> </s> add return <Card title={t('upstream_dns')} subtitle={t('upstream_dns_hint')} bodyType="card-body box-body--settings" > <div className="row"> <div className="col"> <Form initialValues={{ upstream_dns, bootstrap_dns, upstream_mode, }} onSubmit={handleSubmit} processingTestUpstream={processingTestUpstream} processingSetConfig={processingSetConfig} /> </s> remove </Card> ); </s> add </div> </Card>;
https://github.com/AdguardTeam/AdGuardHome/commit/8ea1e64c7ba8ab2b9618a6fe8c83f570b88ce124
client/src/components/Settings/Dns/Upstream/Form.js
keep keep replace keep keep keep keep keep
<mask> import React from 'react'; <mask> import { useTranslation } from 'react-i18next'; <mask> import { shallowEqual, useDispatch } from 'react-redux'; <mask> import Form from './Form'; <mask> import Card from '../../../ui/Card'; <mask> import { setDnsConfig } from '../../../../actions/dnsConfig'; <mask> <mask> const Upstream = () => { </s> - client: Fix DNS settings </s> remove const [t] = useTranslation(); </s> add const { t } = useTranslation(); </s> remove } = ((state) => state.dnsConfig, shallowEqual); </s> add } = useSelector((state) => state.dnsConfig, shallowEqual); </s> remove const bootstrap_dns = useSelector((store) => store.form[FORM_NAME.UPSTREAM] .values.bootstrap_dns); </s> add const bootstrap_dns = useSelector( (store) => store.form[FORM_NAME.UPSTREAM].values.bootstrap_dns, ); </s> remove return ( <Card title={t('upstream_dns')} subtitle={t('upstream_dns_hint')} bodyType="card-body box-body--settings" > <div className="row"> <div className="col"> <Form initialValues={{ upstream_dns, bootstrap_dns, upstream_mode, }} onSubmit={handleSubmit} processingTestUpstream={processingTestUpstream} processingSetConfig={processingSetConfig} /> </div> </s> add return <Card title={t('upstream_dns')} subtitle={t('upstream_dns_hint')} bodyType="card-body box-body--settings" > <div className="row"> <div className="col"> <Form initialValues={{ upstream_dns, bootstrap_dns, upstream_mode, }} onSubmit={handleSubmit} processingTestUpstream={processingTestUpstream} processingSetConfig={processingSetConfig} /> </s> remove </Card> ); </s> add </div> </Card>;
https://github.com/AdguardTeam/AdGuardHome/commit/8ea1e64c7ba8ab2b9618a6fe8c83f570b88ce124
client/src/components/Settings/Dns/Upstream/index.js
keep keep keep keep replace keep keep keep keep keep
<mask> upstream_dns, <mask> bootstrap_dns, <mask> upstream_mode, <mask> processingSetConfig, <mask> } = ((state) => state.dnsConfig, shallowEqual); <mask> <mask> const { processingTestUpstream } = ((state) => state.settings, shallowEqual); <mask> <mask> const handleSubmit = (values) => { <mask> dispatch(setDnsConfig(values)); </s> - client: Fix DNS settings </s> remove const [t] = useTranslation(); </s> add const { t } = useTranslation(); </s> remove return ( <Card title={t('upstream_dns')} subtitle={t('upstream_dns_hint')} bodyType="card-body box-body--settings" > <div className="row"> <div className="col"> <Form initialValues={{ upstream_dns, bootstrap_dns, upstream_mode, }} onSubmit={handleSubmit} processingTestUpstream={processingTestUpstream} processingSetConfig={processingSetConfig} /> </div> </s> add return <Card title={t('upstream_dns')} subtitle={t('upstream_dns_hint')} bodyType="card-body box-body--settings" > <div className="row"> <div className="col"> <Form initialValues={{ upstream_dns, bootstrap_dns, upstream_mode, }} onSubmit={handleSubmit} processingTestUpstream={processingTestUpstream} processingSetConfig={processingSetConfig} /> </s> remove const bootstrap_dns = useSelector((store) => store.form[FORM_NAME.UPSTREAM] .values.bootstrap_dns); </s> add const bootstrap_dns = useSelector( (store) => store.form[FORM_NAME.UPSTREAM].values.bootstrap_dns, ); </s> remove import { shallowEqual, useDispatch } from 'react-redux'; </s> add import { shallowEqual, useDispatch, useSelector } from 'react-redux'; </s> remove </Card> ); </s> add </div> </Card>;
https://github.com/AdguardTeam/AdGuardHome/commit/8ea1e64c7ba8ab2b9618a6fe8c83f570b88ce124
client/src/components/Settings/Dns/Upstream/index.js
keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep replace replace keep
<mask> }; <mask> <mask> return ( <mask> <Card <mask> title={t('upstream_dns')} <mask> subtitle={t('upstream_dns_hint')} <mask> bodyType="card-body box-body--settings" <mask> > <mask> <div className="row"> <mask> <div className="col"> <mask> <Form <mask> initialValues={{ <mask> upstream_dns, <mask> bootstrap_dns, <mask> upstream_mode, <mask> }} <mask> onSubmit={handleSubmit} <mask> processingTestUpstream={processingTestUpstream} <mask> processingSetConfig={processingSetConfig} <mask> /> <mask> </div> <mask> </div> <mask> </Card> <mask> ); <mask> }; </s> - client: Fix DNS settings </s> remove } = ((state) => state.dnsConfig, shallowEqual); </s> add } = useSelector((state) => state.dnsConfig, shallowEqual); </s> remove import { shallowEqual, useDispatch } from 'react-redux'; </s> add import { shallowEqual, useDispatch, useSelector } from 'react-redux'; </s> remove const bootstrap_dns = useSelector((store) => store.form[FORM_NAME.UPSTREAM] .values.bootstrap_dns); </s> add const bootstrap_dns = useSelector( (store) => store.form[FORM_NAME.UPSTREAM].values.bootstrap_dns, ); </s> remove const [t] = useTranslation(); </s> add const { t } = useTranslation();
https://github.com/AdguardTeam/AdGuardHome/commit/8ea1e64c7ba8ab2b9618a6fe8c83f570b88ce124
client/src/components/Settings/Dns/Upstream/index.js
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> addr := s.dnsProxy.Addr(proxy.ProtoUDP) <mask> <mask> // <mask> // NXDomain blocking <mask> // <mask> req := dns.Msg{} <mask> req.Id = dns.Id() <mask> req.RecursionDesired = true <mask> req.Question = []dns.Question{ </s> * DNS: use REFUSED DNS error code as the default blocking method </s> add // Create REFUSED DNS response func (s *Server) makeResponseREFUSED(request *dns.Msg) *dns.Msg { resp := dns.Msg{} resp.SetRcode(request, dns.RcodeRefused) resp.RecursionAvailable = true return &resp } </s> remove assert.Equal(t, dns.RcodeNameError, reply.Rcode) </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode) </s> remove assert.Equal(t, dns.RcodeNameError, reply.Rcode) </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode) </s> remove // If there is no IP, return NXDOMAIN </s> add // If there is no IP, return REFUSED </s> remove d.Res = s.genNXDomain(d.Req) </s> add d.Res = s.makeResponseREFUSED(d.Req) </s> remove return s.genNXDomain(m) </s> add return s.makeResponseREFUSED(m)
https://github.com/AdguardTeam/AdGuardHome/commit/8f017d2c0e25969bd86eafa4adbc184e41c61dc0
dnsforward/dnsforward_test.go
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> reply, err := dns.Exchange(&req, addr.String()) <mask> if err != nil { <mask> t.Fatalf("Couldn't talk to server %s: %s", addr, err) <mask> } <mask> if reply.Rcode != dns.RcodeNameError { <mask> t.Fatalf("Wrong response: %s", reply.String()) <mask> } <mask> <mask> err = s.Stop() <mask> if err != nil { <mask> t.Fatalf("DNS server failed to stop: %s", err) <mask> } </s> * DNS: use REFUSED DNS error code as the default blocking method </s> remove assert.Equal(t, dns.RcodeNameError, reply.Rcode) </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode) </s> remove return s.genNXDomain(m) </s> add return s.makeResponseREFUSED(m) </s> remove // If there is no IP, return NXDOMAIN </s> add // If there is no IP, return REFUSED </s> remove return s.genNXDomain(m) </s> add return s.makeResponseREFUSED(m) </s> remove d.Res = s.genNXDomain(d.Req) </s> add d.Res = s.makeResponseREFUSED(d.Req) </s> remove assert.Equal(t, dns.RcodeNameError, reply.Rcode) </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode)
https://github.com/AdguardTeam/AdGuardHome/commit/8f017d2c0e25969bd86eafa4adbc184e41c61dc0
dnsforward/dnsforward_test.go
keep keep keep keep replace keep keep keep keep keep
<mask> // response is blocked <mask> req := createTestMessage("badhost.") <mask> reply, err := dns.Exchange(req, addr.String()) <mask> assert.Nil(t, err, nil) <mask> assert.Equal(t, dns.RcodeNameError, reply.Rcode) <mask> <mask> // 'whitelist.example.org' has a canonical name 'null.example.org' which is blocked by filters <mask> // but 'whitelist.example.org' is in a whitelist: <mask> // response isn't blocked <mask> req = createTestMessage("whitelist.example.org.") </s> * DNS: use REFUSED DNS error code as the default blocking method </s> remove assert.Equal(t, dns.RcodeNameError, reply.Rcode) </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode) </s> remove // NXDomain blocking </s> add // Default blocking - REFUSED </s> remove // If there is no IP, return NXDOMAIN </s> add // If there is no IP, return REFUSED </s> remove if reply.Rcode != dns.RcodeNameError { t.Fatalf("Wrong response: %s", reply.String()) } </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode) </s> add // Create REFUSED DNS response func (s *Server) makeResponseREFUSED(request *dns.Msg) *dns.Msg { resp := dns.Msg{} resp.SetRcode(request, dns.RcodeRefused) resp.RecursionAvailable = true return &resp } </s> remove return s.genNXDomain(m) </s> add return s.makeResponseREFUSED(m)
https://github.com/AdguardTeam/AdGuardHome/commit/8f017d2c0e25969bd86eafa4adbc184e41c61dc0
dnsforward/dnsforward_test.go
keep keep keep keep replace keep keep keep keep keep
<mask> // response is blocked <mask> req = createTestMessage("example.org.") <mask> reply, err = dns.Exchange(req, addr.String()) <mask> assert.Nil(t, err) <mask> assert.Equal(t, dns.RcodeNameError, reply.Rcode) <mask> <mask> _ = s.Stop() <mask> } <mask> <mask> func TestClientRulesForCNAMEMatching(t *testing.T) { </s> * DNS: use REFUSED DNS error code as the default blocking method </s> remove assert.Equal(t, dns.RcodeNameError, reply.Rcode) </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode) </s> remove if reply.Rcode != dns.RcodeNameError { t.Fatalf("Wrong response: %s", reply.String()) } </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode) </s> add // Create REFUSED DNS response func (s *Server) makeResponseREFUSED(request *dns.Msg) *dns.Msg { resp := dns.Msg{} resp.SetRcode(request, dns.RcodeRefused) resp.RecursionAvailable = true return &resp } </s> remove // NXDomain blocking </s> add // Default blocking - REFUSED </s> remove d.Res = s.genNXDomain(d.Req) </s> add d.Res = s.makeResponseREFUSED(d.Req) </s> remove return s.genNXDomain(m) </s> add return s.makeResponseREFUSED(m)
https://github.com/AdguardTeam/AdGuardHome/commit/8f017d2c0e25969bd86eafa4adbc184e41c61dc0
dnsforward/dnsforward_test.go
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> // disable Mozilla DoH <mask> if (d.Req.Question[0].Qtype == dns.TypeA || d.Req.Question[0].Qtype == dns.TypeAAAA) && <mask> d.Req.Question[0].Name == "use-application-dns.net." { <mask> d.Res = s.genNXDomain(d.Req) <mask> return resultFinish <mask> } <mask> <mask> return resultDone <mask> } </s> * DNS: use REFUSED DNS error code as the default blocking method </s> remove return s.genNXDomain(m) </s> add return s.makeResponseREFUSED(m) </s> remove return s.genNXDomain(m) </s> add return s.makeResponseREFUSED(m) </s> remove // If there is no IP, return NXDOMAIN </s> add // If there is no IP, return REFUSED </s> add // Create REFUSED DNS response func (s *Server) makeResponseREFUSED(request *dns.Msg) *dns.Msg { resp := dns.Msg{} resp.SetRcode(request, dns.RcodeRefused) resp.RecursionAvailable = true return &resp } </s> remove if reply.Rcode != dns.RcodeNameError { t.Fatalf("Wrong response: %s", reply.String()) } </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode) </s> remove assert.Equal(t, dns.RcodeNameError, reply.Rcode) </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode)
https://github.com/AdguardTeam/AdGuardHome/commit/8f017d2c0e25969bd86eafa4adbc184e41c61dc0
dnsforward/handle_dns.go
keep keep keep keep replace keep keep keep keep keep
<mask> func (s *Server) genDNSFilterMessage(d *proxy.DNSContext, result *dnsfilter.Result) *dns.Msg { <mask> m := d.Req <mask> <mask> if m.Question[0].Qtype != dns.TypeA && m.Question[0].Qtype != dns.TypeAAAA { <mask> return s.genNXDomain(m) <mask> } <mask> <mask> switch result.Reason { <mask> case dnsfilter.FilteredSafeBrowsing: <mask> return s.genBlockedHost(m, s.conf.SafeBrowsingBlockHost, d) </s> * DNS: use REFUSED DNS error code as the default blocking method </s> remove return s.genNXDomain(m) </s> add return s.makeResponseREFUSED(m) </s> add // Create REFUSED DNS response func (s *Server) makeResponseREFUSED(request *dns.Msg) *dns.Msg { resp := dns.Msg{} resp.SetRcode(request, dns.RcodeRefused) resp.RecursionAvailable = true return &resp } </s> remove d.Res = s.genNXDomain(d.Req) </s> add d.Res = s.makeResponseREFUSED(d.Req) </s> remove // If there is no IP, return NXDOMAIN </s> add // If there is no IP, return REFUSED </s> remove if reply.Rcode != dns.RcodeNameError { t.Fatalf("Wrong response: %s", reply.String()) } </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode) </s> remove assert.Equal(t, dns.RcodeNameError, reply.Rcode) </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode)
https://github.com/AdguardTeam/AdGuardHome/commit/8f017d2c0e25969bd86eafa4adbc184e41c61dc0
dnsforward/msg.go
keep keep keep keep replace keep keep keep replace keep keep
<mask> } <mask> <mask> // Default blocking mode <mask> // If there's an IP specified in the rule, return it <mask> // If there is no IP, return NXDOMAIN <mask> if result.IP != nil { <mask> return s.genResponseWithIP(m, result.IP) <mask> } <mask> return s.genNXDomain(m) <mask> } <mask> } </s> * DNS: use REFUSED DNS error code as the default blocking method </s> remove // NXDomain blocking </s> add // Default blocking - REFUSED </s> remove d.Res = s.genNXDomain(d.Req) </s> add d.Res = s.makeResponseREFUSED(d.Req) </s> remove return s.genNXDomain(m) </s> add return s.makeResponseREFUSED(m) </s> add // Create REFUSED DNS response func (s *Server) makeResponseREFUSED(request *dns.Msg) *dns.Msg { resp := dns.Msg{} resp.SetRcode(request, dns.RcodeRefused) resp.RecursionAvailable = true return &resp } </s> remove if reply.Rcode != dns.RcodeNameError { t.Fatalf("Wrong response: %s", reply.String()) } </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode)
https://github.com/AdguardTeam/AdGuardHome/commit/8f017d2c0e25969bd86eafa4adbc184e41c61dc0
dnsforward/msg.go
keep keep keep add keep keep keep keep keep
<mask> answer.Target = dns.Fqdn(cname) <mask> return answer <mask> } <mask> <mask> func (s *Server) genNXDomain(request *dns.Msg) *dns.Msg { <mask> resp := dns.Msg{} <mask> resp.SetRcode(request, dns.RcodeNameError) <mask> resp.RecursionAvailable = true <mask> resp.Ns = s.genSOA(request) </s> * DNS: use REFUSED DNS error code as the default blocking method </s> remove return s.genNXDomain(m) </s> add return s.makeResponseREFUSED(m) </s> remove // NXDomain blocking </s> add // Default blocking - REFUSED </s> remove return s.genNXDomain(m) </s> add return s.makeResponseREFUSED(m) </s> remove d.Res = s.genNXDomain(d.Req) </s> add d.Res = s.makeResponseREFUSED(d.Req) </s> remove assert.Equal(t, dns.RcodeNameError, reply.Rcode) </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode) </s> remove if reply.Rcode != dns.RcodeNameError { t.Fatalf("Wrong response: %s", reply.String()) } </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode)
https://github.com/AdguardTeam/AdGuardHome/commit/8f017d2c0e25969bd86eafa4adbc184e41c61dc0
dnsforward/msg.go
keep add keep keep keep keep keep keep
<mask> } <mask> <mask> // configuration is loaded from YAML <mask> // field ordering is important -- yaml fields will mirror ordering from here <mask> type configuration struct { <mask> // Raw file data to avoid re-reading of configuration file <mask> // It's reset after config is parsed <mask> fileData []byte </s> + clients: config: save/restore clients info array </s> add // Note: this array is filled only before file read/write and then it's cleared Clients []clientObject `yaml:"clients"` </s> add config.Clients = nil
https://github.com/AdguardTeam/AdGuardHome/commit/8f7aff93d7297ed93620c53088ce9c70135dae26
config.go
keep keep add keep keep keep keep keep
<mask> UserRules []string `yaml:"user_rules"` <mask> DHCP dhcpd.ServerConfig `yaml:"dhcp"` <mask> <mask> logSettings `yaml:",inline"` <mask> <mask> sync.RWMutex `yaml:"-"` <mask> <mask> SchemaVersion int `yaml:"schema_version"` // keeping last so that users will be less tempted to change it -- used when upgrading between versions </s> + clients: config: save/restore clients info array </s> add type clientObject struct { Name string `yaml:"name"` IP string `yaml:"ip"` MAC string `yaml:"mac"` UseGlobalSettings bool `yaml:"use_global_settings"` FilteringEnabled bool `yaml:"filtering_enabled"` ParentalEnabled bool `yaml:"parental_enabled"` SafeSearchEnabled bool `yaml:"safebrowsing_enabled"` SafeBrowsingEnabled bool `yaml:"safesearch_enabled"` } </s> add config.Clients = nil
https://github.com/AdguardTeam/AdGuardHome/commit/8f7aff93d7297ed93620c53088ce9c70135dae26
config.go
keep keep add keep keep keep keep
<mask> configFile := config.getConfigFilename() <mask> log.Debug("Writing YAML file: %s", configFile) <mask> yamlText, err := yaml.Marshal(&config) <mask> if err != nil { <mask> log.Error("Couldn't generate YAML file: %s", err) <mask> return err <mask> } </s> + clients: config: save/restore clients info array </s> add type clientObject struct { Name string `yaml:"name"` IP string `yaml:"ip"` MAC string `yaml:"mac"` UseGlobalSettings bool `yaml:"use_global_settings"` FilteringEnabled bool `yaml:"filtering_enabled"` ParentalEnabled bool `yaml:"parental_enabled"` SafeSearchEnabled bool `yaml:"safebrowsing_enabled"` SafeBrowsingEnabled bool `yaml:"safesearch_enabled"` } </s> add // Note: this array is filled only before file read/write and then it's cleared Clients []clientObject `yaml:"clients"`
https://github.com/AdguardTeam/AdGuardHome/commit/8f7aff93d7297ed93620c53088ce9c70135dae26
config.go
keep keep add keep keep keep keep keep keep
<mask> "encoding/json" <mask> "net" <mask> "net/http" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/dhcpd" <mask> "github.com/joomcode/errorx" <mask> ) <mask> <mask> var dhcpServer = dhcpd.Server{} </s> Pretty-format leases so it shows human readable MAC address. </s> add rawLeases := dhcpServer.Leases() leases := []map[string]string{} for i := range rawLeases { lease := map[string]string{ "mac": rawLeases[i].HWAddr.String(), "ip": rawLeases[i].IP.String(), "expires": rawLeases[i].Expiry.Format(time.RFC3339), } leases = append(leases, lease) } </s> remove "leases": dhcpServer.Leases(), </s> add "leases": leases,
https://github.com/AdguardTeam/AdGuardHome/commit/8fc5aebf1265b343fe76cdaf1973ac5a3784b498
dhcp.go
keep keep add keep keep keep keep
<mask> var dhcpServer = dhcpd.Server{} <mask> <mask> func handleDHCPStatus(w http.ResponseWriter, r *http.Request) { <mask> status := map[string]interface{}{ <mask> "config": config.DHCP, <mask> "leases": leases, <mask> } </s> Pretty-format leases so it shows human readable MAC address. </s> remove "leases": dhcpServer.Leases(), </s> add "leases": leases, </s> add "time"
https://github.com/AdguardTeam/AdGuardHome/commit/8fc5aebf1265b343fe76cdaf1973ac5a3784b498
dhcp.go
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> func handleDHCPStatus(w http.ResponseWriter, r *http.Request) { <mask> status := map[string]interface{}{ <mask> "config": config.DHCP, <mask> "leases": dhcpServer.Leases(), <mask> } <mask> <mask> w.Header().Set("Content-Type", "application/json") <mask> err := json.NewEncoder(w).Encode(status) <mask> if err != nil { </s> Pretty-format leases so it shows human readable MAC address. </s> add rawLeases := dhcpServer.Leases() leases := []map[string]string{} for i := range rawLeases { lease := map[string]string{ "mac": rawLeases[i].HWAddr.String(), "ip": rawLeases[i].IP.String(), "expires": rawLeases[i].Expiry.Format(time.RFC3339), } leases = append(leases, lease) } </s> add "time"
https://github.com/AdguardTeam/AdGuardHome/commit/8fc5aebf1265b343fe76cdaf1973ac5a3784b498
dhcp.go
keep keep keep replace keep replace keep keep keep
<mask> <mask> configFilename string // Config filename (can be overridden via the command line arguments) <mask> workDir string // Location of our directory, used to protect against CWD being somewhere else <mask> firstRun bool // if set to true, don't run any services except HTTP web interface, and serve only first-run html <mask> pidFileName string // PID file name. Empty if no PID file was created. <mask> disableUpdate bool // If set, don't check for updates <mask> controlLock sync.Mutex <mask> tlsRoots *x509.CertPool // list of root CAs for TLSv1.2 <mask> transport *http.Transport </s> Pull request: imp-pprof Merge in DNS/adguard-home from imp-pprof to master Squashed commit of the following: commit cd6c2ec15342ef55957ab65e1599733c2ee57b7b Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Nov 7 19:45:12 2022 +0300 home: imp pprof handling, field alignment </s> add // disableUpdate, if true, tells AdGuard Home to not check for updates. disableUpdate bool // firstRun, if true, tells AdGuard Home to only start the web interface // service, and only serve the first-run APIs. firstRun bool </s> add // See profileSupportsDelta in src/net/http/pprof/pprof.go. mux.Handle("/debug/pprof/allocs", pprof.Handler("allocs")) mux.Handle("/debug/pprof/block", pprof.Handler("block")) mux.Handle("/debug/pprof/goroutine", pprof.Handler("goroutine")) mux.Handle("/debug/pprof/heap", pprof.Handler("heap")) mux.Handle("/debug/pprof/mutex", pprof.Handler("mutex")) mux.Handle("/debug/pprof/threadcreate", pprof.Handler("threadcreate"))
https://github.com/AdguardTeam/AdGuardHome/commit/8fdbcc005cc1cff80bff7360a55e838e2458fb2f
internal/home/home.go
keep keep keep add keep keep keep keep keep
<mask> <mask> // tlsCipherIDs are the ID of the cipher suites that AdGuard Home must use. <mask> tlsCipherIDs []uint16 <mask> <mask> // runningAsService flag is set to true when options are passed from the service runner <mask> runningAsService bool <mask> } <mask> <mask> // getDataDir returns path to the directory where we store databases and filters </s> Pull request: imp-pprof Merge in DNS/adguard-home from imp-pprof to master Squashed commit of the following: commit cd6c2ec15342ef55957ab65e1599733c2ee57b7b Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Nov 7 19:45:12 2022 +0300 home: imp pprof handling, field alignment </s> remove disableUpdate bool // If set, don't check for updates </s> add </s> remove firstRun bool // if set to true, don't run any services except HTTP web interface, and serve only first-run html </s> add </s> add // See profileSupportsDelta in src/net/http/pprof/pprof.go. mux.Handle("/debug/pprof/allocs", pprof.Handler("allocs")) mux.Handle("/debug/pprof/block", pprof.Handler("block")) mux.Handle("/debug/pprof/goroutine", pprof.Handler("goroutine")) mux.Handle("/debug/pprof/heap", pprof.Handler("heap")) mux.Handle("/debug/pprof/mutex", pprof.Handler("mutex")) mux.Handle("/debug/pprof/threadcreate", pprof.Handler("threadcreate"))
https://github.com/AdguardTeam/AdGuardHome/commit/8fdbcc005cc1cff80bff7360a55e838e2458fb2f
internal/home/home.go
keep keep add keep keep keep keep
<mask> mux.HandleFunc("/debug/pprof/profile", pprof.Profile) <mask> mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol) <mask> mux.HandleFunc("/debug/pprof/trace", pprof.Trace) <mask> go func() { <mask> log.Info("pprof: listening on localhost:6060") <mask> lerr := http.ListenAndServe("localhost:6060", mux) <mask> log.Error("Error while running the pprof server: %s", lerr) </s> Pull request: imp-pprof Merge in DNS/adguard-home from imp-pprof to master Squashed commit of the following: commit cd6c2ec15342ef55957ab65e1599733c2ee57b7b Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Nov 7 19:45:12 2022 +0300 home: imp pprof handling, field alignment </s> add // disableUpdate, if true, tells AdGuard Home to not check for updates. disableUpdate bool // firstRun, if true, tells AdGuard Home to only start the web interface // service, and only serve the first-run APIs. firstRun bool </s> remove disableUpdate bool // If set, don't check for updates </s> add </s> remove firstRun bool // if set to true, don't run any services except HTTP web interface, and serve only first-run html </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/8fdbcc005cc1cff80bff7360a55e838e2458fb2f
internal/home/home.go
keep keep keep keep replace keep keep keep
<mask> "original_response": "Original response", <mask> "click_to_view_queries": "Click to view queries", <mask> "port_53_faq_link": "Port 53 is often occupied by \"DNSStubListener\" or \"systemd-resolved\" services. Please read <0>this instruction</0> on how to resolve this.", <mask> "adg_will_drop_dns_queries": "AdGuard Home will be dropping all DNS queries from this client.", <mask> "client_not_in_allowed_clients": "The client is not allowed because it is not in the \"Allowed clients\" list.", <mask> "experimental": "Experimental", <mask> "use_saved_key": "Use the previously saved key" <mask> } </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove Persistent client's name or an empty string if this is a runtime client. </s> add Persistent client's name or runtime client's hostname. </s> remove // findMultiple is a wrapper around Find to make it a valid client finder for // the query log. err is always nil. </s> add // findMultiple returns info about client. If no information about the client // is found, it sends the client by default only with the "Disallowed" field // filled in. err is always nil. </s> add var emptyClient *querylog.Client </s> remove var name string whois := &querylog.ClientWHOIS{} </s> add </s> add // clientInfo is a wrapper around Find to make it a valid client finder for // the query log. func (clients *clientsContainer) clientInfo( ip net.IP, id string, disallowed bool, rule string, ) (c *querylog.Client) { whois := &querylog.ClientWHOIS{} client, ok := clients.Find(id) if ok { </s> remove 'description': 'Client and host access list' </s> add 'description': > Client and host access list. Each of the lists should contain only unique elements. In addition, allowed and disallowed lists cannot contain the same elements.
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/__locales/en.json
keep keep keep keep replace keep replace replace replace replace replace keep keep keep
<mask> export const toggleClientBlock = (ip, disallowed, disallowed_rule) => async (dispatch) => { <mask> dispatch(toggleClientBlockRequest()); <mask> try { <mask> const accessList = await apiClient.getAccessList(); <mask> const allowed_clients = accessList.allowed_clients ?? []; <mask> const blocked_hosts = accessList.blocked_hosts ?? []; <mask> const disallowed_clients = accessList.disallowed_clients ?? []; <mask> <mask> const updatedDisallowedClients = disallowed <mask> ? disallowed_clients.filter((client) => client !== disallowed_rule) <mask> : disallowed_clients.concat(ip); <mask> <mask> const values = { <mask> allowed_clients, </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> add if (disallowed) { if (!disallowed_rule) { allowed_clients = allowed_clients.concat(ip); } else { disallowed_clients = disallowed_clients .filter((client) => client !== disallowed_rule); } } else if (allowed_clients.length > 1) { allowed_clients = allowed_clients .filter((client) => client !== disallowed_rule); } else { disallowed_clients = disallowed_clients.concat(ip); } </s> remove const Form = (props) => { </s> add let Form = (props) => { </s> remove disallowed_clients: updatedDisallowedClients, </s> add disallowed_clients, </s> remove export default flow([withTranslation(), reduxForm({ form: FORM_NAME.ACCESS })])(Form); </s> add const selector = formValueSelector(FORM_NAME.ACCESS); Form = connect((state) => { const allowedClients = selector(state, 'allowed_clients'); return { allowedClients, }; })(Form); export default flow([ withTranslation(), reduxForm({ form: FORM_NAME.ACCESS, }), ])(Form); </s> remove disabled: isNotInAllowedList, </s> add disabled: processingSet || lastRuleInAllowlist,
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/actions/access.js
keep add keep keep keep keep keep keep
<mask> let disallowed_clients = accessList.disallowed_clients ?? []; <mask> <mask> const values = { <mask> allowed_clients, <mask> blocked_hosts, <mask> disallowed_clients, <mask> }; <mask> </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove const disallowed_clients = accessList.disallowed_clients ?? []; const updatedDisallowedClients = disallowed ? disallowed_clients.filter((client) => client !== disallowed_rule) : disallowed_clients.concat(ip); </s> add let allowed_clients = accessList.allowed_clients ?? []; let disallowed_clients = accessList.disallowed_clients ?? []; </s> remove disallowed_clients: updatedDisallowedClients, </s> add disallowed_clients, </s> remove const allowed_clients = accessList.allowed_clients ?? []; </s> add </s> remove const Form = (props) => { </s> add let Form = (props) => { </s> remove export default flow([withTranslation(), reduxForm({ form: FORM_NAME.ACCESS })])(Form); </s> add const selector = formValueSelector(FORM_NAME.ACCESS); Form = connect((state) => { const allowedClients = selector(state, 'allowed_clients'); return { allowedClients, }; })(Form); export default flow([ withTranslation(), reduxForm({ form: FORM_NAME.ACCESS, }), ])(Form); </s> add allowedClients: PropTypes.string,
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/actions/access.js
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> const values = { <mask> allowed_clients, <mask> blocked_hosts, <mask> disallowed_clients: updatedDisallowedClients, <mask> }; <mask> <mask> await apiClient.setAccessList(values); <mask> dispatch(toggleClientBlockSuccess(values)); <mask> </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove const disallowed_clients = accessList.disallowed_clients ?? []; const updatedDisallowedClients = disallowed ? disallowed_clients.filter((client) => client !== disallowed_rule) : disallowed_clients.concat(ip); </s> add let allowed_clients = accessList.allowed_clients ?? []; let disallowed_clients = accessList.disallowed_clients ?? []; </s> add if (disallowed) { if (!disallowed_rule) { allowed_clients = allowed_clients.concat(ip); } else { disallowed_clients = disallowed_clients .filter((client) => client !== disallowed_rule); } } else if (allowed_clients.length > 1) { allowed_clients = allowed_clients .filter((client) => client !== disallowed_rule); } else { disallowed_clients = disallowed_clients.concat(ip); } </s> remove dispatch(addSuccessToast(i18next.t('client_unblocked', { ip: disallowed_rule }))); </s> add dispatch(addSuccessToast(i18next.t('client_unblocked', { ip: disallowed_rule || ip }))); </s> remove export default flow([withTranslation(), reduxForm({ form: FORM_NAME.ACCESS })])(Form); </s> add const selector = formValueSelector(FORM_NAME.ACCESS); Form = connect((state) => { const allowedClients = selector(state, 'allowed_clients'); return { allowedClients, }; })(Form); export default flow([ withTranslation(), reduxForm({ form: FORM_NAME.ACCESS, }), ])(Form); </s> remove {fields.map(renderField)} </s> add { fields.map((f) => { const props = { ...f }; if (allowedClients && f.id === 'disallowed_clients') { props.disabled = true; } return renderField(props); }) } </s> remove disabled: isNotInAllowedList, </s> add disabled: processingSet || lastRuleInAllowlist,
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/actions/access.js
keep keep keep keep replace keep keep keep keep keep
<mask> await apiClient.setAccessList(values); <mask> dispatch(toggleClientBlockSuccess(values)); <mask> <mask> if (disallowed) { <mask> dispatch(addSuccessToast(i18next.t('client_unblocked', { ip: disallowed_rule }))); <mask> } else { <mask> dispatch(addSuccessToast(i18next.t('client_blocked', { ip }))); <mask> } <mask> } catch (error) { <mask> dispatch(addErrorToast({ error })); </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> add if (disallowed) { if (!disallowed_rule) { allowed_clients = allowed_clients.concat(ip); } else { disallowed_clients = disallowed_clients .filter((client) => client !== disallowed_rule); } } else if (allowed_clients.length > 1) { allowed_clients = allowed_clients .filter((client) => client !== disallowed_rule); } else { disallowed_clients = disallowed_clients.concat(ip); } </s> add dispatch(getAccessList()), </s> remove disallowed_clients: updatedDisallowedClients, </s> add disallowed_clients, </s> remove c, ok := clients.Find(id) if ok { name = c.Name } else if ip != nil { var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if !ok { continue } </s> add client := clients.clientInfo(ip, id, disallowed, disallowedRule) if client.Name == "" && client.DisallowedRule == "" { emptyClient = client </s> remove }, nil </s> add } } if ip == nil { return nil } var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if ok { return &querylog.Client{ Name: rc.Host, DisallowedRule: rule, WHOIS: toQueryLogWHOIS(rc.WHOISInfo), Disallowed: disallowed, } </s> add import { getAccessList } from '../../actions/access';
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/actions/access.js
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> <div className="table__action pl-4"> <mask> <button <mask> type="button" <mask> className={buttonClass} <mask> onClick={isNotInAllowedList ? undefined : onClick} <mask> disabled={isNotInAllowedList || processingSet} <mask> title={t(isNotInAllowedList ? 'client_not_in_allowed_clients' : text)} <mask> > <mask> <Trans>{text}</Trans> <mask> </button> <mask> </div> <mask> ); </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove const disallowed_clients = accessList.disallowed_clients ?? []; const updatedDisallowedClients = disallowed ? disallowed_clients.filter((client) => client !== disallowed_rule) : disallowed_clients.concat(ip); </s> add let allowed_clients = accessList.allowed_clients ?? []; let disallowed_clients = accessList.disallowed_clients ?? []; </s> add {disabled && <> <span> </span> (<Trans>disabled</Trans>) </>} </s> remove disabled={disabled} </s> add disabled={disabled || processingSet} </s> remove isNotInAllowedList, </s> add lastRuleInAllowlist, </s> remove isNotInAllowedList, </s> add lastRuleInAllowlist, </s> remove {fields.map(renderField)} </s> add { fields.map((f) => { const props = { ...f }; if (allowedClients && f.id === 'disallowed_clients') { props.disabled = true; } return renderField(props); }) }
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/components/Dashboard/Clients.js
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> const { <mask> confirmMessage, <mask> buttonKey: blockingClientKey, <mask> isNotInAllowedList, <mask> } = getBlockClientInfo( <mask> client, <mask> client_info?.disallowed || false, <mask> client_info?.disallowed_rule || '', <mask> ); </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove isNotInAllowedList, </s> add lastRuleInAllowlist, </s> remove disabled: isNotInAllowedList, </s> add disabled: processingSet || lastRuleInAllowlist, </s> remove isNotInAllowedList, </s> add lastRuleInAllowlist, </s> remove disabled={isNotInAllowedList}> </s> add disabled={processingSet || lastRuleInAllowlist}> </s> remove onClick={isNotInAllowedList ? undefined : onClick} disabled={isNotInAllowedList || processingSet} title={t(isNotInAllowedList ? 'client_not_in_allowed_clients' : text)} </s> add onClick={onClick} disabled={disabled} title={lastRuleInAllowlist ? t('last_rule_in_allowlist', { disallowed_rule }) : ''} </s> remove disabled={disabled} </s> add disabled={disabled || processingSet}
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/components/Logs/Cells/ClientCell.js
keep keep keep keep replace keep keep keep keep keep
<mask> )); <mask> await dispatch(updateLogs()); <mask> } <mask> }, <mask> disabled: isNotInAllowedList, <mask> }, <mask> ]; <mask> <mask> const onClick = async () => { <mask> await dispatch(toggleBlocking(buttonType, domain)); </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove const Form = (props) => { </s> add let Form = (props) => { </s> remove const allowed_clients = accessList.allowed_clients ?? []; </s> add </s> remove handleSubmit, submitting, invalid, processingSet, </s> add allowedClients, handleSubmit, submitting, invalid, processingSet, </s> remove disallowed_clients: updatedDisallowedClients, </s> add disallowed_clients, </s> add dispatch(getAccessList()), </s> remove const disallowed_clients = accessList.disallowed_clients ?? []; const updatedDisallowedClients = disallowed ? disallowed_clients.filter((client) => client !== disallowed_rule) : disallowed_clients.concat(ip); </s> add let allowed_clients = accessList.allowed_clients ?? []; let disallowed_clients = accessList.disallowed_clients ?? [];
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/components/Logs/Cells/ClientCell.js
keep keep keep keep replace keep keep
<mask> <mask> return { <mask> confirmMessage, <mask> buttonKey, <mask> isNotInAllowedList, <mask> }; <mask> }; </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove {fields.map(renderField)} </s> add { fields.map((f) => { const props = { ...f }; if (allowedClients && f.id === 'disallowed_clients') { props.disabled = true; } return renderField(props); }) } </s> remove isNotInAllowedList, </s> add lastRuleInAllowlist, </s> remove isNotInAllowedList, </s> add lastRuleInAllowlist, </s> remove export default flow([withTranslation(), reduxForm({ form: FORM_NAME.ACCESS })])(Form); </s> add const selector = formValueSelector(FORM_NAME.ACCESS); Form = connect((state) => { const allowedClients = selector(state, 'allowed_clients'); return { allowedClients, }; })(Form); export default flow([ withTranslation(), reduxForm({ form: FORM_NAME.ACCESS, }), ])(Form); </s> remove disallowed_clients: updatedDisallowedClients, </s> add disallowed_clients, </s> add allowedClients: PropTypes.string,
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/components/Logs/Cells/helpers/index.js
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> const { <mask> confirmMessage, <mask> buttonKey: blockingClientKey, <mask> isNotInAllowedList, <mask> } = getBlockClientInfo( <mask> client, <mask> client_info?.disallowed || false, <mask> client_info?.disallowed_rule || '', <mask> ); </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/components/Logs/Cells/index.js
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> const blockClientButton = <button <mask> className='text-center font-weight-bold py-2 button-action--arrow-option' <mask> onClick={onBlockingClientClick} <mask> disabled={isNotInAllowedList}> <mask> {t(blockingClientKey)} <mask> </button>; <mask> <mask> const detailedData = { <mask> time_table_header: formatTime(time, LONG_TIME_FORMAT), </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove {fields.map(renderField)} </s> add { fields.map((f) => { const props = { ...f }; if (allowedClients && f.id === 'disallowed_clients') { props.disabled = true; } return renderField(props); }) } </s> remove const Form = (props) => { </s> add let Form = (props) => { </s> remove const allowed_clients = accessList.allowed_clients ?? []; </s> add </s> remove const disallowed_clients = accessList.disallowed_clients ?? []; const updatedDisallowedClients = disallowed ? disallowed_clients.filter((client) => client !== disallowed_rule) : disallowed_clients.concat(ip); </s> add let allowed_clients = accessList.allowed_clients ?? []; let disallowed_clients = accessList.disallowed_clients ?? []; </s> remove handleSubmit, submitting, invalid, processingSet, </s> add allowedClients, handleSubmit, submitting, invalid, processingSet, </s> add if (disallowed) { if (!disallowed_rule) { allowed_clients = allowed_clients.concat(ip); } else { disallowed_clients = disallowed_clients .filter((client) => client !== disallowed_rule); } } else if (allowed_clients.length > 1) { allowed_clients = allowed_clients .filter((client) => client !== disallowed_rule); } else { disallowed_clients = disallowed_clients.concat(ip); }
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/components/Logs/Cells/index.js
keep add keep keep keep keep
<mask> import { getClients } from '../../actions'; <mask> import { getDnsConfig } from '../../actions/dnsConfig'; <mask> import { <mask> getLogsConfig, <mask> resetFilteredLogs, <mask> setFilteredLogs, </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove import { Field, reduxForm } from 'redux-form'; </s> add import { connect } from 'react-redux'; import { Field, reduxForm, formValueSelector } from 'redux-form'; </s> remove dispatch(addSuccessToast(i18next.t('client_unblocked', { ip: disallowed_rule }))); </s> add dispatch(addSuccessToast(i18next.t('client_unblocked', { ip: disallowed_rule || ip }))); </s> add if (disallowed) { if (!disallowed_rule) { allowed_clients = allowed_clients.concat(ip); } else { disallowed_clients = disallowed_clients .filter((client) => client !== disallowed_rule); } } else if (allowed_clients.length > 1) { allowed_clients = allowed_clients .filter((client) => client !== disallowed_rule); } else { disallowed_clients = disallowed_clients.concat(ip); } </s> add dispatch(getAccessList()), </s> remove {fields.map(renderField)} </s> add { fields.map((f) => { const props = { ...f }; if (allowedClients && f.id === 'disallowed_clients') { props.disabled = true; } return renderField(props); }) } </s> remove }, nil </s> add } } if ip == nil { return nil } var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if ok { return &querylog.Client{ Name: rc.Host, DisallowedRule: rule, WHOIS: toQueryLogWHOIS(rc.WHOISInfo), Disallowed: disallowed, }
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/components/Logs/index.js
keep keep add keep keep keep keep keep
<mask> await Promise.all([ <mask> dispatch(getLogsConfig()), <mask> dispatch(getDnsConfig()), <mask> ]); <mask> } catch (err) { <mask> console.error(err); <mask> } finally { <mask> setIsLoading(false); </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove dispatch(addSuccessToast(i18next.t('client_unblocked', { ip: disallowed_rule }))); </s> add dispatch(addSuccessToast(i18next.t('client_unblocked', { ip: disallowed_rule || ip }))); </s> remove disabled: isNotInAllowedList, </s> add disabled: processingSet || lastRuleInAllowlist, </s> add import { getAccessList } from '../../actions/access'; </s> remove import { Field, reduxForm } from 'redux-form'; </s> add import { connect } from 'react-redux'; import { Field, reduxForm, formValueSelector } from 'redux-form'; </s> add if (disallowed) { if (!disallowed_rule) { allowed_clients = allowed_clients.concat(ip); } else { disallowed_clients = disallowed_clients .filter((client) => client !== disallowed_rule); } } else if (allowed_clients.length > 1) { allowed_clients = allowed_clients .filter((client) => client !== disallowed_rule); } else { disallowed_clients = disallowed_clients.concat(ip); } </s> remove }, nil </s> add } } if ip == nil { return nil } var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if ok { return &querylog.Client{ Name: rc.Host, DisallowedRule: rule, WHOIS: toQueryLogWHOIS(rc.WHOISInfo), Disallowed: disallowed, }
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/components/Logs/index.js
keep keep replace keep keep keep keep keep
<mask> import React from 'react'; <mask> import PropTypes from 'prop-types'; <mask> import { Field, reduxForm } from 'redux-form'; <mask> import { Trans, withTranslation } from 'react-i18next'; <mask> import flow from 'lodash/flow'; <mask> import { renderTextareaField } from '../../../../helpers/form'; <mask> import { <mask> trimMultilineString, </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> add import { getAccessList } from '../../actions/access'; </s> remove "client_not_in_allowed_clients": "The client is not allowed because it is not in the \"Allowed clients\" list.", </s> add "filter_allowlist": "WARNING: This action also will exclude the rule \"{{disallowed_rule}}\" from the list of allowed clients.", "last_rule_in_allowlist": "Cannot disallow this client because excluding the rule \"{{disallowed_rule}}\" will DISABLE \"Allowed clients\" list.", </s> remove dispatch(addSuccessToast(i18next.t('client_unblocked', { ip: disallowed_rule }))); </s> add dispatch(addSuccessToast(i18next.t('client_unblocked', { ip: disallowed_rule || ip }))); </s> add if (disallowed) { if (!disallowed_rule) { allowed_clients = allowed_clients.concat(ip); } else { disallowed_clients = disallowed_clients .filter((client) => client !== disallowed_rule); } } else if (allowed_clients.length > 1) { allowed_clients = allowed_clients .filter((client) => client !== disallowed_rule); } else { disallowed_clients = disallowed_clients.concat(ip); } </s> add dispatch(getAccessList()), </s> remove {fields.map(renderField)} </s> add { fields.map((f) => { const props = { ...f }; if (allowedClients && f.id === 'disallowed_clients') { props.disabled = true; } return renderField(props); }) }
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/components/Settings/Dns/Access/Form.js
keep keep keep replace keep replace
<mask> }, <mask> ]; <mask> <mask> const Form = (props) => { <mask> const { <mask> handleSubmit, submitting, invalid, processingSet, </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove id, title, subtitle, disabled = processingSet, normalizeOnBlur, </s> add id, title, subtitle, disabled = false, processingSet, normalizeOnBlur, </s> remove disabled: isNotInAllowedList, </s> add disabled: processingSet || lastRuleInAllowlist, </s> add allowedClients: PropTypes.string, </s> remove export default flow([withTranslation(), reduxForm({ form: FORM_NAME.ACCESS })])(Form); </s> add const selector = formValueSelector(FORM_NAME.ACCESS); Form = connect((state) => { const allowedClients = selector(state, 'allowed_clients'); return { allowedClients, }; })(Form); export default flow([ withTranslation(), reduxForm({ form: FORM_NAME.ACCESS, }), ])(Form); </s> remove const allowed_clients = accessList.allowed_clients ?? []; </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/components/Settings/Dns/Access/Form.js
keep keep keep keep replace keep keep keep keep keep
<mask> handleSubmit, submitting, invalid, processingSet, <mask> } = props; <mask> <mask> const renderField = ({ <mask> id, title, subtitle, disabled = processingSet, normalizeOnBlur, <mask> }) => <div key={id} className="form__group mb-5"> <mask> <label className="form__label form__label--with-desc" htmlFor={id}> <mask> <Trans>{title}</Trans> <mask> </label> <mask> <div className="form__desc form__desc--top"> </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove handleSubmit, submitting, invalid, processingSet, </s> add allowedClients, handleSubmit, submitting, invalid, processingSet, </s> add {disabled && <> <span> </span> (<Trans>disabled</Trans>) </>} </s> remove const Form = (props) => { </s> add let Form = (props) => { </s> remove {fields.map(renderField)} </s> add { fields.map((f) => { const props = { ...f }; if (allowedClients && f.id === 'disallowed_clients') { props.disabled = true; } return renderField(props); }) } </s> add if (disallowed) { if (!disallowed_rule) { allowed_clients = allowed_clients.concat(ip); } else { disallowed_clients = disallowed_clients .filter((client) => client !== disallowed_rule); } } else if (allowed_clients.length > 1) { allowed_clients = allowed_clients .filter((client) => client !== disallowed_rule); } else { disallowed_clients = disallowed_clients.concat(ip); } </s> remove const allowed_clients = accessList.allowed_clients ?? []; </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/components/Settings/Dns/Access/Form.js
keep add keep keep keep keep
<mask> <label className="form__label form__label--with-desc" htmlFor={id}> <mask> <Trans>{title}</Trans> <mask> </label> <mask> <div className="form__desc form__desc--top"> <mask> <Trans>{subtitle}</Trans> <mask> </div> </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove id, title, subtitle, disabled = processingSet, normalizeOnBlur, </s> add id, title, subtitle, disabled = false, processingSet, normalizeOnBlur, </s> remove onClick={isNotInAllowedList ? undefined : onClick} disabled={isNotInAllowedList || processingSet} title={t(isNotInAllowedList ? 'client_not_in_allowed_clients' : text)} </s> add onClick={onClick} disabled={disabled} title={lastRuleInAllowlist ? t('last_rule_in_allowlist', { disallowed_rule }) : ''} </s> remove {fields.map(renderField)} </s> add { fields.map((f) => { const props = { ...f }; if (allowedClients && f.id === 'disallowed_clients') { props.disabled = true; } return renderField(props); }) } </s> remove handleSubmit, submitting, invalid, processingSet, </s> add allowedClients, handleSubmit, submitting, invalid, processingSet, </s> remove disallowed_clients: updatedDisallowedClients, </s> add disallowed_clients, </s> remove dispatch(addSuccessToast(i18next.t('client_unblocked', { ip: disallowed_rule }))); </s> add dispatch(addSuccessToast(i18next.t('client_unblocked', { ip: disallowed_rule || ip })));
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/components/Settings/Dns/Access/Form.js
keep keep keep keep replace keep keep keep keep keep
<mask> name={id} <mask> component={renderTextareaField} <mask> type="text" <mask> className="form-control form-control--textarea font-monospace" <mask> disabled={disabled} <mask> normalizeOnBlur={normalizeOnBlur} <mask> /> <mask> </div>; <mask> <mask> renderField.propTypes = { </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove onClick={isNotInAllowedList ? undefined : onClick} disabled={isNotInAllowedList || processingSet} title={t(isNotInAllowedList ? 'client_not_in_allowed_clients' : text)} </s> add onClick={onClick} disabled={disabled} title={lastRuleInAllowlist ? t('last_rule_in_allowlist', { disallowed_rule }) : ''} </s> add if (disallowed) { if (!disallowed_rule) { allowed_clients = allowed_clients.concat(ip); } else { disallowed_clients = disallowed_clients .filter((client) => client !== disallowed_rule); } } else if (allowed_clients.length > 1) { allowed_clients = allowed_clients .filter((client) => client !== disallowed_rule); } else { disallowed_clients = disallowed_clients.concat(ip); } </s> remove const Form = (props) => { </s> add let Form = (props) => { </s> remove c, ok := clients.Find(id) if ok { name = c.Name } else if ip != nil { var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if !ok { continue } </s> add client := clients.clientInfo(ip, id, disallowed, disallowedRule) if client.Name == "" && client.DisallowedRule == "" { emptyClient = client </s> remove handleSubmit, submitting, invalid, processingSet, </s> add allowedClients, handleSubmit, submitting, invalid, processingSet, </s> remove const allowed_clients = accessList.allowed_clients ?? []; </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/components/Settings/Dns/Access/Form.js
keep keep keep keep replace keep keep keep keep keep
<mask> }; <mask> <mask> return ( <mask> <form onSubmit={handleSubmit}> <mask> {fields.map(renderField)} <mask> <div className="card-actions"> <mask> <div className="btn-list"> <mask> <button <mask> type="submit" <mask> className="btn btn-success btn-standard" </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove onClick={isNotInAllowedList ? undefined : onClick} disabled={isNotInAllowedList || processingSet} title={t(isNotInAllowedList ? 'client_not_in_allowed_clients' : text)} </s> add onClick={onClick} disabled={disabled} title={lastRuleInAllowlist ? t('last_rule_in_allowlist', { disallowed_rule }) : ''} </s> remove id, title, subtitle, disabled = processingSet, normalizeOnBlur, </s> add id, title, subtitle, disabled = false, processingSet, normalizeOnBlur, </s> add {disabled && <> <span> </span> (<Trans>disabled</Trans>) </>} </s> remove isNotInAllowedList, </s> add lastRuleInAllowlist, </s> remove handleSubmit, submitting, invalid, processingSet, </s> add allowedClients, handleSubmit, submitting, invalid, processingSet, </s> remove export default flow([withTranslation(), reduxForm({ form: FORM_NAME.ACCESS })])(Form); </s> add const selector = formValueSelector(FORM_NAME.ACCESS); Form = connect((state) => { const allowedClients = selector(state, 'allowed_clients'); return { allowedClients, }; })(Form); export default flow([ withTranslation(), reduxForm({ form: FORM_NAME.ACCESS, }), ])(Form);
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/components/Settings/Dns/Access/Form.js
keep keep add keep keep keep keep keep
<mask> processingSet: PropTypes.bool.isRequired, <mask> t: PropTypes.func.isRequired, <mask> textarea: PropTypes.bool, <mask> }; <mask> <mask> const selector = formValueSelector(FORM_NAME.ACCESS); <mask> <mask> Form = connect((state) => { </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove export default flow([withTranslation(), reduxForm({ form: FORM_NAME.ACCESS })])(Form); </s> add const selector = formValueSelector(FORM_NAME.ACCESS); Form = connect((state) => { const allowedClients = selector(state, 'allowed_clients'); return { allowedClients, }; })(Form); export default flow([ withTranslation(), reduxForm({ form: FORM_NAME.ACCESS, }), ])(Form); </s> remove const Form = (props) => { </s> add let Form = (props) => { </s> remove handleSubmit, submitting, invalid, processingSet, </s> add allowedClients, handleSubmit, submitting, invalid, processingSet, </s> remove {fields.map(renderField)} </s> add { fields.map((f) => { const props = { ...f }; if (allowedClients && f.id === 'disallowed_clients') { props.disabled = true; } return renderField(props); }) } </s> add if (disallowed) { if (!disallowed_rule) { allowed_clients = allowed_clients.concat(ip); } else { disallowed_clients = disallowed_clients .filter((client) => client !== disallowed_rule); } } else if (allowed_clients.length > 1) { allowed_clients = allowed_clients .filter((client) => client !== disallowed_rule); } else { disallowed_clients = disallowed_clients.concat(ip); } </s> remove const allowed_clients = accessList.allowed_clients ?? []; </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/components/Settings/Dns/Access/Form.js
keep keep keep keep replace
<mask> t: PropTypes.func.isRequired, <mask> textarea: PropTypes.bool, <mask> }; <mask> <mask> export default flow([withTranslation(), reduxForm({ form: FORM_NAME.ACCESS })])(Form); </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> add allowedClients: PropTypes.string, </s> remove isNotInAllowedList, </s> add lastRuleInAllowlist, </s> remove const allowed_clients = accessList.allowed_clients ?? []; </s> add </s> remove disallowed_clients: updatedDisallowedClients, </s> add disallowed_clients, </s> remove {fields.map(renderField)} </s> add { fields.map((f) => { const props = { ...f }; if (allowedClients && f.id === 'disallowed_clients') { props.disabled = true; } return renderField(props); }) } </s> add var emptyClient *querylog.Client
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
client/src/components/Settings/Dns/Access/Form.js
keep keep keep add keep keep keep keep keep keep
<mask> "net" <mask> "net/http" <mask> "strings" <mask> <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/AdguardTeam/golibs/netutil" <mask> "github.com/AdguardTeam/golibs/stringutil" <mask> "github.com/AdguardTeam/urlfilter" <mask> "github.com/AdguardTeam/urlfilter/filterlist" <mask> ) </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> add // clientInfo is a wrapper around Find to make it a valid client finder for // the query log. func (clients *clientsContainer) clientInfo( ip net.IP, id string, disallowed bool, rule string, ) (c *querylog.Client) { whois := &querylog.ClientWHOIS{} client, ok := clients.Find(id) if ok { </s> remove 'description': 'Client and host access list' </s> add 'description': > Client and host access list. Each of the lists should contain only unique elements. In addition, allowed and disallowed lists cannot contain the same elements. </s> remove isNotInAllowedList, </s> add lastRuleInAllowlist, </s> remove const Form = (props) => { </s> add let Form = (props) => { </s> remove import { Field, reduxForm } from 'redux-form'; </s> add import { connect } from 'react-redux'; import { Field, reduxForm, formValueSelector } from 'redux-form'; </s> add dispatch(getAccessList()),
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
internal/dnsforward/access.go
keep add keep keep keep keep keep
<mask> } <mask> <mask> var a *accessCtx <mask> a, err = newAccessCtx(list.AllowedClients, list.DisallowedClients, list.BlockedHosts) <mask> if err != nil { <mask> httpError(r, w, http.StatusBadRequest, "creating access ctx: %s", err) <mask> </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove var name string whois := &querylog.ClientWHOIS{} </s> add </s> remove c, ok := clients.Find(id) if ok { name = c.Name } else if ip != nil { var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if !ok { continue } </s> add client := clients.clientInfo(ip, id, disallowed, disallowedRule) if client.Name == "" && client.DisallowedRule == "" { emptyClient = client </s> remove // findMultiple is a wrapper around Find to make it a valid client finder for // the query log. err is always nil. </s> add // findMultiple returns info about client. If no information about the client // is found, it sends the client by default only with the "Disallowed" field // filled in. err is always nil. </s> remove }, nil </s> add } } if ip == nil { return nil } var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if ok { return &querylog.Client{ Name: rc.Host, DisallowedRule: rule, WHOIS: toQueryLogWHOIS(rc.WHOISInfo), Disallowed: disallowed, } </s> add var emptyClient *querylog.Client </s> add // clientInfo is a wrapper around Find to make it a valid client finder for // the query log. func (clients *clientsContainer) clientInfo( ip net.IP, id string, disallowed bool, rule string, ) (c *querylog.Client) { whois := &querylog.ClientWHOIS{} client, ok := clients.Find(id) if ok {
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
internal/dnsforward/access.go
keep keep keep keep replace replace keep keep keep keep keep
<mask> Orgname: wi.Orgname, <mask> } <mask> } <mask> <mask> // findMultiple is a wrapper around Find to make it a valid client finder for <mask> // the query log. err is always nil. <mask> func (clients *clientsContainer) findMultiple(ids []string) (c *querylog.Client, err error) { <mask> for _, id := range ids { <mask> var name string <mask> whois := &querylog.ClientWHOIS{} <mask> ip := net.ParseIP(id) </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove var name string whois := &querylog.ClientWHOIS{} </s> add </s> add var emptyClient *querylog.Client </s> add // clientInfo is a wrapper around Find to make it a valid client finder for // the query log. func (clients *clientsContainer) clientInfo( ip net.IP, id string, disallowed bool, rule string, ) (c *querylog.Client) { whois := &querylog.ClientWHOIS{} client, ok := clients.Find(id) if ok { </s> add disallowed, disallowedRule := clients.dnsServer.IsBlockedClient(ip, id) </s> remove c, ok := clients.Find(id) if ok { name = c.Name } else if ip != nil { var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if !ok { continue } </s> add client := clients.clientInfo(ip, id, disallowed, disallowedRule) if client.Name == "" && client.DisallowedRule == "" { emptyClient = client </s> add err = validateAccessSet(list) if err != nil { httpError(r, w, http.StatusBadRequest, err.Error()) return }
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
internal/home/clients.go
keep keep keep add keep keep keep keep keep keep
<mask> // findMultiple returns info about client. If no information about the client <mask> // is found, it sends the client by default only with the "Disallowed" field <mask> // filled in. err is always nil. <mask> func (clients *clientsContainer) findMultiple(ids []string) (c *querylog.Client, err error) { <mask> for _, id := range ids { <mask> ip := net.ParseIP(id) <mask> disallowed, disallowedRule := clients.dnsServer.IsBlockedClient(ip, id) <mask> <mask> client := clients.clientInfo(ip, id, disallowed, disallowedRule) <mask> </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove // findMultiple is a wrapper around Find to make it a valid client finder for // the query log. err is always nil. </s> add // findMultiple returns info about client. If no information about the client // is found, it sends the client by default only with the "Disallowed" field // filled in. err is always nil. </s> remove var name string whois := &querylog.ClientWHOIS{} </s> add </s> add disallowed, disallowedRule := clients.dnsServer.IsBlockedClient(ip, id) </s> add // clientInfo is a wrapper around Find to make it a valid client finder for // the query log. func (clients *clientsContainer) clientInfo( ip net.IP, id string, disallowed bool, rule string, ) (c *querylog.Client) { whois := &querylog.ClientWHOIS{} client, ok := clients.Find(id) if ok { </s> remove c, ok := clients.Find(id) if ok { name = c.Name } else if ip != nil { var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if !ok { continue } </s> add client := clients.clientInfo(ip, id, disallowed, disallowedRule) if client.Name == "" && client.DisallowedRule == "" { emptyClient = client </s> remove name = rc.Host whois = toQueryLogWHOIS(rc.WHOISInfo) </s> add continue
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
internal/home/clients.go
keep keep keep keep replace replace keep keep keep keep keep
<mask> // findMultiple is a wrapper around Find to make it a valid client finder for <mask> // the query log. err is always nil. <mask> func (clients *clientsContainer) findMultiple(ids []string) (c *querylog.Client, err error) { <mask> for _, id := range ids { <mask> var name string <mask> whois := &querylog.ClientWHOIS{} <mask> ip := net.ParseIP(id) <mask> <mask> c, ok := clients.Find(id) <mask> if ok { <mask> name = c.Name </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove // findMultiple is a wrapper around Find to make it a valid client finder for // the query log. err is always nil. </s> add // findMultiple returns info about client. If no information about the client // is found, it sends the client by default only with the "Disallowed" field // filled in. err is always nil. </s> add // clientInfo is a wrapper around Find to make it a valid client finder for // the query log. func (clients *clientsContainer) clientInfo( ip net.IP, id string, disallowed bool, rule string, ) (c *querylog.Client) { whois := &querylog.ClientWHOIS{} client, ok := clients.Find(id) if ok { </s> add var emptyClient *querylog.Client </s> remove c, ok := clients.Find(id) if ok { name = c.Name } else if ip != nil { var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if !ok { continue } </s> add client := clients.clientInfo(ip, id, disallowed, disallowedRule) if client.Name == "" && client.DisallowedRule == "" { emptyClient = client </s> add disallowed, disallowedRule := clients.dnsServer.IsBlockedClient(ip, id) </s> remove Persistent client's name or an empty string if this is a runtime client. </s> add Persistent client's name or runtime client's hostname.
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
internal/home/clients.go
keep keep add keep keep keep keep
<mask> <mask> for _, id := range ids { <mask> ip := net.ParseIP(id) <mask> <mask> client := clients.clientInfo(ip, id, disallowed, disallowedRule) <mask> <mask> if client.Name == "" && client.DisallowedRule == "" { </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove c, ok := clients.Find(id) if ok { name = c.Name } else if ip != nil { var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if !ok { continue } </s> add client := clients.clientInfo(ip, id, disallowed, disallowedRule) if client.Name == "" && client.DisallowedRule == "" { emptyClient = client </s> add var emptyClient *querylog.Client </s> remove var name string whois := &querylog.ClientWHOIS{} </s> add </s> remove // findMultiple is a wrapper around Find to make it a valid client finder for // the query log. err is always nil. </s> add // findMultiple returns info about client. If no information about the client // is found, it sends the client by default only with the "Disallowed" field // filled in. err is always nil. </s> add // clientInfo is a wrapper around Find to make it a valid client finder for // the query log. func (clients *clientsContainer) clientInfo( ip net.IP, id string, disallowed bool, rule string, ) (c *querylog.Client) { whois := &querylog.ClientWHOIS{} client, ok := clients.Find(id) if ok { </s> remove }, nil </s> add } } if ip == nil { return nil } var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if ok { return &querylog.Client{ Name: rc.Host, DisallowedRule: rule, WHOIS: toQueryLogWHOIS(rc.WHOISInfo), Disallowed: disallowed, }
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
internal/home/clients.go
keep replace replace replace replace replace replace replace replace replace keep replace replace keep
<mask> <mask> c, ok := clients.Find(id) <mask> if ok { <mask> name = c.Name <mask> } else if ip != nil { <mask> var rc *RuntimeClient <mask> rc, ok = clients.FindRuntimeClient(ip) <mask> if !ok { <mask> continue <mask> } <mask> <mask> name = rc.Host <mask> whois = toQueryLogWHOIS(rc.WHOISInfo) <mask> } </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove }, nil </s> add } } if ip == nil { return nil } var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if ok { return &querylog.Client{ Name: rc.Host, DisallowedRule: rule, WHOIS: toQueryLogWHOIS(rc.WHOISInfo), Disallowed: disallowed, } </s> remove var name string whois := &querylog.ClientWHOIS{} </s> add </s> remove disallowed, disallowedRule := clients.dnsServer.IsBlockedClient(ip, id) </s> add return client, nil } return emptyClient, nil } </s> add err = validateAccessSet(list) if err != nil { httpError(r, w, http.StatusBadRequest, err.Error()) return } </s> add if (disallowed) { if (!disallowed_rule) { allowed_clients = allowed_clients.concat(ip); } else { disallowed_clients = disallowed_clients .filter((client) => client !== disallowed_rule); } } else if (allowed_clients.length > 1) { allowed_clients = allowed_clients .filter((client) => client !== disallowed_rule); } else { disallowed_clients = disallowed_clients.concat(ip); }
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
internal/home/clients.go
keep keep keep keep replace keep keep keep keep keep
<mask> name = rc.Host <mask> whois = toQueryLogWHOIS(rc.WHOISInfo) <mask> } <mask> <mask> disallowed, disallowedRule := clients.dnsServer.IsBlockedClient(ip, id) <mask> <mask> return &querylog.Client{ <mask> Name: name, <mask> DisallowedRule: disallowedRule, <mask> WHOIS: whois, </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove Name: name, DisallowedRule: disallowedRule, </s> add Name: client.Name, DisallowedRule: rule, </s> remove name = rc.Host whois = toQueryLogWHOIS(rc.WHOISInfo) </s> add continue </s> remove }, nil </s> add } } if ip == nil { return nil } var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if ok { return &querylog.Client{ Name: rc.Host, DisallowedRule: rule, WHOIS: toQueryLogWHOIS(rc.WHOISInfo), Disallowed: disallowed, } </s> remove c, ok := clients.Find(id) if ok { name = c.Name } else if ip != nil { var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if !ok { continue } </s> add client := clients.clientInfo(ip, id, disallowed, disallowedRule) if client.Name == "" && client.DisallowedRule == "" { emptyClient = client </s> add // clientInfo is a wrapper around Find to make it a valid client finder for // the query log. func (clients *clientsContainer) clientInfo( ip net.IP, id string, disallowed bool, rule string, ) (c *querylog.Client) { whois := &querylog.ClientWHOIS{} client, ok := clients.Find(id) if ok { </s> remove return nil, nil </s> add return &querylog.Client{ Name: "", DisallowedRule: rule, WHOIS: &querylog.ClientWHOIS{}, Disallowed: disallowed, }
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
internal/home/clients.go
keep keep keep add keep keep keep keep keep keep
<mask> <mask> return emptyClient, nil <mask> } <mask> <mask> return &querylog.Client{ <mask> Name: client.Name, <mask> DisallowedRule: rule, <mask> WHOIS: whois, <mask> Disallowed: disallowed, <mask> } </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove Name: name, DisallowedRule: disallowedRule, </s> add Name: client.Name, DisallowedRule: rule, </s> remove }, nil </s> add } } if ip == nil { return nil } var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if ok { return &querylog.Client{ Name: rc.Host, DisallowedRule: rule, WHOIS: toQueryLogWHOIS(rc.WHOISInfo), Disallowed: disallowed, } </s> remove disallowed, disallowedRule := clients.dnsServer.IsBlockedClient(ip, id) </s> add return client, nil } return emptyClient, nil } </s> remove return nil, nil </s> add return &querylog.Client{ Name: "", DisallowedRule: rule, WHOIS: &querylog.ClientWHOIS{}, Disallowed: disallowed, } </s> remove name = rc.Host whois = toQueryLogWHOIS(rc.WHOISInfo) </s> add continue </s> add err = validateAccessSet(list) if err != nil { httpError(r, w, http.StatusBadRequest, err.Error()) return }
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
internal/home/clients.go
keep keep keep keep replace replace keep keep replace keep keep keep keep
<mask> <mask> disallowed, disallowedRule := clients.dnsServer.IsBlockedClient(ip, id) <mask> <mask> return &querylog.Client{ <mask> Name: name, <mask> DisallowedRule: disallowedRule, <mask> WHOIS: whois, <mask> Disallowed: disallowed, <mask> }, nil <mask> } <mask> <mask> return nil, nil <mask> } </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove disallowed, disallowedRule := clients.dnsServer.IsBlockedClient(ip, id) </s> add return client, nil } return emptyClient, nil } </s> remove return nil, nil </s> add return &querylog.Client{ Name: "", DisallowedRule: rule, WHOIS: &querylog.ClientWHOIS{}, Disallowed: disallowed, } </s> add // clientInfo is a wrapper around Find to make it a valid client finder for // the query log. func (clients *clientsContainer) clientInfo( ip net.IP, id string, disallowed bool, rule string, ) (c *querylog.Client) { whois := &querylog.ClientWHOIS{} client, ok := clients.Find(id) if ok { </s> remove name = rc.Host whois = toQueryLogWHOIS(rc.WHOISInfo) </s> add continue </s> add disallowed, disallowedRule := clients.dnsServer.IsBlockedClient(ip, id)
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
internal/home/clients.go
keep keep keep keep replace keep keep keep keep keep
<mask> Disallowed: disallowed, <mask> }, nil <mask> } <mask> <mask> return nil, nil <mask> } <mask> <mask> func (clients *clientsContainer) Find(id string) (c *Client, ok bool) { <mask> clients.lock.Lock() <mask> defer clients.lock.Unlock() </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove }, nil </s> add } } if ip == nil { return nil } var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if ok { return &querylog.Client{ Name: rc.Host, DisallowedRule: rule, WHOIS: toQueryLogWHOIS(rc.WHOISInfo), Disallowed: disallowed, } </s> add // clientInfo is a wrapper around Find to make it a valid client finder for // the query log. func (clients *clientsContainer) clientInfo( ip net.IP, id string, disallowed bool, rule string, ) (c *querylog.Client) { whois := &querylog.ClientWHOIS{} client, ok := clients.Find(id) if ok { </s> remove Name: name, DisallowedRule: disallowedRule, </s> add Name: client.Name, DisallowedRule: rule, </s> remove disallowed, disallowedRule := clients.dnsServer.IsBlockedClient(ip, id) </s> add return client, nil } return emptyClient, nil } </s> remove var name string whois := &querylog.ClientWHOIS{} </s> add </s> remove c, ok := clients.Find(id) if ok { name = c.Name } else if ip != nil { var rc *RuntimeClient rc, ok = clients.FindRuntimeClient(ip) if !ok { continue } </s> add client := clients.clientInfo(ip, id, disallowed, disallowedRule) if client.Name == "" && client.DisallowedRule == "" { emptyClient = client
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
internal/home/clients.go
keep keep keep keep replace replace keep keep keep keep keep
<mask> 'description': > <mask> The rule due to which the client is allowed or blocked. <mask> 'name': <mask> 'description': > <mask> Persistent client's name or an empty string if this is a runtime <mask> client. <mask> 'type': 'string' <mask> 'whois': <mask> '$ref': '#/components/schemas/QueryLogItemClientWhois' <mask> 'required': <mask> - 'disallowed' </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove 'description': 'Client and host access list' </s> add 'description': > Client and host access list. Each of the lists should contain only unique elements. In addition, allowed and disallowed lists cannot contain the same elements. </s> remove "client_not_in_allowed_clients": "The client is not allowed because it is not in the \"Allowed clients\" list.", </s> add "filter_allowlist": "WARNING: This action also will exclude the rule \"{{disallowed_rule}}\" from the list of allowed clients.", "last_rule_in_allowlist": "Cannot disallow this client because excluding the rule \"{{disallowed_rule}}\" will DISABLE \"Allowed clients\" list.", </s> remove // findMultiple is a wrapper around Find to make it a valid client finder for // the query log. err is always nil. </s> add // findMultiple returns info about client. If no information about the client // is found, it sends the client by default only with the "Disallowed" field // filled in. err is always nil. </s> remove var name string whois := &querylog.ClientWHOIS{} </s> add </s> add // clientInfo is a wrapper around Find to make it a valid client finder for // the query log. func (clients *clientsContainer) clientInfo( ip net.IP, id string, disallowed bool, rule string, ) (c *querylog.Client) { whois := &querylog.ClientWHOIS{} client, ok := clients.Find(id) if ok { </s> add var emptyClient *querylog.Client
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
openapi/openapi.yaml
keep keep keep keep replace keep keep keep keep keep
<mask> '$ref': '#/components/schemas/AccessList' <mask> 'AccessSetRequest': <mask> '$ref': '#/components/schemas/AccessList' <mask> 'AccessList': <mask> 'description': 'Client and host access list' <mask> 'properties': <mask> 'allowed_clients': <mask> 'description': > <mask> The allowlist of clients: IP addresses, CIDRs, or client IDs. <mask> 'items': </s> Pull request: 3419 client allowlist collision Updates #3419. Squashed commit of the following: commit 370094c00d9c15b1336fbedb1e233bd4436c9898 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:31:16 2021 +0300 added link to github issue commit 407ba9b2db46b887a30ddb081bd37c56e56b0496 Merge: 426c8146 80548233 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 17:29:52 2021 +0300 Merge branch 'master' into 3419-client-allowlist-collision commit 426c8146cff5c112ebb25192af276c6601200528 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 16:28:11 2021 +0300 fix en commit d28c6022321828c6bdc55c3f9a4f655b26d146d2 Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:49:12 2021 +0300 added missing space commit b374a09327968ca5343c1595d1ab8cf317c15ffe Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Fri Sep 10 15:43:55 2021 +0300 fixes after review commit 2be629d66e4703e2f5a85615bf1eaaa92e03c6fd Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Thu Sep 9 14:17:19 2021 +0300 fixes commit 5c2aa6201cc0ecf404d4057e354fbb0bdadcdd6d Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 15:04:30 2021 +0300 return empty line to locale file commit 3631c3772babbd595b1c3de4a7e91be6bac3e80f Author: Dmitriy Seregin <d.seregin@adguard.com> Date: Wed Sep 8 13:57:51 2021 +0300 all: fix collisions in access lists && expand block/unblock client </s> remove Persistent client's name or an empty string if this is a runtime client. </s> add Persistent client's name or runtime client's hostname. </s> remove "client_not_in_allowed_clients": "The client is not allowed because it is not in the \"Allowed clients\" list.", </s> add "filter_allowlist": "WARNING: This action also will exclude the rule \"{{disallowed_rule}}\" from the list of allowed clients.", "last_rule_in_allowlist": "Cannot disallow this client because excluding the rule \"{{disallowed_rule}}\" will DISABLE \"Allowed clients\" list.", </s> add err = validateAccessSet(list) if err != nil { httpError(r, w, http.StatusBadRequest, err.Error()) return } </s> add if (disallowed) { if (!disallowed_rule) { allowed_clients = allowed_clients.concat(ip); } else { disallowed_clients = disallowed_clients .filter((client) => client !== disallowed_rule); } } else if (allowed_clients.length > 1) { allowed_clients = allowed_clients .filter((client) => client !== disallowed_rule); } else { disallowed_clients = disallowed_clients.concat(ip); } </s> remove onClick={isNotInAllowedList ? undefined : onClick} disabled={isNotInAllowedList || processingSet} title={t(isNotInAllowedList ? 'client_not_in_allowed_clients' : text)} </s> add onClick={onClick} disabled={disabled} title={lastRuleInAllowlist ? t('last_rule_in_allowlist', { disallowed_rule }) : ''} </s> add var emptyClient *querylog.Client
https://github.com/AdguardTeam/AdGuardHome/commit/8fdd789474ca1151dfc945fd404883ebb2ffedf1
openapi/openapi.yaml
keep add keep keep keep keep
<mask> s.leases = nil <mask> s.IPpool = make(map[[4]byte]net.HardwareAddr) <mask> <mask> data, err := ioutil.ReadFile(s.conf.DBFilePath) <mask> if err != nil { <mask> if !os.IsNotExist(err) { </s> - DHCP: normalize leases on startup (prioritize static leases over dynamic) </s> remove log.Info("DHCP: loaded %d leases from DB", numLeases) </s> add log.Info("DHCP: loaded %d (%d) leases from DB", len(s.leases), numLeases) } // Skip duplicate leases // Static leases have a priority over dynamic leases func normalizeLeases(staticLeases, dynLeases []*Lease) []*Lease { leases := []*Lease{} index := map[string]int{} for i, lease := range staticLeases { _, ok := index[lease.HWAddr.String()] if ok { continue // skip the lease with the same HW address } index[lease.HWAddr.String()] = i leases = append(leases, lease) } for i, lease := range dynLeases { _, ok := index[lease.HWAddr.String()] if ok { continue // skip the lease with the same HW address } index[lease.HWAddr.String()] = i leases = append(leases, lease) } return leases </s> remove s.leases = append(s.leases, &lease) </s> add if obj[i].Expiry == leaseExpireStatic { staticLeases = append(staticLeases, &lease) } else { dynLeases = append(dynLeases, &lease) } } </s> add s.leases = normalizeLeases(staticLeases, dynLeases) for _, lease := range s.leases { </s> add "github.com/stretchr/testify/assert"
https://github.com/AdguardTeam/AdGuardHome/commit/906f26d7d276c181960048a2c059d5b141e71f0a
dhcpd/db.go
keep keep keep keep replace keep keep keep keep keep
<mask> Hostname: obj[i].Hostname, <mask> Expiry: time.Unix(obj[i].Expiry, 0), <mask> } <mask> <mask> s.leases = append(s.leases, &lease) <mask> <mask> s.reserveIP(lease.IP, lease.HWAddr) <mask> } <mask> log.Info("DHCP: loaded %d leases from DB", numLeases) <mask> } </s> - DHCP: normalize leases on startup (prioritize static leases over dynamic) </s> add s.leases = normalizeLeases(staticLeases, dynLeases) for _, lease := range s.leases { </s> remove log.Info("DHCP: loaded %d leases from DB", numLeases) </s> add log.Info("DHCP: loaded %d (%d) leases from DB", len(s.leases), numLeases) } // Skip duplicate leases // Static leases have a priority over dynamic leases func normalizeLeases(staticLeases, dynLeases []*Lease) []*Lease { leases := []*Lease{} index := map[string]int{} for i, lease := range staticLeases { _, ok := index[lease.HWAddr.String()] if ok { continue // skip the lease with the same HW address } index[lease.HWAddr.String()] = i leases = append(leases, lease) } for i, lease := range dynLeases { _, ok := index[lease.HWAddr.String()] if ok { continue // skip the lease with the same HW address } index[lease.HWAddr.String()] = i leases = append(leases, lease) } return leases </s> add "github.com/stretchr/testify/assert" </s> add dynLeases := []*Lease{} staticLeases := []*Lease{}
https://github.com/AdguardTeam/AdGuardHome/commit/906f26d7d276c181960048a2c059d5b141e71f0a
dhcpd/db.go
keep keep add keep keep keep keep keep keep
<mask> } <mask> } <mask> <mask> s.reserveIP(lease.IP, lease.HWAddr) <mask> } <mask> <mask> log.Info("DHCP: loaded %d (%d) leases from DB", len(s.leases), numLeases) <mask> } <mask> </s> - DHCP: normalize leases on startup (prioritize static leases over dynamic) </s> remove s.leases = append(s.leases, &lease) </s> add if obj[i].Expiry == leaseExpireStatic { staticLeases = append(staticLeases, &lease) } else { dynLeases = append(dynLeases, &lease) } } </s> remove log.Info("DHCP: loaded %d leases from DB", numLeases) </s> add log.Info("DHCP: loaded %d (%d) leases from DB", len(s.leases), numLeases) } // Skip duplicate leases // Static leases have a priority over dynamic leases func normalizeLeases(staticLeases, dynLeases []*Lease) []*Lease { leases := []*Lease{} index := map[string]int{} for i, lease := range staticLeases { _, ok := index[lease.HWAddr.String()] if ok { continue // skip the lease with the same HW address } index[lease.HWAddr.String()] = i leases = append(leases, lease) } for i, lease := range dynLeases { _, ok := index[lease.HWAddr.String()] if ok { continue // skip the lease with the same HW address } index[lease.HWAddr.String()] = i leases = append(leases, lease) } return leases </s> add "github.com/stretchr/testify/assert" </s> add dynLeases := []*Lease{} staticLeases := []*Lease{}
https://github.com/AdguardTeam/AdGuardHome/commit/906f26d7d276c181960048a2c059d5b141e71f0a
dhcpd/db.go
keep keep keep keep replace keep keep keep keep keep
<mask> s.leases = append(s.leases, &lease) <mask> <mask> s.reserveIP(lease.IP, lease.HWAddr) <mask> } <mask> log.Info("DHCP: loaded %d leases from DB", numLeases) <mask> } <mask> <mask> // Store lease table in DB <mask> func (s *Server) dbStore() { <mask> var leases []leaseJSON </s> - DHCP: normalize leases on startup (prioritize static leases over dynamic) </s> remove s.leases = append(s.leases, &lease) </s> add if obj[i].Expiry == leaseExpireStatic { staticLeases = append(staticLeases, &lease) } else { dynLeases = append(dynLeases, &lease) } } </s> add s.leases = normalizeLeases(staticLeases, dynLeases) for _, lease := range s.leases { </s> add "github.com/stretchr/testify/assert" </s> add dynLeases := []*Lease{} staticLeases := []*Lease{}
https://github.com/AdguardTeam/AdGuardHome/commit/906f26d7d276c181960048a2c059d5b141e71f0a
dhcpd/db.go
keep keep add keep keep keep keep keep keep
<mask> "time" <mask> <mask> "github.com/krolaw/dhcp4" <mask> ) <mask> <mask> func check(t *testing.T, result bool, msg string) { <mask> if !result { <mask> t.Fatal(msg) <mask> } </s> - DHCP: normalize leases on startup (prioritize static leases over dynamic) </s> remove log.Info("DHCP: loaded %d leases from DB", numLeases) </s> add log.Info("DHCP: loaded %d (%d) leases from DB", len(s.leases), numLeases) } // Skip duplicate leases // Static leases have a priority over dynamic leases func normalizeLeases(staticLeases, dynLeases []*Lease) []*Lease { leases := []*Lease{} index := map[string]int{} for i, lease := range staticLeases { _, ok := index[lease.HWAddr.String()] if ok { continue // skip the lease with the same HW address } index[lease.HWAddr.String()] = i leases = append(leases, lease) } for i, lease := range dynLeases { _, ok := index[lease.HWAddr.String()] if ok { continue // skip the lease with the same HW address } index[lease.HWAddr.String()] = i leases = append(leases, lease) } return leases </s> remove s.leases = append(s.leases, &lease) </s> add if obj[i].Expiry == leaseExpireStatic { staticLeases = append(staticLeases, &lease) } else { dynLeases = append(dynLeases, &lease) } } </s> add dynLeases := []*Lease{} staticLeases := []*Lease{} </s> add s.leases = normalizeLeases(staticLeases, dynLeases) for _, lease := range s.leases {
https://github.com/AdguardTeam/AdGuardHome/commit/906f26d7d276c181960048a2c059d5b141e71f0a
dhcpd/dhcpd_test.go
keep replace keep keep keep replace keep keep keep keep
<mask> <mask> export const refreshFilters = () => async (dispatch) => { <mask> dispatch(refreshFiltersRequest()); <mask> dispatch(showLoading()); <mask> try { <mask> const data = await apiClient.refreshFilters(); <mask> const { updated } = data; <mask> dispatch(refreshFiltersSuccess()); <mask> <mask> if (updated > 0) { </s> + client: handle allowlist refresh </s> remove return this.makeRequest(path, method); </s> add const parameters = { data: config, headers: { 'Content-Type': 'application/json' }, }; return this.makeRequest(path, method, parameters); </s> add handleRefresh = () => { this.props.refreshFilters({ whitelist: false }); }; </s> remove refreshFilters() { </s> add refreshFilters(config) { </s> add handleRefresh = () => { this.props.refreshFilters({ whitelist: true }); }; </s> remove refreshFilters, </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/90b25300df15c588b4bea1eac02e92017c71d315
client/src/actions/filtering.js
keep keep keep keep replace keep keep keep keep keep
<mask> const { path, method } = this.FILTERING_STATUS; <mask> return this.makeRequest(path, method); <mask> } <mask> <mask> refreshFilters() { <mask> const { path, method } = this.FILTERING_REFRESH; <mask> return this.makeRequest(path, method); <mask> } <mask> <mask> addFilter(config) { </s> + client: handle allowlist refresh </s> remove return this.makeRequest(path, method); </s> add const parameters = { data: config, headers: { 'Content-Type': 'application/json' }, }; return this.makeRequest(path, method, parameters); </s> remove const data = await apiClient.refreshFilters(); </s> add const data = await apiClient.refreshFilters(config); </s> remove export const refreshFilters = () => async (dispatch) => { </s> add export const refreshFilters = config => async (dispatch) => { </s> add handleRefresh = () => { this.props.refreshFilters({ whitelist: false }); }; </s> add handleRefresh = () => { this.props.refreshFilters({ whitelist: true }); }; </s> remove refreshFilters, </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/90b25300df15c588b4bea1eac02e92017c71d315
client/src/api/Api.js
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> refreshFilters() { <mask> const { path, method } = this.FILTERING_REFRESH; <mask> return this.makeRequest(path, method); <mask> } <mask> <mask> addFilter(config) { <mask> const { path, method } = this.FILTERING_ADD_FILTER; <mask> const parameters = { </s> + client: handle allowlist refresh </s> remove refreshFilters() { </s> add refreshFilters(config) { </s> remove const data = await apiClient.refreshFilters(); </s> add const data = await apiClient.refreshFilters(config); </s> remove export const refreshFilters = () => async (dispatch) => { </s> add export const refreshFilters = config => async (dispatch) => { </s> add handleRefresh = () => { this.props.refreshFilters({ whitelist: false }); }; </s> add handleRefresh = () => { this.props.refreshFilters({ whitelist: true }); }; </s> remove refreshFilters, </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/90b25300df15c588b4bea1eac02e92017c71d315
client/src/api/Api.js
keep add keep keep keep keep keep
<mask> }; <mask> <mask> render() { <mask> const { <mask> t, <mask> toggleFilteringModal, <mask> addFilter, </s> + client: handle allowlist refresh </s> add handleRefresh = () => { this.props.refreshFilters({ whitelist: false }); }; </s> remove refreshFilters, </s> add </s> remove refreshFilters, </s> add </s> remove return this.makeRequest(path, method); </s> add const parameters = { data: config, headers: { 'Content-Type': 'application/json' }, }; return this.makeRequest(path, method, parameters); </s> remove refreshFilters() { </s> add refreshFilters(config) { </s> remove const data = await apiClient.refreshFilters(); </s> add const data = await apiClient.refreshFilters(config);
https://github.com/AdguardTeam/AdGuardHome/commit/90b25300df15c588b4bea1eac02e92017c71d315
client/src/components/Filters/DnsAllowlist.js
keep keep keep keep replace keep keep keep keep keep
<mask> render() { <mask> const { <mask> t, <mask> toggleFilteringModal, <mask> refreshFilters, <mask> addFilter, <mask> toggleFilterStatus, <mask> filtering: { <mask> whitelistFilters, <mask> isModalOpen, </s> + client: handle allowlist refresh </s> remove refreshFilters, </s> add </s> add handleRefresh = () => { this.props.refreshFilters({ whitelist: true }); }; </s> add handleRefresh = () => { this.props.refreshFilters({ whitelist: false }); }; </s> remove return this.makeRequest(path, method); </s> add const parameters = { data: config, headers: { 'Content-Type': 'application/json' }, }; return this.makeRequest(path, method, parameters); </s> remove refreshFilters() { </s> add refreshFilters(config) { </s> remove const data = await apiClient.refreshFilters(); </s> add const data = await apiClient.refreshFilters(config);
https://github.com/AdguardTeam/AdGuardHome/commit/90b25300df15c588b4bea1eac02e92017c71d315
client/src/components/Filters/DnsAllowlist.js
keep keep keep keep replace keep keep keep keep keep
<mask> whitelist={whitelist} <mask> /> <mask> <Actions <mask> handleAdd={() => toggleFilteringModal({ type: MODAL_TYPE.ADD })} <mask> handleRefresh={refreshFilters} <mask> processingRefreshFilters={processingRefreshFilters} <mask> whitelist={whitelist} <mask> /> <mask> </Card> <mask> </div> </s> + client: handle allowlist refresh </s> remove handleRefresh={refreshFilters} </s> add handleRefresh={this.handleRefresh} </s> remove export const refreshFilters = () => async (dispatch) => { </s> add export const refreshFilters = config => async (dispatch) => { </s> add handleRefresh = () => { this.props.refreshFilters({ whitelist: false }); }; </s> remove const data = await apiClient.refreshFilters(); </s> add const data = await apiClient.refreshFilters(config); </s> add handleRefresh = () => { this.props.refreshFilters({ whitelist: true }); }; </s> remove refreshFilters, </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/90b25300df15c588b4bea1eac02e92017c71d315
client/src/components/Filters/DnsAllowlist.js
keep keep keep add keep keep keep keep keep
<mask> toggleFilter = (url, data) => { <mask> this.props.toggleFilterStatus(url, data); <mask> }; <mask> <mask> render() { <mask> const { <mask> t, <mask> toggleFilteringModal, <mask> addFilter, </s> + client: handle allowlist refresh </s> add handleRefresh = () => { this.props.refreshFilters({ whitelist: true }); }; </s> remove refreshFilters, </s> add </s> remove refreshFilters, </s> add </s> remove return this.makeRequest(path, method); </s> add const parameters = { data: config, headers: { 'Content-Type': 'application/json' }, }; return this.makeRequest(path, method, parameters); </s> remove export const refreshFilters = () => async (dispatch) => { </s> add export const refreshFilters = config => async (dispatch) => { </s> remove const data = await apiClient.refreshFilters(); </s> add const data = await apiClient.refreshFilters(config);
https://github.com/AdguardTeam/AdGuardHome/commit/90b25300df15c588b4bea1eac02e92017c71d315
client/src/components/Filters/DnsBlocklist.js
keep keep keep keep replace keep keep keep keep keep
<mask> render() { <mask> const { <mask> t, <mask> toggleFilteringModal, <mask> refreshFilters, <mask> addFilter, <mask> filtering: { <mask> filters, <mask> isModalOpen, <mask> isFilterAdded, </s> + client: handle allowlist refresh </s> remove refreshFilters, </s> add </s> add handleRefresh = () => { this.props.refreshFilters({ whitelist: true }); }; </s> add handleRefresh = () => { this.props.refreshFilters({ whitelist: false }); }; </s> remove return this.makeRequest(path, method); </s> add const parameters = { data: config, headers: { 'Content-Type': 'application/json' }, }; return this.makeRequest(path, method, parameters); </s> remove refreshFilters() { </s> add refreshFilters(config) { </s> remove const data = await apiClient.refreshFilters(); </s> add const data = await apiClient.refreshFilters(config);
https://github.com/AdguardTeam/AdGuardHome/commit/90b25300df15c588b4bea1eac02e92017c71d315
client/src/components/Filters/DnsBlocklist.js
keep keep keep keep replace keep keep keep keep keep
<mask> toggleFilter={this.toggleFilter} <mask> /> <mask> <Actions <mask> handleAdd={() => toggleFilteringModal({ type: MODAL_TYPE.ADD })} <mask> handleRefresh={refreshFilters} <mask> processingRefreshFilters={processingRefreshFilters} <mask> /> <mask> </Card> <mask> </div> <mask> </div> </s> + client: handle allowlist refresh </s> remove handleRefresh={refreshFilters} </s> add handleRefresh={this.handleRefresh} </s> remove export const refreshFilters = () => async (dispatch) => { </s> add export const refreshFilters = config => async (dispatch) => { </s> add handleRefresh = () => { this.props.refreshFilters({ whitelist: false }); }; </s> remove const data = await apiClient.refreshFilters(); </s> add const data = await apiClient.refreshFilters(config); </s> add handleRefresh = () => { this.props.refreshFilters({ whitelist: true }); }; </s> remove refreshFilters, </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/90b25300df15c588b4bea1eac02e92017c71d315
client/src/components/Filters/DnsBlocklist.js
keep keep keep keep replace keep keep keep keep keep
<mask> // so that all incoming packets are ignored and the discovering process <mask> // is spoiled. <mask> // <mask> // It's also known that listening on the specified interface's address <mask> // ignores broadcasted packets when reading. <mask> var c net.PacketConn <mask> if c, err = listenPacketReusable(iface.Name, "udp4", ":68"); err != nil { <mask> return false, fmt.Errorf("couldn't listen on :68: %w", err) <mask> } <mask> defer func() { err = errors.WithDeferred(err, c.Close()) }() </s> Pull request: home: mv local domain name to dhcp setts Closes #3367. Squashed commit of the following: commit e2cabcac2d91af24b9e5f4ac8f78daf5e8d339b9 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 25 19:35:31 2022 +0300 home: imp test, skip dhcp test on windows commit e58053f11e081630ad4e8d1e77a7a74226029db0 Merge: ff2fe87d 0b72bcc5 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 25 19:10:25 2022 +0300 Merge branch 'master' into 3367-dhcp-local-domain-name commit ff2fe87d8cab12e60d045be636e366e392d6d96f Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Dec 30 20:55:34 2021 +0300 home: mv local domain name to dhcp setts </s> remove // TODO(e.burkov): leases.db isn't created on Windows so removing it // causes an error. Split the test to make it run properly on different // operating systems. t.Cleanup(func() { _ = os.Remove("leases.db") }) </s> add testutil.CleanupAndRequireSuccess(t, func() (err error) { return os.Remove("leases.db") }) </s> remove s.conf.Enabled = conf.Enabled s.conf.InterfaceName = conf.InterfaceName s.conf.HTTPRegister = conf.HTTPRegister s.conf.ConfigModified = conf.ConfigModified s.conf.DBFilePath = filepath.Join(conf.WorkDir, dbFilename) </s> add HTTPRegister: conf.HTTPRegister, Enabled: conf.Enabled, InterfaceName: conf.InterfaceName, LocalDomainName: conf.LocalDomainName, DBFilePath: filepath.Join(conf.WorkDir, dbFilename), }, } </s> remove // Set the broadcast bit in the DHCPNAK, so that the // relay agent broadcasted it to the client, because the // client may not have a correct network address or // subnet mask, and the client may not be answering ARP // requests. </s> add // Set the broadcast bit in the DHCPNAK, so that the relay agent // broadcasts it to the client, because the client may not have // a correct network address or subnet mask, and the client may not // be answering ARP requests. </s> remove c := dhcpd.ServerConfig{} Context.dhcpServer.WriteDiskConfig(&c) </s> add c := &dhcpd.ServerConfig{} Context.dhcpServer.WriteDiskConfig(c) </s> add // TODO(a.garipov): Properly decouple the DHCP server from the client // storage. if runtime.GOOS == "windows" { t.Skip("skipping dhcp test on windows") } </s> add c.LocalDomainName = s.conf.LocalDomainName
https://github.com/AdguardTeam/AdGuardHome/commit/90c17c79de14b51d1979c67650177b784216487c
internal/aghnet/dhcp_unix.go