docstring_tokens
stringlengths
18
16.9k
code_tokens
stringlengths
75
1.81M
html_url
stringlengths
74
116
file_name
stringlengths
3
311
keep keep add keep keep keep keep
<mask> </div> <mask> </div> <mask> </div> <mask> </Tabs> <mask> </div> <mask> <mask> <div className="modal-footer"> </s> + client: handle upstream DNS servers for clients </s> add import Examples from '../Dns/Upstream/Examples'; </s> remove use_global_settings: true, use_global_blocked_services: true, ...client, </s> add upstreams: (upstreams && upstreams.join('\n')) || '', ...values, </s> add const { upstreams, whois_info, ...values } = client; </s> remove if (values && values.blocked_services) { const blocked_services = Object .keys(values.blocked_services) .filter(service => values.blocked_services[service]); config = { ...values, blocked_services }; </s> add if (values) { if (values.blocked_services) { config.blocked_services = Object .keys(values.blocked_services) .filter(service => values.blocked_services[service]); } if (values.upstreams && typeof values.upstreams === 'string') { config.upstreams = normalizeTextarea(values.upstreams); } else { config.upstreams = []; } </s> remove let config = values; </s> add const config = values; </s> add import { normalizeTextarea } from '../../../helpers/helpers';
https://github.com/AdguardTeam/AdGuardHome/commit/6684a120ac9909140e4ecbe674e09c8f24e87ac4
client/src/components/Settings/Clients/Form.js
keep keep replace keep keep replace keep keep keep keep
<mask> <mask> // Unpack all files from .zip file to the specified directory <mask> func zipFileUnpack(zipfile, outdir string) error { <mask> r, err := zip.OpenReader(zipfile) <mask> if err != nil { <mask> return fmt.Errorf("zip.OpenReader(): %s", err) <mask> } <mask> defer r.Close() <mask> <mask> for _, zf := range r.File { </s> * auto-update: zipFileUnpack() returns list of unpacked files </s> add var files []string var err2 error var zr io.ReadCloser </s> remove zr.Close() </s> add f.Close() log.Tracef("created file %s", fn) files = append(files, fi.Name()) </s> remove zr, err := zf.Open() </s> add zr, err = zf.Open() </s> remove return nil </s> add zr.Close() return files, err2 </s> remove return fmt.Errorf("zip file Open(): %s", err) </s> add err2 = fmt.Errorf("zip file Open(): %s", err) break
https://github.com/AdguardTeam/AdGuardHome/commit/66c670c6fff0489ce1195e5fabec1128505220b5
control_update.go
keep keep keep add keep keep keep keep keep
<mask> return nil, fmt.Errorf("zip.OpenReader(): %s", err) <mask> } <mask> defer r.Close() <mask> <mask> for _, zf := range r.File { <mask> zr, err = zf.Open() <mask> if err != nil { <mask> err2 = fmt.Errorf("zip file Open(): %s", err) <mask> break </s> * auto-update: zipFileUnpack() returns list of unpacked files </s> remove zr, err := zf.Open() </s> add zr, err = zf.Open() </s> remove return fmt.Errorf("zip file Open(): %s", err) </s> add err2 = fmt.Errorf("zip file Open(): %s", err) break </s> remove return fmt.Errorf("zip.OpenReader(): %s", err) </s> add return nil, fmt.Errorf("zip.OpenReader(): %s", err) </s> remove if err != nil { return fmt.Errorf("zip file Read(): %s", err) </s> add if err != nil && !os.IsExist(err) { err2 = fmt.Errorf("os.Mkdir(): %s", err) break </s> remove zr.Close() return fmt.Errorf("os.OpenFile(): %s", err) </s> add err2 = fmt.Errorf("os.OpenFile(): %s", err) break </s> remove zr.Close() return fmt.Errorf("io.Copy(): %s", err) </s> add f.Close() err2 = fmt.Errorf("io.Copy(): %s", err) break
https://github.com/AdguardTeam/AdGuardHome/commit/66c670c6fff0489ce1195e5fabec1128505220b5
control_update.go
keep replace keep replace keep keep keep
<mask> for _, zf := range r.File { <mask> zr, err := zf.Open() <mask> if err != nil { <mask> return fmt.Errorf("zip file Open(): %s", err) <mask> } <mask> fi := zf.FileInfo() <mask> fn := filepath.Join(outdir, fi.Name()) </s> * auto-update: zipFileUnpack() returns list of unpacked files </s> add var files []string var err2 error var zr io.ReadCloser </s> remove return fmt.Errorf("zip.OpenReader(): %s", err) </s> add return nil, fmt.Errorf("zip.OpenReader(): %s", err) </s> add if len(fi.Name()) == 0 { continue } </s> remove if err != nil { return fmt.Errorf("zip file Read(): %s", err) </s> add if err != nil && !os.IsExist(err) { err2 = fmt.Errorf("os.Mkdir(): %s", err) break </s> remove zr.Close() return fmt.Errorf("os.OpenFile(): %s", err) </s> add err2 = fmt.Errorf("os.OpenFile(): %s", err) break
https://github.com/AdguardTeam/AdGuardHome/commit/66c670c6fff0489ce1195e5fabec1128505220b5
control_update.go
keep add keep keep keep keep
<mask> <mask> fi := zf.FileInfo() <mask> fn := filepath.Join(outdir, fi.Name()) <mask> <mask> if fi.IsDir() { <mask> err = os.Mkdir(fn, fi.Mode()) </s> * auto-update: zipFileUnpack() returns list of unpacked files </s> remove if err != nil { return fmt.Errorf("zip file Read(): %s", err) </s> add if err != nil && !os.IsExist(err) { err2 = fmt.Errorf("os.Mkdir(): %s", err) break </s> remove return fmt.Errorf("zip file Open(): %s", err) </s> add err2 = fmt.Errorf("zip file Open(): %s", err) break </s> remove zr, err := zf.Open() </s> add zr, err = zf.Open() </s> remove zr.Close() return fmt.Errorf("os.OpenFile(): %s", err) </s> add err2 = fmt.Errorf("os.OpenFile(): %s", err) break </s> add log.Tracef("created directory %s", fn) </s> remove e := zipFileUnpack(fn, outdir) </s> add files, e := zipFileUnpack(fn, outdir)
https://github.com/AdguardTeam/AdGuardHome/commit/66c670c6fff0489ce1195e5fabec1128505220b5
control_update.go
keep keep keep keep replace replace keep keep keep keep keep
<mask> fn := filepath.Join(outdir, fi.Name()) <mask> <mask> if fi.IsDir() { <mask> err = os.Mkdir(fn, fi.Mode()) <mask> if err != nil { <mask> return fmt.Errorf("zip file Read(): %s", err) <mask> } <mask> continue <mask> } <mask> <mask> f, err := os.OpenFile(fn, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode()) </s> * auto-update: zipFileUnpack() returns list of unpacked files </s> add if len(fi.Name()) == 0 { continue } </s> add log.Tracef("created directory %s", fn) </s> remove zr.Close() return fmt.Errorf("os.OpenFile(): %s", err) </s> add err2 = fmt.Errorf("os.OpenFile(): %s", err) break </s> remove return fmt.Errorf("zip file Open(): %s", err) </s> add err2 = fmt.Errorf("zip file Open(): %s", err) break </s> remove zr, err := zf.Open() </s> add zr, err = zf.Open() </s> add var files []string var err2 error var zr io.ReadCloser
https://github.com/AdguardTeam/AdGuardHome/commit/66c670c6fff0489ce1195e5fabec1128505220b5
control_update.go
keep add keep keep keep keep keep
<mask> break <mask> } <mask> continue <mask> } <mask> <mask> f, err := os.OpenFile(fn, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode()) <mask> if err != nil { </s> * auto-update: zipFileUnpack() returns list of unpacked files </s> remove if err != nil { return fmt.Errorf("zip file Read(): %s", err) </s> add if err != nil && !os.IsExist(err) { err2 = fmt.Errorf("os.Mkdir(): %s", err) break </s> remove zr.Close() return fmt.Errorf("os.OpenFile(): %s", err) </s> add err2 = fmt.Errorf("os.OpenFile(): %s", err) break </s> add if len(fi.Name()) == 0 { continue } </s> remove zr.Close() return fmt.Errorf("io.Copy(): %s", err) </s> add f.Close() err2 = fmt.Errorf("io.Copy(): %s", err) break </s> remove return fmt.Errorf("zip file Open(): %s", err) </s> add err2 = fmt.Errorf("zip file Open(): %s", err) break </s> remove zr, err := zf.Open() </s> add zr, err = zf.Open()
https://github.com/AdguardTeam/AdGuardHome/commit/66c670c6fff0489ce1195e5fabec1128505220b5
control_update.go
keep keep keep keep replace replace keep keep keep replace replace
<mask> } <mask> <mask> f, err := os.OpenFile(fn, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode()) <mask> if err != nil { <mask> zr.Close() <mask> return fmt.Errorf("os.OpenFile(): %s", err) <mask> } <mask> _, err = io.Copy(f, zr) <mask> if err != nil { <mask> zr.Close() <mask> return fmt.Errorf("io.Copy(): %s", err) </s> * auto-update: zipFileUnpack() returns list of unpacked files </s> remove if err != nil { return fmt.Errorf("zip file Read(): %s", err) </s> add if err != nil && !os.IsExist(err) { err2 = fmt.Errorf("os.Mkdir(): %s", err) break </s> add log.Tracef("created directory %s", fn) </s> remove zr.Close() </s> add f.Close() log.Tracef("created file %s", fn) files = append(files, fi.Name()) </s> remove err = zipFileUnpack(u.pkgName, u.updateDir) </s> add _, err = zipFileUnpack(u.pkgName, u.updateDir) </s> remove return fmt.Errorf("zip file Open(): %s", err) </s> add err2 = fmt.Errorf("zip file Open(): %s", err) break
https://github.com/AdguardTeam/AdGuardHome/commit/66c670c6fff0489ce1195e5fabec1128505220b5
control_update.go
keep keep replace keep replace
<mask> return fmt.Errorf("io.Copy(): %s", err) <mask> } <mask> zr.Close() <mask> } <mask> return nil </s> * auto-update: zipFileUnpack() returns list of unpacked files </s> remove zr.Close() return fmt.Errorf("io.Copy(): %s", err) </s> add f.Close() err2 = fmt.Errorf("io.Copy(): %s", err) break </s> remove zr.Close() return fmt.Errorf("os.OpenFile(): %s", err) </s> add err2 = fmt.Errorf("os.OpenFile(): %s", err) break </s> remove if err != nil { return fmt.Errorf("zip file Read(): %s", err) </s> add if err != nil && !os.IsExist(err) { err2 = fmt.Errorf("os.Mkdir(): %s", err) break </s> remove zr, err := zf.Open() </s> add zr, err = zf.Open() </s> remove return fmt.Errorf("zip.OpenReader(): %s", err) </s> add return nil, fmt.Errorf("zip.OpenReader(): %s", err)
https://github.com/AdguardTeam/AdGuardHome/commit/66c670c6fff0489ce1195e5fabec1128505220b5
control_update.go
keep keep keep keep replace keep keep keep keep keep
<mask> log.Tracef("Unpacking the package") <mask> _ = os.Mkdir(u.updateDir, 0755) <mask> _, file := filepath.Split(u.pkgName) <mask> if strings.HasSuffix(file, ".zip") { <mask> err = zipFileUnpack(u.pkgName, u.updateDir) <mask> if err != nil { <mask> return fmt.Errorf("zipFileUnpack() failed: %s", err) <mask> } <mask> } else if strings.HasSuffix(file, ".tar.gz") { <mask> _, err = targzFileUnpack(u.pkgName, u.updateDir) </s> * auto-update: zipFileUnpack() returns list of unpacked files </s> remove if err != nil { return fmt.Errorf("zip file Read(): %s", err) </s> add if err != nil && !os.IsExist(err) { err2 = fmt.Errorf("os.Mkdir(): %s", err) break </s> remove zr.Close() return fmt.Errorf("os.OpenFile(): %s", err) </s> add err2 = fmt.Errorf("os.OpenFile(): %s", err) break </s> remove e := zipFileUnpack(fn, outdir) </s> add files, e := zipFileUnpack(fn, outdir) </s> remove return fmt.Errorf("zip file Open(): %s", err) </s> add err2 = fmt.Errorf("zip file Open(): %s", err) break </s> remove zr.Close() return fmt.Errorf("io.Copy(): %s", err) </s> add f.Close() err2 = fmt.Errorf("io.Copy(): %s", err) break </s> remove zr, err := zf.Open() </s> add zr, err = zf.Open()
https://github.com/AdguardTeam/AdGuardHome/commit/66c670c6fff0489ce1195e5fabec1128505220b5
control_update.go
keep keep keep keep replace keep keep keep keep keep
<mask> func testZipFileUnpack(t *testing.T) { <mask> fn := "./dist/AdGuardHome_v0.95_Windows_amd64.zip" <mask> outdir := "./test-unpack" <mask> _ = os.Mkdir(outdir, 0755) <mask> e := zipFileUnpack(fn, outdir) <mask> if e != nil { <mask> t.Fatalf("FAILED: %s", e) <mask> } <mask> os.RemoveAll(outdir) <mask> } </s> * auto-update: zipFileUnpack() returns list of unpacked files </s> add t.Logf("%v", files) </s> remove err = zipFileUnpack(u.pkgName, u.updateDir) </s> add _, err = zipFileUnpack(u.pkgName, u.updateDir) </s> remove func zipFileUnpack(zipfile, outdir string) error { </s> add // Existing files are overwritten // Return the list of files (not directories) written func zipFileUnpack(zipfile, outdir string) ([]string, error) { </s> remove return fmt.Errorf("zip.OpenReader(): %s", err) </s> add return nil, fmt.Errorf("zip.OpenReader(): %s", err) </s> remove if err != nil { return fmt.Errorf("zip file Read(): %s", err) </s> add if err != nil && !os.IsExist(err) { err2 = fmt.Errorf("os.Mkdir(): %s", err) break </s> remove zr, err := zf.Open() </s> add zr, err = zf.Open()
https://github.com/AdguardTeam/AdGuardHome/commit/66c670c6fff0489ce1195e5fabec1128505220b5
control_update_test.go
keep add keep keep
<mask> t.Fatalf("FAILED: %s", e) <mask> } <mask> os.RemoveAll(outdir) <mask> } </s> * auto-update: zipFileUnpack() returns list of unpacked files </s> remove e := zipFileUnpack(fn, outdir) </s> add files, e := zipFileUnpack(fn, outdir) </s> remove zr.Close() return fmt.Errorf("io.Copy(): %s", err) </s> add f.Close() err2 = fmt.Errorf("io.Copy(): %s", err) break </s> remove zr.Close() </s> add f.Close() log.Tracef("created file %s", fn) files = append(files, fi.Name()) </s> add log.Tracef("created directory %s", fn) </s> remove zr.Close() return fmt.Errorf("os.OpenFile(): %s", err) </s> add err2 = fmt.Errorf("os.OpenFile(): %s", err) break </s> remove return nil </s> add zr.Close() return files, err2
https://github.com/AdguardTeam/AdGuardHome/commit/66c670c6fff0489ce1195e5fabec1128505220b5
control_update_test.go
keep keep add keep keep keep keep keep
<mask> versionCheckJSON []byte <mask> versionCheckLastTime time.Time <mask> <mask> dnsServer *dnsforward.Server <mask> dhcpServer dhcpd.Server <mask> httpServer *http.Server <mask> httpsServer HTTPSServer <mask> </s> * move "dnsctx" to "config" </s> remove dnsctx.rdnsLock.Lock() delete(dnsctx.rdnsIP, ip) dnsctx.rdnsLock.Unlock() </s> add config.dnsctx.rdnsLock.Lock() delete(config.dnsctx.rdnsIP, ip) config.dnsctx.rdnsLock.Unlock() </s> remove ip = <-dnsctx.rdnsChannel </s> add ip = <-config.dnsctx.rdnsChannel </s> remove resp, err := dnsctx.upstream.Exchange(&req) </s> add resp, err := config.dnsctx.upstream.Exchange(&req) </s> remove case dnsctx.rdnsChannel <- ip: </s> add case config.dnsctx.rdnsChannel <- ip: </s> remove dnsctx.rdnsIP[ip] = true </s> add config.dnsctx.rdnsIP[ip] = true </s> remove dnsctx.rdnsLock.Lock() defer dnsctx.rdnsLock.Unlock() _, ok := dnsctx.rdnsIP[ip] </s> add config.dnsctx.rdnsLock.Lock() defer config.dnsctx.rdnsLock.Unlock() _, ok := config.dnsctx.rdnsIP[ip]
https://github.com/AdguardTeam/AdGuardHome/commit/6701e9ce068d7caba926673f0217f7d8108d7db2
home/config.go
keep keep keep keep replace replace keep keep keep keep keep
<mask> rdnsLock sync.Mutex // synchronize access to rdnsIP <mask> upstream upstream.Upstream // Upstream object for our own DNS server <mask> } <mask> <mask> var dnsctx dnsContext <mask> <mask> // initDNSServer creates an instance of the dnsforward.Server <mask> // Please note that we must do it even if we don't start it <mask> // so that we had access to the query log and the stats <mask> func initDNSServer(baseDir string) { <mask> err := os.MkdirAll(baseDir, 0755) </s> * move "dnsctx" to "config" </s> remove ip = <-dnsctx.rdnsChannel </s> add ip = <-config.dnsctx.rdnsChannel </s> remove resp, err := dnsctx.upstream.Exchange(&req) </s> add resp, err := config.dnsctx.upstream.Exchange(&req) </s> remove dnsctx.rdnsLock.Lock() defer dnsctx.rdnsLock.Unlock() _, ok := dnsctx.rdnsIP[ip] </s> add config.dnsctx.rdnsLock.Lock() defer config.dnsctx.rdnsLock.Unlock() _, ok := config.dnsctx.rdnsIP[ip] </s> add dnsctx dnsContext </s> remove dnsctx.upstream, err = upstream.AddressToUpstream(resolverAddress, opts) </s> add config.dnsctx.upstream, err = upstream.AddressToUpstream(resolverAddress, opts) </s> remove dnsctx.rdnsIP = make(map[string]bool) dnsctx.rdnsChannel = make(chan string, 256) </s> add config.dnsctx.rdnsIP = make(map[string]bool) config.dnsctx.rdnsChannel = make(chan string, 256)
https://github.com/AdguardTeam/AdGuardHome/commit/6701e9ce068d7caba926673f0217f7d8108d7db2
home/dns.go
keep keep keep keep replace keep keep keep keep replace replace keep keep keep keep
<mask> resolverAddress := fmt.Sprintf("%s:%d", bindhost, config.DNS.Port) <mask> opts := upstream.Options{ <mask> Timeout: rdnsTimeout, <mask> } <mask> dnsctx.upstream, err = upstream.AddressToUpstream(resolverAddress, opts) <mask> if err != nil { <mask> log.Error("upstream.AddressToUpstream: %s", err) <mask> return <mask> } <mask> dnsctx.rdnsIP = make(map[string]bool) <mask> dnsctx.rdnsChannel = make(chan string, 256) <mask> go asyncRDNSLoop() <mask> } <mask> <mask> func isRunning() bool { </s> * move "dnsctx" to "config" </s> remove resp, err := dnsctx.upstream.Exchange(&req) </s> add resp, err := config.dnsctx.upstream.Exchange(&req) </s> remove ip = <-dnsctx.rdnsChannel </s> add ip = <-config.dnsctx.rdnsChannel </s> remove dnsctx.rdnsIP[ip] = true </s> add config.dnsctx.rdnsIP[ip] = true </s> remove dnsctx.rdnsLock.Lock() defer dnsctx.rdnsLock.Unlock() _, ok := dnsctx.rdnsIP[ip] </s> add config.dnsctx.rdnsLock.Lock() defer config.dnsctx.rdnsLock.Unlock() _, ok := config.dnsctx.rdnsIP[ip] </s> remove dnsctx.rdnsLock.Lock() delete(dnsctx.rdnsIP, ip) dnsctx.rdnsLock.Unlock() </s> add config.dnsctx.rdnsLock.Lock() delete(config.dnsctx.rdnsIP, ip) config.dnsctx.rdnsLock.Unlock()
https://github.com/AdguardTeam/AdGuardHome/commit/6701e9ce068d7caba926673f0217f7d8108d7db2
home/dns.go
keep keep replace replace replace keep keep keep replace
<mask> <mask> // add IP to rdnsIP, if not exists <mask> dnsctx.rdnsLock.Lock() <mask> defer dnsctx.rdnsLock.Unlock() <mask> _, ok := dnsctx.rdnsIP[ip] <mask> if ok { <mask> return <mask> } <mask> dnsctx.rdnsIP[ip] = true </s> * move "dnsctx" to "config" </s> remove dnsctx.rdnsLock.Lock() delete(dnsctx.rdnsIP, ip) dnsctx.rdnsLock.Unlock() </s> add config.dnsctx.rdnsLock.Lock() delete(config.dnsctx.rdnsIP, ip) config.dnsctx.rdnsLock.Unlock() </s> remove case dnsctx.rdnsChannel <- ip: </s> add case config.dnsctx.rdnsChannel <- ip: </s> remove ip = <-dnsctx.rdnsChannel </s> add ip = <-config.dnsctx.rdnsChannel </s> remove dnsctx.upstream, err = upstream.AddressToUpstream(resolverAddress, opts) </s> add config.dnsctx.upstream, err = upstream.AddressToUpstream(resolverAddress, opts) </s> remove resp, err := dnsctx.upstream.Exchange(&req) </s> add resp, err := config.dnsctx.upstream.Exchange(&req)
https://github.com/AdguardTeam/AdGuardHome/commit/6701e9ce068d7caba926673f0217f7d8108d7db2
home/dns.go
keep keep keep keep replace keep keep keep keep keep
<mask> dnsctx.rdnsIP[ip] = true <mask> <mask> log.Tracef("Adding %s for rDNS resolve", ip) <mask> select { <mask> case dnsctx.rdnsChannel <- ip: <mask> // <mask> default: <mask> log.Tracef("rDNS queue is full") <mask> } <mask> } </s> * move "dnsctx" to "config" </s> remove dnsctx.rdnsIP[ip] = true </s> add config.dnsctx.rdnsIP[ip] = true </s> remove dnsctx.rdnsLock.Lock() defer dnsctx.rdnsLock.Unlock() _, ok := dnsctx.rdnsIP[ip] </s> add config.dnsctx.rdnsLock.Lock() defer config.dnsctx.rdnsLock.Unlock() _, ok := config.dnsctx.rdnsIP[ip] </s> remove dnsctx.rdnsLock.Lock() delete(dnsctx.rdnsIP, ip) dnsctx.rdnsLock.Unlock() </s> add config.dnsctx.rdnsLock.Lock() delete(config.dnsctx.rdnsIP, ip) config.dnsctx.rdnsLock.Unlock() </s> remove dnsctx.rdnsIP = make(map[string]bool) dnsctx.rdnsChannel = make(chan string, 256) </s> add config.dnsctx.rdnsIP = make(map[string]bool) config.dnsctx.rdnsChannel = make(chan string, 256) </s> remove resp, err := dnsctx.upstream.Exchange(&req) </s> add resp, err := config.dnsctx.upstream.Exchange(&req) </s> remove dnsctx.upstream, err = upstream.AddressToUpstream(resolverAddress, opts) </s> add config.dnsctx.upstream, err = upstream.AddressToUpstream(resolverAddress, opts)
https://github.com/AdguardTeam/AdGuardHome/commit/6701e9ce068d7caba926673f0217f7d8108d7db2
home/dns.go
keep keep keep keep replace keep keep keep keep keep
<mask> log.Debug("Error while calling dns.ReverseAddr(%s): %s", ip, err) <mask> return "" <mask> } <mask> <mask> resp, err := dnsctx.upstream.Exchange(&req) <mask> if err != nil { <mask> log.Error("Error while making an rDNS lookup for %s: %s", ip, err) <mask> return "" <mask> } <mask> if len(resp.Answer) != 1 { </s> * move "dnsctx" to "config" </s> remove dnsctx.upstream, err = upstream.AddressToUpstream(resolverAddress, opts) </s> add config.dnsctx.upstream, err = upstream.AddressToUpstream(resolverAddress, opts) </s> remove dnsctx.rdnsIP = make(map[string]bool) dnsctx.rdnsChannel = make(chan string, 256) </s> add config.dnsctx.rdnsIP = make(map[string]bool) config.dnsctx.rdnsChannel = make(chan string, 256) </s> remove dnsctx.rdnsIP[ip] = true </s> add config.dnsctx.rdnsIP[ip] = true </s> remove dnsctx.rdnsLock.Lock() defer dnsctx.rdnsLock.Unlock() _, ok := dnsctx.rdnsIP[ip] </s> add config.dnsctx.rdnsLock.Lock() defer config.dnsctx.rdnsLock.Unlock() _, ok := config.dnsctx.rdnsIP[ip] </s> remove var dnsctx dnsContext </s> add </s> remove ip = <-dnsctx.rdnsChannel </s> add ip = <-config.dnsctx.rdnsChannel
https://github.com/AdguardTeam/AdGuardHome/commit/6701e9ce068d7caba926673f0217f7d8108d7db2
home/dns.go
keep keep keep keep replace keep keep keep keep keep
<mask> // Add the hostname:IP pair to "Clients" array <mask> func asyncRDNSLoop() { <mask> for { <mask> var ip string <mask> ip = <-dnsctx.rdnsChannel <mask> <mask> host := resolveRDNS(ip) <mask> if len(host) == 0 { <mask> continue <mask> } </s> * move "dnsctx" to "config" </s> remove dnsctx.rdnsLock.Lock() delete(dnsctx.rdnsIP, ip) dnsctx.rdnsLock.Unlock() </s> add config.dnsctx.rdnsLock.Lock() delete(config.dnsctx.rdnsIP, ip) config.dnsctx.rdnsLock.Unlock() </s> remove var dnsctx dnsContext </s> add </s> remove dnsctx.rdnsIP = make(map[string]bool) dnsctx.rdnsChannel = make(chan string, 256) </s> add config.dnsctx.rdnsIP = make(map[string]bool) config.dnsctx.rdnsChannel = make(chan string, 256) </s> remove dnsctx.rdnsLock.Lock() defer dnsctx.rdnsLock.Unlock() _, ok := dnsctx.rdnsIP[ip] </s> add config.dnsctx.rdnsLock.Lock() defer config.dnsctx.rdnsLock.Unlock() _, ok := config.dnsctx.rdnsIP[ip] </s> remove dnsctx.rdnsIP[ip] = true </s> add config.dnsctx.rdnsIP[ip] = true </s> remove dnsctx.upstream, err = upstream.AddressToUpstream(resolverAddress, opts) </s> add config.dnsctx.upstream, err = upstream.AddressToUpstream(resolverAddress, opts)
https://github.com/AdguardTeam/AdGuardHome/commit/6701e9ce068d7caba926673f0217f7d8108d7db2
home/dns.go
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> if len(host) == 0 { <mask> continue <mask> } <mask> <mask> dnsctx.rdnsLock.Lock() <mask> delete(dnsctx.rdnsIP, ip) <mask> dnsctx.rdnsLock.Unlock() <mask> <mask> _, _ = config.clients.AddHost(ip, host, ClientSourceRDNS) <mask> } <mask> } <mask> </s> * move "dnsctx" to "config" </s> remove ip = <-dnsctx.rdnsChannel </s> add ip = <-config.dnsctx.rdnsChannel </s> remove dnsctx.rdnsLock.Lock() defer dnsctx.rdnsLock.Unlock() _, ok := dnsctx.rdnsIP[ip] </s> add config.dnsctx.rdnsLock.Lock() defer config.dnsctx.rdnsLock.Unlock() _, ok := config.dnsctx.rdnsIP[ip] </s> remove dnsctx.rdnsIP[ip] = true </s> add config.dnsctx.rdnsIP[ip] = true </s> remove case dnsctx.rdnsChannel <- ip: </s> add case config.dnsctx.rdnsChannel <- ip: </s> remove dnsctx.rdnsIP = make(map[string]bool) dnsctx.rdnsChannel = make(chan string, 256) </s> add config.dnsctx.rdnsIP = make(map[string]bool) config.dnsctx.rdnsChannel = make(chan string, 256) </s> remove dnsctx.upstream, err = upstream.AddressToUpstream(resolverAddress, opts) </s> add config.dnsctx.upstream, err = upstream.AddressToUpstream(resolverAddress, opts)
https://github.com/AdguardTeam/AdGuardHome/commit/6701e9ce068d7caba926673f0217f7d8108d7db2
home/dns.go
keep add keep keep keep keep
<mask> el := map[string]interface{}{} <mask> c, ok := clients.Find(ip) <mask> if !ok { <mask> var found bool <mask> cj, found = clients.findTemporary(ip) <mask> if !found { </s> Pull request: home: don't miss blocked clients in client search api Merge in DNS/adguard-home from 2428-blocked-runtime-fix to master Updates #2428. Squashed commit of the following: commit 8aaa3e22a894f0335ced93339655771989846c94 Author: Ainar Garipov <[email protected]> Date: Fri Jan 15 16:32:53 2021 +0300 home: don't miss blocked clients in client search api </s> remove ch, ok := clients.FindAutoClient(ip) if !ok { continue // a client with this IP isn't found </s> add var found bool cj, found = clients.findTemporary(ip) if !found { continue </s> remove cj := clientHostToJSON(ip, ch) cj.Disallowed, cj.DisallowedRule = clients.dnsServer.IsBlockedIP(ip) el[ip] = cj </s> add </s> add el[ip] = cj </s> remove respData.Web.Status = fmt.Sprintf("%v", err) </s> add respData.Web.Status = err.Error() </s> remove respData.DNS.Status = fmt.Sprintf("%v", err) </s> add respData.DNS.Status = err.Error() </s> remove el[ip] = cj </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/679bbcdc26775bc3d961cbeef553dce7aa9c091b
internal/home/clientshttp.go
keep keep replace replace replace keep replace replace replace replace keep keep keep
<mask> c, ok := clients.Find(ip) <mask> if !ok { <mask> ch, ok := clients.FindAutoClient(ip) <mask> if !ok { <mask> continue // a client with this IP isn't found <mask> } <mask> cj := clientHostToJSON(ip, ch) <mask> <mask> cj.Disallowed, cj.DisallowedRule = clients.dnsServer.IsBlockedIP(ip) <mask> el[ip] = cj <mask> } else { <mask> cj := clientToJSON(&c) <mask> </s> Pull request: home: don't miss blocked clients in client search api Merge in DNS/adguard-home from 2428-blocked-runtime-fix to master Updates #2428. Squashed commit of the following: commit 8aaa3e22a894f0335ced93339655771989846c94 Author: Ainar Garipov <[email protected]> Date: Fri Jan 15 16:32:53 2021 +0300 home: don't miss blocked clients in client search api </s> add var cj clientJSON </s> remove cj := clientToJSON(&c) </s> add cj = clientToJSON(&c) </s> remove el[ip] = cj </s> add </s> add el[ip] = cj </s> remove respData.DNS.Status = fmt.Sprintf("%v", err) </s> add respData.DNS.Status = err.Error()
https://github.com/AdguardTeam/AdGuardHome/commit/679bbcdc26775bc3d961cbeef553dce7aa9c091b
internal/home/clientshttp.go
keep keep keep replace replace keep replace keep
<mask> cj.Disallowed, cj.DisallowedRule = clients.dnsServer.IsBlockedIP(ip) <mask> el[ip] = cj <mask> } else { <mask> cj := clientToJSON(&c) <mask> <mask> cj.Disallowed, cj.DisallowedRule = clients.dnsServer.IsBlockedIP(ip) <mask> el[ip] = cj <mask> } </s> Pull request: home: don't miss blocked clients in client search api Merge in DNS/adguard-home from 2428-blocked-runtime-fix to master Updates #2428. Squashed commit of the following: commit 8aaa3e22a894f0335ced93339655771989846c94 Author: Ainar Garipov <[email protected]> Date: Fri Jan 15 16:32:53 2021 +0300 home: don't miss blocked clients in client search api </s> remove cj := clientHostToJSON(ip, ch) cj.Disallowed, cj.DisallowedRule = clients.dnsServer.IsBlockedIP(ip) el[ip] = cj </s> add </s> add el[ip] = cj </s> remove ch, ok := clients.FindAutoClient(ip) if !ok { continue // a client with this IP isn't found </s> add var found bool cj, found = clients.findTemporary(ip) if !found { continue </s> remove respData.DNS.Status = fmt.Sprintf("%v", err) </s> add respData.DNS.Status = err.Error() </s> add var cj clientJSON
https://github.com/AdguardTeam/AdGuardHome/commit/679bbcdc26775bc3d961cbeef553dce7aa9c091b
internal/home/clientshttp.go
keep keep add keep keep keep keep keep keep
<mask> cj.Disallowed, cj.DisallowedRule = clients.dnsServer.IsBlockedIP(ip) <mask> } <mask> <mask> data = append(data, el) <mask> } <mask> <mask> js, err := json.Marshal(data) <mask> if err != nil { <mask> httpError(w, http.StatusInternalServerError, "json.Marshal: %s", err) </s> Pull request: home: don't miss blocked clients in client search api Merge in DNS/adguard-home from 2428-blocked-runtime-fix to master Updates #2428. Squashed commit of the following: commit 8aaa3e22a894f0335ced93339655771989846c94 Author: Ainar Garipov <[email protected]> Date: Fri Jan 15 16:32:53 2021 +0300 home: don't miss blocked clients in client search api </s> remove respData.DNS.Status = fmt.Sprintf("%v", err) </s> add respData.DNS.Status = err.Error() </s> remove respData.Web.Status = fmt.Sprintf("%v", err) </s> add respData.Web.Status = err.Error() </s> remove el[ip] = cj </s> add </s> remove cj := clientToJSON(&c) </s> add cj = clientToJSON(&c) </s> remove cj := clientHostToJSON(ip, ch) cj.Disallowed, cj.DisallowedRule = clients.dnsServer.IsBlockedIP(ip) el[ip] = cj </s> add </s> remove ch, ok := clients.FindAutoClient(ip) if !ok { continue // a client with this IP isn't found </s> add var found bool cj, found = clients.findTemporary(ip) if !found { continue
https://github.com/AdguardTeam/AdGuardHome/commit/679bbcdc26775bc3d961cbeef553dce7aa9c091b
internal/home/clientshttp.go
keep keep keep keep replace replace keep keep keep keep keep
<mask> data.ValidKey && <mask> data.KeyType == "RSA" && <mask> data.Subject == "CN=AdGuard Home,O=AdGuard Ltd" && <mask> data.Issuer == "CN=AdGuard Home,O=AdGuard Ltd" && <mask> data.NotBefore == notBefore && <mask> data.NotAfter == notAfter && <mask> // data.DNSNames[0] == && <mask> data.ValidPair) { <mask> t.Fatalf("valid cert & priv key: validateCertificates(): %v", data) <mask> } <mask> } </s> Pull request: home: don't miss blocked clients in client search api Merge in DNS/adguard-home from 2428-blocked-runtime-fix to master Updates #2428. Squashed commit of the following: commit 8aaa3e22a894f0335ced93339655771989846c94 Author: Ainar Garipov <[email protected]> Date: Fri Jan 15 16:32:53 2021 +0300 home: don't miss blocked clients in client search api </s> remove respData.Web.Status = fmt.Sprintf("%v", err) </s> add respData.Web.Status = err.Error() </s> remove cj := clientHostToJSON(ip, ch) cj.Disallowed, cj.DisallowedRule = clients.dnsServer.IsBlockedIP(ip) el[ip] = cj </s> add </s> remove ch, ok := clients.FindAutoClient(ip) if !ok { continue // a client with this IP isn't found </s> add var found bool cj, found = clients.findTemporary(ip) if !found { continue </s> remove respData.DNS.Status = fmt.Sprintf("%v", err) </s> add respData.DNS.Status = err.Error() </s> remove el[ip] = cj </s> add </s> add el[ip] = cj
https://github.com/AdguardTeam/AdGuardHome/commit/679bbcdc26775bc3d961cbeef553dce7aa9c091b
internal/home/control_test.go
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> if reqData.Web.Port != 0 && reqData.Web.Port != config.BindPort && reqData.Web.Port != config.BetaBindPort { <mask> err = util.CheckPortAvailable(reqData.Web.IP, reqData.Web.Port) <mask> if err != nil { <mask> respData.Web.Status = fmt.Sprintf("%v", err) <mask> } <mask> } <mask> <mask> if reqData.DNS.Port != 0 { <mask> err = util.CheckPacketPortAvailable(reqData.DNS.IP, reqData.DNS.Port) </s> Pull request: home: don't miss blocked clients in client search api Merge in DNS/adguard-home from 2428-blocked-runtime-fix to master Updates #2428. Squashed commit of the following: commit 8aaa3e22a894f0335ced93339655771989846c94 Author: Ainar Garipov <[email protected]> Date: Fri Jan 15 16:32:53 2021 +0300 home: don't miss blocked clients in client search api </s> remove respData.DNS.Status = fmt.Sprintf("%v", err) </s> add respData.DNS.Status = err.Error() </s> add el[ip] = cj </s> remove data.NotBefore == notBefore && data.NotAfter == notAfter && </s> add data.NotBefore.Equal(notBefore) && data.NotAfter.Equal(notAfter) && </s> remove ch, ok := clients.FindAutoClient(ip) if !ok { continue // a client with this IP isn't found </s> add var found bool cj, found = clients.findTemporary(ip) if !found { continue </s> remove cj := clientHostToJSON(ip, ch) cj.Disallowed, cj.DisallowedRule = clients.dnsServer.IsBlockedIP(ip) el[ip] = cj </s> add </s> remove el[ip] = cj </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/679bbcdc26775bc3d961cbeef553dce7aa9c091b
internal/home/controlinstall.go
keep keep keep keep replace keep keep keep keep keep
<mask> err = util.CheckPortAvailable(reqData.DNS.IP, reqData.DNS.Port) <mask> } <mask> <mask> if err != nil { <mask> respData.DNS.Status = fmt.Sprintf("%v", err) <mask> } else if reqData.DNS.IP != "0.0.0.0" { <mask> respData.StaticIP = handleStaticIP(reqData.DNS.IP, reqData.SetStaticIP) <mask> } <mask> } <mask> </s> Pull request: home: don't miss blocked clients in client search api Merge in DNS/adguard-home from 2428-blocked-runtime-fix to master Updates #2428. Squashed commit of the following: commit 8aaa3e22a894f0335ced93339655771989846c94 Author: Ainar Garipov <[email protected]> Date: Fri Jan 15 16:32:53 2021 +0300 home: don't miss blocked clients in client search api </s> remove respData.Web.Status = fmt.Sprintf("%v", err) </s> add respData.Web.Status = err.Error() </s> add el[ip] = cj </s> remove el[ip] = cj </s> add </s> remove cj := clientHostToJSON(ip, ch) cj.Disallowed, cj.DisallowedRule = clients.dnsServer.IsBlockedIP(ip) el[ip] = cj </s> add </s> remove ch, ok := clients.FindAutoClient(ip) if !ok { continue // a client with this IP isn't found </s> add var found bool cj, found = clients.findTemporary(ip) if !found { continue </s> remove cj := clientToJSON(&c) </s> add cj = clientToJSON(&c)
https://github.com/AdguardTeam/AdGuardHome/commit/679bbcdc26775bc3d961cbeef553dce7aa9c091b
internal/home/controlinstall.go
replace replace keep keep keep keep keep
<mask> // Package cmd is the AdGuard Home entry point. It contains the on-disk <mask> // configuration file utilities, signal processing logic, and so on. <mask> // <mask> // TODO(a.garipov): Move to the upper-level internal/. <mask> package cmd <mask> <mask> import ( </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add "io/fs" </s> add // frontend is the filesystem with the frontend and other statically // compiled files. frontend fs.FS </s> remove func New(fileName string, start time.Time) (m *Manager, err error) { </s> add func New( fileName string, frontend fs.FS, start time.Time, ) (m *Manager, err error) { </s> remove // Main is the entry point of application. func Main(clientBuildFS fs.FS) { </s> add // Main is the entry point of AdGuard Home. func Main(frontend fs.FS) { </s> remove var clientBuildFS embed.FS </s> add var frontend embed.FS </s> remove confMgr, err := configmgr.New(h.confFile, h.start) fatalOnError(err) </s> add confMgr, err := configmgr.New(h.confFile, h.frontend, h.start) check(err)
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/cmd/cmd.go
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> import ( <mask> "context" <mask> "io/fs" <mask> "math/rand" <mask> "os" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/next/configmgr" <mask> "github.com/AdguardTeam/AdGuardHome/internal/version" </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add "io/fs" </s> add "io/fs" </s> add "time" </s> add "io/fs" </s> add "io/fs" </s> remove // Package cmd is the AdGuard Home entry point. It contains the on-disk // configuration file utilities, signal processing logic, and so on. </s> add // Package cmd is the AdGuard Home entry point. It assembles the configuration // file manager, sets up signal processing logic, and so on.
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/cmd/cmd.go
keep replace replace keep keep keep replace keep keep keep
<mask> <mask> // Main is the entry point of application. <mask> func Main(clientBuildFS fs.FS) { <mask> // Initial Configuration <mask> <mask> start := time.Now() <mask> rand.Seed(start.UnixNano()) <mask> <mask> // TODO(a.garipov): Set up logging. <mask> </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove // Package cmd is the AdGuard Home entry point. It contains the on-disk // configuration file utilities, signal processing logic, and so on. </s> add // Package cmd is the AdGuard Home entry point. It assembles the configuration // file manager, sets up signal processing logic, and so on. </s> remove // TODO(a.garipov): Use in the Web service. _ = clientBuildFS </s> add </s> remove func New(fileName string, start time.Time) (m *Manager, err error) { </s> add func New( fileName string, frontend fs.FS, start time.Time, ) (m *Manager, err error) { </s> remove func New(c *Config) (svc *Service) { </s> add // // TODO(a.garipov): Get rid of this special handling of nil or explain it // better. func New(c *Config) (svc *Service, err error) { </s> remove confMgr, err := configmgr.New(confFile, start) fatalOnError(err) </s> add confMgr, err := configmgr.New(confFile, frontend, start) check(err)
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/cmd/cmd.go
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> log.Info("starting adguard home, version %s, pid %d", version.Version(), os.Getpid()) <mask> <mask> // Web Service <mask> <mask> // TODO(a.garipov): Use in the Web service. <mask> _ = clientBuildFS <mask> <mask> // TODO(a.garipov): Set up configuration file name. <mask> const confFile = "AdGuardHome.1.yaml" <mask> <mask> confMgr, err := configmgr.New(confFile, start) <mask> fatalOnError(err) </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove rand.Seed(start.UnixNano()) </s> add </s> remove confMgr, err := configmgr.New(confFile, start) fatalOnError(err) </s> add confMgr, err := configmgr.New(confFile, frontend, start) check(err) </s> remove // Package cmd is the AdGuard Home entry point. It contains the on-disk // configuration file utilities, signal processing logic, and so on. </s> add // Package cmd is the AdGuard Home entry point. It assembles the configuration // file manager, sets up signal processing logic, and so on. </s> remove confMgr, err := configmgr.New(h.confFile, h.start) fatalOnError(err) </s> add confMgr, err := configmgr.New(h.confFile, h.frontend, h.start) check(err) </s> add frontend fs.FS </s> remove err = m.assemble(ctx, conf, start) </s> add err = m.assemble(ctx, conf, frontend, start)
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/cmd/cmd.go
keep keep keep replace replace keep keep keep keep keep keep keep replace
<mask> // TODO(a.garipov): Set up configuration file name. <mask> const confFile = "AdGuardHome.1.yaml" <mask> <mask> confMgr, err := configmgr.New(confFile, start) <mask> fatalOnError(err) <mask> <mask> web := confMgr.Web() <mask> err = web.Start() <mask> fatalOnError(err) <mask> <mask> web := confMgr.Web() <mask> err = web.Start() <mask> fatalOnError(err) </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove // TODO(a.garipov): Use in the Web service. _ = clientBuildFS </s> add </s> remove fatalOnError(err) </s> add check(err) </s> remove confMgr, err := configmgr.New(h.confFile, h.start) fatalOnError(err) </s> add confMgr, err := configmgr.New(h.confFile, h.frontend, h.start) check(err) </s> remove fatalOnError(err) </s> add check(err) </s> remove fatalOnError(err) </s> add check(err)
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/cmd/cmd.go
keep keep keep keep replace keep keep keep keep keep
<mask> fatalOnError(err) <mask> <mask> dns := confMgr.DNS() <mask> err = dns.Start() <mask> fatalOnError(err) <mask> <mask> sigHdlr := newSignalHandler( <mask> confFile, <mask> start, <mask> web, </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove fatalOnError(err) </s> add check(err) </s> add frontend, </s> remove fatalOnError(err) </s> add check(err) </s> remove fatalOnError(err) </s> add check(err) </s> remove confMgr, err := configmgr.New(confFile, start) fatalOnError(err) </s> add confMgr, err := configmgr.New(confFile, frontend, start) check(err) </s> remove func newSignalHandler(confFile string, start time.Time, svcs ...agh.Service) (h *signalHandler) { </s> add func newSignalHandler( confFile string, frontend fs.FS, start time.Time, svcs ...agh.Service, ) (h *signalHandler) {
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/cmd/cmd.go
keep add keep keep keep keep keep
<mask> sigHdlr := newSignalHandler( <mask> confFile, <mask> start, <mask> web, <mask> dns, <mask> ) <mask> </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove fatalOnError(err) </s> add check(err) </s> remove func newSignalHandler(confFile string, start time.Time, svcs ...agh.Service) (h *signalHandler) { </s> add func newSignalHandler( confFile string, frontend fs.FS, start time.Time, svcs ...agh.Service, ) (h *signalHandler) { </s> remove fatalOnError(err) </s> add check(err) </s> remove go sigHdlr.handle() select {} </s> add sigHdlr.handle() </s> add frontend: frontend, </s> add Frontend: frontend,
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/cmd/cmd.go
keep keep keep keep replace replace replace keep keep keep keep replace keep
<mask> web, <mask> dns, <mask> ) <mask> <mask> go sigHdlr.handle() <mask> <mask> select {} <mask> } <mask> <mask> // defaultTimeout is the timeout used for some operations where another timeout <mask> // hasn't been defined yet. <mask> const defaultTimeout = 15 * time.Second <mask> </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add frontend, </s> add frontend fs.FS </s> remove err = m.assemble(ctx, conf, start) </s> add err = m.assemble(ctx, conf, frontend, start) </s> remove fatalOnError(err) </s> add check(err) </s> add // frontend is the filesystem with the frontend and other statically // compiled files. frontend fs.FS
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/cmd/cmd.go
keep replace replace replace keep replace
<mask> <mask> // fatalOnError is a helper that exits the program with an error code if err is <mask> // not nil. It must only be used within Main. <mask> func fatalOnError(err error) { <mask> if err != nil { <mask> log.Fatal(err) </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove func New(c *Config) (svc *Service) { </s> add // // TODO(a.garipov): Get rid of this special handling of nil or explain it // better. func New(c *Config) (svc *Service, err error) { </s> remove return nil </s> add return nil, nil } frontend, err := fs.Sub(c.Frontend, "build/static") if err != nil { return nil, fmt.Errorf("frontend fs: %w", err) </s> remove func New(fileName string, start time.Time) (m *Manager, err error) { </s> add func New( fileName string, frontend fs.FS, start time.Time, ) (m *Manager, err error) { </s> remove const defaultTimeout = 15 * time.Second </s> add const defaultTimeout = 5 * time.Second </s> add // Frontend is the filesystem with the frontend and other statically // compiled files. Frontend fs.FS
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/cmd/cmd.go
keep keep add keep keep keep keep keep keep
<mask> package cmd <mask> <mask> import ( <mask> "os" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos" <mask> "github.com/AdguardTeam/AdGuardHome/internal/next/agh" <mask> "github.com/AdguardTeam/AdGuardHome/internal/next/configmgr" </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove "math/rand" </s> add </s> add "io/fs" </s> add "time" </s> remove // Package cmd is the AdGuard Home entry point. It contains the on-disk // configuration file utilities, signal processing logic, and so on. </s> add // Package cmd is the AdGuard Home entry point. It assembles the configuration // file manager, sets up signal processing logic, and so on. </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghtest" </s> add "io/fs"
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/cmd/signal.go
keep keep add keep keep keep keep keep
<mask> // confFile is the path to the configuration file. <mask> confFile string <mask> <mask> // start is the time at which AdGuard Home has been started. <mask> start time.Time <mask> <mask> // services are the services that are shut down before application exiting. <mask> services []agh.Service </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add frontend fs.FS </s> remove // Package cmd is the AdGuard Home entry point. It contains the on-disk // configuration file utilities, signal processing logic, and so on. </s> add // Package cmd is the AdGuard Home entry point. It assembles the configuration // file manager, sets up signal processing logic, and so on. </s> remove func New(fileName string, start time.Time) (m *Manager, err error) { </s> add func New( fileName string, frontend fs.FS, start time.Time, ) (m *Manager, err error) { </s> remove confMgr, err := configmgr.New(h.confFile, h.start) fatalOnError(err) </s> add confMgr, err := configmgr.New(h.confFile, h.frontend, h.start) check(err) </s> remove // Main is the entry point of application. func Main(clientBuildFS fs.FS) { </s> add // Main is the entry point of AdGuard Home. func Main(frontend fs.FS) { </s> remove func (m *Manager) assemble(ctx context.Context, conf *config, start time.Time) (err error) { </s> add func (m *Manager) assemble( ctx context.Context, conf *config, frontend fs.FS, start time.Time, ) (err error) {
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/cmd/signal.go
keep replace replace keep keep keep keep keep keep keep replace
<mask> <mask> confMgr, err := configmgr.New(h.confFile, h.start) <mask> fatalOnError(err) <mask> <mask> web := confMgr.Web() <mask> err = web.Start() <mask> fatalOnError(err) <mask> <mask> web := confMgr.Web() <mask> err = web.Start() <mask> fatalOnError(err) </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/cmd/signal.go
keep keep keep keep replace keep keep keep keep keep
<mask> fatalOnError(err) <mask> <mask> dns := confMgr.DNS() <mask> err = dns.Start() <mask> fatalOnError(err) <mask> <mask> h.services = []agh.Service{ <mask> dns, <mask> web, <mask> } </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove fatalOnError(err) </s> add check(err) </s> remove fatalOnError(err) </s> add check(err) </s> remove fatalOnError(err) </s> add check(err) </s> add frontend, </s> remove confMgr, err := configmgr.New(confFile, start) fatalOnError(err) </s> add confMgr, err := configmgr.New(confFile, frontend, start) check(err) </s> remove confMgr, err := configmgr.New(h.confFile, h.start) fatalOnError(err) </s> add confMgr, err := configmgr.New(h.confFile, h.frontend, h.start) check(err)
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/cmd/signal.go
keep keep keep keep replace keep keep keep keep keep
<mask> return status <mask> } <mask> <mask> // newSignalHandler returns a new signalHandler that shuts down svcs. <mask> func newSignalHandler(confFile string, start time.Time, svcs ...agh.Service) (h *signalHandler) { <mask> h = &signalHandler{ <mask> signal: make(chan os.Signal, 1), <mask> confFile: confFile, <mask> start: start, <mask> services: svcs, </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add frontend: frontend, </s> remove func New(fileName string, start time.Time) (m *Manager, err error) { </s> add func New( fileName string, frontend fs.FS, start time.Time, ) (m *Manager, err error) { </s> remove return svc </s> add return svc, nil </s> remove func New(c *Config) (svc *Service) { </s> add // // TODO(a.garipov): Get rid of this special handling of nil or explain it // better. func New(c *Config) (svc *Service, err error) { </s> remove const defaultTimeout = 15 * time.Second </s> add const defaultTimeout = 5 * time.Second </s> add frontend,
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/cmd/signal.go
keep keep add keep keep keep keep keep keep
<mask> h = &signalHandler{ <mask> signal: make(chan os.Signal, 1), <mask> confFile: confFile, <mask> start: start, <mask> services: svcs, <mask> } <mask> <mask> aghos.NotifyShutdownSignal(h.signal) <mask> aghos.NotifyReconfigureSignal(h.signal) </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove func newSignalHandler(confFile string, start time.Time, svcs ...agh.Service) (h *signalHandler) { </s> add func newSignalHandler( confFile string, frontend fs.FS, start time.Time, svcs ...agh.Service, ) (h *signalHandler) { </s> add frontend, </s> remove fatalOnError(err) </s> add check(err) </s> add frontend: frontend, </s> add Frontend: frontend, </s> remove mux.Handle(r.method, r.path, r.handler) </s> add hdlr = r.handler
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/cmd/signal.go
keep add keep keep keep keep keep keep
<mask> "context" <mask> "fmt" <mask> "os" <mask> "sync" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/next/agh" <mask> "github.com/AdguardTeam/AdGuardHome/internal/next/dnssvc" </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add "io/fs" </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghtest" </s> remove "math/rand" </s> add </s> add "io/fs" </s> add "io/fs" </s> add "time"
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/configmgr/configmgr.go
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> // New creates a new *Manager that persists changes to the file pointed to by <mask> // fileName. It reads the configuration file and populates the service fields. <mask> // start is the startup time of AdGuard Home. <mask> func New(fileName string, start time.Time) (m *Manager, err error) { <mask> defer func() { err = errors.Annotate(err, "reading config") }() <mask> <mask> conf := &config{} <mask> f, err := os.Open(fileName) <mask> if err != nil { </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove func (m *Manager) assemble(ctx context.Context, conf *config, start time.Time) (err error) { </s> add func (m *Manager) assemble( ctx context.Context, conf *config, frontend fs.FS, start time.Time, ) (err error) { </s> remove // Package cmd is the AdGuard Home entry point. It contains the on-disk // configuration file utilities, signal processing logic, and so on. </s> add // Package cmd is the AdGuard Home entry point. It assembles the configuration // file manager, sets up signal processing logic, and so on. </s> remove log.Fatal(err) </s> add panic(err) </s> add // frontend is the filesystem with the frontend and other statically // compiled files. frontend fs.FS </s> remove // Main is the entry point of application. func Main(clientBuildFS fs.FS) { </s> add // Main is the entry point of AdGuard Home. func Main(frontend fs.FS) { </s> remove // fatalOnError is a helper that exits the program with an error code if err is // not nil. It must only be used within Main. func fatalOnError(err error) { </s> add // check is a simple error-checking helper. It must only be used within Main. func check(err error) {
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/configmgr/configmgr.go
keep keep keep keep replace keep keep keep keep keep
<mask> const assemblyTimeout = 5 * time.Second <mask> ctx, cancel := context.WithTimeout(context.Background(), assemblyTimeout) <mask> defer cancel() <mask> <mask> err = m.assemble(ctx, conf, start) <mask> if err != nil { <mask> // Don't wrap the error, because it's informative enough as is. <mask> return nil, err <mask> } <mask> </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove const defaultTimeout = 15 * time.Second </s> add const defaultTimeout = 5 * time.Second </s> remove err := svc.Start() </s> add err = svc.Start() </s> remove return nil </s> add return nil, nil } frontend, err := fs.Sub(c.Frontend, "build/static") if err != nil { return nil, fmt.Errorf("frontend fs: %w", err) </s> remove // fatalOnError is a helper that exits the program with an error code if err is // not nil. It must only be used within Main. func fatalOnError(err error) { </s> add // check is a simple error-checking helper. It must only be used within Main. func check(err error) { </s> remove svc = websvc.New(c) </s> add svc, err := websvc.New(c) require.NoError(t, err) </s> remove m.web = websvc.New(c) </s> add m.web, err = websvc.New(c) if err != nil { return fmt.Errorf("creating web svc: %w", err) }
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/configmgr/configmgr.go
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> // assemble creates all services and puts them into the corresponding fields. <mask> // The fields of conf must not be modified after calling assemble. <mask> func (m *Manager) assemble(ctx context.Context, conf *config, start time.Time) (err error) { <mask> dnsConf := &dnssvc.Config{ <mask> Addresses: conf.DNS.Addresses, <mask> BootstrapServers: conf.DNS.BootstrapDNS, <mask> UpstreamServers: conf.DNS.UpstreamDNS, <mask> UpstreamTimeout: conf.DNS.UpstreamTimeout.Duration, </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove func New(fileName string, start time.Time) (m *Manager, err error) { </s> add func New( fileName string, frontend fs.FS, start time.Time, ) (m *Manager, err error) { </s> remove func New(c *Config) (svc *Service) { </s> add // // TODO(a.garipov): Get rid of this special handling of nil or explain it // better. func New(c *Config) (svc *Service, err error) { </s> remove return nil </s> add return nil, nil } frontend, err := fs.Sub(c.Frontend, "build/static") if err != nil { return nil, fmt.Errorf("frontend fs: %w", err) </s> remove // fatalOnError is a helper that exits the program with an error code if err is // not nil. It must only be used within Main. func fatalOnError(err error) { </s> add // check is a simple error-checking helper. It must only be used within Main. func check(err error) { </s> remove log.Fatal(err) </s> add panic(err) </s> add // frontend is the filesystem with the frontend and other statically // compiled files. frontend fs.FS
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/configmgr/configmgr.go
keep keep keep add keep keep keep keep keep
<mask> } <mask> <mask> webSvcConf := &websvc.Config{ <mask> ConfigManager: m, <mask> // TODO(a.garipov): Fill from config file. <mask> TLS: nil, <mask> Start: start, <mask> Addresses: conf.HTTP.Addresses, <mask> SecureAddresses: conf.HTTP.SecureAddresses, </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove ConfigManager: confMgr, </s> add ConfigManager: confMgr, Frontend: &aghtest.FS{ OnOpen: func(_ string) (_ fs.File, _ error) { return nil, fs.ErrNotExist }, }, </s> add Frontend: svc.frontend, </s> remove return websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: wantWeb.Addresses, SecureAddresses: wantWeb.SecureAddresses, Timeout: time.Duration(wantWeb.Timeout), ForceHTTPS: true, }) </s> add return svc </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: wantWeb.Addresses, SecureAddresses: wantWeb.SecureAddresses, Timeout: time.Duration(wantWeb.Timeout), ForceHTTPS: true, }) require.NoError(t, err) </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) require.NoError(t, err) </s> remove confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil } </s> add confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return svc } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil }
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/configmgr/configmgr.go
keep keep keep keep replace keep keep keep
<mask> return fmt.Errorf("shutting down web svc: %w", err) <mask> } <mask> } <mask> <mask> m.web = websvc.New(c) <mask> <mask> return nil <mask> } </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove return nil </s> add return nil, nil } frontend, err := fs.Sub(c.Frontend, "build/static") if err != nil { return nil, fmt.Errorf("frontend fs: %w", err) </s> remove svc = websvc.New(c) </s> add svc, err := websvc.New(c) require.NoError(t, err) </s> remove return svc </s> add return svc, nil </s> remove err := svc.Start() </s> add err = svc.Start() </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) require.NoError(t, err) </s> remove confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil } </s> add confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return svc } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil }
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/configmgr/configmgr.go
keep add keep keep keep keep
<mask> newConf := &Config{ <mask> ConfigManager: svc.confMgr, <mask> TLS: svc.tls, <mask> Addresses: req.Addresses, <mask> SecureAddresses: req.SecureAddresses, <mask> Timeout: time.Duration(req.Timeout), </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove ConfigManager: confMgr, </s> add ConfigManager: confMgr, Frontend: &aghtest.FS{ OnOpen: func(_ string) (_ fs.File, _ error) { return nil, fs.ErrNotExist }, }, </s> add Frontend: frontend, </s> remove return websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: wantWeb.Addresses, SecureAddresses: wantWeb.SecureAddresses, Timeout: time.Duration(wantWeb.Timeout), ForceHTTPS: true, }) </s> add return svc </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: wantWeb.Addresses, SecureAddresses: wantWeb.SecureAddresses, Timeout: time.Duration(wantWeb.Timeout), ForceHTTPS: true, }) require.NoError(t, err) </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) require.NoError(t, err) </s> remove confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil } </s> add confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return svc } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil }
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/http.go
keep add keep keep keep keep
<mask> } <mask> <mask> confMgr := newConfigManager() <mask> confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return svc } <mask> confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil } <mask> </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil } </s> add confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return svc } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil } </s> remove return websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: wantWeb.Addresses, SecureAddresses: wantWeb.SecureAddresses, Timeout: time.Duration(wantWeb.Timeout), ForceHTTPS: true, }) </s> add return svc </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: wantWeb.Addresses, SecureAddresses: wantWeb.SecureAddresses, Timeout: time.Duration(wantWeb.Timeout), ForceHTTPS: true, }) require.NoError(t, err) </s> remove return nil </s> add return nil, nil } frontend, err := fs.Sub(c.Frontend, "build/static") if err != nil { return nil, fmt.Errorf("frontend fs: %w", err) </s> remove func New(c *Config) (svc *Service) { </s> add // // TODO(a.garipov): Get rid of this special handling of nil or explain it // better. func New(c *Config) (svc *Service, err error) { </s> remove func (m *Manager) assemble(ctx context.Context, conf *config, start time.Time) (err error) { </s> add func (m *Manager) assemble( ctx context.Context, conf *config, frontend fs.FS, start time.Time, ) (err error) {
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/http_test.go
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> ForceHTTPS: false, <mask> } <mask> <mask> confMgr := newConfigManager() <mask> confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { <mask> return websvc.New(&websvc.Config{ <mask> TLS: &tls.Config{ <mask> Certificates: []tls.Certificate{{}}, <mask> }, <mask> Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, <mask> SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, <mask> Timeout: 5 * time.Second, <mask> ForceHTTPS: true, <mask> }) <mask> } <mask> confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { <mask> return nil <mask> } <mask> <mask> _, addr := newTestServer(t, confMgr) <mask> u := &url.URL{ <mask> Scheme: "http", <mask> Host: addr.String(), </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) require.NoError(t, err) </s> remove return websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: wantWeb.Addresses, SecureAddresses: wantWeb.SecureAddresses, Timeout: time.Duration(wantWeb.Timeout), ForceHTTPS: true, }) </s> add return svc </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: wantWeb.Addresses, SecureAddresses: wantWeb.SecureAddresses, Timeout: time.Duration(wantWeb.Timeout), ForceHTTPS: true, }) require.NoError(t, err) </s> remove ConfigManager: confMgr, </s> add ConfigManager: confMgr, Frontend: &aghtest.FS{ OnOpen: func(_ string) (_ fs.File, _ error) { return nil, fs.ErrNotExist }, }, </s> remove func (m *Manager) assemble(ctx context.Context, conf *config, start time.Time) (err error) { </s> add func (m *Manager) assemble( ctx context.Context, conf *config, frontend fs.FS, start time.Time, ) (err error) { </s> add Frontend: svc.frontend,
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/http_test.go
keep keep keep keep replace keep keep keep keep
<mask> } <mask> <mask> respBody := httpPatch(t, u, req, http.StatusOK) <mask> resp := &websvc.HTTPAPIHTTPSettings{} <mask> err := json.Unmarshal(respBody, resp) <mask> require.NoError(t, err) <mask> <mask> assert.Equal(t, wantWeb, resp) <mask> } </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove err := json.Unmarshal(body, resp) </s> add err = json.Unmarshal(body, resp) </s> remove svc = websvc.New(c) </s> add svc, err := websvc.New(c) require.NoError(t, err) </s> remove err := svc.Start() </s> add err = svc.Start() </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: wantWeb.Addresses, SecureAddresses: wantWeb.SecureAddresses, Timeout: time.Duration(wantWeb.Timeout), ForceHTTPS: true, }) require.NoError(t, err) </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) require.NoError(t, err) </s> remove m.web = websvc.New(c) </s> add m.web, err = websvc.New(c) if err != nil { return fmt.Errorf("creating web svc: %w", err) }
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/http_test.go
keep keep add keep keep keep keep keep
<mask> <mask> import ( <mask> "net/http" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" <mask> "github.com/AdguardTeam/golibs/httphdr" <mask> "github.com/AdguardTeam/golibs/log" <mask> ) </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add "github.com/AdguardTeam/golibs/log" </s> remove "math/rand" </s> add </s> add "io/fs" </s> remove // Main is the entry point of application. func Main(clientBuildFS fs.FS) { </s> add // Main is the entry point of AdGuard Home. func Main(frontend fs.FS) { </s> add "io/fs" </s> add "io/fs"
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/middleware.go
keep keep add keep keep keep keep
<mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" <mask> "github.com/AdguardTeam/golibs/httphdr" <mask> ) <mask> <mask> // Middlewares <mask> </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add "time" </s> add frontend, </s> remove go sigHdlr.handle() select {} </s> add sigHdlr.handle() </s> remove // Main is the entry point of application. func Main(clientBuildFS fs.FS) { </s> add // Main is the entry point of AdGuard Home. func Main(frontend fs.FS) { </s> remove func newSignalHandler(confFile string, start time.Time, svcs ...agh.Service) (h *signalHandler) { </s> add func newSignalHandler( confFile string, frontend fs.FS, start time.Time, svcs ...agh.Service, ) (h *signalHandler) { </s> remove ConfigManager: confMgr, </s> add ConfigManager: confMgr, Frontend: &aghtest.FS{ OnOpen: func(_ string) (_ fs.File, _ error) { return nil, fs.ErrNotExist }, },
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/middleware.go
keep keep add keep keep keep keep keep
<mask> <mask> // Path constants <mask> const ( <mask> PathHealthCheck = "/health-check" <mask> <mask> PathV1SettingsAll = "/api/v1/settings/all" <mask> PathV1SettingsDNS = "/api/v1/settings/dns" <mask> PathV1SettingsHTTP = "/api/v1/settings/http" </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add "time" </s> remove "math/rand" </s> add </s> add "io/fs" </s> remove const defaultTimeout = 15 * time.Second </s> add const defaultTimeout = 5 * time.Second </s> remove go sigHdlr.handle() select {} </s> add sigHdlr.handle() </s> remove confMgr, err := configmgr.New(confFile, start) fatalOnError(err) </s> add confMgr, err := configmgr.New(confFile, frontend, start) check(err)
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/path.go
keep keep add keep keep keep keep keep keep
<mask> return c <mask> } <mask> <mask> confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { <mask> return svc <mask> } <mask> <mask> _, addr := newTestServer(t, confMgr) <mask> u := &url.URL{ </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove return websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: wantWeb.Addresses, SecureAddresses: wantWeb.SecureAddresses, Timeout: time.Duration(wantWeb.Timeout), ForceHTTPS: true, }) </s> add return svc </s> remove confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil } </s> add confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return svc } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil } </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) require.NoError(t, err) </s> remove return nil </s> add return nil, nil } frontend, err := fs.Sub(c.Frontend, "build/static") if err != nil { return nil, fmt.Errorf("frontend fs: %w", err) </s> remove ConfigManager: confMgr, </s> add ConfigManager: confMgr, Frontend: &aghtest.FS{ OnOpen: func(_ string) (_ fs.File, _ error) { return nil, fs.ErrNotExist }, }, </s> remove func New(c *Config) (svc *Service) { </s> add // // TODO(a.garipov): Get rid of this special handling of nil or explain it // better. func New(c *Config) (svc *Service, err error) {
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/settings_test.go
keep keep keep keep replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> return c <mask> } <mask> <mask> confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { <mask> return websvc.New(&websvc.Config{ <mask> TLS: &tls.Config{ <mask> Certificates: []tls.Certificate{{}}, <mask> }, <mask> Addresses: wantWeb.Addresses, <mask> SecureAddresses: wantWeb.SecureAddresses, <mask> Timeout: time.Duration(wantWeb.Timeout), <mask> ForceHTTPS: true, <mask> }) <mask> } <mask> <mask> _, addr := newTestServer(t, confMgr) <mask> u := &url.URL{ <mask> Scheme: "http", </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: wantWeb.Addresses, SecureAddresses: wantWeb.SecureAddresses, Timeout: time.Duration(wantWeb.Timeout), ForceHTTPS: true, }) require.NoError(t, err) </s> remove confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil } </s> add confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return svc } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil } </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) require.NoError(t, err) </s> remove ConfigManager: confMgr, </s> add ConfigManager: confMgr, Frontend: &aghtest.FS{ OnOpen: func(_ string) (_ fs.File, _ error) { return nil, fs.ErrNotExist }, }, </s> add Frontend: svc.frontend, </s> remove path: PathV1SystemInfo, </s> add pattern: PathV1SystemInfo,
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/settings_test.go
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> body := httpGet(t, u, http.StatusOK) <mask> resp := &websvc.RespGetV1SettingsAll{} <mask> err := json.Unmarshal(body, resp) <mask> require.NoError(t, err) <mask> <mask> assert.Equal(t, wantDNS, resp.DNS) <mask> assert.Equal(t, wantWeb, resp.HTTP) <mask> } </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove err := json.Unmarshal(respBody, resp) </s> add err = json.Unmarshal(respBody, resp) </s> remove svc = websvc.New(c) </s> add svc, err := websvc.New(c) require.NoError(t, err) </s> remove err := svc.Start() </s> add err = svc.Start() </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: wantWeb.Addresses, SecureAddresses: wantWeb.SecureAddresses, Timeout: time.Duration(wantWeb.Timeout), ForceHTTPS: true, }) require.NoError(t, err) </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) require.NoError(t, err) </s> remove m.web = websvc.New(c) </s> add m.web, err = websvc.New(c) if err != nil { return fmt.Errorf("creating web svc: %w", err) }
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/settings_test.go
keep keep add keep keep keep keep keep keep
<mask> "crypto/tls" <mask> "fmt" <mask> "io" <mask> "net" <mask> "net/http" <mask> "net/netip" <mask> "sync" <mask> "time" <mask> </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add "io/fs" </s> add "io/fs" </s> add "time" </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghtest" </s> remove "math/rand" </s> add </s> add "io/fs"
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/websvc.go
keep keep add keep keep keep keep
<mask> // dynamically reconfigure them. <mask> ConfigManager ConfigManager <mask> <mask> // TLS is the optional TLS configuration. If TLS is not nil, <mask> // SecureAddresses must not be empty. <mask> TLS *tls.Config <mask> </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add frontend fs.FS </s> remove log.Fatal(err) </s> add panic(err) </s> remove func New(c *Config) (svc *Service) { </s> add // // TODO(a.garipov): Get rid of this special handling of nil or explain it // better. func New(c *Config) (svc *Service, err error) { </s> remove // fatalOnError is a helper that exits the program with an error code if err is // not nil. It must only be used within Main. func fatalOnError(err error) { </s> add // check is a simple error-checking helper. It must only be used within Main. func check(err error) { </s> remove confMgr, err := configmgr.New(h.confFile, h.start) fatalOnError(err) </s> add confMgr, err := configmgr.New(h.confFile, h.frontend, h.start) check(err) </s> remove return nil </s> add return nil, nil } frontend, err := fs.Sub(c.Frontend, "build/static") if err != nil { return nil, fmt.Errorf("frontend fs: %w", err)
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/websvc.go
keep keep keep add keep keep keep keep
<mask> // Service is the AdGuard Home web service. A nil *Service is a valid <mask> // [agh.Service] that does nothing. <mask> type Service struct { <mask> confMgr ConfigManager <mask> tls *tls.Config <mask> start time.Time <mask> servers []*http.Server <mask> timeout time.Duration </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add // frontend is the filesystem with the frontend and other statically // compiled files. frontend fs.FS </s> remove return svc </s> add return svc, nil </s> remove func New(c *Config) (svc *Service) { </s> add // // TODO(a.garipov): Get rid of this special handling of nil or explain it // better. func New(c *Config) (svc *Service, err error) { </s> add // Frontend is the filesystem with the frontend and other statically // compiled files. Frontend fs.FS </s> remove const defaultTimeout = 15 * time.Second </s> add const defaultTimeout = 5 * time.Second </s> remove return nil </s> add return nil, nil } frontend, err := fs.Sub(c.Frontend, "build/static") if err != nil { return nil, fmt.Errorf("frontend fs: %w", err)
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/websvc.go
keep keep keep keep replace keep replace keep keep keep
<mask> <mask> // New returns a new properly initialized *Service. If c is nil, svc is a nil <mask> // *Service that does nothing. The fields of c must not be modified after <mask> // calling New. <mask> func New(c *Config) (svc *Service) { <mask> if c == nil { <mask> return nil <mask> } <mask> <mask> svc = &Service{ </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove return svc </s> add return svc, nil </s> remove // fatalOnError is a helper that exits the program with an error code if err is // not nil. It must only be used within Main. func fatalOnError(err error) { </s> add // check is a simple error-checking helper. It must only be used within Main. func check(err error) { </s> remove log.Fatal(err) </s> add panic(err) </s> add frontend fs.FS </s> remove func (m *Manager) assemble(ctx context.Context, conf *config, start time.Time) (err error) { </s> add func (m *Manager) assemble( ctx context.Context, conf *config, frontend fs.FS, start time.Time, ) (err error) {
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/websvc.go
keep add keep keep keep keep keep
<mask> svc = &Service{ <mask> confMgr: c.ConfigManager, <mask> tls: c.TLS, <mask> start: c.Start, <mask> timeout: c.Timeout, <mask> forceHTTPS: c.ForceHTTPS, <mask> } </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove return nil </s> add return nil, nil } frontend, err := fs.Sub(c.Frontend, "build/static") if err != nil { return nil, fmt.Errorf("frontend fs: %w", err) </s> remove return svc </s> add return svc, nil </s> add frontend: frontend, </s> remove func New(c *Config) (svc *Service) { </s> add // // TODO(a.garipov): Get rid of this special handling of nil or explain it // better. func New(c *Config) (svc *Service, err error) { </s> remove func newSignalHandler(confFile string, start time.Time, svcs ...agh.Service) (h *signalHandler) { </s> add func newSignalHandler( confFile string, frontend fs.FS, start time.Time, svcs ...agh.Service, ) (h *signalHandler) { </s> remove err := svc.Start() </s> add err = svc.Start()
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/websvc.go
keep keep keep keep replace keep keep keep keep keep
<mask> ReadHeaderTimeout: c.Timeout, <mask> }) <mask> } <mask> <mask> return svc <mask> } <mask> <mask> // newMux returns a new HTTP request multiplexor for the AdGuard Home web <mask> // service. <mask> func newMux(svc *Service) (mux *httptreemux.ContextMux) { </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add frontend fs.FS </s> remove func New(c *Config) (svc *Service) { </s> add // // TODO(a.garipov): Get rid of this special handling of nil or explain it // better. func New(c *Config) (svc *Service, err error) { </s> remove const defaultTimeout = 15 * time.Second </s> add const defaultTimeout = 5 * time.Second </s> add mux.Handle(r.method, r.pattern, logMw(hdlr)) </s> remove func newSignalHandler(confFile string, start time.Time, svcs ...agh.Service) (h *signalHandler) { </s> add func newSignalHandler( confFile string, frontend fs.FS, start time.Time, svcs ...agh.Service, ) (h *signalHandler) { </s> remove func New(fileName string, start time.Time) (m *Manager, err error) { </s> add func New( fileName string, frontend fs.FS, start time.Time, ) (m *Manager, err error) {
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/websvc.go
keep replace keep keep keep keep replace keep
<mask> method string <mask> path string <mask> isJSON bool <mask> }{{ <mask> handler: svc.handleGetHealthCheck, <mask> method: http.MethodGet, <mask> path: PathHealthCheck, <mask> isJSON: false, </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove path: PathV1SettingsAll, </s> add pattern: PathV1SettingsAll, </s> remove path: PathV1SettingsHTTP, </s> add pattern: PathV1SettingsHTTP, </s> remove path: PathV1SettingsDNS, </s> add pattern: PathV1SettingsDNS, </s> remove path: PathV1SystemInfo, </s> add pattern: PathV1SystemInfo, </s> add // frontend is the filesystem with the frontend and other statically // compiled files. frontend fs.FS
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/websvc.go
keep keep keep keep replace keep keep keep keep replace keep keep
<mask> isJSON: false, <mask> }, { <mask> handler: svc.handleGetSettingsAll, <mask> method: http.MethodGet, <mask> path: PathV1SettingsAll, <mask> isJSON: true, <mask> }, { <mask> handler: svc.handlePatchSettingsDNS, <mask> method: http.MethodPatch, <mask> path: PathV1SettingsDNS, <mask> isJSON: true, <mask> }, { </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove path: PathHealthCheck, </s> add pattern: PathHealthCheck, isJSON: false, }, { handler: http.FileServer(http.FS(svc.frontend)).ServeHTTP, method: http.MethodGet, pattern: PathFrontend, isJSON: false, }, { handler: http.FileServer(http.FS(svc.frontend)).ServeHTTP, method: http.MethodGet, pattern: PathRoot, </s> remove path: PathV1SettingsHTTP, </s> add pattern: PathV1SettingsHTTP, </s> remove path: PathV1SystemInfo, </s> add pattern: PathV1SystemInfo, </s> remove path string </s> add pattern string </s> remove confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil } </s> add confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return svc } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil }
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/websvc.go
keep keep keep replace keep keep keep keep replace keep keep
<mask> }, { <mask> handler: svc.handlePatchSettingsHTTP, <mask> method: http.MethodPatch, <mask> path: PathV1SettingsHTTP, <mask> isJSON: true, <mask> }, { <mask> handler: svc.handleGetV1SystemInfo, <mask> method: http.MethodGet, <mask> path: PathV1SystemInfo, <mask> isJSON: true, <mask> }} </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove path: PathV1SettingsDNS, </s> add pattern: PathV1SettingsDNS, </s> remove path: PathV1SettingsAll, </s> add pattern: PathV1SettingsAll, </s> remove path: PathHealthCheck, </s> add pattern: PathHealthCheck, isJSON: false, }, { handler: http.FileServer(http.FS(svc.frontend)).ServeHTTP, method: http.MethodGet, pattern: PathFrontend, isJSON: false, }, { handler: http.FileServer(http.FS(svc.frontend)).ServeHTTP, method: http.MethodGet, pattern: PathRoot, </s> remove path string </s> add pattern string </s> remove return websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: wantWeb.Addresses, SecureAddresses: wantWeb.SecureAddresses, Timeout: time.Duration(wantWeb.Timeout), ForceHTTPS: true, }) </s> add return svc
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/websvc.go
keep keep add keep keep keep keep keep
<mask> }} <mask> <mask> for _, r := range routes { <mask> if r.isJSON { <mask> hdlr = jsonMw(r.handler) <mask> } else { <mask> hdlr = r.handler <mask> } </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove mux.Handle(r.method, r.path, jsonMw(r.handler)) </s> add hdlr = jsonMw(r.handler) </s> remove mux.Handle(r.method, r.path, r.handler) </s> add hdlr = r.handler </s> remove path: PathV1SystemInfo, </s> add pattern: PathV1SystemInfo, </s> add mux.Handle(r.method, r.pattern, logMw(hdlr)) </s> remove path string </s> add pattern string </s> remove log.Fatal(err) </s> add panic(err)
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/websvc.go
keep keep keep keep replace keep replace keep keep keep keep
<mask> }} <mask> <mask> for _, r := range routes { <mask> if r.isJSON { <mask> mux.Handle(r.method, r.path, jsonMw(r.handler)) <mask> } else { <mask> mux.Handle(r.method, r.path, r.handler) <mask> } <mask> } <mask> <mask> return mux </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add var hdlr http.Handler </s> remove path: PathV1SystemInfo, </s> add pattern: PathV1SystemInfo, </s> add mux.Handle(r.method, r.pattern, logMw(hdlr)) </s> remove return nil </s> add return nil, nil } frontend, err := fs.Sub(c.Frontend, "build/static") if err != nil { return nil, fmt.Errorf("frontend fs: %w", err) </s> remove confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil } </s> add confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return svc } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil }
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/websvc.go
keep keep keep add keep keep keep keep keep keep
<mask> hdlr = jsonMw(r.handler) <mask> } else { <mask> hdlr = r.handler <mask> } <mask> } <mask> <mask> return mux <mask> } <mask> <mask> // addrs returns all addresses on which this server serves the HTTP API. addrs </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add var hdlr http.Handler </s> remove mux.Handle(r.method, r.path, r.handler) </s> add hdlr = r.handler </s> remove mux.Handle(r.method, r.path, jsonMw(r.handler)) </s> add hdlr = jsonMw(r.handler) </s> remove return svc </s> add return svc, nil </s> remove func New(c *Config) (svc *Service) { </s> add // // TODO(a.garipov): Get rid of this special handling of nil or explain it // better. func New(c *Config) (svc *Service, err error) { </s> add // frontend is the filesystem with the frontend and other statically // compiled files. frontend fs.FS
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/websvc.go
keep keep keep add keep keep keep keep keep
<mask> "bytes" <mask> "context" <mask> "encoding/json" <mask> "io" <mask> "net/http" <mask> "net/netip" <mask> "net/url" <mask> "testing" <mask> "time" </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add "io/fs" </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghtest" </s> add "io/fs" </s> add "time" </s> remove "math/rand" </s> add </s> add "io/fs"
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/websvc_test.go
keep keep add keep keep keep keep keep
<mask> "testing" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/next/agh" <mask> "github.com/AdguardTeam/AdGuardHome/internal/next/dnssvc" <mask> "github.com/AdguardTeam/AdGuardHome/internal/next/websvc" <mask> "github.com/AdguardTeam/golibs/testutil" <mask> "github.com/stretchr/testify/assert" </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add "io/fs" </s> add "io/fs" </s> add "io/fs" </s> add "time" </s> remove "math/rand" </s> add </s> add "io/fs"
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/websvc_test.go
keep keep keep keep replace keep keep keep keep keep
<mask> ) (svc *websvc.Service, addr netip.AddrPort) { <mask> t.Helper() <mask> <mask> c := &websvc.Config{ <mask> ConfigManager: confMgr, <mask> TLS: nil, <mask> Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:0")}, <mask> SecureAddresses: nil, <mask> Timeout: testTimeout, <mask> Start: testStart, </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> add Frontend: frontend, </s> add Frontend: svc.frontend, </s> remove return websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: wantWeb.Addresses, SecureAddresses: wantWeb.SecureAddresses, Timeout: time.Duration(wantWeb.Timeout), ForceHTTPS: true, }) </s> add return svc </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: wantWeb.Addresses, SecureAddresses: wantWeb.SecureAddresses, Timeout: time.Duration(wantWeb.Timeout), ForceHTTPS: true, }) require.NoError(t, err) </s> remove return nil </s> add return nil, nil } frontend, err := fs.Sub(c.Frontend, "build/static") if err != nil { return nil, fmt.Errorf("frontend fs: %w", err) </s> remove confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil } </s> add confMgr.onWeb = func() (s agh.ServiceWithConfig[*websvc.Config]) { return svc } confMgr.onUpdateWeb = func(ctx context.Context, c *websvc.Config) (err error) { return nil }
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/websvc_test.go
keep replace keep replace keep keep
<mask> <mask> svc = websvc.New(c) <mask> <mask> err := svc.Start() <mask> require.NoError(t, err) <mask> t.Cleanup(func() { </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove m.web = websvc.New(c) </s> add m.web, err = websvc.New(c) if err != nil { return fmt.Errorf("creating web svc: %w", err) } </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: wantWeb.Addresses, SecureAddresses: wantWeb.SecureAddresses, Timeout: time.Duration(wantWeb.Timeout), ForceHTTPS: true, }) require.NoError(t, err) </s> add svc, err := websvc.New(&websvc.Config{ TLS: &tls.Config{ Certificates: []tls.Certificate{{}}, }, Addresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:80")}, SecureAddresses: []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:443")}, Timeout: 5 * time.Second, ForceHTTPS: true, }) require.NoError(t, err) </s> remove err := json.Unmarshal(respBody, resp) </s> add err = json.Unmarshal(respBody, resp) </s> remove err := json.Unmarshal(body, resp) </s> add err = json.Unmarshal(body, resp)
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
internal/next/websvc/websvc_test.go
keep keep keep replace keep keep replace
<mask> // outside of the same or underlying directory. <mask> <mask> //go:embed build <mask> var clientBuildFS embed.FS <mask> <mask> func main() { <mask> cmd.Main(clientBuildFS) </s> Pull request 1870: nextapi-frontend-fs Merge in DNS/adguard-home from nextapi-frontend-fs to master Squashed commit of the following: commit 3ed959f21939cf5590c27426af46906cbffed502 Merge: e60bbdd04 9fda7bfd3 Author: Ainar Garipov <[email protected]> Date: Tue Jun 13 13:37:00 2023 +0300 Merge branch 'master' into nextapi-frontend-fs commit e60bbdd04ce841c1aaaa198cc9dc85ae14799ffa Author: Ainar Garipov <[email protected]> Date: Fri Jun 9 14:53:09 2023 +0300 next: support frontend fs </s> remove // Main is the entry point of application. func Main(clientBuildFS fs.FS) { </s> add // Main is the entry point of AdGuard Home. func Main(frontend fs.FS) { </s> remove func New(c *Config) (svc *Service) { </s> add // // TODO(a.garipov): Get rid of this special handling of nil or explain it // better. func New(c *Config) (svc *Service, err error) { </s> remove func New(fileName string, start time.Time) (m *Manager, err error) { </s> add func New( fileName string, frontend fs.FS, start time.Time, ) (m *Manager, err error) { </s> remove func (m *Manager) assemble(ctx context.Context, conf *config, start time.Time) (err error) { </s> add func (m *Manager) assemble( ctx context.Context, conf *config, frontend fs.FS, start time.Time, ) (err error) { </s> add var hdlr http.Handler
https://github.com/AdguardTeam/AdGuardHome/commit/681c604c228942dfcb90c02f88e0fe148c7acd67
main_next.go
keep keep keep keep replace keep keep keep keep keep
<mask> maxAttempts int, <mask> backoff time.Duration, <mask> ) (addrs []net.IP, err error) { <mask> var n int <mask> waitForIP: <mask> for n = 1; n <= maxAttempts; n++ { <mask> addrs, err = ifaceIPAddrs(iface, ipv) <mask> if err != nil { <mask> return nil, fmt.Errorf("getting ip addrs: %w", err) <mask> } </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> remove switch len(addrs) { case 0: log.Debug("dhcpv%d: attempt %d: no ip addresses", ipv, n) time.Sleep(backoff) case 1: // Some Android devices use 8.8.8.8 if there is not // a secondary DNS server. Fix that by setting the // secondary DNS address to the same address. // // See https://github.com/AdguardTeam/AdGuardHome/issues/1708. log.Debug("dhcpv%d: setting secondary dns ip to itself", ipv) addrs = append(addrs, addrs[0]) fallthrough default: break waitForIP </s> add if len(addrs) > 0 { break </s> remove log.Debug("DHCPv6: removed lease %s", s.leases[i].HWAddr) </s> add log.Debug("dhcpv6: removed lease %s", s.leases[i].HWAddr) </s> remove log.Debug("DHCPv6: stopping") </s> add log.Debug("dhcpv6: stopping") </s> remove log.Error("dhcpv%d: no ip address for interface after %d attempts and %s", ipv, n, time.Duration(n)*backoff) } else { log.Debug("dhcpv%d: got addresses %s after %d attempts", ipv, addrs, n) </s> add t := time.Duration(n) * backoff log.Error("dhcpv%d: no ip for iface after %d attempts and %s", ipv, n, t) return nil, nil case 1: // Some Android devices use 8.8.8.8 if there is not a secondary // DNS server. Fix that by setting the secondary DNS address to // the same address. // // See https://github.com/AdguardTeam/AdGuardHome/issues/1708. log.Debug("dhcpv%d: setting secondary dns ip to itself", ipv) addrs = append(addrs, addrs[0]) default: // Go on. </s> remove log.Error("DHCPv6: srv.Close: %s", err) </s> add log.Error("dhcpv6: srv.Close: %s", err) </s> remove log.Debug("DHCPv6: %s", err) </s> add log.Debug("dhcpv6: %s", err)
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dhcpd/v46.go
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> if err != nil { <mask> return nil, fmt.Errorf("getting ip addrs: %w", err) <mask> } <mask> <mask> switch len(addrs) { <mask> case 0: <mask> log.Debug("dhcpv%d: attempt %d: no ip addresses", ipv, n) <mask> <mask> time.Sleep(backoff) <mask> case 1: <mask> // Some Android devices use 8.8.8.8 if there is not <mask> // a secondary DNS server. Fix that by setting the <mask> // secondary DNS address to the same address. <mask> // <mask> // See https://github.com/AdguardTeam/AdGuardHome/issues/1708. <mask> log.Debug("dhcpv%d: setting secondary dns ip to itself", ipv) <mask> addrs = append(addrs, addrs[0]) <mask> <mask> fallthrough <mask> default: <mask> break waitForIP <mask> } <mask> } <mask> <mask> if len(addrs) == 0 { <mask> // Don't return errors in case the users want to try and enable </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> remove log.Error("dhcpv%d: no ip address for interface after %d attempts and %s", ipv, n, time.Duration(n)*backoff) } else { log.Debug("dhcpv%d: got addresses %s after %d attempts", ipv, addrs, n) </s> add t := time.Duration(n) * backoff log.Error("dhcpv%d: no ip for iface after %d attempts and %s", ipv, n, t) return nil, nil case 1: // Some Android devices use 8.8.8.8 if there is not a secondary // DNS server. Fix that by setting the secondary DNS address to // the same address. // // See https://github.com/AdguardTeam/AdGuardHome/issues/1708. log.Debug("dhcpv%d: setting secondary dns ip to itself", ipv) addrs = append(addrs, addrs[0]) default: // Go on. </s> add log.Debug("dhcpv%d: attempt %d: no ip addresses", ipv, n) time.Sleep(backoff) </s> remove if len(addrs) == 0 { </s> add switch len(addrs) { case 0: </s> remove waitForIP: </s> add </s> remove fallthrough </s> add </s> remove log.Error("DHCPv6: conn.Write to %s failed: %s", peer, err) </s> add log.Error("dhcpv6: conn.Write to %s failed: %s", peer, err)
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dhcpd/v46.go
keep keep keep add keep keep keep keep keep keep
<mask> <mask> if len(addrs) > 0 { <mask> break <mask> } <mask> } <mask> <mask> switch len(addrs) { <mask> case 0: <mask> // Don't return errors in case the users want to try and enable <mask> // the DHCP server later. </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> remove if len(addrs) == 0 { </s> add switch len(addrs) { case 0: </s> remove switch len(addrs) { case 0: log.Debug("dhcpv%d: attempt %d: no ip addresses", ipv, n) time.Sleep(backoff) case 1: // Some Android devices use 8.8.8.8 if there is not // a secondary DNS server. Fix that by setting the // secondary DNS address to the same address. // // See https://github.com/AdguardTeam/AdGuardHome/issues/1708. log.Debug("dhcpv%d: setting secondary dns ip to itself", ipv) addrs = append(addrs, addrs[0]) fallthrough default: break waitForIP </s> add if len(addrs) > 0 { break </s> remove log.Error("dhcpv%d: no ip address for interface after %d attempts and %s", ipv, n, time.Duration(n)*backoff) } else { log.Debug("dhcpv%d: got addresses %s after %d attempts", ipv, addrs, n) </s> add t := time.Duration(n) * backoff log.Error("dhcpv%d: no ip for iface after %d attempts and %s", ipv, n, t) return nil, nil case 1: // Some Android devices use 8.8.8.8 if there is not a secondary // DNS server. Fix that by setting the secondary DNS address to // the same address. // // See https://github.com/AdguardTeam/AdGuardHome/issues/1708. log.Debug("dhcpv%d: setting secondary dns ip to itself", ipv) addrs = append(addrs, addrs[0]) default: // Go on. </s> remove fallthrough </s> add </s> remove log.Debug("DHCPv6: removed lease %s", s.leases[i].HWAddr) </s> add log.Debug("dhcpv6: removed lease %s", s.leases[i].HWAddr) </s> remove log.Debug("DHCPv6: no lease for: %s", mac) </s> add log.Debug("dhcpv6: no lease for: %s", mac)
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dhcpd/v46.go
keep replace keep keep replace replace replace keep
<mask> <mask> if len(addrs) == 0 { <mask> // Don't return errors in case the users want to try and enable <mask> // the DHCP server later. <mask> log.Error("dhcpv%d: no ip address for interface after %d attempts and %s", ipv, n, time.Duration(n)*backoff) <mask> } else { <mask> log.Debug("dhcpv%d: got addresses %s after %d attempts", ipv, addrs, n) <mask> } </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> add log.Debug("dhcpv%d: attempt %d: no ip addresses", ipv, n) time.Sleep(backoff) </s> add log.Debug("dhcpv%d: got addresses %s after %d attempts", ipv, addrs, n) </s> remove switch len(addrs) { case 0: log.Debug("dhcpv%d: attempt %d: no ip addresses", ipv, n) time.Sleep(backoff) case 1: // Some Android devices use 8.8.8.8 if there is not // a secondary DNS server. Fix that by setting the // secondary DNS address to the same address. // // See https://github.com/AdguardTeam/AdGuardHome/issues/1708. log.Debug("dhcpv%d: setting secondary dns ip to itself", ipv) addrs = append(addrs, addrs[0]) fallthrough default: break waitForIP </s> add if len(addrs) > 0 { break </s> remove log.Error("DHCPv6: message type %d not supported", msg.Type()) </s> add log.Error("dhcpv6: message type %d not supported", msg.Type()) </s> remove log.Error("DHCPv6: conn.Write to %s failed: %s", peer, err) </s> add log.Error("dhcpv6: conn.Write to %s failed: %s", peer, err)
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dhcpd/v46.go
keep keep keep add keep keep
<mask> default: <mask> // Go on. <mask> } <mask> <mask> return addrs, nil <mask> } </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> remove log.Error("dhcpv%d: no ip address for interface after %d attempts and %s", ipv, n, time.Duration(n)*backoff) } else { log.Debug("dhcpv%d: got addresses %s after %d attempts", ipv, addrs, n) </s> add t := time.Duration(n) * backoff log.Error("dhcpv%d: no ip for iface after %d attempts and %s", ipv, n, t) return nil, nil case 1: // Some Android devices use 8.8.8.8 if there is not a secondary // DNS server. Fix that by setting the secondary DNS address to // the same address. // // See https://github.com/AdguardTeam/AdGuardHome/issues/1708. log.Debug("dhcpv%d: setting secondary dns ip to itself", ipv) addrs = append(addrs, addrs[0]) default: // Go on. </s> remove log.Error("DHCPv6: message type %d not supported", msg.Type()) </s> add log.Error("dhcpv6: message type %d not supported", msg.Type()) </s> remove log.Error("DHCPv6: %s", err) </s> add log.Error("dhcpv6: %s", err) </s> remove waitForIP: </s> add </s> remove if len(addrs) == 0 { </s> add switch len(addrs) { case 0: </s> remove log.Error("DHCPv6: srv.Close: %s", err) </s> add log.Error("dhcpv6: srv.Close: %s", err)
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dhcpd/v46.go
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> if l.Expiry.Unix() != leaseExpireStatic && <mask> !ip6InRange(s.conf.ipStart, l.IP) { <mask> <mask> log.Debug("DHCPv6: skipping a lease with IP %v: not within current IP range", l.IP) <mask> continue <mask> } <mask> <mask> s.addLease(l) <mask> } </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> remove log.Debug("DHCPv6: added lease %s <-> %s", l.IP, l.HWAddr) </s> add log.Debug("dhcpv6: added lease %s <-> %s", l.IP, l.HWAddr) </s> remove log.Debug("DHCPv6: removed lease %s", s.leases[i].HWAddr) </s> add log.Debug("dhcpv6: removed lease %s", s.leases[i].HWAddr) </s> remove log.Debug("DHCPv6: dhcpv6.ExtractMAC: %s", err) </s> add log.Debug("dhcpv6: dhcpv6.ExtractMAC: %s", err) </s> remove log.Debug("DHCPv6: no lease for: %s", mac) </s> add log.Debug("dhcpv6: no lease for: %s", mac) </s> remove log.Error("DHCPv6: message type %d not supported", msg.Type()) </s> add log.Error("dhcpv6: message type %d not supported", msg.Type()) </s> remove log.Debug("DHCPv6: stopping") </s> add log.Debug("dhcpv6: stopping")
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dhcpd/v6.go
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> // Remove (swap) lease by index <mask> func (s *v6Server) leaseRemoveSwapByIndex(i int) { <mask> s.ipAddrs[s.leases[i].IP[15]] = 0 <mask> log.Debug("DHCPv6: removed lease %s", s.leases[i].HWAddr) <mask> <mask> n := len(s.leases) <mask> if i != n-1 { <mask> s.leases[i] = s.leases[n-1] // swap with the last element <mask> } </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> remove log.Debug("DHCPv6: added lease %s <-> %s", l.IP, l.HWAddr) </s> add log.Debug("dhcpv6: added lease %s <-> %s", l.IP, l.HWAddr) </s> remove log.Error("DHCPv6: %s", err) </s> add log.Error("dhcpv6: %s", err) </s> remove log.Debug("DHCPv6: no lease for: %s", mac) </s> add log.Debug("dhcpv6: no lease for: %s", mac) </s> remove log.Debug("DHCPv6: dhcpv6.ExtractMAC: %s", err) </s> add log.Debug("dhcpv6: dhcpv6.ExtractMAC: %s", err) </s> remove log.Debug("DHCPv6: skipping a lease with IP %v: not within current IP range", l.IP) </s> add log.Debug("dhcpv6: skipping a lease with IP %v: not within current IP range", l.IP) </s> remove waitForIP: </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dhcpd/v6.go
keep keep keep keep replace keep keep keep keep keep
<mask> // Add a lease <mask> func (s *v6Server) addLease(l *Lease) { <mask> s.leases = append(s.leases, l) <mask> s.ipAddrs[l.IP[15]] = 1 <mask> log.Debug("DHCPv6: added lease %s <-> %s", l.IP, l.HWAddr) <mask> } <mask> <mask> // Remove a lease with the same properties <mask> func (s *v6Server) rmLease(lease Lease) error { <mask> for i, l := range s.leases { </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> remove log.Debug("DHCPv6: removed lease %s", s.leases[i].HWAddr) </s> add log.Debug("dhcpv6: removed lease %s", s.leases[i].HWAddr) </s> remove log.Error("DHCPv6: %s", err) </s> add log.Error("dhcpv6: %s", err) </s> remove log.Debug("DHCPv6: skipping a lease with IP %v: not within current IP range", l.IP) </s> add log.Debug("dhcpv6: skipping a lease with IP %v: not within current IP range", l.IP) </s> remove log.Debug("DHCPv6: no lease for: %s", mac) </s> add log.Debug("dhcpv6: no lease for: %s", mac) </s> remove log.Debug("DHCPv6: dhcpv6.ExtractMAC: %s", err) </s> add log.Debug("dhcpv6: dhcpv6.ExtractMAC: %s", err) </s> remove log.Error("dhcpv%d: no ip address for interface after %d attempts and %s", ipv, n, time.Duration(n)*backoff) } else { log.Debug("dhcpv%d: got addresses %s after %d attempts", ipv, addrs, n) </s> add t := time.Duration(n) * backoff log.Error("dhcpv%d: no ip for iface after %d attempts and %s", ipv, n, t) return nil, nil case 1: // Some Android devices use 8.8.8.8 if there is not a secondary // DNS server. Fix that by setting the secondary DNS address to // the same address. // // See https://github.com/AdguardTeam/AdGuardHome/issues/1708. log.Debug("dhcpv%d: setting secondary dns ip to itself", ipv) addrs = append(addrs, addrs[0]) default: // Go on.
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dhcpd/v6.go
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> mac, err := dhcpv6.ExtractMAC(req) <mask> if err != nil { <mask> log.Debug("DHCPv6: dhcpv6.ExtractMAC: %s", err) <mask> return false <mask> } <mask> <mask> lease := s.findLease(mac) <mask> if lease == nil { </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> remove log.Debug("DHCPv6: no lease for: %s", mac) </s> add log.Debug("dhcpv6: no lease for: %s", mac) </s> remove log.Debug("DHCPv6: %s", err) </s> add log.Debug("dhcpv6: %s", err) </s> remove log.Debug("DHCPv6: stopping") </s> add log.Debug("dhcpv6: stopping") </s> remove log.Error("DHCPv6: %s", err) </s> add log.Error("dhcpv6: %s", err) </s> remove log.Error("DHCPv6: %s", err) </s> add log.Error("dhcpv6: %s", err) </s> remove log.Error("DHCPv6: srv.Close: %s", err) </s> add log.Error("dhcpv6: srv.Close: %s", err)
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dhcpd/v6.go
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> lease := s.findLease(mac) <mask> if lease == nil { <mask> log.Debug("DHCPv6: no lease for: %s", mac) <mask> <mask> switch msg.Type() { <mask> <mask> case dhcpv6.MessageTypeSolicit: <mask> lease = s.reserveLease(mac) </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> remove log.Debug("DHCPv6: dhcpv6.ExtractMAC: %s", err) </s> add log.Debug("dhcpv6: dhcpv6.ExtractMAC: %s", err) </s> remove log.Debug("DHCPv6: removed lease %s", s.leases[i].HWAddr) </s> add log.Debug("dhcpv6: removed lease %s", s.leases[i].HWAddr) </s> remove log.Debug("DHCPv6: added lease %s <-> %s", l.IP, l.HWAddr) </s> add log.Debug("dhcpv6: added lease %s <-> %s", l.IP, l.HWAddr) </s> remove log.Debug("DHCPv6: skipping a lease with IP %v: not within current IP range", l.IP) </s> add log.Debug("dhcpv6: skipping a lease with IP %v: not within current IP range", l.IP) </s> remove log.Debug("DHCPv6: stopping") </s> add log.Debug("dhcpv6: stopping") </s> remove if len(addrs) == 0 { </s> add switch len(addrs) { case 0:
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dhcpd/v6.go
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> err = s.checkIA(msg, lease) <mask> if err != nil { <mask> log.Debug("DHCPv6: %s", err) <mask> return false <mask> } <mask> <mask> lifetime := s.commitLease(msg, lease) <mask> </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> remove log.Debug("DHCPv6: dhcpv6.ExtractMAC: %s", err) </s> add log.Debug("dhcpv6: dhcpv6.ExtractMAC: %s", err) </s> remove log.Debug("DHCPv6: stopping") </s> add log.Debug("dhcpv6: stopping") </s> remove log.Error("DHCPv6: srv.Close: %s", err) </s> add log.Error("dhcpv6: srv.Close: %s", err) </s> remove log.Debug("DHCPv6: received: %s", req.Summary()) </s> add log.Debug("dhcpv6: received: %s", req.Summary()) </s> remove log.Error("DHCPv6: %s", err) </s> add log.Error("dhcpv6: %s", err) </s> remove log.Error("DHCPv6: %s", err) </s> add log.Error("dhcpv6: %s", err)
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dhcpd/v6.go
keep keep keep replace keep keep keep replace keep keep
<mask> func (s *v6Server) packetHandler(conn net.PacketConn, peer net.Addr, req dhcpv6.DHCPv6) { <mask> msg, err := req.GetInnerMessage() <mask> if err != nil { <mask> log.Error("DHCPv6: %s", err) <mask> return <mask> } <mask> <mask> log.Debug("DHCPv6: received: %s", req.Summary()) <mask> <mask> err = s.checkCID(msg) </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> remove log.Debug("DHCPv6: %s", err) </s> add log.Debug("dhcpv6: %s", err) </s> remove log.Debug("DHCPv6: stopping") </s> add log.Debug("dhcpv6: stopping") </s> remove log.Debug("DHCPv6: dhcpv6.ExtractMAC: %s", err) </s> add log.Debug("dhcpv6: dhcpv6.ExtractMAC: %s", err) </s> remove log.Error("DHCPv6: srv.Close: %s", err) </s> add log.Error("dhcpv6: srv.Close: %s", err) </s> remove log.Debug("DHCPv6: added lease %s <-> %s", l.IP, l.HWAddr) </s> add log.Debug("dhcpv6: added lease %s <-> %s", l.IP, l.HWAddr)
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dhcpd/v6.go
keep keep keep keep replace keep keep keep keep keep
<mask> if msg.GetOneOption(dhcpv6.OptionRapidCommit) == nil { <mask> resp, err = dhcpv6.NewAdvertiseFromSolicit(msg) <mask> break <mask> } <mask> fallthrough <mask> <mask> case dhcpv6.MessageTypeRequest, <mask> dhcpv6.MessageTypeConfirm, <mask> dhcpv6.MessageTypeRenew, <mask> dhcpv6.MessageTypeRebind, </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> add resp, err = dhcpv6.NewReplyFromMessage(msg) </s> remove switch len(addrs) { case 0: log.Debug("dhcpv%d: attempt %d: no ip addresses", ipv, n) time.Sleep(backoff) case 1: // Some Android devices use 8.8.8.8 if there is not // a secondary DNS server. Fix that by setting the // secondary DNS address to the same address. // // See https://github.com/AdguardTeam/AdGuardHome/issues/1708. log.Debug("dhcpv%d: setting secondary dns ip to itself", ipv) addrs = append(addrs, addrs[0]) fallthrough default: break waitForIP </s> add if len(addrs) > 0 { break </s> remove log.Debug("DHCPv6: stopping") </s> add log.Debug("dhcpv6: stopping") </s> remove case filtering.FilteredBlockList: fallthrough case filtering.FilteredInvalid: fallthrough case filtering.FilteredBlockedService: </s> add case filtering.FilteredBlockList, filtering.FilteredInvalid, filtering.FilteredBlockedService: </s> remove log.Error("DHCPv6: message type %d not supported", msg.Type()) </s> add log.Error("dhcpv6: message type %d not supported", msg.Type()) </s> remove log.Debug("DHCPv6: dhcpv6.ExtractMAC: %s", err) </s> add log.Debug("dhcpv6: dhcpv6.ExtractMAC: %s", err)
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dhcpd/v6.go
keep keep add keep keep keep keep
<mask> break <mask> } <mask> <mask> case dhcpv6.MessageTypeRequest, <mask> dhcpv6.MessageTypeConfirm, <mask> dhcpv6.MessageTypeRenew, <mask> dhcpv6.MessageTypeRebind, </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> remove fallthrough </s> add </s> add log.Debug("dhcpv%d: attempt %d: no ip addresses", ipv, n) time.Sleep(backoff) </s> remove if len(addrs) == 0 { </s> add switch len(addrs) { case 0: </s> remove switch len(addrs) { case 0: log.Debug("dhcpv%d: attempt %d: no ip addresses", ipv, n) time.Sleep(backoff) case 1: // Some Android devices use 8.8.8.8 if there is not // a secondary DNS server. Fix that by setting the // secondary DNS address to the same address. // // See https://github.com/AdguardTeam/AdGuardHome/issues/1708. log.Debug("dhcpv%d: setting secondary dns ip to itself", ipv) addrs = append(addrs, addrs[0]) fallthrough default: break waitForIP </s> add if len(addrs) > 0 { break </s> remove case filtering.FilteredBlockList: fallthrough case filtering.FilteredInvalid: fallthrough case filtering.FilteredBlockedService: </s> add case filtering.FilteredBlockList, filtering.FilteredInvalid, filtering.FilteredBlockedService: </s> remove log.Debug("DHCPv6: no lease for: %s", mac) </s> add log.Debug("dhcpv6: no lease for: %s", mac)
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dhcpd/v6.go
keep replace keep keep keep keep replace keep
<mask> default: <mask> log.Error("DHCPv6: message type %d not supported", msg.Type()) <mask> return <mask> } <mask> <mask> if err != nil { <mask> log.Error("DHCPv6: %s", err) <mask> return </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> remove log.Debug("DHCPv6: received: %s", req.Summary()) </s> add log.Debug("dhcpv6: received: %s", req.Summary()) </s> remove log.Debug("DHCPv6: stopping") </s> add log.Debug("dhcpv6: stopping") </s> remove log.Error("DHCPv6: srv.Close: %s", err) </s> add log.Error("dhcpv6: srv.Close: %s", err) </s> remove log.Error("DHCPv6: conn.Write to %s failed: %s", peer, err) </s> add log.Error("dhcpv6: conn.Write to %s failed: %s", peer, err) </s> remove log.Error("DHCPv6: %s", err) </s> add log.Error("dhcpv6: %s", err)
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dhcpd/v6.go
keep keep keep keep replace keep keep keep replace
<mask> resp.AddOption(dhcpv6.OptServerID(s.sid)) <mask> <mask> _ = s.process(msg, req, resp) <mask> <mask> log.Debug("DHCPv6: sending: %s", resp.Summary()) <mask> <mask> _, err = conn.WriteTo(resp.ToBytes(), peer) <mask> if err != nil { <mask> log.Error("DHCPv6: conn.Write to %s failed: %s", peer, err) </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> remove log.Error("DHCPv6: %s", err) </s> add log.Error("dhcpv6: %s", err) </s> remove log.Error("DHCPv6: srv.Close: %s", err) </s> add log.Error("dhcpv6: srv.Close: %s", err) </s> remove log.Debug("DHCPv6: received: %s", req.Summary()) </s> add log.Debug("dhcpv6: received: %s", req.Summary()) </s> remove log.Debug("DHCPv6: stopping") </s> add log.Debug("dhcpv6: stopping") </s> remove log.Debug("DHCPv6: %s", err) </s> add log.Debug("dhcpv6: %s", err)
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dhcpd/v6.go
keep keep keep keep replace keep keep keep keep keep keep keep keep replace keep keep keep keep
<mask> if s.srv == nil { <mask> return <mask> } <mask> <mask> log.Debug("DHCPv6: stopping") <mask> err = s.srv.Close() <mask> if err != nil { <mask> log.Error("DHCPv6: srv.Close: %s", err) <mask> } <mask> <mask> log.Debug("DHCPv6: stopping") <mask> err = s.srv.Close() <mask> if err != nil { <mask> log.Error("DHCPv6: srv.Close: %s", err) <mask> } <mask> <mask> // now server.Serve() will return <mask> s.srv = nil </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> remove log.Debug("DHCPv6: received: %s", req.Summary()) </s> add log.Debug("dhcpv6: received: %s", req.Summary()) </s> remove log.Debug("DHCPv6: %s", err) </s> add log.Debug("dhcpv6: %s", err) </s> remove log.Debug("DHCPv6: dhcpv6.ExtractMAC: %s", err) </s> add log.Debug("dhcpv6: dhcpv6.ExtractMAC: %s", err) </s> remove log.Error("DHCPv6: %s", err) </s> add log.Error("dhcpv6: %s", err) </s> remove log.Error("DHCPv6: conn.Write to %s failed: %s", peer, err) </s> add log.Error("dhcpv6: conn.Write to %s failed: %s", peer, err)
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dhcpd/v6.go
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
<mask> case filtering.FilteredParental: <mask> e.Result = stats.RParental <mask> case filtering.FilteredSafeSearch: <mask> e.Result = stats.RSafeSearch <mask> case filtering.FilteredBlockList: <mask> fallthrough <mask> case filtering.FilteredInvalid: <mask> fallthrough <mask> case filtering.FilteredBlockedService: <mask> e.Result = stats.RFiltered <mask> } <mask> <mask> s.stats.Update(e) <mask> } </s> Pull request: all: avoid fallthrough Merge in DNS/adguard-home from rm-fallthrough to master Squashed commit of the following: commit 14308b6cd3580d2c51b6da9f40b8a37766046708 Author: Ainar Garipov <[email protected]> Date: Fri May 21 18:16:42 2021 +0300 dhcpd: imp code commit 2009219df7d35713d06848010ce57b387e407c0e Author: Ainar Garipov <[email protected]> Date: Fri May 21 17:54:38 2021 +0300 all: avoid fallthrough </s> remove fallthrough </s> add </s> add resp, err = dhcpv6.NewReplyFromMessage(msg) </s> remove switch len(addrs) { case 0: log.Debug("dhcpv%d: attempt %d: no ip addresses", ipv, n) time.Sleep(backoff) case 1: // Some Android devices use 8.8.8.8 if there is not // a secondary DNS server. Fix that by setting the // secondary DNS address to the same address. // // See https://github.com/AdguardTeam/AdGuardHome/issues/1708. log.Debug("dhcpv%d: setting secondary dns ip to itself", ipv) addrs = append(addrs, addrs[0]) fallthrough default: break waitForIP </s> add if len(addrs) > 0 { break </s> remove log.Debug("DHCPv6: no lease for: %s", mac) </s> add log.Debug("dhcpv6: no lease for: %s", mac) </s> add log.Debug("dhcpv%d: attempt %d: no ip addresses", ipv, n) time.Sleep(backoff) </s> remove if len(addrs) == 0 { </s> add switch len(addrs) { case 0:
https://github.com/AdguardTeam/AdGuardHome/commit/6847f7c8bb3a827cfe4b1798f64cd4e14d6c7173
internal/dnsforward/stats.go
keep replace keep keep replace keep keep
<mask> const nameB = b.name.toUpperCase(); <mask> let comparison = 0; <mask> <mask> if (nameA > nameB) { <mask> comparison = 1; <mask> } else if (nameA < nameB) { <mask> comparison = -1; </s> * client: fix sort helper </s> remove return comparison; </s> add return 0; </s> remove comparison = -1; </s> add return -1;
https://github.com/AdguardTeam/AdGuardHome/commit/68a4cc597f4da5bcd507c182e936683e426b0709
client/src/helpers/helpers.js
keep keep replace keep keep replace
<mask> comparison = 1; <mask> } else if (nameA < nameB) { <mask> comparison = -1; <mask> } <mask> <mask> return comparison; </s> * client: fix sort helper </s> remove let comparison = 0; </s> add </s> remove comparison = 1; </s> add return 1;
https://github.com/AdguardTeam/AdGuardHome/commit/68a4cc597f4da5bcd507c182e936683e426b0709
client/src/helpers/helpers.js
keep keep keep keep replace keep keep keep keep keep
<mask> configureLogger(args) <mask> <mask> // print the first message after logger is configured <mask> log.Printf("AdGuard Home, version %s\n", VersionString) <mask> log.Printf("Current working directory is %s", config.ourBinaryDir) <mask> if args.runningAsService { <mask> log.Printf("AdGuard Home is running as a service") <mask> } <mask> <mask> config.firstRun = detectFirstRun() </s> Demote some log.printf into log.tracef </s> remove log.Printf("Got IP that is not IPv4: %v", ipnet.IP) </s> add log.Tracef("Got IP that is not IPv4: %v", ipnet.IP) </s> remove log.Printf("Got IP that is IPv4: %v", ipnet.IP) </s> add log.Tracef("Got IP that is IPv4: %v", ipnet.IP) </s> remove log.Printf("Writing YAML file: %s", configFile) </s> add log.Tracef("Writing YAML file: %s", configFile) </s> remove log.Printf("%s(): got schema version %v", _Func(), schemaVersionInterface) </s> add log.Tracef("got schema version %v", schemaVersionInterface) </s> remove log.Printf("Reading YAML file: %s", configFile) </s> add log.Tracef("Reading YAML file: %s", configFile) </s> remove log.Printf("Creating dnsfilter") </s> add log.Tracef("Creating dnsfilter")
https://github.com/AdguardTeam/AdGuardHome/commit/68c8a4d484bead62b688eddca69152b8160fb2b1
app.go
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> // parseConfig loads configuration from the YAML file <mask> func parseConfig() error { <mask> configFile := config.getConfigFilename() <mask> log.Printf("Reading YAML file: %s", configFile) <mask> yamlFile, err := readConfigFile() <mask> if err != nil { <mask> log.Printf("Couldn't read config file: %s", err) <mask> return err <mask> } </s> Demote some log.printf into log.tracef </s> remove log.Printf("Writing YAML file: %s", configFile) </s> add log.Tracef("Writing YAML file: %s", configFile) </s> remove log.Printf("Creating dnsfilter") </s> add log.Tracef("Creating dnsfilter") </s> remove log.Printf("Loading stats from querylog") </s> add log.Tracef("Loading stats from querylog") </s> remove log.Printf("Loading filter %d contents to: %s", filter.ID, filterFilePath) </s> add log.Tracef("Loading filter %d contents to: %s", filter.ID, filterFilePath) </s> remove log.Printf("File %s, id %d, length %d", filterFilePath, filter.ID, len(filterFileContents)) </s> add log.Tracef("File %s, id %d, length %d", filterFilePath, filter.ID, len(filterFileContents)) </s> remove log.Printf("%s(): got schema version %v", _Func(), schemaVersionInterface) </s> add log.Tracef("got schema version %v", schemaVersionInterface)
https://github.com/AdguardTeam/AdGuardHome/commit/68c8a4d484bead62b688eddca69152b8160fb2b1
config.go
keep keep keep keep replace keep keep keep keep keep
<mask> log.Tracef("Silently refusing to write config because first run and not configured yet") <mask> return nil <mask> } <mask> configFile := config.getConfigFilename() <mask> log.Printf("Writing YAML file: %s", configFile) <mask> yamlText, err := yaml.Marshal(&config) <mask> if err != nil { <mask> log.Printf("Couldn't generate YAML file: %s", err) <mask> return err <mask> } </s> Demote some log.printf into log.tracef </s> remove log.Printf("Reading YAML file: %s", configFile) </s> add log.Tracef("Reading YAML file: %s", configFile) </s> remove log.Printf("Loading stats from querylog") </s> add log.Tracef("Loading stats from querylog") </s> remove log.Printf("Loading filter %d contents to: %s", filter.ID, filterFilePath) </s> add log.Tracef("Loading filter %d contents to: %s", filter.ID, filterFilePath) </s> remove log.Printf("%s(): got schema version %v", _Func(), schemaVersionInterface) </s> add log.Tracef("got schema version %v", schemaVersionInterface) </s> remove log.Printf("File %s, id %d, length %d", filterFilePath, filter.ID, len(filterFileContents)) </s> add log.Tracef("File %s, id %d, length %d", filterFilePath, filter.ID, len(filterFileContents)) </s> remove log.Printf("Creating dnsfilter") </s> add log.Tracef("Creating dnsfilter")
https://github.com/AdguardTeam/AdGuardHome/commit/68c8a4d484bead62b688eddca69152b8160fb2b1
config.go
keep replace keep keep keep replace keep
<mask> if ipnet.IP.To4() == nil { <mask> log.Printf("Got IP that is not IPv4: %v", ipnet.IP) <mask> continue <mask> } <mask> <mask> log.Printf("Got IP that is IPv4: %v", ipnet.IP) <mask> return &net.IPNet{ </s> Demote some log.printf into log.tracef </s> remove log.Printf("%s(): got schema version %v", _Func(), schemaVersionInterface) </s> add log.Tracef("got schema version %v", schemaVersionInterface) </s> remove log.Printf("Current working directory is %s", config.ourBinaryDir) </s> add log.Tracef("Current working directory is %s", config.ourBinaryDir) </s> remove log.Printf("Writing YAML file: %s", configFile) </s> add log.Tracef("Writing YAML file: %s", configFile) </s> remove log.Printf("Loading stats from querylog") </s> add log.Tracef("Loading stats from querylog") </s> remove log.Printf("Loading filter %d contents to: %s", filter.ID, filterFilePath) </s> add log.Tracef("Loading filter %d contents to: %s", filter.ID, filterFilePath)
https://github.com/AdguardTeam/AdGuardHome/commit/68c8a4d484bead62b688eddca69152b8160fb2b1
dhcpd/helpers.go
keep keep keep keep replace keep keep keep keep keep
<mask> if err != nil { <mask> return err <mask> } <mask> <mask> log.Printf("Loading stats from querylog") <mask> err = fillStatsFromQueryLog() <mask> if err != nil { <mask> return errorx.Decorate(err, "failed to load stats from querylog") <mask> } <mask> </s> Demote some log.printf into log.tracef </s> remove log.Printf("Reading YAML file: %s", configFile) </s> add log.Tracef("Reading YAML file: %s", configFile) </s> remove log.Printf("Loading filter %d contents to: %s", filter.ID, filterFilePath) </s> add log.Tracef("Loading filter %d contents to: %s", filter.ID, filterFilePath) </s> remove log.Printf("Writing YAML file: %s", configFile) </s> add log.Tracef("Writing YAML file: %s", configFile) </s> remove log.Printf("Creating dnsfilter") </s> add log.Tracef("Creating dnsfilter") </s> remove log.Printf("File %s, id %d, length %d", filterFilePath, filter.ID, len(filterFileContents)) </s> add log.Tracef("File %s, id %d, length %d", filterFilePath, filter.ID, len(filterFileContents)) </s> remove log.Printf("%s(): got schema version %v", _Func(), schemaVersionInterface) </s> add log.Tracef("got schema version %v", schemaVersionInterface)
https://github.com/AdguardTeam/AdGuardHome/commit/68c8a4d484bead62b688eddca69152b8160fb2b1
dnsforward/dnsforward.go