docstring_tokens
stringlengths 18
16.9k
| code_tokens
stringlengths 75
1.81M
| html_url
stringlengths 74
116
| file_name
stringlengths 3
311
|
---|---|---|---|
keep keep keep keep replace keep keep keep keep keep | <mask> mac, err := net.ParseMAC(c.MAC)
<mask> if err != nil {
<mask> continue
<mask> }
<mask> ipAddr := dhcpServer.FindIPbyMAC(mac)
<mask> if ipAddr == nil {
<mask> continue
<mask> }
<mask> if ip == ipAddr.String() {
<mask> return *c, true
</s> * move "dhcpServer" to "config" </s> remove ipAddr := dhcpServer.FindIPbyMAC(hwAddr)
</s> add ipAddr := config.dhcpServer.FindIPbyMAC(hwAddr) </s> remove err := dhcpServer.Stop()
</s> add err := config.dhcpServer.Stop() </s> remove err = dhcpServer.Start()
</s> add err = config.dhcpServer.Start() </s> remove err = dhcpServer.RemoveStaticLease(lease)
</s> add err = config.dhcpServer.RemoveStaticLease(lease) </s> remove err = dhcpServer.AddStaticLease(lease)
</s> add err = config.dhcpServer.AddStaticLease(lease) </s> remove err = dhcpServer.Init(newconfig.ServerConfig)
</s> add err = config.dhcpServer.Init(newconfig.ServerConfig) | https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b | home/clients.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask>
<mask> if len(c.MAC) != 0 {
<mask> hwAddr, _ := net.ParseMAC(c.MAC)
<mask> ipAddr := dhcpServer.FindIPbyMAC(hwAddr)
<mask> if ipAddr != nil {
<mask> cj.IP = ipAddr.String()
<mask> }
<mask> }
<mask>
</s> * move "dhcpServer" to "config" </s> remove ipAddr := dhcpServer.FindIPbyMAC(mac)
</s> add ipAddr := config.dhcpServer.FindIPbyMAC(mac) </s> remove err = dhcpServer.Start()
</s> add err = config.dhcpServer.Start() </s> remove err := dhcpServer.Stop()
</s> add err := config.dhcpServer.Stop() </s> remove err = dhcpServer.Init(newconfig.ServerConfig)
</s> add err = config.dhcpServer.Init(newconfig.ServerConfig) </s> remove err = dhcpServer.Start()
</s> add err = config.dhcpServer.Start() </s> remove err := dhcpServer.Init(config.DHCP)
</s> add err := config.dhcpServer.Init(config.DHCP) | https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b | home/clients.go |
keep keep add keep keep keep keep | <mask> versionCheckJSON []byte
<mask> versionCheckLastTime time.Time
<mask>
<mask> httpServer *http.Server
<mask> httpsServer HTTPSServer
<mask>
<mask> BindHost string `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to
</s> * move "dhcpServer" to "config" </s> remove err = dhcpServer.Stop()
</s> add err = config.dhcpServer.Stop() </s> remove err = dhcpServer.Init(newconfig.ServerConfig)
</s> add err = config.dhcpServer.Init(newconfig.ServerConfig) </s> remove err := dhcpServer.Init(config.DHCP)
</s> add err := config.dhcpServer.Init(config.DHCP) </s> remove var dhcpServer = dhcpd.Server{}
</s> add </s> remove err = dhcpServer.Start()
</s> add err = config.dhcpServer.Start() </s> remove err = dhcpServer.CheckConfig(newconfig.ServerConfig)
</s> add err = config.dhcpServer.CheckConfig(newconfig.ServerConfig) | https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b | home/config.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/joomcode/errorx"
<mask> )
<mask>
<mask> var dhcpServer = dhcpd.Server{}
<mask>
<mask> // []dhcpd.Lease -> JSON
<mask> func convertLeases(inputLeases []dhcpd.Lease, includeExpires bool) []map[string]string {
<mask> leases := []map[string]string{}
<mask> for _, l := range inputLeases {
<mask> lease := map[string]string{
</s> * move "dhcpServer" to "config" </s> remove leases := convertLeases(dhcpServer.Leases(), true)
staticLeases := convertLeases(dhcpServer.StaticLeases(), false)
</s> add leases := convertLeases(config.dhcpServer.Leases(), true)
staticLeases := convertLeases(config.dhcpServer.StaticLeases(), false) </s> remove err := dhcpServer.Init(config.DHCP)
</s> add err := config.dhcpServer.Init(config.DHCP) </s> remove ipAddr := dhcpServer.FindIPbyMAC(hwAddr)
</s> add ipAddr := config.dhcpServer.FindIPbyMAC(hwAddr) </s> add dhcpServer dhcpd.Server </s> remove ipAddr := dhcpServer.FindIPbyMAC(mac)
</s> add ipAddr := config.dhcpServer.FindIPbyMAC(mac) </s> remove err := dhcpServer.Stop()
</s> add err := config.dhcpServer.Stop() | https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b | home/dhcp.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> }
<mask>
<mask> func handleDHCPStatus(w http.ResponseWriter, r *http.Request) {
<mask> log.Tracef("%s %v", r.Method, r.URL)
<mask> leases := convertLeases(dhcpServer.Leases(), true)
<mask> staticLeases := convertLeases(dhcpServer.StaticLeases(), false)
<mask> status := map[string]interface{}{
<mask> "config": config.DHCP,
<mask> "leases": leases,
<mask> "static_leases": staticLeases,
<mask> }
</s> * move "dhcpServer" to "config" </s> remove var dhcpServer = dhcpd.Server{}
</s> add </s> remove ipAddr := dhcpServer.FindIPbyMAC(hwAddr)
</s> add ipAddr := config.dhcpServer.FindIPbyMAC(hwAddr) </s> remove ipAddr := dhcpServer.FindIPbyMAC(mac)
</s> add ipAddr := config.dhcpServer.FindIPbyMAC(mac) </s> remove err := dhcpServer.Stop()
</s> add err := config.dhcpServer.Stop() </s> remove err := dhcpServer.Init(config.DHCP)
</s> add err := config.dhcpServer.Init(config.DHCP) </s> remove err = dhcpServer.Start()
</s> add err = config.dhcpServer.Start() | https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b | home/dhcp.go |
keep keep keep keep replace keep keep keep keep keep | <mask> httpError(w, http.StatusBadRequest, "Failed to parse new DHCP config json: %s", err)
<mask> return
<mask> }
<mask>
<mask> err = dhcpServer.CheckConfig(newconfig.ServerConfig)
<mask> if err != nil {
<mask> httpError(w, http.StatusBadRequest, "Invalid DHCP configuration: %s", err)
<mask> return
<mask> }
<mask>
</s> * move "dhcpServer" to "config" </s> remove err = dhcpServer.Init(newconfig.ServerConfig)
</s> add err = config.dhcpServer.Init(newconfig.ServerConfig) </s> remove err = dhcpServer.Stop()
</s> add err = config.dhcpServer.Stop() </s> remove err = dhcpServer.Start()
</s> add err = config.dhcpServer.Start() </s> remove err = dhcpServer.RemoveStaticLease(lease)
</s> add err = config.dhcpServer.RemoveStaticLease(lease) </s> remove err = dhcpServer.AddStaticLease(lease)
</s> add err = config.dhcpServer.AddStaticLease(lease) </s> remove err = dhcpServer.Start()
</s> add err = config.dhcpServer.Start() | https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b | home/dhcp.go |
keep replace keep keep keep keep replace keep keep | <mask>
<mask> err = dhcpServer.Stop()
<mask> if err != nil {
<mask> log.Error("failed to stop the DHCP server: %s", err)
<mask> }
<mask>
<mask> err = dhcpServer.Init(newconfig.ServerConfig)
<mask> if err != nil {
<mask> httpError(w, http.StatusBadRequest, "Invalid DHCP configuration: %s", err)
</s> * move "dhcpServer" to "config" </s> remove err = dhcpServer.CheckConfig(newconfig.ServerConfig)
</s> add err = config.dhcpServer.CheckConfig(newconfig.ServerConfig) </s> remove err = dhcpServer.Start()
</s> add err = config.dhcpServer.Start() </s> remove err := dhcpServer.Stop()
</s> add err := config.dhcpServer.Stop() </s> remove err = dhcpServer.Start()
</s> add err = config.dhcpServer.Start() </s> remove err = dhcpServer.RemoveStaticLease(lease)
</s> add err = config.dhcpServer.RemoveStaticLease(lease) | https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b | home/dhcp.go |
keep keep keep keep replace keep keep keep keep keep | <mask> return
<mask> }
<mask> }
<mask>
<mask> err = dhcpServer.Start()
<mask> if err != nil {
<mask> httpError(w, http.StatusBadRequest, "Failed to start DHCP server: %s", err)
<mask> return
<mask> }
<mask> }
</s> * move "dhcpServer" to "config" </s> remove err = dhcpServer.CheckConfig(newconfig.ServerConfig)
</s> add err = config.dhcpServer.CheckConfig(newconfig.ServerConfig) </s> remove err = dhcpServer.Start()
</s> add err = config.dhcpServer.Start() </s> remove err = dhcpServer.Init(newconfig.ServerConfig)
</s> add err = config.dhcpServer.Init(newconfig.ServerConfig) </s> remove err = dhcpServer.Stop()
</s> add err = config.dhcpServer.Stop() </s> remove err := dhcpServer.Init(config.DHCP)
</s> add err := config.dhcpServer.Init(config.DHCP) </s> remove err = dhcpServer.RemoveStaticLease(lease)
</s> add err = config.dhcpServer.RemoveStaticLease(lease) | https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b | home/dhcp.go |
keep keep keep keep replace keep keep keep keep keep | <mask> IP: ip,
<mask> HWAddr: mac,
<mask> Hostname: lj.Hostname,
<mask> }
<mask> err = dhcpServer.AddStaticLease(lease)
<mask> if err != nil {
<mask> httpError(w, http.StatusBadRequest, "%s", err)
<mask> return
<mask> }
<mask> returnOK(w)
</s> * move "dhcpServer" to "config" </s> remove err = dhcpServer.RemoveStaticLease(lease)
</s> add err = config.dhcpServer.RemoveStaticLease(lease) </s> remove err = dhcpServer.Start()
</s> add err = config.dhcpServer.Start() </s> remove err = dhcpServer.Init(newconfig.ServerConfig)
</s> add err = config.dhcpServer.Init(newconfig.ServerConfig) </s> remove err = dhcpServer.Start()
</s> add err = config.dhcpServer.Start() </s> remove err = dhcpServer.CheckConfig(newconfig.ServerConfig)
</s> add err = config.dhcpServer.CheckConfig(newconfig.ServerConfig) </s> remove err = dhcpServer.Stop()
</s> add err = config.dhcpServer.Stop() | https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b | home/dhcp.go |
keep keep keep keep replace keep keep keep keep keep | <mask> IP: ip,
<mask> HWAddr: mac,
<mask> Hostname: lj.Hostname,
<mask> }
<mask> err = dhcpServer.RemoveStaticLease(lease)
<mask> if err != nil {
<mask> httpError(w, http.StatusBadRequest, "%s", err)
<mask> return
<mask> }
<mask> returnOK(w)
</s> * move "dhcpServer" to "config" </s> remove err = dhcpServer.AddStaticLease(lease)
</s> add err = config.dhcpServer.AddStaticLease(lease) </s> remove err = dhcpServer.Start()
</s> add err = config.dhcpServer.Start() </s> remove err = dhcpServer.Init(newconfig.ServerConfig)
</s> add err = config.dhcpServer.Init(newconfig.ServerConfig) </s> remove err = dhcpServer.Start()
</s> add err = config.dhcpServer.Start() </s> remove err = dhcpServer.CheckConfig(newconfig.ServerConfig)
</s> add err = config.dhcpServer.CheckConfig(newconfig.ServerConfig) </s> remove err = dhcpServer.Stop()
</s> add err = config.dhcpServer.Stop() | https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b | home/dhcp.go |
keep keep replace keep keep keep keep replace keep keep keep keep | <mask> }
<mask>
<mask> err := dhcpServer.Init(config.DHCP)
<mask> if err != nil {
<mask> return errorx.Decorate(err, "Couldn't init DHCP server")
<mask> }
<mask>
<mask> err = dhcpServer.Start()
<mask> if err != nil {
<mask> return errorx.Decorate(err, "Couldn't start DHCP server")
<mask> }
<mask> return nil
</s> * move "dhcpServer" to "config" </s> remove err := dhcpServer.Stop()
</s> add err := config.dhcpServer.Stop() </s> remove err = dhcpServer.Start()
</s> add err = config.dhcpServer.Start() </s> remove err = dhcpServer.Init(newconfig.ServerConfig)
</s> add err = config.dhcpServer.Init(newconfig.ServerConfig) </s> remove ipAddr := dhcpServer.FindIPbyMAC(mac)
</s> add ipAddr := config.dhcpServer.FindIPbyMAC(mac) </s> remove err = dhcpServer.RemoveStaticLease(lease)
</s> add err = config.dhcpServer.RemoveStaticLease(lease) | https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b | home/dhcp.go |
keep keep keep keep replace keep keep keep keep keep | <mask> if !config.DHCP.Enabled {
<mask> return nil
<mask> }
<mask>
<mask> err := dhcpServer.Stop()
<mask> if err != nil {
<mask> return errorx.Decorate(err, "Couldn't stop DHCP server")
<mask> }
<mask>
<mask> return nil
</s> * move "dhcpServer" to "config" </s> remove err = dhcpServer.Start()
</s> add err = config.dhcpServer.Start() </s> remove err := dhcpServer.Init(config.DHCP)
</s> add err := config.dhcpServer.Init(config.DHCP) </s> remove err = dhcpServer.Stop()
</s> add err = config.dhcpServer.Stop() </s> remove err = dhcpServer.Init(newconfig.ServerConfig)
</s> add err = config.dhcpServer.Init(newconfig.ServerConfig) </s> remove ipAddr := dhcpServer.FindIPbyMAC(mac)
</s> add ipAddr := config.dhcpServer.FindIPbyMAC(mac) </s> remove err = dhcpServer.Start()
</s> add err = config.dhcpServer.Start() | https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b | home/dhcp.go |
keep keep add keep keep keep keep keep keep | <mask> github.com/gobuffalo/packr v1.30.1
<mask> github.com/gobuffalo/packr/v2 v2.8.1 // indirect
<mask> github.com/google/go-cmp v0.5.5 // indirect
<mask> github.com/hugelgupf/socketpair v0.0.0-20190730060125-05d35a94e714
<mask> github.com/insomniacslk/dhcp v0.0.0-20210310193751-cfd4d47082c2
<mask> github.com/kardianos/service v1.2.0
<mask> github.com/karrick/godirwalk v1.16.1 // indirect
<mask> github.com/lucas-clemente/quic-go v0.19.3
<mask> github.com/marten-seemann/qtls-go1-15 v0.1.4 // indirect
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> add "github.com/google/renameio/maybe" </s> remove log.Info("DHCP: loaded leases v4:%d v6:%d total-read:%d from DB",
</s> add log.Info("dhcp: loaded leases v4:%d v6:%d total-read:%d from DB", </s> remove "github.com/AdguardTeam/golibs/file"
</s> add "github.com/google/renameio/maybe" </s> remove err = file.SafeWrite(configFile, yamlText)
</s> add err = maybe.WriteFile(configFile, yamlText, 0o644) </s> add "github.com/google/renameio/maybe" </s> remove "github.com/AdguardTeam/golibs/file"
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | go.mod |
keep add keep keep keep keep keep keep | <mask> github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
<mask> github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
<mask> github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY=
<mask> github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg=
<mask> github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
<mask> github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
<mask> github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
<mask> github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> add github.com/google/renameio v1.0.1-0.20210406141108-81588dbe0453 </s> remove log.Info("DHCP: invalid IP: %s", obj[i].IP)
</s> add log.Info("dhcp: invalid IP: %s", obj[i].IP) </s> remove "github.com/AdguardTeam/golibs/file"
</s> add "github.com/google/renameio/maybe" </s> remove err = file.SafeWrite("/etc/dhcpcd.conf", body)
</s> add err = maybe.WriteFile("/etc/dhcpcd.conf", body, 0o644) </s> remove return err
</s> add return fmt.Errorf("writing conf: %w", err) </s> remove "github.com/AdguardTeam/golibs/file"
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | go.sum |
keep keep keep keep replace keep keep keep keep keep | <mask> "os"
<mask> "strings"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghio"
<mask> "github.com/AdguardTeam/golibs/file"
<mask> )
<mask>
<mask> // maxConfigFileSize is the maximum length of interfaces configuration file.
<mask> const maxConfigFileSize = 1024 * 1024
<mask>
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> add "github.com/google/renameio/maybe" </s> remove "github.com/AdguardTeam/golibs/file"
</s> add </s> remove "github.com/AdguardTeam/golibs/file"
</s> add </s> add "github.com/google/renameio/maybe" </s> remove "github.com/AdguardTeam/golibs/file"
</s> add </s> add github.com/google/renameio v1.0.1-0.20210406141108-81588dbe0453 | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | internal/aghnet/net_linux.go |
keep keep keep keep replace keep keep keep keep keep | <mask> return err
<mask> }
<mask>
<mask> body = append(body, []byte(add)...)
<mask> err = file.SafeWrite("/etc/dhcpcd.conf", body)
<mask> if err != nil {
<mask> return err
<mask> }
<mask>
<mask> return nil
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> remove return err
</s> add return fmt.Errorf("writing conf: %w", err) </s> remove err = file.SafeWrite(confFile, body)
</s> add err = maybe.WriteFile(confFile, body, 0o644) </s> remove err = file.SafeWrite(configFile, yamlText)
</s> add err = maybe.WriteFile(configFile, yamlText, 0o644) </s> remove err = file.SafeWrite(s.conf.DBFilePath, data)
</s> add err = maybe.WriteFile(s.conf.DBFilePath, data, 0o644) </s> remove log.Error("DHCP: invalid DB: %v", err)
</s> add log.Error("dhcp: invalid DB: %v", err) </s> remove log.Error("DHCP: can't store lease table on disk: %v filename: %s",
</s> add log.Error("dhcp: can't store lease table on disk: %v filename: %s", | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | internal/aghnet/net_linux.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> body = append(body, []byte(add)...)
<mask> err = file.SafeWrite("/etc/dhcpcd.conf", body)
<mask> if err != nil {
<mask> return err
<mask> }
<mask>
<mask> return nil
<mask> }
<mask>
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> remove err = file.SafeWrite("/etc/dhcpcd.conf", body)
</s> add err = maybe.WriteFile("/etc/dhcpcd.conf", body, 0o644) </s> remove err = file.SafeWrite(confFile, body)
</s> add err = maybe.WriteFile(confFile, body, 0o644) </s> remove err = file.SafeWrite(configFile, yamlText)
</s> add err = maybe.WriteFile(configFile, yamlText, 0o644) </s> remove err = file.SafeWrite(s.conf.DBFilePath, data)
</s> add err = maybe.WriteFile(s.conf.DBFilePath, data, 0o644) </s> remove log.Error("DHCP: can't store lease table on disk: %v filename: %s",
</s> add log.Error("dhcp: can't store lease table on disk: %v filename: %s", </s> remove log.Error("DHCP: invalid DB: %v", err)
</s> add log.Error("dhcp: invalid DB: %v", err) | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | internal/aghnet/net_linux.go |
keep keep keep keep replace keep keep keep keep keep | <mask> "net"
<mask> "os"
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/golibs/file"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> )
<mask>
<mask> const dbFilename = "leases.db"
<mask>
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> add "github.com/google/renameio/maybe" </s> remove "github.com/AdguardTeam/golibs/file"
</s> add "github.com/google/renameio/maybe" </s> remove "github.com/AdguardTeam/golibs/file"
</s> add </s> remove "github.com/AdguardTeam/golibs/file"
</s> add </s> add "github.com/google/renameio/maybe" </s> add "github.com/google/renameio/maybe" | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | internal/dhcpd/db.go |
keep add keep keep keep keep | <mask>
<mask> "github.com/AdguardTeam/golibs/log"
<mask> )
<mask>
<mask> const dbFilename = "leases.db"
<mask>
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> remove "github.com/AdguardTeam/golibs/file"
</s> add </s> add "github.com/google/renameio/maybe" </s> remove "github.com/AdguardTeam/golibs/file"
</s> add </s> remove "github.com/AdguardTeam/golibs/file"
</s> add "github.com/google/renameio/maybe" </s> remove "github.com/AdguardTeam/golibs/file"
</s> add </s> add "github.com/google/renameio/maybe" | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | internal/dhcpd/db.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> obj := []leaseJSON{}
<mask> err = json.Unmarshal(data, &obj)
<mask> if err != nil {
<mask> log.Error("DHCP: invalid DB: %v", err)
<mask> return
<mask> }
<mask>
<mask> numLeases := len(obj)
<mask> for i := range obj {
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> remove log.Info("DHCP: invalid IP: %s", obj[i].IP)
</s> add log.Info("dhcp: invalid IP: %s", obj[i].IP) </s> remove err = file.SafeWrite(confFile, body)
</s> add err = maybe.WriteFile(confFile, body, 0o644) </s> remove err = file.SafeWrite(s.conf.DBFilePath, data)
</s> add err = maybe.WriteFile(s.conf.DBFilePath, data, 0o644) </s> remove err = file.SafeWrite(configFile, yamlText)
</s> add err = maybe.WriteFile(configFile, yamlText, 0o644) </s> remove return err
</s> add return fmt.Errorf("writing conf: %w", err) </s> remove err = file.SafeWrite("/etc/dhcpcd.conf", body)
</s> add err = maybe.WriteFile("/etc/dhcpcd.conf", body, 0o644) | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | internal/dhcpd/db.go |
keep keep keep keep replace keep keep keep keep keep | <mask> for i := range obj {
<mask> obj[i].IP = normalizeIP(obj[i].IP)
<mask>
<mask> if !(len(obj[i].IP) == 4 || len(obj[i].IP) == 16) {
<mask> log.Info("DHCP: invalid IP: %s", obj[i].IP)
<mask> continue
<mask> }
<mask>
<mask> lease := Lease{
<mask> HWAddr: obj[i].HWAddr,
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> remove log.Error("DHCP: invalid DB: %v", err)
</s> add log.Error("dhcp: invalid DB: %v", err) </s> remove log.Error("DHCP: can't store lease table on disk: %v filename: %s",
</s> add log.Error("dhcp: can't store lease table on disk: %v filename: %s", </s> remove err = file.SafeWrite(confFile, body)
</s> add err = maybe.WriteFile(confFile, body, 0o644) </s> remove log.Info("DHCP: stored %d leases in DB", len(leases))
</s> add log.Info("dhcp: stored %d leases in DB", len(leases)) </s> remove err = file.SafeWrite(s.conf.DBFilePath, data)
</s> add err = maybe.WriteFile(s.conf.DBFilePath, data, 0o644) </s> remove err = file.SafeWrite(configFile, yamlText)
</s> add err = maybe.WriteFile(configFile, yamlText, 0o644) | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | internal/dhcpd/db.go |
keep keep keep keep replace keep keep keep keep keep | <mask> if s.srv6 != nil {
<mask> s.srv6.ResetLeases(leases6)
<mask> }
<mask>
<mask> log.Info("DHCP: loaded leases v4:%d v6:%d total-read:%d from DB",
<mask> len(leases4), len(leases6), numLeases)
<mask> }
<mask>
<mask> // Skip duplicate leases
<mask> // Static leases have a priority over dynamic leases
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> remove log.Info("DHCP: stored %d leases in DB", len(leases))
</s> add log.Info("dhcp: stored %d leases in DB", len(leases)) </s> remove log.Error("DHCP: can't store lease table on disk: %v filename: %s",
</s> add log.Error("dhcp: can't store lease table on disk: %v filename: %s", </s> add github.com/google/renameio v1.0.1-0.20210406141108-81588dbe0453 </s> add "github.com/google/renameio/maybe" </s> remove "github.com/AdguardTeam/golibs/file"
</s> add "github.com/google/renameio/maybe" </s> remove return err
</s> add return fmt.Errorf("writing conf: %w", err) | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | internal/dhcpd/db.go |
keep keep keep keep replace keep keep keep keep keep keep keep keep replace keep keep keep keep | <mask> log.Error("json.Marshal: %v", err)
<mask> return
<mask> }
<mask>
<mask> err = file.SafeWrite(s.conf.DBFilePath, data)
<mask> if err != nil {
<mask> log.Error("DHCP: can't store lease table on disk: %v filename: %s",
<mask> err, s.conf.DBFilePath)
<mask> return
<mask> }
<mask>
<mask> err = file.SafeWrite(s.conf.DBFilePath, data)
<mask> if err != nil {
<mask> log.Error("DHCP: can't store lease table on disk: %v filename: %s",
<mask> err, s.conf.DBFilePath)
<mask> return
<mask> }
<mask> log.Info("DHCP: stored %d leases in DB", len(leases))
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> remove log.Info("DHCP: stored %d leases in DB", len(leases))
</s> add log.Info("dhcp: stored %d leases in DB", len(leases)) </s> remove err = file.SafeWrite(configFile, yamlText)
</s> add err = maybe.WriteFile(configFile, yamlText, 0o644) </s> remove log.Error("DHCP: invalid DB: %v", err)
</s> add log.Error("dhcp: invalid DB: %v", err) </s> remove return err
</s> add return fmt.Errorf("writing conf: %w", err) </s> remove err = file.SafeWrite("/etc/dhcpcd.conf", body)
</s> add err = maybe.WriteFile("/etc/dhcpcd.conf", body, 0o644) | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | internal/dhcpd/db.go |
keep keep keep keep replace keep | <mask> log.Error("DHCP: can't store lease table on disk: %v filename: %s",
<mask> err, s.conf.DBFilePath)
<mask> return
<mask> }
<mask> log.Info("DHCP: stored %d leases in DB", len(leases))
<mask> }
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> remove log.Error("DHCP: can't store lease table on disk: %v filename: %s",
</s> add log.Error("dhcp: can't store lease table on disk: %v filename: %s", </s> remove err = file.SafeWrite(s.conf.DBFilePath, data)
</s> add err = maybe.WriteFile(s.conf.DBFilePath, data, 0o644) </s> remove log.Info("DHCP: loaded leases v4:%d v6:%d total-read:%d from DB",
</s> add log.Info("dhcp: loaded leases v4:%d v6:%d total-read:%d from DB", </s> remove log.Info("DHCP: invalid IP: %s", obj[i].IP)
</s> add log.Info("dhcp: invalid IP: %s", obj[i].IP) </s> remove err = file.SafeWrite(configFile, yamlText)
</s> add err = maybe.WriteFile(configFile, yamlText, 0o644) </s> remove log.Error("DHCP: invalid DB: %v", err)
</s> add log.Error("dhcp: invalid DB: %v", err) | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | internal/dhcpd/db.go |
keep keep keep keep replace keep keep keep keep keep | <mask> "github.com/AdguardTeam/AdGuardHome/internal/dnsforward"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/querylog"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/stats"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/version"
<mask> "github.com/AdguardTeam/golibs/file"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> yaml "gopkg.in/yaml.v2"
<mask> )
<mask>
<mask> const (
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> add "github.com/google/renameio/maybe" </s> remove "github.com/AdguardTeam/golibs/file"
</s> add </s> add "github.com/google/renameio/maybe" </s> remove "github.com/AdguardTeam/golibs/file"
</s> add </s> add "github.com/google/renameio/maybe" </s> remove "github.com/AdguardTeam/golibs/file"
</s> add "github.com/google/renameio/maybe" | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | internal/home/config.go |
keep add keep keep keep keep | <mask> "github.com/AdguardTeam/AdGuardHome/internal/version"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> yaml "gopkg.in/yaml.v2"
<mask> )
<mask>
<mask> const (
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> remove "github.com/AdguardTeam/golibs/file"
</s> add </s> remove "github.com/AdguardTeam/golibs/file"
</s> add </s> add "github.com/google/renameio/maybe" </s> add "github.com/google/renameio/maybe" </s> remove "github.com/AdguardTeam/golibs/file"
</s> add </s> remove "github.com/AdguardTeam/golibs/file"
</s> add "github.com/google/renameio/maybe" | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | internal/home/config.go |
keep keep keep keep replace keep keep keep keep keep | <mask> if err != nil {
<mask> log.Error("Couldn't generate YAML file: %s", err)
<mask> return err
<mask> }
<mask> err = file.SafeWrite(configFile, yamlText)
<mask> if err != nil {
<mask> log.Error("Couldn't save YAML config: %s", err)
<mask> return err
<mask> }
<mask>
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> remove err = file.SafeWrite(confFile, body)
</s> add err = maybe.WriteFile(confFile, body, 0o644) </s> remove err = file.SafeWrite(s.conf.DBFilePath, data)
</s> add err = maybe.WriteFile(s.conf.DBFilePath, data, 0o644) </s> remove return err
</s> add return fmt.Errorf("writing conf: %w", err) </s> remove err = file.SafeWrite("/etc/dhcpcd.conf", body)
</s> add err = maybe.WriteFile("/etc/dhcpcd.conf", body, 0o644) </s> remove log.Error("DHCP: invalid DB: %v", err)
</s> add log.Error("dhcp: invalid DB: %v", err) </s> remove log.Error("DHCP: can't store lease table on disk: %v filename: %s",
</s> add log.Error("dhcp: can't store lease table on disk: %v filename: %s", | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | internal/home/config.go |
keep keep keep keep replace keep keep keep keep keep | <mask> "path"
<mask> "path/filepath"
<mask> "runtime"
<mask>
<mask> "github.com/AdguardTeam/golibs/file"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "golang.org/x/crypto/bcrypt"
<mask> yaml "gopkg.in/yaml.v2"
<mask> )
<mask>
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> add "github.com/google/renameio/maybe" </s> remove "github.com/AdguardTeam/golibs/file"
</s> add </s> add "github.com/google/renameio/maybe" </s> remove "github.com/AdguardTeam/golibs/file"
</s> add </s> remove "github.com/AdguardTeam/golibs/file"
</s> add "github.com/google/renameio/maybe" </s> add "github.com/google/renameio/maybe" | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | internal/home/upgrade.go |
keep add keep keep keep keep keep | <mask>
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "golang.org/x/crypto/bcrypt"
<mask> yaml "gopkg.in/yaml.v2"
<mask> )
<mask>
<mask> // currentSchemaVersion is the current schema version.
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> remove "github.com/AdguardTeam/golibs/file"
</s> add </s> remove "github.com/AdguardTeam/golibs/file"
</s> add "github.com/google/renameio/maybe" </s> add "github.com/google/renameio/maybe" </s> remove "github.com/AdguardTeam/golibs/file"
</s> add </s> add github.com/google/renameio v1.0.1-0.20210406141108-81588dbe0453 </s> add "github.com/google/renameio/maybe" | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | internal/home/upgrade.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask>
<mask> config.fileData = body
<mask> confFile := config.getConfigFilename()
<mask> err = file.SafeWrite(confFile, body)
<mask> if err != nil {
<mask> return fmt.Errorf("saving new config: %w", err)
<mask> }
<mask>
<mask> return nil
</s> Pull request: all: use renameio instead of golibs/file
Merge in DNS/adguard-home from use-renameio to master
Squashed commit of the following:
commit 807cda37b0e9e49539c1a8ce7912b74bd3c05b08
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/file </s> remove return err
</s> add return fmt.Errorf("writing conf: %w", err) </s> remove err = file.SafeWrite("/etc/dhcpcd.conf", body)
</s> add err = maybe.WriteFile("/etc/dhcpcd.conf", body, 0o644) </s> remove err = file.SafeWrite(configFile, yamlText)
</s> add err = maybe.WriteFile(configFile, yamlText, 0o644) </s> remove log.Error("DHCP: invalid DB: %v", err)
</s> add log.Error("dhcp: invalid DB: %v", err) </s> remove err = file.SafeWrite(s.conf.DBFilePath, data)
</s> add err = maybe.WriteFile(s.conf.DBFilePath, data, 0o644) </s> remove log.Error("DHCP: can't store lease table on disk: %v filename: %s",
</s> add log.Error("dhcp: can't store lease table on disk: %v filename: %s", | https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29 | internal/home/upgrade.go |
keep keep replace replace replace replace replace replace keep replace replace | <mask> }
<mask>
<mask> type ipport struct {
<mask> IP string `json:"ip,omitempty"`
<mask> Port int `json:"port"`
<mask> Warning string `json:"warning"`
<mask> }
<mask>
<mask> type firstRunData struct {
<mask> Web ipport `json:"web"`
<mask> DNS ipport `json:"dns"`
</s> * control: /install/get_addresses: don't check if ports are available
* always use port 80 </s> remove
// find out if port 80 is available -- if not, fall back to 3000
if checkPortAvailable("", 80) == nil {
data.Web.Port = 80
} else {
data.Web.Port = 3000
}
// find out if port 53 is available -- if not, show a big warning
data.DNS.Port = 53
if checkPacketPortAvailable("", 53) != nil {
data.DNS.Warning = "Port 53 is not available for binding -- this will make DNS clients unable to contact AdGuard Home."
}
</s> add data.WebPort = 80
data.DNSPort = 53 | https://github.com/AdguardTeam/AdGuardHome/commit/00c128f0a4deff119f93d02de03fa3fc47c54ec1 | control.go |
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep | <mask>
<mask> func handleInstallGetAddresses(w http.ResponseWriter, r *http.Request) {
<mask> log.Tracef("%s %v", r.Method, r.URL)
<mask> data := firstRunData{}
<mask>
<mask> // find out if port 80 is available -- if not, fall back to 3000
<mask> if checkPortAvailable("", 80) == nil {
<mask> data.Web.Port = 80
<mask> } else {
<mask> data.Web.Port = 3000
<mask> }
<mask>
<mask> // find out if port 53 is available -- if not, show a big warning
<mask> data.DNS.Port = 53
<mask> if checkPacketPortAvailable("", 53) != nil {
<mask> data.DNS.Warning = "Port 53 is not available for binding -- this will make DNS clients unable to contact AdGuard Home."
<mask> }
<mask>
<mask> ifaces, err := getValidNetInterfacesForWeb()
<mask> if err != nil {
<mask> httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
<mask> return
</s> * control: /install/get_addresses: don't check if ports are available
* always use port 80 </s> remove type ipport struct {
IP string `json:"ip,omitempty"`
Port int `json:"port"`
Warning string `json:"warning"`
}
</s> add </s> remove Web ipport `json:"web"`
DNS ipport `json:"dns"`
</s> add WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"` | https://github.com/AdguardTeam/AdGuardHome/commit/00c128f0a4deff119f93d02de03fa3fc47c54ec1 | control.go |
keep keep keep keep replace keep | <mask> "encryption_private_key_path": "Private key path",
<mask> "encryption_certificates_source_path": "Set a certificates file path",
<mask> "encryption_certificates_source_content":"Paste the certificates contents",
<mask> "encryption_key_source_path": "Set a private key file",
<mask> "encryption_key_source_content": "Paste the private key contents"
<mask> }
</s> + client: handle time interval for statistics </s> add import { getStatsConfig, setStatsConfig } from '../actions/stats'; </s> add .custom-control-label,
.custom-control-label:before {
transition: 0.3s ease-in-out background-color, 0.3s ease-in-out color;
} </s> remove const { settings, services } = state;
</s> add const { settings, services, stats } = state; </s> add this.props.getStatsConfig(); </s> add stats, </s> remove settings, services, setBlockedServices, t,
</s> add settings,
services,
setBlockedServices,
setStatsConfig,
stats,
t, | https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d | client/src/__locales/en.json |
keep keep keep add | <mask> height: 23px;
<mask> min-width: 23px;
<mask> padding: 5px;
<mask> }
</s> + client: handle time interval for statistics </s> add import { getStatsConfig, setStatsConfig } from '../actions/stats'; </s> remove const { settings, services } = state;
</s> add const { settings, services, stats } = state; </s> add this.props.getStatsConfig(); </s> add stats, </s> remove settings, services, setBlockedServices, t,
</s> add settings,
services,
setBlockedServices,
setStatsConfig,
stats,
t, </s> add import StatsConfig from './StatsConfig'; | https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d | client/src/components/Settings/Settings.css |
keep keep add keep keep keep keep keep | <mask> import { withNamespaces, Trans } from 'react-i18next';
<mask>
<mask> import Services from './Services';
<mask> import Checkbox from '../ui/Checkbox';
<mask> import Loading from '../ui/Loading';
<mask> import PageTitle from '../ui/PageTitle';
<mask> import Card from '../ui/Card';
<mask>
</s> + client: handle time interval for statistics </s> add import { getStatsConfig, setStatsConfig } from '../actions/stats'; </s> add import stats from './stats'; </s> remove const { settings, services } = state;
</s> add const { settings, services, stats } = state; </s> add this.props.getStatsConfig(); </s> add .custom-control-label,
.custom-control-label:before {
transition: 0.3s ease-in-out background-color, 0.3s ease-in-out color;
} </s> add stats, | https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d | client/src/components/Settings/index.js |
keep add keep keep keep keep keep | <mask> this.props.initSettings(this.settings);
<mask> this.props.getBlockedServices();
<mask> }
<mask>
<mask> renderSettings = (settings) => {
<mask> if (Object.keys(settings).length > 0) {
<mask> return Object.keys(settings).map((key) => {
</s> + client: handle time interval for statistics </s> remove const { settings, services } = state;
</s> add const { settings, services, stats } = state; </s> add stats, </s> add import { getStatsConfig, setStatsConfig } from '../actions/stats'; </s> remove settings, services, setBlockedServices, t,
</s> add settings,
services,
setBlockedServices,
setStatsConfig,
stats,
t, </s> remove }, { getLogsProcessing: false, logsDownloading: false });
</s> add }, {
getLogsProcessing: false,
logsDownloading: false,
logs: [],
}); </s> add .custom-control-label,
.custom-control-label:before {
transition: 0.3s ease-in-out background-color, 0.3s ease-in-out color;
} | https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d | client/src/components/Settings/index.js |
keep keep keep keep replace keep keep keep keep keep | <mask> };
<mask>
<mask> render() {
<mask> const {
<mask> settings, services, setBlockedServices, t,
<mask> } = this.props;
<mask> return (
<mask> <Fragment>
<mask> <PageTitle title={t('general_settings')} />
<mask> {settings.processing && <Loading />}
</s> + client: handle time interval for statistics </s> add stats, </s> remove const { settings, services } = state;
</s> add const { settings, services, stats } = state; </s> add import { getStatsConfig, setStatsConfig } from '../actions/stats'; </s> add this.props.getStatsConfig(); </s> add getStatsConfig,
setStatsConfig, </s> add <div className="col-md-12">
<StatsConfig
interval={stats.interval}
processing={stats.setConfigProcessing}
setStatsConfig={setStatsConfig}
/>
</div> | https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d | client/src/components/Settings/index.js |
keep keep add keep keep keep keep keep keep | <mask> </div>
<mask> </Card>
<mask> </div>
<mask> <div className="col-md-12">
<mask> <Services
<mask> services={services}
<mask> setBlockedServices={setBlockedServices}
<mask> />
<mask> </div>
</s> + client: handle time interval for statistics </s> remove settings, services, setBlockedServices, t,
</s> add settings,
services,
setBlockedServices,
setStatsConfig,
stats,
t, </s> add stats, </s> remove }, { getLogsProcessing: false, logsDownloading: false });
</s> add }, {
getLogsProcessing: false,
logsDownloading: false,
logs: [],
}); </s> add stats: {
dns_queries: '',
blocked_filtering: '',
replaced_safebrowsing: '',
replaced_parental: '',
replaced_safesearch: '',
avg_processing_time: '',
}, </s> add import stats from './stats'; </s> add getStatsConfig,
setStatsConfig, | https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d | client/src/components/Settings/index.js |
keep keep keep add keep keep keep keep | <mask> initSettings: PropTypes.func,
<mask> settings: PropTypes.object,
<mask> settingsList: PropTypes.object,
<mask> toggleSetting: PropTypes.func,
<mask> t: PropTypes.func,
<mask> };
<mask>
<mask> export default withNamespaces()(Settings);
</s> + client: handle time interval for statistics </s> add getStatsConfig,
setStatsConfig, </s> add stats, </s> remove settings, services, setBlockedServices, t,
</s> add settings,
services,
setBlockedServices,
setStatsConfig,
stats,
t, </s> remove const { settings, services } = state;
</s> add const { settings, services, stats } = state; </s> add stats, </s> remove }, { getLogsProcessing: false, logsDownloading: false });
</s> add }, {
getLogsProcessing: false,
logsDownloading: false,
logs: [],
}); | https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d | client/src/components/Settings/index.js |
keep add keep keep keep keep | <mask> import { initSettings, toggleSetting } from '../actions';
<mask> import { getBlockedServices, setBlockedServices } from '../actions/services';
<mask> import Settings from '../components/Settings';
<mask>
<mask> const mapStateToProps = (state) => {
<mask> const { settings, services, stats } = state;
</s> + client: handle time interval for statistics </s> remove const { settings, services } = state;
</s> add const { settings, services, stats } = state; </s> add import StatsConfig from './StatsConfig'; </s> add stats, </s> add import stats from './stats'; </s> remove settings, services, setBlockedServices, t,
</s> add settings,
services,
setBlockedServices,
setStatsConfig,
stats,
t, </s> add this.props.getStatsConfig(); | https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d | client/src/containers/Settings.js |
keep keep keep keep replace keep keep keep keep keep | <mask> import { getBlockedServices, setBlockedServices } from '../actions/services';
<mask> import Settings from '../components/Settings';
<mask>
<mask> const mapStateToProps = (state) => {
<mask> const { settings, services } = state;
<mask> const props = {
<mask> settings,
<mask> services,
<mask> };
<mask> return props;
</s> + client: handle time interval for statistics </s> add import { getStatsConfig, setStatsConfig } from '../actions/stats'; </s> add stats, </s> remove settings, services, setBlockedServices, t,
</s> add settings,
services,
setBlockedServices,
setStatsConfig,
stats,
t, </s> add import StatsConfig from './StatsConfig'; </s> add import stats from './stats'; </s> add this.props.getStatsConfig(); | https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d | client/src/containers/Settings.js |
keep keep keep add keep keep keep keep keep keep | <mask> const { settings, services, stats } = state;
<mask> const props = {
<mask> settings,
<mask> services,
<mask> };
<mask> return props;
<mask> };
<mask>
<mask> const mapDispatchToProps = {
<mask> initSettings,
</s> + client: handle time interval for statistics </s> remove const { settings, services } = state;
</s> add const { settings, services, stats } = state; </s> add import { getStatsConfig, setStatsConfig } from '../actions/stats'; </s> remove settings, services, setBlockedServices, t,
</s> add settings,
services,
setBlockedServices,
setStatsConfig,
stats,
t, </s> add this.props.getStatsConfig(); </s> add getStatsConfig,
setStatsConfig, </s> add stats: {
dns_queries: '',
blocked_filtering: '',
replaced_safebrowsing: '',
replaced_parental: '',
replaced_safesearch: '',
avg_processing_time: '',
}, | https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d | client/src/containers/Settings.js |
keep keep keep add keep keep keep keep keep | <mask> initSettings,
<mask> toggleSetting,
<mask> getBlockedServices,
<mask> setBlockedServices,
<mask> };
<mask>
<mask> export default connect(
<mask> mapStateToProps,
<mask> mapDispatchToProps,
</s> + client: handle time interval for statistics </s> add getStatsConfig: PropTypes.func,
setStatsConfig: PropTypes.func, </s> remove settings, services, setBlockedServices, t,
</s> add settings,
services,
setBlockedServices,
setStatsConfig,
stats,
t, </s> add stats, </s> add import { getStatsConfig, setStatsConfig } from '../actions/stats'; </s> remove const { settings, services } = state;
</s> add const { settings, services, stats } = state; </s> add stats, | https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d | client/src/containers/Settings.js |
keep keep add keep keep keep keep | <mask> import access from './access';
<mask> import rewrites from './rewrites';
<mask> import services from './services';
<mask>
<mask> const settings = handleActions({
<mask> [actions.initSettingsRequest]: state => ({ ...state, processing: true }),
<mask> [actions.initSettingsFailure]: state => ({ ...state, processing: false }),
</s> + client: handle time interval for statistics </s> remove }, { getLogsProcessing: false, logsDownloading: false });
</s> add }, {
getLogsProcessing: false,
logsDownloading: false,
logs: [],
}); </s> add stats: {
dns_queries: '',
blocked_filtering: '',
replaced_safebrowsing: '',
replaced_parental: '',
replaced_safesearch: '',
avg_processing_time: '',
}, </s> add import StatsConfig from './StatsConfig'; </s> add import { getStatsConfig, setStatsConfig } from '../actions/stats'; </s> remove const { settings, services } = state;
</s> add const { settings, services, stats } = state; </s> add this.props.getStatsConfig(); | https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d | client/src/reducers/index.js |
keep keep keep add keep keep keep keep keep | <mask> dnsVersion: '',
<mask> clients: [],
<mask> autoClients: [],
<mask> topStats: [],
<mask> });
<mask>
<mask> const queryLogs = handleActions({
<mask> [actions.getLogsRequest]: state => ({ ...state, getLogsProcessing: true }),
<mask> [actions.getLogsFailure]: state => ({ ...state, getLogsProcessing: false }),
</s> + client: handle time interval for statistics </s> remove }, { getLogsProcessing: false, logsDownloading: false });
</s> add }, {
getLogsProcessing: false,
logsDownloading: false,
logs: [],
}); </s> add import stats from './stats'; </s> add stats, </s> add this.props.getStatsConfig(); </s> remove const { settings, services } = state;
</s> add const { settings, services, stats } = state; </s> add import { getStatsConfig, setStatsConfig } from '../actions/stats'; | https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d | client/src/reducers/index.js |
keep keep keep keep replace keep keep keep keep keep | <mask> },
<mask> [actions.downloadQueryLogRequest]: state => ({ ...state, logsDownloading: true }),
<mask> [actions.downloadQueryLogFailure]: state => ({ ...state, logsDownloading: false }),
<mask> [actions.downloadQueryLogSuccess]: state => ({ ...state, logsDownloading: false }),
<mask> }, { getLogsProcessing: false, logsDownloading: false });
<mask>
<mask> const filtering = handleActions({
<mask> [actions.setRulesRequest]: state => ({ ...state, processingRules: true }),
<mask> [actions.setRulesFailure]: state => ({ ...state, processingRules: false }),
<mask> [actions.setRulesSuccess]: state => ({ ...state, processingRules: false }),
</s> + client: handle time interval for statistics </s> add stats: {
dns_queries: '',
blocked_filtering: '',
replaced_safebrowsing: '',
replaced_parental: '',
replaced_safesearch: '',
avg_processing_time: '',
}, </s> add import stats from './stats'; </s> add this.props.getStatsConfig(); </s> remove const { settings, services } = state;
</s> add const { settings, services, stats } = state; </s> add import { getStatsConfig, setStatsConfig } from '../actions/stats'; </s> add stats, | https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d | client/src/reducers/index.js |
keep add keep keep keep | <mask> rewrites,
<mask> services,
<mask> loadingBar: loadingBarReducer,
<mask> form: formReducer,
<mask> });
</s> + client: handle time interval for statistics </s> remove }, { getLogsProcessing: false, logsDownloading: false });
</s> add }, {
getLogsProcessing: false,
logsDownloading: false,
logs: [],
}); </s> add stats: {
dns_queries: '',
blocked_filtering: '',
replaced_safebrowsing: '',
replaced_parental: '',
replaced_safesearch: '',
avg_processing_time: '',
}, </s> add stats, </s> remove settings, services, setBlockedServices, t,
</s> add settings,
services,
setBlockedServices,
setStatsConfig,
stats,
t, </s> remove const { settings, services } = state;
</s> add const { settings, services, stats } = state; </s> add import { getStatsConfig, setStatsConfig } from '../actions/stats'; | https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d | client/src/reducers/index.js |
keep keep keep keep replace keep keep keep keep keep | <mask> const fs = require('fs');
<mask> const request = require('request-promise');
<mask> const twoskyConfig = require('../../.twosky.json')[0];
<mask>
<mask> const { project_id: TWOSKY_PROJECT_ID, base_locale: LANGUAGE } = twoskyConfig;
<mask> const LOCALES_DIR = '../../client/src/__locales';
<mask> const BASE_FILE = 'en.json';
<mask> const TWOSKY_URI = process.env.TWOSKY_URI;
<mask>
<mask> /**
</s> Pull request: scripts: imp i18n upload script
Merge in DNS/adguard-home from imp-i18n-script to master
Squashed commit of the following:
commit 2ea88dcfaf24722f2b7568802a54cbe4f8ebc084
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 3 16:05:00 2021 +0300
scripts: imp i18n upload script </s> add const language = process.env.UPLOAD_LANGUAGE || DEFAULT_LANGUAGE; </s> remove language: LANGUAGE,
</s> add language: language, </s> add console.log(`uploading ${language}`);
</s> remove file: fs.createReadStream(path.resolve(LOCALES_DIR, `${LANGUAGE}.json`)),
</s> add file: fs.createReadStream(path.resolve(LOCALES_DIR, `${language}.json`)), | https://github.com/AdguardTeam/AdGuardHome/commit/0122710750ae3c8c5039886cd27ec14c9579c85b | scripts/translations/upload.js |
keep keep keep add keep keep keep keep | <mask> /**
<mask> * Prepare post params
<mask> */
<mask> const getRequestData = (url, projectId) => {
<mask> const formData = {
<mask> format: 'json',
<mask> language: language,
<mask> filename: BASE_FILE,
</s> Pull request: scripts: imp i18n upload script
Merge in DNS/adguard-home from imp-i18n-script to master
Squashed commit of the following:
commit 2ea88dcfaf24722f2b7568802a54cbe4f8ebc084
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 3 16:05:00 2021 +0300
scripts: imp i18n upload script </s> remove language: LANGUAGE,
</s> add language: language, </s> remove const { project_id: TWOSKY_PROJECT_ID, base_locale: LANGUAGE } = twoskyConfig;
</s> add const { project_id: TWOSKY_PROJECT_ID, base_locale: DEFAULT_LANGUAGE } = twoskyConfig; </s> remove file: fs.createReadStream(path.resolve(LOCALES_DIR, `${LANGUAGE}.json`)),
</s> add file: fs.createReadStream(path.resolve(LOCALES_DIR, `${language}.json`)), </s> add console.log(`uploading ${language}`);
| https://github.com/AdguardTeam/AdGuardHome/commit/0122710750ae3c8c5039886cd27ec14c9579c85b | scripts/translations/upload.js |
keep keep keep keep replace keep keep replace keep | <mask> */
<mask> const getRequestData = (url, projectId) => {
<mask> const formData = {
<mask> format: 'json',
<mask> language: LANGUAGE,
<mask> filename: BASE_FILE,
<mask> project: projectId,
<mask> file: fs.createReadStream(path.resolve(LOCALES_DIR, `${LANGUAGE}.json`)),
<mask> };
</s> Pull request: scripts: imp i18n upload script
Merge in DNS/adguard-home from imp-i18n-script to master
Squashed commit of the following:
commit 2ea88dcfaf24722f2b7568802a54cbe4f8ebc084
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 3 16:05:00 2021 +0300
scripts: imp i18n upload script </s> add const language = process.env.UPLOAD_LANGUAGE || DEFAULT_LANGUAGE; </s> remove const { project_id: TWOSKY_PROJECT_ID, base_locale: LANGUAGE } = twoskyConfig;
</s> add const { project_id: TWOSKY_PROJECT_ID, base_locale: DEFAULT_LANGUAGE } = twoskyConfig; </s> add console.log(`uploading ${language}`);
| https://github.com/AdguardTeam/AdGuardHome/commit/0122710750ae3c8c5039886cd27ec14c9579c85b | scripts/translations/upload.js |
keep keep add keep keep keep keep keep keep | <mask> file: fs.createReadStream(path.resolve(LOCALES_DIR, `${language}.json`)),
<mask> };
<mask>
<mask> return {
<mask> url: `${url}/upload`,
<mask> formData
<mask> };
<mask> };
<mask>
</s> Pull request: scripts: imp i18n upload script
Merge in DNS/adguard-home from imp-i18n-script to master
Squashed commit of the following:
commit 2ea88dcfaf24722f2b7568802a54cbe4f8ebc084
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 3 16:05:00 2021 +0300
scripts: imp i18n upload script </s> remove file: fs.createReadStream(path.resolve(LOCALES_DIR, `${LANGUAGE}.json`)),
</s> add file: fs.createReadStream(path.resolve(LOCALES_DIR, `${language}.json`)), </s> remove language: LANGUAGE,
</s> add language: language, </s> add const language = process.env.UPLOAD_LANGUAGE || DEFAULT_LANGUAGE; </s> remove const { project_id: TWOSKY_PROJECT_ID, base_locale: LANGUAGE } = twoskyConfig;
</s> add const { project_id: TWOSKY_PROJECT_ID, base_locale: DEFAULT_LANGUAGE } = twoskyConfig; | https://github.com/AdguardTeam/AdGuardHome/commit/0122710750ae3c8c5039886cd27ec14c9579c85b | scripts/translations/upload.js |
keep keep keep keep replace keep keep keep keep keep | <mask> package rewrite
<mask>
<mask> import (
<mask> "fmt"
<mask> "net"
<mask> "strings"
<mask>
<mask> "github.com/miekg/dns"
<mask> )
<mask>
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> remove "encoding/json"
</s> add </s> remove "net/http"
</s> add </s> add "net" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
</s> add </s> remove "github.com/AdguardTeam/golibs/log"
</s> add </s> add "github.com/AdguardTeam/urlfilter"
"github.com/AdguardTeam/urlfilter/rules"
"github.com/miekg/dns"
"github.com/stretchr/testify/assert" | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrite/item.go |
keep keep keep keep replace keep keep keep keep keep | <mask> } else if other == nil {
<mask> return false
<mask> }
<mask>
<mask> return rw.Domain == other.Domain && rw.Answer == other.Answer
<mask> }
<mask>
<mask> // toRule converts rw to a filter rule.
<mask> func (rw *Item) toRule() (res string) {
<mask> domain := strings.ToLower(rw.Domain)
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> add if rw == nil {
return ""
}
</s> remove ip := net.ParseIP(rw.Answer)
if ip == nil {
</s> add addr, err := netip.ParseAddr(rw.Answer)
if err != nil {
// TODO(d.kolyshev): Validate rw.Answer as a domain name. </s> remove ip4 := ip.To4()
if ip4 != nil {
</s> add if addr.Is4() { </s> remove
type rewriteEntryJSON struct {
Domain string `json:"domain"`
Answer string `json:"answer"`
}
func (d *DNSFilter) handleRewriteList(w http.ResponseWriter, r *http.Request) {
arr := []*rewriteEntryJSON{}
d.confLock.Lock()
for _, ent := range d.Config.Rewrites {
jsent := rewriteEntryJSON{
Domain: ent.Domain,
Answer: ent.Answer,
}
arr = append(arr, &jsent)
}
d.confLock.Unlock()
_ = aghhttp.WriteJSONResponse(w, r, arr)
}
func (d *DNSFilter) handleRewriteAdd(w http.ResponseWriter, r *http.Request) {
rwJSON := rewriteEntryJSON{}
err := json.NewDecoder(r.Body).Decode(&rwJSON)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
return
}
rw := &LegacyRewrite{
Domain: rwJSON.Domain,
Answer: rwJSON.Answer,
}
err = rw.normalize()
if err != nil {
// Shouldn't happen currently, since normalize only returns a non-nil
// error when a rewrite is nil, but be change-proof.
aghhttp.Error(r, w, http.StatusBadRequest, "normalizing: %s", err)
return
}
d.confLock.Lock()
d.Config.Rewrites = append(d.Config.Rewrites, rw)
d.confLock.Unlock()
log.Debug("rewrite: added element: %s -> %s [%d]", rw.Domain, rw.Answer, len(d.Config.Rewrites))
d.Config.ConfigModified()
}
func (d *DNSFilter) handleRewriteDelete(w http.ResponseWriter, r *http.Request) {
jsent := rewriteEntryJSON{}
err := json.NewDecoder(r.Body).Decode(&jsent)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
return
}
entDel := &LegacyRewrite{
Domain: jsent.Domain,
Answer: jsent.Answer,
}
arr := []*LegacyRewrite{}
d.confLock.Lock()
for _, ent := range d.Config.Rewrites {
if ent.equal(entDel) {
log.Debug("rewrite: removed element: %s -> %s", ent.Domain, ent.Answer)
continue
}
arr = append(arr, ent)
}
d.Config.Rewrites = arr
d.confLock.Unlock()
d.Config.ConfigModified()
}
</s> add </s> remove func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool) {
</s> add func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) { </s> remove log.Info("filter %d: reset %d rules", s.urlFilterID, s.engine.RulesCount)
</s> add log.Info("rewrite: filter %d: reset %d rules", s.urlFilterID, s.engine.RulesCount) | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrite/item.go |
keep add keep keep keep keep keep keep | <mask> // toRule converts rw to a filter rule.
<mask> func (rw *Item) toRule() (res string) {
<mask> domain := strings.ToLower(rw.Domain)
<mask>
<mask> dType, exception := rw.rewriteParams()
<mask> dTypeKey := dns.TypeToString[dType]
<mask> if exception {
<mask> return fmt.Sprintf("@@||%s^$dnstype=%s,dnsrewrite", domain, dTypeKey)
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> remove return rw.Domain == other.Domain && rw.Answer == other.Answer
</s> add return *rw == *other </s> remove ip := net.ParseIP(rw.Answer)
if ip == nil {
</s> add addr, err := netip.ParseAddr(rw.Answer)
if err != nil {
// TODO(d.kolyshev): Validate rw.Answer as a domain name. </s> remove
type rewriteEntryJSON struct {
Domain string `json:"domain"`
Answer string `json:"answer"`
}
func (d *DNSFilter) handleRewriteList(w http.ResponseWriter, r *http.Request) {
arr := []*rewriteEntryJSON{}
d.confLock.Lock()
for _, ent := range d.Config.Rewrites {
jsent := rewriteEntryJSON{
Domain: ent.Domain,
Answer: ent.Answer,
}
arr = append(arr, &jsent)
}
d.confLock.Unlock()
_ = aghhttp.WriteJSONResponse(w, r, arr)
}
func (d *DNSFilter) handleRewriteAdd(w http.ResponseWriter, r *http.Request) {
rwJSON := rewriteEntryJSON{}
err := json.NewDecoder(r.Body).Decode(&rwJSON)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
return
}
rw := &LegacyRewrite{
Domain: rwJSON.Domain,
Answer: rwJSON.Answer,
}
err = rw.normalize()
if err != nil {
// Shouldn't happen currently, since normalize only returns a non-nil
// error when a rewrite is nil, but be change-proof.
aghhttp.Error(r, w, http.StatusBadRequest, "normalizing: %s", err)
return
}
d.confLock.Lock()
d.Config.Rewrites = append(d.Config.Rewrites, rw)
d.confLock.Unlock()
log.Debug("rewrite: added element: %s -> %s [%d]", rw.Domain, rw.Answer, len(d.Config.Rewrites))
d.Config.ConfigModified()
}
func (d *DNSFilter) handleRewriteDelete(w http.ResponseWriter, r *http.Request) {
jsent := rewriteEntryJSON{}
err := json.NewDecoder(r.Body).Decode(&jsent)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
return
}
entDel := &LegacyRewrite{
Domain: jsent.Domain,
Answer: jsent.Answer,
}
arr := []*LegacyRewrite{}
d.confLock.Lock()
for _, ent := range d.Config.Rewrites {
if ent.equal(entDel) {
log.Debug("rewrite: removed element: %s -> %s", ent.Domain, ent.Answer)
continue
}
arr = append(arr, ent)
}
d.Config.Rewrites = arr
d.confLock.Unlock()
d.Config.ConfigModified()
}
</s> add </s> remove ip4 := ip.To4()
if ip4 != nil {
</s> add if addr.Is4() { </s> remove func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool) {
</s> add func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) { </s> remove // MatchRequest finds a matching rule for the specified request.
MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool)
</s> add // MatchRequest returns matching dnsrewrites for the specified request.
MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrite/item.go |
keep keep keep keep replace replace keep keep keep replace replace keep keep keep keep | <mask> default:
<mask> // Go on.
<mask> }
<mask>
<mask> ip := net.ParseIP(rw.Answer)
<mask> if ip == nil {
<mask> return dns.TypeCNAME, false
<mask> }
<mask>
<mask> ip4 := ip.To4()
<mask> if ip4 != nil {
<mask> dType = dns.TypeA
<mask> } else {
<mask> dType = dns.TypeAAAA
<mask> }
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> remove return rw.Domain == other.Domain && rw.Answer == other.Answer
</s> add return *rw == *other </s> remove
type rewriteEntryJSON struct {
Domain string `json:"domain"`
Answer string `json:"answer"`
}
func (d *DNSFilter) handleRewriteList(w http.ResponseWriter, r *http.Request) {
arr := []*rewriteEntryJSON{}
d.confLock.Lock()
for _, ent := range d.Config.Rewrites {
jsent := rewriteEntryJSON{
Domain: ent.Domain,
Answer: ent.Answer,
}
arr = append(arr, &jsent)
}
d.confLock.Unlock()
_ = aghhttp.WriteJSONResponse(w, r, arr)
}
func (d *DNSFilter) handleRewriteAdd(w http.ResponseWriter, r *http.Request) {
rwJSON := rewriteEntryJSON{}
err := json.NewDecoder(r.Body).Decode(&rwJSON)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
return
}
rw := &LegacyRewrite{
Domain: rwJSON.Domain,
Answer: rwJSON.Answer,
}
err = rw.normalize()
if err != nil {
// Shouldn't happen currently, since normalize only returns a non-nil
// error when a rewrite is nil, but be change-proof.
aghhttp.Error(r, w, http.StatusBadRequest, "normalizing: %s", err)
return
}
d.confLock.Lock()
d.Config.Rewrites = append(d.Config.Rewrites, rw)
d.confLock.Unlock()
log.Debug("rewrite: added element: %s -> %s [%d]", rw.Domain, rw.Answer, len(d.Config.Rewrites))
d.Config.ConfigModified()
}
func (d *DNSFilter) handleRewriteDelete(w http.ResponseWriter, r *http.Request) {
jsent := rewriteEntryJSON{}
err := json.NewDecoder(r.Body).Decode(&jsent)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
return
}
entDel := &LegacyRewrite{
Domain: jsent.Domain,
Answer: jsent.Answer,
}
arr := []*LegacyRewrite{}
d.confLock.Lock()
for _, ent := range d.Config.Rewrites {
if ent.equal(entDel) {
log.Debug("rewrite: removed element: %s -> %s", ent.Domain, ent.Answer)
continue
}
arr = append(arr, ent)
}
d.Config.Rewrites = arr
d.confLock.Unlock()
d.Config.ConfigModified()
}
</s> add </s> add if rw == nil {
return ""
}
</s> add // TODO(a.garipov): Use strings.Builder. </s> remove log.Info("filter %d: reset %d rules", s.urlFilterID, s.engine.RulesCount)
</s> add log.Info("rewrite: filter %d: reset %d rules", s.urlFilterID, s.engine.RulesCount) | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrite/item.go |
keep keep add keep keep keep keep keep keep | <mask> "sync"
<mask>
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/AdguardTeam/urlfilter"
<mask> "github.com/AdguardTeam/urlfilter/filterlist"
<mask> "github.com/AdguardTeam/urlfilter/rules"
<mask> "github.com/miekg/dns"
<mask> "golang.org/x/exp/slices"
<mask> )
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> add "github.com/AdguardTeam/urlfilter/rules"
"github.com/miekg/dns" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
</s> add </s> remove "github.com/AdguardTeam/golibs/log"
</s> add </s> add "net" </s> add "github.com/AdguardTeam/urlfilter"
"github.com/AdguardTeam/urlfilter/rules"
"github.com/miekg/dns"
"github.com/stretchr/testify/assert" </s> remove // TODO(d.kolyshev): Rename this file to rewritehttp.go.
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrite/storage.go |
keep keep add keep keep keep keep keep | <mask> "github.com/AdguardTeam/golibs/stringutil"
<mask> "github.com/AdguardTeam/urlfilter"
<mask> "github.com/AdguardTeam/urlfilter/filterlist"
<mask> "golang.org/x/exp/slices"
<mask> )
<mask>
<mask> // Storage is a storage for rewrite rules.
<mask> type Storage interface {
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> remove // MatchRequest finds a matching rule for the specified request.
MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool)
</s> add // MatchRequest returns matching dnsrewrites for the specified request.
MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) </s> add "github.com/AdguardTeam/golibs/stringutil" </s> remove func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool) {
</s> add func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) { </s> remove // TODO(d.kolyshev): Rename this file to rewritehttp.go.
</s> add </s> add // TODO(a.garipov): Use strings.Builder. </s> add // rewrites stores the rewrite entries from configuration.
rewrites []*Item
| https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrite/storage.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> )
<mask>
<mask> // Storage is a storage for rewrite rules.
<mask> type Storage interface {
<mask> // MatchRequest finds a matching rule for the specified request.
<mask> MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool)
<mask>
<mask> // Add adds item to the storage.
<mask> Add(item *Item) (err error)
<mask>
<mask> // Remove deletes item from the storage.
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> remove func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool) {
</s> add func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) { </s> add "github.com/AdguardTeam/urlfilter/rules"
"github.com/miekg/dns" </s> remove
// rewrites stores the rewrite entries from configuration.
rewrites []*Item
</s> add </s> add // TODO(a.garipov): Use strings.Builder. </s> add // rewrites stores the rewrite entries from configuration.
rewrites []*Item
</s> remove // TODO(d.kolyshev): Rename this file to rewritehttp.go.
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrite/storage.go |
keep add keep keep keep keep keep keep | <mask> ruleList filterlist.RuleList
<mask>
<mask> // urlFilterID is the synthetic integer identifier for the urlfilter engine.
<mask> //
<mask> // TODO(a.garipov): Change the type to a string in module urlfilter and
<mask> // remove this crutch.
<mask> urlFilterID int
<mask> }
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> remove
// rewrites stores the rewrite entries from configuration.
rewrites []*Item
</s> add </s> remove // TODO(d.kolyshev): Rename this file to rewritehttp.go.
</s> add </s> remove // TODO(d.kolyshev): Move these tests to rewrite package.
</s> add </s> remove // MatchRequest finds a matching rule for the specified request.
MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool)
</s> add // MatchRequest returns matching dnsrewrites for the specified request.
MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) </s> add // TODO(a.garipov): Use strings.Builder. </s> remove func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool) {
</s> add func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) { | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrite/storage.go |
keep keep keep keep replace replace replace keep keep keep keep keep | <mask> //
<mask> // TODO(a.garipov): Change the type to a string in module urlfilter and
<mask> // remove this crutch.
<mask> urlFilterID int
<mask>
<mask> // rewrites stores the rewrite entries from configuration.
<mask> rewrites []*Item
<mask> }
<mask>
<mask> // NewDefaultStorage returns new rewrites storage. listID is used as an
<mask> // identifier of the underlying rules list. rewrites must not be nil.
<mask> func NewDefaultStorage(listID int, rewrites []*Item) (s *DefaultStorage, err error) {
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> add // rewrites stores the rewrite entries from configuration.
rewrites []*Item
</s> remove // TODO(d.kolyshev): Rename this file to rewritehttp.go.
</s> add </s> remove // MatchRequest finds a matching rule for the specified request.
MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool)
</s> add // MatchRequest returns matching dnsrewrites for the specified request.
MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) </s> add // TODO(a.garipov): Use strings.Builder. </s> remove // TODO(d.kolyshev): Move these tests to rewrite package.
</s> add </s> remove func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool) {
</s> add func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) { | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrite/storage.go |
keep keep keep keep replace keep keep keep keep keep | <mask> // type check
<mask> var _ Storage = (*DefaultStorage)(nil)
<mask>
<mask> // MatchRequest implements the [Storage] interface for *DefaultStorage.
<mask> func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool) {
<mask> s.mu.RLock()
<mask> defer s.mu.RUnlock()
<mask>
<mask> return s.engine.MatchRequest(dReq)
<mask> }
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> remove // MatchRequest finds a matching rule for the specified request.
MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool)
</s> add // MatchRequest returns matching dnsrewrites for the specified request.
MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) </s> add // TODO(a.garipov): Use strings.Builder. </s> add "github.com/AdguardTeam/urlfilter/rules"
"github.com/miekg/dns" </s> remove
// rewrites stores the rewrite entries from configuration.
rewrites []*Item
</s> add </s> remove
type rewriteEntryJSON struct {
Domain string `json:"domain"`
Answer string `json:"answer"`
}
func (d *DNSFilter) handleRewriteList(w http.ResponseWriter, r *http.Request) {
arr := []*rewriteEntryJSON{}
d.confLock.Lock()
for _, ent := range d.Config.Rewrites {
jsent := rewriteEntryJSON{
Domain: ent.Domain,
Answer: ent.Answer,
}
arr = append(arr, &jsent)
}
d.confLock.Unlock()
_ = aghhttp.WriteJSONResponse(w, r, arr)
}
func (d *DNSFilter) handleRewriteAdd(w http.ResponseWriter, r *http.Request) {
rwJSON := rewriteEntryJSON{}
err := json.NewDecoder(r.Body).Decode(&rwJSON)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
return
}
rw := &LegacyRewrite{
Domain: rwJSON.Domain,
Answer: rwJSON.Answer,
}
err = rw.normalize()
if err != nil {
// Shouldn't happen currently, since normalize only returns a non-nil
// error when a rewrite is nil, but be change-proof.
aghhttp.Error(r, w, http.StatusBadRequest, "normalizing: %s", err)
return
}
d.confLock.Lock()
d.Config.Rewrites = append(d.Config.Rewrites, rw)
d.confLock.Unlock()
log.Debug("rewrite: added element: %s -> %s [%d]", rw.Domain, rw.Answer, len(d.Config.Rewrites))
d.Config.ConfigModified()
}
func (d *DNSFilter) handleRewriteDelete(w http.ResponseWriter, r *http.Request) {
jsent := rewriteEntryJSON{}
err := json.NewDecoder(r.Body).Decode(&jsent)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
return
}
entDel := &LegacyRewrite{
Domain: jsent.Domain,
Answer: jsent.Answer,
}
arr := []*LegacyRewrite{}
d.confLock.Lock()
for _, ent := range d.Config.Rewrites {
if ent.equal(entDel) {
log.Debug("rewrite: removed element: %s -> %s", ent.Domain, ent.Answer)
continue
}
arr = append(arr, ent)
}
d.Config.Rewrites = arr
d.confLock.Unlock()
d.Config.ConfigModified()
}
</s> add </s> remove // TODO(d.kolyshev): Move these tests to rewrite package.
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrite/storage.go |
keep keep add keep keep keep keep | <mask>
<mask> // resetRules resets the filtering rules.
<mask> func (s *DefaultStorage) resetRules() (err error) {
<mask> var rulesText []string
<mask> for _, rewrite := range s.rewrites {
<mask> rulesText = append(rulesText, rewrite.toRule())
<mask> }
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> remove func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool) {
</s> add func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) { </s> remove // MatchRequest finds a matching rule for the specified request.
MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool)
</s> add // MatchRequest returns matching dnsrewrites for the specified request.
MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) </s> remove
type rewriteEntryJSON struct {
Domain string `json:"domain"`
Answer string `json:"answer"`
}
func (d *DNSFilter) handleRewriteList(w http.ResponseWriter, r *http.Request) {
arr := []*rewriteEntryJSON{}
d.confLock.Lock()
for _, ent := range d.Config.Rewrites {
jsent := rewriteEntryJSON{
Domain: ent.Domain,
Answer: ent.Answer,
}
arr = append(arr, &jsent)
}
d.confLock.Unlock()
_ = aghhttp.WriteJSONResponse(w, r, arr)
}
func (d *DNSFilter) handleRewriteAdd(w http.ResponseWriter, r *http.Request) {
rwJSON := rewriteEntryJSON{}
err := json.NewDecoder(r.Body).Decode(&rwJSON)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
return
}
rw := &LegacyRewrite{
Domain: rwJSON.Domain,
Answer: rwJSON.Answer,
}
err = rw.normalize()
if err != nil {
// Shouldn't happen currently, since normalize only returns a non-nil
// error when a rewrite is nil, but be change-proof.
aghhttp.Error(r, w, http.StatusBadRequest, "normalizing: %s", err)
return
}
d.confLock.Lock()
d.Config.Rewrites = append(d.Config.Rewrites, rw)
d.confLock.Unlock()
log.Debug("rewrite: added element: %s -> %s [%d]", rw.Domain, rw.Answer, len(d.Config.Rewrites))
d.Config.ConfigModified()
}
func (d *DNSFilter) handleRewriteDelete(w http.ResponseWriter, r *http.Request) {
jsent := rewriteEntryJSON{}
err := json.NewDecoder(r.Body).Decode(&jsent)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
return
}
entDel := &LegacyRewrite{
Domain: jsent.Domain,
Answer: jsent.Answer,
}
arr := []*LegacyRewrite{}
d.confLock.Lock()
for _, ent := range d.Config.Rewrites {
if ent.equal(entDel) {
log.Debug("rewrite: removed element: %s -> %s", ent.Domain, ent.Answer)
continue
}
arr = append(arr, ent)
}
d.Config.Rewrites = arr
d.confLock.Unlock()
d.Config.ConfigModified()
}
</s> add </s> remove
// rewrites stores the rewrite entries from configuration.
rewrites []*Item
</s> add </s> add "github.com/AdguardTeam/urlfilter/rules"
"github.com/miekg/dns" </s> remove ip4 := ip.To4()
if ip4 != nil {
</s> add if addr.Is4() { | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrite/storage.go |
keep keep keep keep replace keep keep keep | <mask>
<mask> s.ruleList = strList
<mask> s.engine = urlfilter.NewDNSEngine(rs)
<mask>
<mask> log.Info("filter %d: reset %d rules", s.urlFilterID, s.engine.RulesCount)
<mask>
<mask> return nil
<mask> }
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> remove ip4 := ip.To4()
if ip4 != nil {
</s> add if addr.Is4() { </s> remove
type rewriteEntryJSON struct {
Domain string `json:"domain"`
Answer string `json:"answer"`
}
func (d *DNSFilter) handleRewriteList(w http.ResponseWriter, r *http.Request) {
arr := []*rewriteEntryJSON{}
d.confLock.Lock()
for _, ent := range d.Config.Rewrites {
jsent := rewriteEntryJSON{
Domain: ent.Domain,
Answer: ent.Answer,
}
arr = append(arr, &jsent)
}
d.confLock.Unlock()
_ = aghhttp.WriteJSONResponse(w, r, arr)
}
func (d *DNSFilter) handleRewriteAdd(w http.ResponseWriter, r *http.Request) {
rwJSON := rewriteEntryJSON{}
err := json.NewDecoder(r.Body).Decode(&rwJSON)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
return
}
rw := &LegacyRewrite{
Domain: rwJSON.Domain,
Answer: rwJSON.Answer,
}
err = rw.normalize()
if err != nil {
// Shouldn't happen currently, since normalize only returns a non-nil
// error when a rewrite is nil, but be change-proof.
aghhttp.Error(r, w, http.StatusBadRequest, "normalizing: %s", err)
return
}
d.confLock.Lock()
d.Config.Rewrites = append(d.Config.Rewrites, rw)
d.confLock.Unlock()
log.Debug("rewrite: added element: %s -> %s [%d]", rw.Domain, rw.Answer, len(d.Config.Rewrites))
d.Config.ConfigModified()
}
func (d *DNSFilter) handleRewriteDelete(w http.ResponseWriter, r *http.Request) {
jsent := rewriteEntryJSON{}
err := json.NewDecoder(r.Body).Decode(&jsent)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
return
}
entDel := &LegacyRewrite{
Domain: jsent.Domain,
Answer: jsent.Answer,
}
arr := []*LegacyRewrite{}
d.confLock.Lock()
for _, ent := range d.Config.Rewrites {
if ent.equal(entDel) {
log.Debug("rewrite: removed element: %s -> %s", ent.Domain, ent.Answer)
continue
}
arr = append(arr, ent)
}
d.Config.Rewrites = arr
d.confLock.Unlock()
d.Config.ConfigModified()
}
</s> add </s> remove func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool) {
</s> add func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) { </s> add // TODO(a.garipov): Use strings.Builder. </s> remove ip := net.ParseIP(rw.Answer)
if ip == nil {
</s> add addr, err := netip.ParseAddr(rw.Answer)
if err != nil {
// TODO(d.kolyshev): Validate rw.Answer as a domain name. </s> remove return rw.Domain == other.Domain && rw.Answer == other.Answer
</s> add return *rw == *other | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrite/storage.go |
keep keep add keep keep keep keep keep keep | <mask> package rewrite
<mask>
<mask> import (
<mask> "testing"
<mask>
<mask> "github.com/AdguardTeam/urlfilter"
<mask> "github.com/AdguardTeam/urlfilter/rules"
<mask> "github.com/miekg/dns"
<mask> "github.com/stretchr/testify/assert"
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> add "github.com/AdguardTeam/urlfilter"
"github.com/AdguardTeam/urlfilter/rules"
"github.com/miekg/dns"
"github.com/stretchr/testify/assert" </s> remove "net"
</s> add "net/netip" </s> remove "encoding/json"
</s> add </s> add "github.com/AdguardTeam/golibs/stringutil" </s> add "github.com/AdguardTeam/urlfilter/rules"
"github.com/miekg/dns" </s> remove "net/http"
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrite/storage_test.go |
keep keep add keep keep keep keep keep keep | <mask> "net"
<mask> "testing"
<mask>
<mask> "github.com/stretchr/testify/require"
<mask> )
<mask>
<mask> func TestNewDefaultStorage(t *testing.T) {
<mask> items := []*Item{{
<mask> Domain: "example.com",
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> remove // TODO(d.kolyshev): Move these tests to rewrite package.
</s> add </s> add "net" </s> remove
type rewriteEntryJSON struct {
Domain string `json:"domain"`
Answer string `json:"answer"`
}
func (d *DNSFilter) handleRewriteList(w http.ResponseWriter, r *http.Request) {
arr := []*rewriteEntryJSON{}
d.confLock.Lock()
for _, ent := range d.Config.Rewrites {
jsent := rewriteEntryJSON{
Domain: ent.Domain,
Answer: ent.Answer,
}
arr = append(arr, &jsent)
}
d.confLock.Unlock()
_ = aghhttp.WriteJSONResponse(w, r, arr)
}
func (d *DNSFilter) handleRewriteAdd(w http.ResponseWriter, r *http.Request) {
rwJSON := rewriteEntryJSON{}
err := json.NewDecoder(r.Body).Decode(&rwJSON)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
return
}
rw := &LegacyRewrite{
Domain: rwJSON.Domain,
Answer: rwJSON.Answer,
}
err = rw.normalize()
if err != nil {
// Shouldn't happen currently, since normalize only returns a non-nil
// error when a rewrite is nil, but be change-proof.
aghhttp.Error(r, w, http.StatusBadRequest, "normalizing: %s", err)
return
}
d.confLock.Lock()
d.Config.Rewrites = append(d.Config.Rewrites, rw)
d.confLock.Unlock()
log.Debug("rewrite: added element: %s -> %s [%d]", rw.Domain, rw.Answer, len(d.Config.Rewrites))
d.Config.ConfigModified()
}
func (d *DNSFilter) handleRewriteDelete(w http.ResponseWriter, r *http.Request) {
jsent := rewriteEntryJSON{}
err := json.NewDecoder(r.Body).Decode(&jsent)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
return
}
entDel := &LegacyRewrite{
Domain: jsent.Domain,
Answer: jsent.Answer,
}
arr := []*LegacyRewrite{}
d.confLock.Lock()
for _, ent := range d.Config.Rewrites {
if ent.equal(entDel) {
log.Debug("rewrite: removed element: %s -> %s", ent.Domain, ent.Answer)
continue
}
arr = append(arr, ent)
}
d.Config.Rewrites = arr
d.confLock.Unlock()
d.Config.ConfigModified()
}
</s> add </s> add if rw == nil {
return ""
}
</s> remove "net"
</s> add "net/netip" </s> add // TODO(a.garipov): Use strings.Builder. | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrite/storage_test.go |
keep keep keep keep replace keep keep replace | <mask>
<mask> package filtering
<mask>
<mask> import (
<mask> "encoding/json"
<mask> "fmt"
<mask> "net"
<mask> "net/http"
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> remove "net"
</s> add "net/netip" </s> add "net" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
</s> add </s> add // TODO(a.garipov): Use strings.Builder. </s> add "github.com/AdguardTeam/urlfilter"
"github.com/AdguardTeam/urlfilter/rules"
"github.com/miekg/dns"
"github.com/stretchr/testify/assert" | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrites.go |
keep replace keep replace keep keep | <mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/miekg/dns"
<mask> "golang.org/x/exp/slices"
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> add "github.com/AdguardTeam/golibs/stringutil" </s> remove "net/http"
</s> add </s> add "github.com/AdguardTeam/urlfilter/rules"
"github.com/miekg/dns" </s> remove // TODO(d.kolyshev): Rename this file to rewritehttp.go.
</s> add </s> remove "net"
</s> add "net/netip" | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrites.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> "github.com/miekg/dns"
<mask> "golang.org/x/exp/slices"
<mask> )
<mask>
<mask> // TODO(d.kolyshev): Rename this file to rewritehttp.go.
<mask>
<mask> // LegacyRewrite is a single legacy DNS rewrite record.
<mask> //
<mask> // Instances of *LegacyRewrite must never be nil.
<mask> type LegacyRewrite struct {
<mask> // Domain is the domain pattern for which this rewrite should work.
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> remove "github.com/AdguardTeam/golibs/log"
</s> add </s> remove
// rewrites stores the rewrite entries from configuration.
rewrites []*Item
</s> add </s> remove // TODO(d.kolyshev): Move these tests to rewrite package.
</s> add </s> add // rewrites stores the rewrite entries from configuration.
rewrites []*Item
</s> add "github.com/AdguardTeam/urlfilter/rules"
"github.com/miekg/dns" </s> remove // MatchRequest finds a matching rule for the specified request.
MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool)
</s> add // MatchRequest returns matching dnsrewrites for the specified request.
MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrites.go |
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace | <mask> }
<mask>
<mask> return b
<mask> }
<mask>
<mask> type rewriteEntryJSON struct {
<mask> Domain string `json:"domain"`
<mask> Answer string `json:"answer"`
<mask> }
<mask>
<mask> func (d *DNSFilter) handleRewriteList(w http.ResponseWriter, r *http.Request) {
<mask> arr := []*rewriteEntryJSON{}
<mask>
<mask> d.confLock.Lock()
<mask> for _, ent := range d.Config.Rewrites {
<mask> jsent := rewriteEntryJSON{
<mask> Domain: ent.Domain,
<mask> Answer: ent.Answer,
<mask> }
<mask> arr = append(arr, &jsent)
<mask> }
<mask> d.confLock.Unlock()
<mask>
<mask> _ = aghhttp.WriteJSONResponse(w, r, arr)
<mask> }
<mask>
<mask> func (d *DNSFilter) handleRewriteAdd(w http.ResponseWriter, r *http.Request) {
<mask> rwJSON := rewriteEntryJSON{}
<mask> err := json.NewDecoder(r.Body).Decode(&rwJSON)
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
<mask>
<mask> return
<mask> }
<mask>
<mask> rw := &LegacyRewrite{
<mask> Domain: rwJSON.Domain,
<mask> Answer: rwJSON.Answer,
<mask> }
<mask>
<mask> err = rw.normalize()
<mask> if err != nil {
<mask> // Shouldn't happen currently, since normalize only returns a non-nil
<mask> // error when a rewrite is nil, but be change-proof.
<mask> aghhttp.Error(r, w, http.StatusBadRequest, "normalizing: %s", err)
<mask>
<mask> return
<mask> }
<mask>
<mask> d.confLock.Lock()
<mask> d.Config.Rewrites = append(d.Config.Rewrites, rw)
<mask> d.confLock.Unlock()
<mask> log.Debug("rewrite: added element: %s -> %s [%d]", rw.Domain, rw.Answer, len(d.Config.Rewrites))
<mask>
<mask> d.Config.ConfigModified()
<mask> }
<mask>
<mask> func (d *DNSFilter) handleRewriteDelete(w http.ResponseWriter, r *http.Request) {
<mask> jsent := rewriteEntryJSON{}
<mask> err := json.NewDecoder(r.Body).Decode(&jsent)
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
<mask>
<mask> return
<mask> }
<mask>
<mask> entDel := &LegacyRewrite{
<mask> Domain: jsent.Domain,
<mask> Answer: jsent.Answer,
<mask> }
<mask> arr := []*LegacyRewrite{}
<mask>
<mask> d.confLock.Lock()
<mask> for _, ent := range d.Config.Rewrites {
<mask> if ent.equal(entDel) {
<mask> log.Debug("rewrite: removed element: %s -> %s", ent.Domain, ent.Answer)
<mask>
<mask> continue
<mask> }
<mask>
<mask> arr = append(arr, ent)
<mask> }
<mask> d.Config.Rewrites = arr
<mask> d.confLock.Unlock()
<mask>
<mask> d.Config.ConfigModified()
<mask> }
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> remove ip := net.ParseIP(rw.Answer)
if ip == nil {
</s> add addr, err := netip.ParseAddr(rw.Answer)
if err != nil {
// TODO(d.kolyshev): Validate rw.Answer as a domain name. </s> remove ip4 := ip.To4()
if ip4 != nil {
</s> add if addr.Is4() { </s> add if rw == nil {
return ""
}
</s> add // TODO(a.garipov): Use strings.Builder. </s> remove return rw.Domain == other.Domain && rw.Answer == other.Answer
</s> add return *rw == *other </s> remove func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool) {
</s> add func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) { | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrites.go |
keep keep keep keep replace keep keep keep keep keep | <mask> "github.com/stretchr/testify/require"
<mask> )
<mask>
<mask> // TODO(e.burkov): All the tests in this file may and should me merged together.
<mask> // TODO(d.kolyshev): Move these tests to rewrite package.
<mask>
<mask> func TestRewrites(t *testing.T) {
<mask> d, _ := newForTest(t, nil, nil)
<mask> t.Cleanup(d.Close)
<mask>
</s> Pull request: 2499 rewrite: storage vol.2
Merge in DNS/adguard-home from 2499-rewrites-1 to master
Squashed commit of the following:
commit 6303107d6ca7dd88175e4e123128189e5958f060
Merge: e2040b95 09f88cf2
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-tracking branch 'origin/master' into 2499-rewrites-1
commit e2040b95dd3157d033d929bb45fc7662b9918a78
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Dec 5 12:00:21 2022 +0200
rewrite: item
commit c7278e8adeec1ba3a090cc93db30c80699617c52
Author: Dimitry Kolyshev <[email protected]>
Date: Sun Dec 4 12:57:59 2022 +0200
rewrite: imp code
commit d23a740262a4fbdd9b25f7449ced707c0d2be634
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:08:25 2022 +0200
rewrite: imp code
commit 773a5211b6662afd03a34219e7114c6f1e2bb579
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:05:20 2022 +0200
rewrite: imp code
commit 48b54e19da9844d9b868d0be7e428ad6bacae6a5
Author: Dimitry Kolyshev <[email protected]>
Date: Fri Dec 2 13:02:47 2022 +0200
rewrite: tests item
commit 62af2bd91f5559840e7948ac4bf7c36b1bee1dc2
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:11:21 2022 +0200
rewrite: tests
commit f040b609391cb2275b11d4732bbac0380c01de07
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:04:59 2022 +0200
rewrite: imp code
commit 4592b8c4e6107e5a746261d3335282827ce36b74
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 17:02:31 2022 +0200
rewrite: imp code
commit cc1660695341c558dbac6acaa31ac160a45f6105
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 16:19:27 2022 +0200
rewrite: imp code
commit cf3840b76d45bf319630256c01586159dd1e85fe
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 13:16:40 2022 +0200
rewrite: tests
commit 6fd6f03ca4320d4345032139b43cb457b3ae4278
Author: Dimitry Kolyshev <[email protected]>
Date: Thu Dec 1 11:14:44 2022 +0200
rewrite: imp code
commit 2ebd2a1e79afc8f486cf6533968c51ca61bc03ab
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 11:43:24 2022 +0200
rewrite: tests
commit 7da987994303a3e7b16eb6b0baaa4b59a52b97be
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Nov 30 10:54:57 2022 +0200
filtering: imp code
commit ab98efc6710fac7cba28dab5bca9b60e9ec34ef7
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Nov 28 13:31:12 2022 +0200
filtering: rewritehttp </s> remove // TODO(d.kolyshev): Rename this file to rewritehttp.go.
</s> add </s> remove "github.com/AdguardTeam/golibs/log"
</s> add </s> add // rewrites stores the rewrite entries from configuration.
rewrites []*Item
</s> add "github.com/AdguardTeam/urlfilter"
"github.com/AdguardTeam/urlfilter/rules"
"github.com/miekg/dns"
"github.com/stretchr/testify/assert" </s> remove
// rewrites stores the rewrite entries from configuration.
rewrites []*Item
</s> add </s> remove func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool) {
</s> add func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) { | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrites_test.go |
keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace | <mask>
<mask> // command-line arguments
<mask> type options struct {
<mask> verbose bool // is verbose logging enabled
<mask> configFilename string // path to the config file
<mask> workDir string // path to the working directory where we will store the filters data and the querylog
<mask> bindHost string // host address to bind HTTP server on
<mask> bindPort int // port to serve HTTP pages on
<mask> logFile string // Path to the log file. If empty, write to stdout. If "syslog", writes to syslog
<mask> pidFile string // File name to save PID to
<mask> checkConfig bool // Check configuration and exit
<mask> disableUpdate bool // If set, don't check for updates
<mask>
<mask> // service control action (see service.ControlAction array + "status" command)
<mask> serviceControlAction string
<mask>
<mask> // runningAsService flag is set to true when options are passed from the service runner
<mask> runningAsService bool
<mask>
<mask> glinetMode bool // Activate GL-Inet mode
<mask> }
<mask>
<mask> // loadOptions reads command line arguments and initializes configuration
<mask> func loadOptions() options {
<mask> o := options{}
<mask>
<mask> var printHelp func()
<mask> var opts = []struct {
<mask> longName string
<mask> shortName string
<mask> description string
<mask> callbackWithValue func(value string)
<mask> callbackNoValue func()
<mask> }{
<mask> {"config", "c", "Path to the config file", func(value string) { o.configFilename = value }, nil},
<mask> {"work-dir", "w", "Path to the working directory", func(value string) { o.workDir = value }, nil},
<mask> {"host", "h", "Host address to bind HTTP server on", func(value string) { o.bindHost = value }, nil},
<mask> {"port", "p", "Port to serve HTTP pages on", func(value string) {
<mask> v, err := strconv.Atoi(value)
<mask> if err != nil {
<mask> panic("Got port that is not a number")
<mask> }
<mask> o.bindPort = v
<mask> }, nil},
<mask> {"service", "s", "Service control action: status, install, uninstall, start, stop, restart, reload (configuration)", func(value string) {
<mask> o.serviceControlAction = value
<mask> }, nil},
<mask> {"logfile", "l", "Path to log file. If empty: write to stdout; if 'syslog': write to system log", func(value string) {
<mask> o.logFile = value
<mask> }, nil},
<mask> {"pidfile", "", "Path to a file where PID is stored", func(value string) { o.pidFile = value }, nil},
<mask> {"check-config", "", "Check configuration and exit", nil, func() { o.checkConfig = true }},
<mask> {"no-check-update", "", "Don't check for updates", nil, func() { o.disableUpdate = true }},
<mask> {"verbose", "v", "Enable verbose output", nil, func() { o.verbose = true }},
<mask> {"glinet", "", "Run in GL-Inet compatibility mode", nil, func() { o.glinetMode = true }},
<mask> {"version", "", "Show the version and exit", nil, func() {
<mask> fmt.Println(version())
</s> cli: factor options struct and parsing into home/options.go </s> remove }},
{"help", "", "Print this help", nil, func() {
printHelp()
os.Exit(64)
}},
}
printHelp = func() {
fmt.Printf("Usage:\n\n")
fmt.Printf("%s [options]\n\n", os.Args[0])
fmt.Printf("Options:\n")
for _, opt := range opts {
val := ""
if opt.callbackWithValue != nil {
val = " VALUE"
}
if opt.shortName != "" {
fmt.Printf(" -%s, %-30s %s\n", opt.shortName, "--"+opt.longName+val, opt.description)
} else {
fmt.Printf(" %-34s %s\n", "--"+opt.longName+val, opt.description)
}
}
}
for i := 1; i < len(os.Args); i++ {
v := os.Args[i]
knownParam := false
for _, opt := range opts {
if v == "--"+opt.longName || (opt.shortName != "" && v == "-"+opt.shortName) {
if opt.callbackWithValue != nil {
if i+1 >= len(os.Args) {
log.Error("Got %s without argument\n", v)
os.Exit(64)
}
i++
opt.callbackWithValue(os.Args[i])
} else if opt.callbackNoValue != nil {
opt.callbackNoValue()
}
knownParam = true
break
}
}
if !knownParam {
log.Error("unknown option %v\n", v)
printHelp()
os.Exit(64)
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/03506df25d5c6af6daf1ba19300d2697ad241bda | home/home.go |
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep | <mask> {"glinet", "", "Run in GL-Inet compatibility mode", nil, func() { o.glinetMode = true }},
<mask> {"version", "", "Show the version and exit", nil, func() {
<mask> fmt.Println(version())
<mask> os.Exit(0)
<mask> }},
<mask> {"help", "", "Print this help", nil, func() {
<mask> printHelp()
<mask> os.Exit(64)
<mask> }},
<mask> }
<mask> printHelp = func() {
<mask> fmt.Printf("Usage:\n\n")
<mask> fmt.Printf("%s [options]\n\n", os.Args[0])
<mask> fmt.Printf("Options:\n")
<mask> for _, opt := range opts {
<mask> val := ""
<mask> if opt.callbackWithValue != nil {
<mask> val = " VALUE"
<mask> }
<mask> if opt.shortName != "" {
<mask> fmt.Printf(" -%s, %-30s %s\n", opt.shortName, "--"+opt.longName+val, opt.description)
<mask> } else {
<mask> fmt.Printf(" %-34s %s\n", "--"+opt.longName+val, opt.description)
<mask> }
<mask> }
<mask> }
<mask> for i := 1; i < len(os.Args); i++ {
<mask> v := os.Args[i]
<mask> knownParam := false
<mask> for _, opt := range opts {
<mask> if v == "--"+opt.longName || (opt.shortName != "" && v == "-"+opt.shortName) {
<mask> if opt.callbackWithValue != nil {
<mask> if i+1 >= len(os.Args) {
<mask> log.Error("Got %s without argument\n", v)
<mask> os.Exit(64)
<mask> }
<mask> i++
<mask> opt.callbackWithValue(os.Args[i])
<mask> } else if opt.callbackNoValue != nil {
<mask> opt.callbackNoValue()
<mask> }
<mask> knownParam = true
<mask> break
<mask> }
<mask> }
<mask> if !knownParam {
<mask> log.Error("unknown option %v\n", v)
<mask> printHelp()
<mask> os.Exit(64)
<mask> }
<mask> }
<mask>
<mask> return o
<mask> }
</s> cli: factor options struct and parsing into home/options.go </s> remove o := options{}
var printHelp func()
var opts = []struct {
longName string
shortName string
description string
callbackWithValue func(value string)
callbackNoValue func()
}{
{"config", "c", "Path to the config file", func(value string) { o.configFilename = value }, nil},
{"work-dir", "w", "Path to the working directory", func(value string) { o.workDir = value }, nil},
{"host", "h", "Host address to bind HTTP server on", func(value string) { o.bindHost = value }, nil},
{"port", "p", "Port to serve HTTP pages on", func(value string) {
v, err := strconv.Atoi(value)
if err != nil {
panic("Got port that is not a number")
}
o.bindPort = v
}, nil},
{"service", "s", "Service control action: status, install, uninstall, start, stop, restart, reload (configuration)", func(value string) {
o.serviceControlAction = value
}, nil},
{"logfile", "l", "Path to log file. If empty: write to stdout; if 'syslog': write to system log", func(value string) {
o.logFile = value
}, nil},
{"pidfile", "", "Path to a file where PID is stored", func(value string) { o.pidFile = value }, nil},
{"check-config", "", "Check configuration and exit", nil, func() { o.checkConfig = true }},
{"no-check-update", "", "Don't check for updates", nil, func() { o.disableUpdate = true }},
{"verbose", "v", "Enable verbose output", nil, func() { o.verbose = true }},
{"glinet", "", "Run in GL-Inet compatibility mode", nil, func() { o.glinetMode = true }},
{"version", "", "Show the version and exit", nil, func() {
fmt.Println(version())
</s> add o, f, err := parse(os.Args[0], os.Args[1:])
if err != nil {
log.Error(err.Error())
_ = printHelp(os.Args[0])
exitWithError()
} else if f != nil {
err = f()
if err != nil {
log.Error(err.Error())
exitWithError()
} else { </s> remove // command-line arguments
type options struct {
verbose bool // is verbose logging enabled
configFilename string // path to the config file
workDir string // path to the working directory where we will store the filters data and the querylog
bindHost string // host address to bind HTTP server on
bindPort int // port to serve HTTP pages on
logFile string // Path to the log file. If empty, write to stdout. If "syslog", writes to syslog
pidFile string // File name to save PID to
checkConfig bool // Check configuration and exit
disableUpdate bool // If set, don't check for updates
// service control action (see service.ControlAction array + "status" command)
serviceControlAction string
// runningAsService flag is set to true when options are passed from the service runner
runningAsService bool
glinetMode bool // Activate GL-Inet mode
</s> add func exitWithError() {
os.Exit(64) | https://github.com/AdguardTeam/AdGuardHome/commit/03506df25d5c6af6daf1ba19300d2697ad241bda | home/home.go |
keep keep keep keep replace keep keep keep keep keep | <mask> go 1.16
<mask>
<mask> require (
<mask> github.com/AdguardTeam/dnsproxy v0.37.4
<mask> github.com/AdguardTeam/golibs v0.5.0
<mask> github.com/AdguardTeam/urlfilter v0.14.5
<mask> github.com/NYTimes/gziphandler v1.1.1
<mask> github.com/ameshkov/dnscrypt/v2 v2.1.3
<mask> github.com/digineo/go-ipset/v2 v2.2.1
<mask> github.com/fsnotify/fsnotify v1.4.9
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove github.com/AdguardTeam/golibs v0.5.0 h1:qwhEKjDrT0UcwDnHrNU2Yg/DLR9b/GsUncnXYW6VzAU=
github.com/AdguardTeam/golibs v0.5.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
</s> add github.com/AdguardTeam/golibs v0.8.0 h1:rHo+yIgT2fivFG0yW2Cwk/DPc2+t/Aw6QvzPpiIFre0=
github.com/AdguardTeam/golibs v0.8.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= </s> remove defer agherr.LogPanic("systemResolvers")
</s> add defer log.OnPanic("systemResolvers")
</s> remove var stdoutLimited io.ReadCloser
stdoutLimited, err = aghio.LimitReadCloser(stdout, aghos.MaxCmdOutputSize)
</s> add var stdoutLimited io.Reader
stdoutLimited, err = aghio.LimitReader(stdout, aghos.MaxCmdOutputSize) </s> remove return nil, agherr.Error("invalid ip")
</s> add return nil, errors.Error("invalid ip") </s> add "github.com/AdguardTeam/golibs/errors" </s> remove "errors"
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | go.mod |
keep keep keep keep replace replace keep keep keep keep keep | <mask> github.com/AdguardTeam/dnsproxy v0.37.4/go.mod h1:xkJWEuTr550gPDmB9azsciKZzSXjf9wMn+Ji54PQ4gE=
<mask> github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
<mask> github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
<mask> github.com/AdguardTeam/golibs v0.4.4/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
<mask> github.com/AdguardTeam/golibs v0.5.0 h1:qwhEKjDrT0UcwDnHrNU2Yg/DLR9b/GsUncnXYW6VzAU=
<mask> github.com/AdguardTeam/golibs v0.5.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
<mask> github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU=
<mask> github.com/AdguardTeam/urlfilter v0.14.5 h1:WyF0hg0MwKevsqNPkoaZFH8f5WRi/yuy/7qePtYt5Ts=
<mask> github.com/AdguardTeam/urlfilter v0.14.5/go.mod h1:klx4JbOfc4EaNb5lWLqOwfg+pVcyRukmoJRvO55lL5U=
<mask> github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
<mask> github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove github.com/AdguardTeam/golibs v0.5.0
</s> add github.com/AdguardTeam/golibs v0.8.0 </s> remove "errors"
</s> add </s> add "github.com/AdguardTeam/golibs/errors" </s> remove "errors"
</s> add </s> add "github.com/AdguardTeam/golibs/errors" </s> remove "errors"
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | go.sum |
keep keep keep keep replace keep keep keep keep keep | <mask> "net"
<mask> "strconv"
<mask> "strings"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/agherr"
<mask> "golang.org/x/net/idna"
<mask> )
<mask>
<mask> // IsValidHostOuterRune returns true if r is a valid initial or final rune for
<mask> // a hostname label.
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add "github.com/AdguardTeam/golibs/errors" </s> add "github.com/AdguardTeam/golibs/errors" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add </s> remove defer agherr.Annotate("validating hardware address %q: %w", &err, hwa)
</s> add defer func() { err = errors.Annotate(err, "validating hardware address %q: %w", hwa) }() </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add "github.com/AdguardTeam/golibs/errors" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/addr.go |
keep replace keep keep keep replace keep | <mask> func ValidateHardwareAddress(hwa net.HardwareAddr) (err error) {
<mask> defer agherr.Annotate("validating hardware address %q: %w", &err, hwa)
<mask>
<mask> switch l := len(hwa); l {
<mask> case 0:
<mask> return agherr.Error("address is empty")
<mask> case 6, 8, 20:
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove defer agherr.Annotate("validating label %q: %w", &err, label)
</s> add defer func() { err = errors.Annotate(err, "validating label %q: %w", label) }() </s> remove defer agherr.Annotate("parsing %q: %w", &err, host)
</s> add defer func() { err = errors.Annotate(err, "parsing %q: %w", host) }() </s> remove return agherr.Error("client is nil")
</s> add return errors.Error("client is nil") </s> remove func ReplaceLogLevel(t *testing.T, l int) {
</s> add func ReplaceLogLevel(t *testing.T, l log.Level) { </s> remove return agherr.Error("question is nil")
</s> add return errors.Error("question is nil") | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/addr.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> // ValidateDomainNameLabel returns an error if label is not a valid label of
<mask> // a domain name.
<mask> func ValidateDomainNameLabel(label string) (err error) {
<mask> defer agherr.Annotate("validating label %q: %w", &err, label)
<mask>
<mask> l := len(label)
<mask> if l > maxDomainLabelLen {
<mask> return fmt.Errorf("label is too long, max: %d", maxDomainLabelLen)
<mask> } else if l == 0 {
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove return agherr.Error("label is empty")
</s> add return errors.Error("label is empty") </s> remove return agherr.Error("domain name is empty")
</s> add return errors.Error("domain name is empty") </s> remove defer agherr.Annotate("validating hardware address %q: %w", &err, hwa)
</s> add defer func() { err = errors.Annotate(err, "validating hardware address %q: %w", hwa) }() </s> remove return agherr.Error("address is empty")
</s> add return errors.Error("address is empty") </s> remove defer agherr.Annotate("normalizing %q: %w", &err, hostname)
</s> add defer func() { err = errors.Annotate(err, "normalizing %q: %w", hostname) }() </s> remove defer agherr.Annotate("bad upstream for domain spec %q: %w", &err, upstreamStr)
</s> add defer func() { err = errors.Annotate(err, "bad upstream for domain spec %q: %w", upstreamStr) }() | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/addr.go |
keep keep keep keep replace keep keep keep keep keep | <mask> l := len(label)
<mask> if l > maxDomainLabelLen {
<mask> return fmt.Errorf("label is too long, max: %d", maxDomainLabelLen)
<mask> } else if l == 0 {
<mask> return agherr.Error("label is empty")
<mask> }
<mask>
<mask> if r := label[0]; !IsValidHostOuterRune(rune(r)) {
<mask> return fmt.Errorf("invalid char %q at index %d", r, 0)
<mask> } else if l == 1 {
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove return agherr.Error("domain name is empty")
</s> add return errors.Error("domain name is empty") </s> remove defer agherr.Annotate("validating label %q: %w", &err, label)
</s> add defer func() { err = errors.Annotate(err, "validating label %q: %w", label) }() </s> remove return agherr.Error("address is empty")
</s> add return errors.Error("address is empty") </s> remove func ReplaceLogLevel(t *testing.T, l int) {
</s> add func ReplaceLogLevel(t *testing.T, l log.Level) { </s> remove return agherr.Error("static lease already exists")
</s> add return errors.Error("static lease already exists") </s> remove defer agherr.Annotate("validating hardware address %q: %w", &err, hwa)
</s> add defer func() { err = errors.Annotate(err, "validating hardware address %q: %w", hwa) }() | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/addr.go |
keep keep keep keep replace keep keep keep keep keep | <mask> //
<mask> // TODO(a.garipov): After making sure that this works correctly, port this into
<mask> // module golibs.
<mask> func ValidateDomainName(name string) (err error) {
<mask> defer agherr.Annotate("validating domain name %q: %w", &err, name)
<mask>
<mask> name, err = idna.ToASCII(name)
<mask> if err != nil {
<mask> return err
<mask> }
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove defer agherr.Annotate("validating label %q: %w", &err, label)
</s> add defer func() { err = errors.Annotate(err, "validating label %q: %w", label) }() </s> remove defer agherr.Annotate("bad upstream for domain spec %q: %w", &err, upstreamStr)
</s> add defer func() { err = errors.Annotate(err, "bad upstream for domain spec %q: %w", upstreamStr) }() </s> remove defer agherr.Annotate("parsing %q: %w", &err, host)
</s> add defer func() { err = errors.Annotate(err, "parsing %q: %w", host) }() </s> remove defer agherr.Annotate("normalizing %q: %w", &err, hostname)
</s> add defer func() { err = errors.Annotate(err, "normalizing %q: %w", hostname) }() </s> remove defer agherr.Annotate("validating hardware address %q: %w", &err, hwa)
</s> add defer func() { err = errors.Annotate(err, "validating hardware address %q: %w", hwa) }() </s> remove defer agherr.Annotate("invalid option string %q: %w", &err, s)
</s> add defer func() { err = errors.Annotate(err, "invalid option string %q: %w", s) }() | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/addr.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask>
<mask> l := len(name)
<mask> if l == 0 {
<mask> return agherr.Error("domain name is empty")
<mask> } else if l > maxDomainNameLen {
<mask> return fmt.Errorf("too long, max: %d", maxDomainNameLen)
<mask> }
<mask>
<mask> labels := strings.Split(name, ".")
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove return agherr.Error("label is empty")
</s> add return errors.Error("label is empty") </s> remove defer agherr.Annotate("validating label %q: %w", &err, label)
</s> add defer func() { err = errors.Annotate(err, "validating label %q: %w", label) }() </s> remove return agherr.Error("address is empty")
</s> add return errors.Error("address is empty") </s> remove func ReplaceLogLevel(t *testing.T, l int) {
</s> add func ReplaceLogLevel(t *testing.T, l log.Level) { </s> remove return agherr.Error("static lease already exists")
</s> add return errors.Error("static lease already exists") </s> remove defer agherr.Annotate("validating hardware address %q: %w", &err, hwa)
</s> add defer func() { err = errors.Annotate(err, "validating hardware address %q: %w", hwa) }() | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/addr.go |
keep keep keep keep replace keep keep keep keep keep | <mask> package aghnet
<mask>
<mask> import (
<mask> "bufio"
<mask> "errors"
<mask> "io"
<mask> "net"
<mask> "os"
<mask> "path/filepath"
<mask> "runtime"
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/etchostscontainer.go |
keep add keep keep keep keep | <mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/fsnotify/fsnotify"
<mask> "github.com/miekg/dns"
<mask> )
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> add "github.com/AdguardTeam/golibs/errors" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add </s> add "github.com/AdguardTeam/golibs/errors" </s> add "github.com/AdguardTeam/golibs/errors" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add </s> add "github.com/AdguardTeam/golibs/errors" | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/etchostscontainer.go |
keep keep keep keep replace keep keep keep keep keep | <mask> if err != nil {
<mask> log.Error("etchostscontainer: %s", err)
<mask> return
<mask> }
<mask> defer f.Close()
<mask> r := bufio.NewReader(f)
<mask> log.Debug("etchostscontainer: loading hosts from file %s", fn)
<mask>
<mask> for done := false; !done; {
<mask> var line string
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove defer f.Close()
fileReadCloser, err := aghio.LimitReadCloser(f, MaxFileSize)
</s> add defer func() {
derr := f.Close()
if derr != nil {
log.Error("glinet: closing file: %s", err)
}
}()
fileReader, err := aghio.LimitReader(f, MaxFileSize) </s> remove defer f.Close()
</s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() </s> remove var files []string
var err2 error
var zr io.ReadCloser
for _, zf := range r.File {
zr, err = zf.Open()
</s> add for _, zf := range zrc.File {
var name string
name, err = zipFileUnpackOne(outDir, zf) </s> remove defer f.Close()
</s> add defer func() {
derr := f.Close()
if derr != nil {
log.Error("querylog: closing file: %s", derr)
}
}() </s> remove err := e.Encode(entry)
</s> add err = e.Encode(entry) </s> remove err = f.Close()
if err != nil {
err2 = fmt.Errorf("f.Close(): %w", err)
break
}
log.Tracef("created file %s", outputName)
files = append(files, inputNameOnly)
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/etchostscontainer.go |
keep keep keep keep replace keep keep keep keep keep | <mask> package aghnet
<mask>
<mask> import (
<mask> "encoding/json"
<mask> "errors"
<mask> "fmt"
<mask> "net"
<mask> "os"
<mask> "os/exec"
<mask> "runtime"
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net.go |
keep keep keep keep replace keep keep keep keep keep | <mask> "strings"
<mask> "syscall"
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/agherr"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghstrings"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> )
<mask>
<mask> // ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> add "github.com/AdguardTeam/golibs/errors" </s> remove const ErrNoStaticIPInfo agherr.Error = "no information about static ip"
</s> add const ErrNoStaticIPInfo errors.Error = "no information about static ip" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add </s> remove rDNSEmptyAnswerErr agherr.Error = "the answer section is empty"
</s> add rDNSEmptyAnswerErr errors.Error = "the answer section is empty" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add </s> add "github.com/AdguardTeam/golibs/errors" | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net.go |
keep keep add keep keep keep keep keep keep | <mask> "time"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghstrings"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> )
<mask>
<mask> // ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about
<mask> // the IP being static is available.
<mask> const ErrNoStaticIPInfo errors.Error = "no information about static ip"
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove const ErrNoStaticIPInfo agherr.Error = "no information about static ip"
</s> add const ErrNoStaticIPInfo errors.Error = "no information about static ip" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add </s> remove errBadAddrPassed agherr.Error = "the passed string is not a valid IP address"
</s> add errBadAddrPassed errors.Error = "the passed string is not a valid IP address" </s> add "github.com/AdguardTeam/golibs/errors" </s> remove rDNSEmptyAnswerErr agherr.Error = "the answer section is empty"
</s> add rDNSEmptyAnswerErr errors.Error = "the answer section is empty" </s> remove errFakeDial agherr.Error = "this error signals the successful dialFunc work"
</s> add errFakeDial errors.Error = "this error signals the successful dialFunc work" | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net.go |
keep keep keep keep replace keep keep keep keep keep | <mask> )
<mask>
<mask> // ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about
<mask> // the IP being static is available.
<mask> const ErrNoStaticIPInfo agherr.Error = "no information about static ip"
<mask>
<mask> // IfaceHasStaticIP checks if interface is configured to have static IP address.
<mask> // If it can't give a definitive answer, it returns false and an error for which
<mask> // errors.Is(err, ErrNoStaticIPInfo) is true.
<mask> func IfaceHasStaticIP(ifaceName string) (has bool, err error) {
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> add "github.com/AdguardTeam/golibs/errors" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add </s> remove errBadAddrPassed agherr.Error = "the passed string is not a valid IP address"
</s> add errBadAddrPassed errors.Error = "the passed string is not a valid IP address" </s> remove errFakeDial agherr.Error = "this error signals the successful dialFunc work"
</s> add errFakeDial errors.Error = "this error signals the successful dialFunc work" </s> remove rDNSNotPTRErr agherr.Error = "the response is not a ptr"
</s> add rDNSNotPTRErr errors.Error = "the response is not a ptr" </s> remove rDNSEmptyAnswerErr agherr.Error = "the answer section is empty"
</s> add rDNSEmptyAnswerErr errors.Error = "the answer section is empty" | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net.go |
keep keep keep keep replace keep keep keep keep keep | <mask> if err != nil {
<mask> return nil, fmt.Errorf("couldn't get interfaces: %w", err)
<mask> }
<mask> if len(ifaces) == 0 {
<mask> return nil, errors.New("couldn't find any legible interface")
<mask> }
<mask>
<mask> var netInterfaces []*NetInterface
<mask>
<mask> for _, iface := range ifaces {
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove var files []string
var err2 error
var zr io.ReadCloser
for _, zf := range r.File {
zr, err = zf.Open()
</s> add for _, zf := range zrc.File {
var name string
name, err = zipFileUnpackOne(outDir, zf) </s> remove defer r.Close()
</s> add defer func() { err = errors.WithDeferred(err, zrc.Close()) }() </s> remove var files []string
var err2 error
</s> add </s> remove return errors.New(data.WarningValidation)
</s> add return errors.Error(data.WarningValidation) </s> add defer func() { err = errors.WithDeferred(err, gzReader.Close()) }() </s> remove return nil, errors.New("found no DNS servers in /etc/resolv.conf")
</s> add return nil, errors.Error("found no DNS servers in /etc/resolv.conf") | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> package aghnet
<mask>
<mask> import (
<mask> "errors"
<mask> "fmt"
<mask> "os"
<mask> "regexp"
<mask> "strings"
<mask>
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net_darwin.go |
keep keep keep add keep keep keep keep | <mask> "regexp"
<mask> "strings"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos"
<mask> )
<mask>
<mask> // hardwarePortInfo - information obtained using MacOS networksetup
<mask> // about the current state of the internet connection
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> add "github.com/AdguardTeam/golibs/errors" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add </s> remove const ErrNoStaticIPInfo agherr.Error = "no information about static ip"
</s> add const ErrNoStaticIPInfo errors.Error = "no information about static ip" </s> add "github.com/AdguardTeam/golibs/errors" </s> add "github.com/AdguardTeam/golibs/errors" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net_darwin.go |
keep keep keep keep replace keep keep keep keep keep | <mask> re := regexp.MustCompile("IP address: (.*?)\nSubnet mask: (.*?)\nRouter: (.*?)\n")
<mask>
<mask> match := re.FindStringSubmatch(out)
<mask> if len(match) == 0 {
<mask> return h, errors.New("could not find hardware port info")
<mask> }
<mask>
<mask> h.name = hardwarePort
<mask> h.ip = match[1]
<mask> h.subnet = match[2]
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove return nil, errors.New("couldn't find any legible interface")
</s> add return nil, errors.Error("couldn't find any legible interface") </s> remove return nil, errors.New("found no DNS servers in /etc/resolv.conf")
</s> add return nil, errors.Error("found no DNS servers in /etc/resolv.conf") </s> remove return nil, errors.New("newBroadcastPacketConn(): not supported on Windows")
</s> add return nil, errors.Error("newBroadcastPacketConn(): not supported on Windows") </s> remove return errors.New(data.WarningValidation)
</s> add return errors.Error(data.WarningValidation) </s> remove defer agherr.Annotate("validating hardware address %q: %w", &err, hwa)
</s> add defer func() { err = errors.Annotate(err, "validating hardware address %q: %w", hwa) }() </s> remove return agherr.Error("domain name is empty")
</s> add return errors.Error("domain name is empty") | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net_darwin.go |
keep keep keep keep replace keep keep keep keep keep | <mask> return err
<mask> }
<mask>
<mask> if portInfo.static {
<mask> return errors.New("IP address is already static")
<mask> }
<mask>
<mask> dnsAddrs, err := getEtcResolvConfServers()
<mask> if err != nil {
<mask> return err
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove return agherr.Error("static lease already exists")
</s> add return errors.Error("static lease already exists") </s> remove return agherr.Error("static lease already exists")
</s> add return errors.Error("static lease already exists") </s> remove return agherr.Error("client already exists")
</s> add return errors.Error("client already exists") </s> remove }
</s> add } else if err != nil {
err = fmt.Errorf("tarReader.Next(): %w", err) </s> remove defer conn.Close()
</s> add defer func() { err = errors.WithDeferred(err, conn.Close()) }() </s> remove defer f.Close()
</s> add defer func() {
derr := f.Close()
if derr != nil {
log.Error("querylog: closing file: %s", derr)
}
}() | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net_darwin.go |
keep keep keep keep replace keep keep keep keep keep | <mask> re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
<mask>
<mask> matches := re.FindAllStringSubmatch(string(body), -1)
<mask> if len(matches) == 0 {
<mask> return nil, errors.New("found no DNS servers in /etc/resolv.conf")
<mask> }
<mask>
<mask> addrs := make([]string, 0)
<mask> for i := range matches {
<mask> addrs = append(addrs, matches[i][1])
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove return nil, errors.New("couldn't find any legible interface")
</s> add return nil, errors.Error("couldn't find any legible interface") </s> remove return errors.New(data.WarningValidation)
</s> add return errors.Error(data.WarningValidation) </s> remove return agherr.Error("label is empty")
</s> add return errors.Error("label is empty") </s> remove return proxyConfig, errors.New("no default upstream servers configured")
</s> add return proxyConfig, errors.Error("no default upstream servers configured") </s> remove return agherr.Error("no dns rewrite rule responses")
</s> add return errors.Error("no dns rewrite rule responses") </s> remove var files []string
var err2 error
var zr io.ReadCloser
for _, zf := range r.File {
zr, err = zf.Open()
</s> add for _, zf := range zrc.File {
var name string
name, err = zipFileUnpackOne(outDir, zf) | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net_darwin.go |
keep keep keep keep replace keep keep keep keep keep | <mask> package aghnet
<mask>
<mask> import (
<mask> "bufio"
<mask> "errors"
<mask> "fmt"
<mask> "io"
<mask> "net"
<mask> "os"
<mask> "strings"
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net_linux.go |
keep keep keep add keep keep keep keep keep keep | <mask> "os"
<mask> "strings"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghio"
<mask> "github.com/google/renameio/maybe"
<mask> )
<mask>
<mask> // maxConfigFileSize is the maximum length of interfaces configuration file.
<mask> const maxConfigFileSize = 1024 * 1024
<mask>
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> add "github.com/AdguardTeam/golibs/errors" </s> remove func (u *Updater) downloadPackageFile(url, filename string) error {
resp, err := u.client.Get(url)
</s> add func (u *Updater) downloadPackageFile(url, filename string) (err error) {
var resp *http.Response
resp, err = u.client.Get(url) </s> remove ErrTSNotFound agherr.Error = "ts not found"
ErrTSTooLate agherr.Error = "ts too late"
ErrTSTooEarly agherr.Error = "ts too early"
</s> add ErrTSNotFound errors.Error = "ts not found"
ErrTSTooLate errors.Error = "ts too late"
ErrTSTooEarly errors.Error = "ts too early" </s> remove func (u *Updater) VersionInfo(forceRecheck bool) (VersionInfo, error) {
</s> add func (u *Updater) VersionInfo(forceRecheck bool) (vi VersionInfo, err error) { </s> add "github.com/AdguardTeam/golibs/errors" </s> add "github.com/AdguardTeam/golibs/errors" | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net_linux.go |
keep keep replace keep keep keep keep keep keep keep keep replace replace keep keep keep keep | <mask> return false, err
<mask> }
<mask> defer f.Close()
<mask>
<mask> var fileReadCloser io.ReadCloser
<mask> fileReadCloser, err = aghio.LimitReadCloser(f, maxConfigFileSize)
<mask> if err != nil {
<mask> return false, err
<mask> }
<mask> defer f.Close()
<mask>
<mask> var fileReadCloser io.ReadCloser
<mask> fileReadCloser, err = aghio.LimitReadCloser(f, maxConfigFileSize)
<mask> if err != nil {
<mask> return false, err
<mask> }
<mask> defer fileReadCloser.Close()
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove defer fileReadCloser.Close()
</s> add </s> remove has, err = check.checker(fileReadCloser, ifaceName)
</s> add has, err = check.checker(fileReader, ifaceName) </s> remove defer f.Close()
fileReadCloser, err := aghio.LimitReadCloser(f, MaxFileSize)
</s> add defer func() {
derr := f.Close()
if derr != nil {
log.Error("glinet: closing file: %s", err)
}
}()
fileReader, err := aghio.LimitReader(f, MaxFileSize) </s> remove defer c.Close()
</s> add defer func() { err = errors.WithDeferred(err, c.Close()) }() </s> remove defer c.Close()
</s> add defer func() { err = errors.WithDeferred(err, c.Close()) }() | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net_linux.go |
keep keep replace keep keep keep keep keep keep keep replace keep | <mask> return false, err
<mask> }
<mask> defer fileReadCloser.Close()
<mask>
<mask> has, err = check.checker(fileReadCloser, ifaceName)
<mask> if err != nil {
<mask> return false, err
<mask> }
<mask> defer fileReadCloser.Close()
<mask>
<mask> has, err = check.checker(fileReadCloser, ifaceName)
<mask> if err != nil {
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove var fileReadCloser io.ReadCloser
fileReadCloser, err = aghio.LimitReadCloser(f, maxConfigFileSize)
</s> add var fileReader io.Reader
fileReader, err = aghio.LimitReader(f, maxConfigFileSize) </s> remove defer f.Close()
</s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() </s> remove defer c.Close()
</s> add defer func() { err = errors.WithDeferred(err, c.Close()) }() </s> remove defer c.Close()
</s> add defer func() { err = errors.WithDeferred(err, c.Close()) }() </s> remove return "", false, agherr.Error("duplicated separator")
</s> add return "", false, errors.Error("duplicated separator") | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net_linux.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> func ifaceSetStaticIP(ifaceName string) (err error) {
<mask> ipNet := GetSubnet(ifaceName)
<mask> if ipNet.IP == nil {
<mask> return errors.New("can't get IP address")
<mask> }
<mask>
<mask> gatewayIP := GatewayIP(ifaceName)
<mask> add := updateStaticIPdhcpcdConf(ifaceName, ipNet.String(), gatewayIP, ipNet.IP)
<mask>
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove defer agherr.Annotate("systemResolvers: %w", &err)
</s> add defer func() { err = errors.Annotate(err, "systemResolvers: %w") }() </s> remove func (l *queryLog) flushToFile(buffer []*logEntry) error {
</s> add func (l *queryLog) flushToFile(buffer []*logEntry) (err error) { </s> remove defer agherr.Annotate("systemResolvers: %w", &err)
</s> add defer func() { err = errors.Annotate(err, "systemResolvers: %w") }() </s> remove return agherr.Error("no dns rewrite rule content")
</s> add return errors.Error("no dns rewrite rule content") </s> remove defer agherr.Annotate("parsing %q: %w", &err, host)
</s> add defer func() { err = errors.Annotate(err, "parsing %q: %w", host) }() </s> remove func (u *Updater) downloadPackageFile(url, filename string) error {
resp, err := u.client.Get(url)
</s> add func (u *Updater) downloadPackageFile(url, filename string) (err error) {
var resp *http.Response
resp, err = u.client.Get(url) | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net_linux.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> import (
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/agherr"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> )
<mask>
<mask> // DefaultRefreshIvl is the default period of time between refreshing cached
<mask> // addresses.
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add "github.com/AdguardTeam/golibs/errors" </s> add "github.com/AdguardTeam/golibs/errors" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add "github.com/AdguardTeam/golibs/errors" </s> remove "errors"
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/systemresolvers.go |
keep keep keep replace keep keep replace keep | <mask>
<mask> const (
<mask> // errBadAddrPassed is returned when dialFunc can't parse an IP address.
<mask> errBadAddrPassed agherr.Error = "the passed string is not a valid IP address"
<mask>
<mask> // errFakeDial is an error which dialFunc is expected to return.
<mask> errFakeDial agherr.Error = "this error signals the successful dialFunc work"
<mask>
</s> Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9e391d98c31c1eeba7ef323
Author: Ainar Garipov <[email protected]>
Date: Mon May 24 15:33:45 2021 +0300
replace agherr with golibs' errors </s> remove errUnexpectedHostFormat agherr.Error = "unexpected host format"
</s> add errUnexpectedHostFormat errors.Error = "unexpected host format" </s> remove const ErrNoStaticIPInfo agherr.Error = "no information about static ip"
</s> add const ErrNoStaticIPInfo errors.Error = "no information about static ip" </s> remove rDNSEmptyAnswerErr agherr.Error = "the answer section is empty"
</s> add rDNSEmptyAnswerErr errors.Error = "the answer section is empty" </s> remove rDNSNotPTRErr agherr.Error = "the response is not a ptr"
</s> add rDNSNotPTRErr errors.Error = "the response is not a ptr" </s> add "github.com/AdguardTeam/golibs/errors" | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/systemresolvers.go |