docstring_tokens
stringlengths
0
76.5k
code_tokens
stringlengths
75
1.81M
label_window
sequencelengths
4
2.12k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
ipAddr := config.dhcpServer.FindIPbyMAC(mac)
<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)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/clients.go
ipAddr := config.dhcpServer.FindIPbyMAC(hwAddr)
<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()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/clients.go
dhcpServer dhcpd.Server
<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()
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/config.go
<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> remove ipAddr := dhcpServer.FindIPbyMAC(mac) </s> add ipAddr := config.dhcpServer.FindIPbyMAC(mac)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
leases := convertLeases(config.dhcpServer.Leases(), true) staticLeases := convertLeases(config.dhcpServer.StaticLeases(), false)
<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)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
err = config.dhcpServer.CheckConfig(newconfig.ServerConfig)
<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)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
err = config.dhcpServer.Stop()
<mask> httpError(w, http.StatusBadRequest, "Invalid DHCP configuration: %s", err) <mask> return <mask> } <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) </s> * move "dhcpServer" to "config" </s> remove err = dhcpServer.Init(newconfig.ServerConfig) </s> add err = config.dhcpServer.Init(newconfig.ServerConfig) </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.RemoveStaticLease(lease) </s> add err = config.dhcpServer.RemoveStaticLease(lease)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
err = config.dhcpServer.Init(newconfig.ServerConfig)
<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) <mask> return <mask> } <mask> </s> * move "dhcpServer" to "config" </s> remove err = dhcpServer.Stop() </s> add err = config.dhcpServer.Stop() </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()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
err = config.dhcpServer.Start()
<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)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
err = config.dhcpServer.AddStaticLease(lease)
<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)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
err = config.dhcpServer.RemoveStaticLease(lease)
<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)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
err := config.dhcpServer.Init(config.DHCP)
<mask> // not enabled, don't do anything <mask> return nil <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() </s> * move "dhcpServer" to "config" </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.Init(newconfig.ServerConfig) </s> add err = config.dhcpServer.Init(newconfig.ServerConfig) </s> remove err = dhcpServer.RemoveStaticLease(lease) </s> add err = config.dhcpServer.RemoveStaticLease(lease)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
err = config.dhcpServer.Start()
<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 <mask> } </s> * move "dhcpServer" to "config" </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.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.RemoveStaticLease(lease) </s> add err = config.dhcpServer.RemoveStaticLease(lease)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
err := config.dhcpServer.Stop()
<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)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
github.com/google/renameio v1.0.1-0.20210406141108-81588dbe0453
<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> 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)
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
go.mod
github.com/google/renameio v1.0.1-0.20210406141108-81588dbe0453 h1:vvZyWjAX9oDB+DWpMsZMyv6Q3NZtim2C5Zcdh+H0OmQ= github.com/google/renameio v1.0.1-0.20210406141108-81588dbe0453/go.mod h1:t/HQoYBZSsWSNK35C6CO/TpPLDVWvxOHboWUAweKUpk=
<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> 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)
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
go.sum
"github.com/google/renameio/maybe"
<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> remove "github.com/AdguardTeam/golibs/file" </s> add </s> remove "github.com/AdguardTeam/golibs/file" </s> add </s> remove "github.com/AdguardTeam/golibs/file" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/aghnet/net_linux.go
err = maybe.WriteFile("/etc/dhcpcd.conf", body, 0o644)
<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)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/aghnet/net_linux.go
return fmt.Errorf("writing conf: %w", err)
<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",
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/aghnet/net_linux.go
<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> 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
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/dhcpd/db.go
"github.com/google/renameio/maybe"
<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> 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
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/dhcpd/db.go
log.Error("dhcp: invalid DB: %v", err)
<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)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/dhcpd/db.go
log.Info("dhcp: invalid IP: %s", obj[i].IP)
<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)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/dhcpd/db.go
log.Info("dhcp: loaded leases v4:%d v6:%d total-read:%d from DB",
<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> remove "github.com/AdguardTeam/golibs/file" </s> add "github.com/google/renameio/maybe"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/dhcpd/db.go
err = maybe.WriteFile(s.conf.DBFilePath, data, 0o644)
<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> } </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 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: invalid DB: %v", err) </s> add log.Error("dhcp: invalid DB: %v", err) </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)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/dhcpd/db.go
log.Error("dhcp: can't store lease table on disk: %v filename: %s",
<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)) <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.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 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 err = file.SafeWrite(configFile, yamlText) </s> add err = maybe.WriteFile(configFile, yamlText, 0o644) </s> remove err = file.SafeWrite("/etc/dhcpcd.conf", body) </s> add err = maybe.WriteFile("/etc/dhcpcd.conf", body, 0o644)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/dhcpd/db.go
log.Info("dhcp: stored %d leases in DB", len(leases))
<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)
[ "keep", "keep", "keep", "keep", "replace", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/dhcpd/db.go
<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> remove "github.com/AdguardTeam/golibs/file" </s> add </s> remove "github.com/AdguardTeam/golibs/file" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/home/config.go
"github.com/google/renameio/maybe"
<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> remove "github.com/AdguardTeam/golibs/file" </s> add
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/home/config.go
err = maybe.WriteFile(configFile, yamlText, 0o644)
<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)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/home/config.go
<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> remove "github.com/AdguardTeam/golibs/file" </s> add </s> remove "github.com/AdguardTeam/golibs/file" </s> add </s> remove "github.com/AdguardTeam/golibs/file" </s> add "github.com/google/renameio/maybe"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/home/upgrade.go
"github.com/google/renameio/maybe"
<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> remove "github.com/AdguardTeam/golibs/file" </s> add
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/home/upgrade.go
err = maybe.WriteFile(confFile, body, 0o644)
<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)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/home/upgrade.go
<mask> return <mask> } <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"` <mask> Username string `json:"username,omitempty"` <mask> Password string `json:"password,omitempty"` </s> * control: /install/get_addresses: don't check if ports are available * always use port 80 </s> remove Web ipport `json:"web"` DNS ipport `json:"dns"` </s> add WebPort int `json:"web_port"` DNSPort int `json:"dns_port"` </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
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00c128f0a4deff119f93d02de03fa3fc47c54ec1
control.go
WebPort int `json:"web_port"` DNSPort int `json:"dns_port"`
<mask> Warning string `json:"warning"` <mask> } <mask> <mask> type firstRunData struct { <mask> Web ipport `json:"web"` <mask> DNS ipport `json:"dns"` <mask> Username string `json:"username,omitempty"` <mask> Password string `json:"password,omitempty"` <mask> Interfaces map[string]interface{} `json:"interfaces"` <mask> } <mask> </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 // 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
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00c128f0a4deff119f93d02de03fa3fc47c54ec1
control.go
data.WebPort = 80 data.DNSPort = 53
<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"`
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/00c128f0a4deff119f93d02de03fa3fc47c54ec1
control.go
"encryption_key_source_content": "Paste the private key contents", "stats_params": "Statistics configuration", "config_successfully_saved": "Configuration successfully saved", "interval_24_hour": "24 hours", "interval_days": "{{value}} days", "time_period": "Time period"
<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> remove const { settings, services } = state; </s> add const { settings, services, stats } = state;
[ "keep", "keep", "keep", "keep", "replace", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/__locales/en.json
.custom-control-label, .custom-control-label:before { transition: 0.3s ease-in-out background-color, 0.3s ease-in-out color; }
<mask> height: 23px; <mask> min-width: 23px; <mask> padding: 5px; <mask> } </s> + client: handle time interval for statistics </s> remove const { settings, services } = state; </s> add const { settings, services, stats } = state; </s> remove settings, services, setBlockedServices, t, </s> add settings, services, setBlockedServices, setStatsConfig, stats, t,
[ "keep", "keep", "keep", "add" ]
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/components/Settings/Settings.css
import StatsConfig from './StatsConfig';
<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> remove const { settings, services } = state; </s> add const { settings, services, stats } = state;
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/components/Settings/index.js
this.props.getStatsConfig();
<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> 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: [], });
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/components/Settings/index.js
settings, services, setBlockedServices, setStatsConfig, stats, t,
<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> remove const { settings, services } = state; </s> add const { settings, services, stats } = state;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/components/Settings/index.js
<div className="col-md-12"> <StatsConfig interval={stats.interval} processing={stats.setConfigProcessing} setStatsConfig={setStatsConfig} /> </div>
<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> remove }, { getLogsProcessing: false, logsDownloading: false }); </s> add }, { getLogsProcessing: false, logsDownloading: false, logs: [], });
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/components/Settings/index.js
getStatsConfig: PropTypes.func, setStatsConfig: PropTypes.func,
<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> 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;
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/components/Settings/index.js
import { getStatsConfig, setStatsConfig } from '../actions/stats';
<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> remove settings, services, setBlockedServices, t, </s> add settings, services, setBlockedServices, setStatsConfig, stats, t,
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/containers/Settings.js
const { settings, services, stats } = state;
<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> remove settings, services, setBlockedServices, t, </s> add settings, services, setBlockedServices, setStatsConfig, stats, t,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/containers/Settings.js
stats,
<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> remove settings, services, setBlockedServices, t, </s> add settings, services, setBlockedServices, setStatsConfig, stats, t,
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/containers/Settings.js
getStatsConfig, setStatsConfig,
<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> 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;
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/containers/Settings.js
import stats from './stats';
<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> remove const { settings, services } = state; </s> add const { settings, services, stats } = state;
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/reducers/index.js
stats: { dns_queries: '', blocked_filtering: '', replaced_safebrowsing: '', replaced_parental: '', replaced_safesearch: '', avg_processing_time: '', },
<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> remove const { settings, services } = state; </s> add const { settings, services, stats } = state;
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/reducers/index.js
}, { getLogsProcessing: false, logsDownloading: false, logs: [], });
<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> remove const { settings, services } = state; </s> add const { settings, services, stats } = state;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/reducers/index.js
stats,
<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> 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;
[ "keep", "add", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/reducers/index.js
const { project_id: TWOSKY_PROJECT_ID, base_locale: DEFAULT_LANGUAGE } = twoskyConfig;
<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> remove language: LANGUAGE, </s> add language: language, </s> remove file: fs.createReadStream(path.resolve(LOCALES_DIR, `${LANGUAGE}.json`)), </s> add file: fs.createReadStream(path.resolve(LOCALES_DIR, `${language}.json`)),
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0122710750ae3c8c5039886cd27ec14c9579c85b
scripts/translations/upload.js
const language = process.env.UPLOAD_LANGUAGE || DEFAULT_LANGUAGE;
<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`)),
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0122710750ae3c8c5039886cd27ec14c9579c85b
scripts/translations/upload.js
language: language,
<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> }; <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 const { project_id: TWOSKY_PROJECT_ID, base_locale: LANGUAGE } = twoskyConfig; </s> add const { project_id: TWOSKY_PROJECT_ID, base_locale: DEFAULT_LANGUAGE } = twoskyConfig;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0122710750ae3c8c5039886cd27ec14c9579c85b
scripts/translations/upload.js
file: fs.createReadStream(path.resolve(LOCALES_DIR, `${language}.json`)),
<mask> format: 'json', <mask> language: LANGUAGE, <mask> filename: BASE_FILE, <mask> project: projectId, <mask> file: fs.createReadStream(path.resolve(LOCALES_DIR, `${LANGUAGE}.json`)), <mask> }; <mask> <mask> return { <mask> url: `${url}/upload`, <mask> formData </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;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0122710750ae3c8c5039886cd27ec14c9579c85b
scripts/translations/upload.js
console.log(`uploading ${language}`);
<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> remove const { project_id: TWOSKY_PROJECT_ID, base_locale: LANGUAGE } = twoskyConfig; </s> add const { project_id: TWOSKY_PROJECT_ID, base_locale: DEFAULT_LANGUAGE } = twoskyConfig;
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/0122710750ae3c8c5039886cd27ec14c9579c85b
scripts/translations/upload.js
"net/netip"
<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> remove "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> add </s> remove "github.com/AdguardTeam/golibs/log" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/item.go
return *rw == *other
<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> 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) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/item.go
if rw == nil { return "" }
<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) {
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/item.go
addr, err := netip.ParseAddr(rw.Answer) if err != nil { // TODO(d.kolyshev): Validate rw.Answer as a domain name.
<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 { </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 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
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/item.go
if addr.Is4() {
<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> } <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 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> 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)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/item.go
"github.com/AdguardTeam/golibs/stringutil"
<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> remove "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> add </s> remove "github.com/AdguardTeam/golibs/log" </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage.go
"github.com/AdguardTeam/urlfilter/rules" "github.com/miekg/dns"
<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> 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
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage.go
// MatchRequest returns matching dnsrewrites for the specified request. MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite)
<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> remove // rewrites stores the rewrite entries from configuration. rewrites []*Item </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage.go
// rewrites stores the rewrite entries from configuration. rewrites []*Item
<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)
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage.go
<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> 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> remove // TODO(d.kolyshev): Move these tests to rewrite package. </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage.go
func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) {
<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> 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
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage.go
// TODO(a.garipov): Use strings.Builder.
<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
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage.go
log.Info("rewrite: filter %d: reset %d rules", s.urlFilterID, s.engine.RulesCount)
<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> 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.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage.go
"net"
<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> remove "net" </s> add "net/netip" </s> remove "encoding/json" </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage_test.go
"github.com/AdguardTeam/urlfilter" "github.com/AdguardTeam/urlfilter/rules" "github.com/miekg/dns" "github.com/stretchr/testify/assert"
<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> 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 "net" </s> add "net/netip"
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage_test.go
<mask> <mask> package filtering <mask> <mask> import ( <mask> "encoding/json" <mask> "fmt" <mask> "net" <mask> "net/http" <mask> "sort" <mask> "strings" </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/http" </s> add </s> remove "net" </s> add "net/netip" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrites.go
<mask> import ( <mask> "encoding/json" <mask> "fmt" <mask> "net" <mask> "net/http" <mask> "sort" <mask> "strings" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" <mask> "github.com/AdguardTeam/golibs/errors" </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 "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> add </s> remove "net" </s> add "net/netip" </s> remove "github.com/AdguardTeam/golibs/log" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrites.go
<mask> "net/http" <mask> "sort" <mask> "strings" <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" <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 "net/http" </s> add </s> remove "github.com/AdguardTeam/golibs/log" </s> add </s> remove "encoding/json" </s> add </s> remove "net" </s> add "net/netip"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrites.go
<mask> "strings" <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" <mask> ) <mask> <mask> // TODO(d.kolyshev): Rename this file to rewritehttp.go. </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/AdGuardHome/internal/aghhttp" </s> add </s> remove // TODO(d.kolyshev): Rename this file to rewritehttp.go. </s> add </s> remove "net/http" </s> add </s> remove // TODO(d.kolyshev): Move these tests to rewrite package. </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrites.go
<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
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrites.go
<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> remove return rw.Domain == other.Domain && rw.Answer == other.Answer </s> add return *rw == *other
[ "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" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrites.go
<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> remove // rewrites stores the rewrite entries from configuration. rewrites []*Item </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrites_test.go
func exitWithError() { os.Exit(64)
<mask> } <mask> log.Info("Stopped") <mask> } <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{} </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 }}, {"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
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03506df25d5c6af6daf1ba19300d2697ad241bda
home/home.go
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 {
<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()) <mask> os.Exit(0) <mask> }}, <mask> {"help", "", "Print this help", nil, func() { <mask> printHelp() <mask> os.Exit(64) </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 </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)
[ "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", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03506df25d5c6af6daf1ba19300d2697ad241bda
home/home.go
<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)
[ "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" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03506df25d5c6af6daf1ba19300d2697ad241bda
home/home.go
github.com/AdguardTeam/golibs v0.8.0
<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")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
go.mod
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=
<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> remove "errors" </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
go.sum
"github.com/AdguardTeam/golibs/errors"
<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> 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"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/addr.go
defer func() { err = errors.Annotate(err, "validating hardware address %q: %w", hwa) }()
<mask> <mask> // ValidateHardwareAddress returns an error if hwa is not a valid EUI-48, <mask> // EUI-64, or 20-octet InfiniBand link-layer address. <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 return agherr.Error("address is empty") </s> add return errors.Error("address 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("question is nil") </s> add return errors.Error("question is nil") </s> remove return agherr.Error("client is nil") </s> add return errors.Error("client is nil") </s> remove defer agherr.Annotate("parsing %q: %w", &err, host) </s> add defer func() { err = errors.Annotate(err, "parsing %q: %w", host) }()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/addr.go
return errors.Error("address is empty")
<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: <mask> return nil <mask> default: <mask> return fmt.Errorf("bad len: %d", l) <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 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("validating label %q: %w", &err, label) </s> add defer func() { err = errors.Annotate(err, "validating label %q: %w", label) }() </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 func ReplaceLogLevel(t *testing.T, l int) { </s> add func ReplaceLogLevel(t *testing.T, l log.Level) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/addr.go
defer func() { err = errors.Annotate(err, "validating label %q: %w", label) }()
<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) }()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/addr.go
return errors.Error("label is empty")
<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")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/addr.go
defer func() { err = errors.Annotate(err, "validating domain name %q: %w", name) }()
<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) }()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/addr.go
return errors.Error("domain name is empty")
<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")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/addr.go
<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
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/etchostscontainer.go
"github.com/AdguardTeam/golibs/errors"
<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> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/etchostscontainer.go
defer func() { derr := f.Close() if derr != nil { log.Error("etchostscontainer: closing file: %s", err) } }()
<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)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/etchostscontainer.go
<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
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/net.go
<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> 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
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/net.go
"github.com/AdguardTeam/golibs/errors"
<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> remove rDNSEmptyAnswerErr agherr.Error = "the answer section is empty" </s> add rDNSEmptyAnswerErr errors.Error = "the answer section is empty"
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/net.go
const ErrNoStaticIPInfo errors.Error = "no information about static ip"
<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> 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"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/net.go
return nil, errors.Error("couldn't find any legible interface")
<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)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/net.go
<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
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/net_darwin.go
"github.com/AdguardTeam/golibs/errors"
<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> 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"
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/net_darwin.go