code_before
stringlengths
16
1.81M
edits
stringlengths
4
328k
next_edit
stringlengths
0
76.5k
code_after
stringlengths
3
49.9M
label_window
sequencelengths
4
1.81k
instruction
stringlengths
20
51.9k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
mac, err := net.ParseMAC(c.MAC) if err != nil { continue } ipAddr := dhcpServer.FindIPbyMAC(mac) if ipAddr == nil { continue } if ip == ipAddr.String() { return *c, true
</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)
ipAddr := config.dhcpServer.FindIPbyMAC(mac)
mac, err := net.ParseMAC(c.MAC) if err != nil { continue } ipAddr := config.dhcpServer.FindIPbyMAC(mac) if ipAddr == nil { continue } if ip == ipAddr.String() { return *c, true
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* move "dhcpServer" to "config"
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/clients.go
} if len(c.MAC) != 0 { hwAddr, _ := net.ParseMAC(c.MAC) ipAddr := dhcpServer.FindIPbyMAC(hwAddr) if ipAddr != nil { cj.IP = ipAddr.String() } }
</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()
ipAddr := config.dhcpServer.FindIPbyMAC(hwAddr)
} if len(c.MAC) != 0 { hwAddr, _ := net.ParseMAC(c.MAC) ipAddr := config.dhcpServer.FindIPbyMAC(hwAddr) if ipAddr != nil { cj.IP = ipAddr.String() } }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* move "dhcpServer" to "config"
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/clients.go
versionCheckJSON []byte versionCheckLastTime time.Time httpServer *http.Server httpsServer HTTPSServer BindHost string `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to
</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()
dhcpServer dhcpd.Server
versionCheckJSON []byte versionCheckLastTime time.Time dhcpServer dhcpd.Server httpServer *http.Server httpsServer HTTPSServer BindHost string `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
* move "dhcpServer" to "config"
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/config.go
"github.com/AdguardTeam/golibs/log" "github.com/joomcode/errorx" ) var dhcpServer = dhcpd.Server{} // []dhcpd.Lease -> JSON func convertLeases(inputLeases []dhcpd.Lease, includeExpires bool) []map[string]string { leases := []map[string]string{} for _, l := range inputLeases { lease := map[string]string{
</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)
"github.com/AdguardTeam/golibs/log" "github.com/joomcode/errorx" ) // []dhcpd.Lease -> JSON func convertLeases(inputLeases []dhcpd.Lease, includeExpires bool) []map[string]string { leases := []map[string]string{} for _, l := range inputLeases { lease := map[string]string{
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* move "dhcpServer" to "config"
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
} func handleDHCPStatus(w http.ResponseWriter, r *http.Request) { log.Tracef("%s %v", r.Method, r.URL) leases := convertLeases(dhcpServer.Leases(), true) staticLeases := convertLeases(dhcpServer.StaticLeases(), false) status := map[string]interface{}{ "config": config.DHCP, "leases": leases, "static_leases": staticLeases, }
</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)
leases := convertLeases(config.dhcpServer.Leases(), true) staticLeases := convertLeases(config.dhcpServer.StaticLeases(), false)
} func handleDHCPStatus(w http.ResponseWriter, r *http.Request) { log.Tracef("%s %v", r.Method, r.URL) leases := convertLeases(config.dhcpServer.Leases(), true) staticLeases := convertLeases(config.dhcpServer.StaticLeases(), false) leases := convertLeases(config.dhcpServer.Leases(), true) staticLeases := convertLeases(config.dhcpServer.StaticLeases(), false) status := map[string]interface{}{ "config": config.DHCP, "leases": leases, "static_leases": staticLeases, }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* move "dhcpServer" to "config"
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
httpError(w, http.StatusBadRequest, "Failed to parse new DHCP config json: %s", err) return } err = dhcpServer.CheckConfig(newconfig.ServerConfig) if err != nil { httpError(w, http.StatusBadRequest, "Invalid DHCP configuration: %s", err) return }
</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)
err = config.dhcpServer.CheckConfig(newconfig.ServerConfig)
httpError(w, http.StatusBadRequest, "Failed to parse new DHCP config json: %s", err) return } err = config.dhcpServer.CheckConfig(newconfig.ServerConfig) if err != nil { httpError(w, http.StatusBadRequest, "Invalid DHCP configuration: %s", err) return }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* move "dhcpServer" to "config"
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
httpError(w, http.StatusBadRequest, "Invalid DHCP configuration: %s", err) return } err = dhcpServer.Stop() if err != nil { log.Error("failed to stop the DHCP server: %s", err) } err = dhcpServer.Init(newconfig.ServerConfig)
</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)
err = config.dhcpServer.Stop()
httpError(w, http.StatusBadRequest, "Invalid DHCP configuration: %s", err) return } err = config.dhcpServer.Stop() if err != nil { log.Error("failed to stop the DHCP server: %s", err) } err = dhcpServer.Init(newconfig.ServerConfig)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* move "dhcpServer" to "config"
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
if err != nil { log.Error("failed to stop the DHCP server: %s", err) } err = dhcpServer.Init(newconfig.ServerConfig) if err != nil { httpError(w, http.StatusBadRequest, "Invalid DHCP configuration: %s", err) return }
</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()
err = config.dhcpServer.Init(newconfig.ServerConfig)
if err != nil { log.Error("failed to stop the DHCP server: %s", err) } err = config.dhcpServer.Init(newconfig.ServerConfig) if err != nil { httpError(w, http.StatusBadRequest, "Invalid DHCP configuration: %s", err) return }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* move "dhcpServer" to "config"
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
return } } err = dhcpServer.Start() if err != nil { httpError(w, http.StatusBadRequest, "Failed to start DHCP server: %s", err) return } }
</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)
err = config.dhcpServer.Start()
return } } err = config.dhcpServer.Start() if err != nil { httpError(w, http.StatusBadRequest, "Failed to start DHCP server: %s", err) return } }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* move "dhcpServer" to "config"
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
IP: ip, HWAddr: mac, Hostname: lj.Hostname, } err = dhcpServer.AddStaticLease(lease) if err != nil { httpError(w, http.StatusBadRequest, "%s", err) return } returnOK(w)
</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)
err = config.dhcpServer.AddStaticLease(lease)
IP: ip, HWAddr: mac, Hostname: lj.Hostname, } err = config.dhcpServer.AddStaticLease(lease) if err != nil { httpError(w, http.StatusBadRequest, "%s", err) return } returnOK(w)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* move "dhcpServer" to "config"
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
IP: ip, HWAddr: mac, Hostname: lj.Hostname, } err = dhcpServer.RemoveStaticLease(lease) if err != nil { httpError(w, http.StatusBadRequest, "%s", err) return } returnOK(w)
</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)
err = config.dhcpServer.RemoveStaticLease(lease)
IP: ip, HWAddr: mac, Hostname: lj.Hostname, } err = config.dhcpServer.RemoveStaticLease(lease) if err != nil { httpError(w, http.StatusBadRequest, "%s", err) return } returnOK(w)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* move "dhcpServer" to "config"
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
// not enabled, don't do anything return nil } err := dhcpServer.Init(config.DHCP) if err != nil { return errorx.Decorate(err, "Couldn't init DHCP server") } err = dhcpServer.Start()
</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)
err := config.dhcpServer.Init(config.DHCP)
// not enabled, don't do anything return nil } err := config.dhcpServer.Init(config.DHCP) if err != nil { return errorx.Decorate(err, "Couldn't init DHCP server") } err = dhcpServer.Start()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* move "dhcpServer" to "config"
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
if err != nil { return errorx.Decorate(err, "Couldn't init DHCP server") } err = dhcpServer.Start() if err != nil { return errorx.Decorate(err, "Couldn't start DHCP server") } return nil }
</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)
err = config.dhcpServer.Start()
if err != nil { return errorx.Decorate(err, "Couldn't init DHCP server") } err = config.dhcpServer.Start() if err != nil { return errorx.Decorate(err, "Couldn't start DHCP server") } return nil }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* move "dhcpServer" to "config"
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
if !config.DHCP.Enabled { return nil } err := dhcpServer.Stop() if err != nil { return errorx.Decorate(err, "Couldn't stop DHCP server") } return nil
</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)
err := config.dhcpServer.Stop()
if !config.DHCP.Enabled { return nil } err := config.dhcpServer.Stop() if err != nil { return errorx.Decorate(err, "Couldn't stop DHCP server") } return nil
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* move "dhcpServer" to "config"
https://github.com/AdguardTeam/AdGuardHome/commit/001b4b981f0fd9563fa87724fe44a32c5d7bbc4b
home/dhcp.go
github.com/gobuffalo/packr v1.30.1 github.com/gobuffalo/packr/v2 v2.8.1 // indirect github.com/google/go-cmp v0.5.5 // indirect github.com/hugelgupf/socketpair v0.0.0-20190730060125-05d35a94e714 github.com/insomniacslk/dhcp v0.0.0-20210310193751-cfd4d47082c2 github.com/kardianos/service v1.2.0 github.com/karrick/godirwalk v1.16.1 // indirect github.com/lucas-clemente/quic-go v0.19.3 github.com/marten-seemann/qtls-go1-15 v0.1.4 // indirect
</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)
github.com/google/renameio v1.0.1-0.20210406141108-81588dbe0453
github.com/gobuffalo/packr v1.30.1 github.com/gobuffalo/packr/v2 v2.8.1 // indirect github.com/google/go-cmp v0.5.5 // indirect github.com/google/renameio v1.0.1-0.20210406141108-81588dbe0453 github.com/hugelgupf/socketpair v0.0.0-20190730060125-05d35a94e714 github.com/insomniacslk/dhcp v0.0.0-20210310193751-cfd4d47082c2 github.com/kardianos/service v1.2.0 github.com/karrick/godirwalk v1.16.1 // indirect github.com/lucas-clemente/quic-go v0.19.3 github.com/marten-seemann/qtls-go1-15 v0.1.4 // indirect
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
go.mod
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
</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)
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=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= 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= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
go.sum
"os" "strings" "github.com/AdguardTeam/AdGuardHome/internal/aghio" "github.com/AdguardTeam/golibs/file" ) // maxConfigFileSize is the maximum length of interfaces configuration file. const maxConfigFileSize = 1024 * 1024
</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"
"os" "strings" "github.com/AdguardTeam/AdGuardHome/internal/aghio" "github.com/google/renameio/maybe" ) // maxConfigFileSize is the maximum length of interfaces configuration file. const maxConfigFileSize = 1024 * 1024
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/aghnet/net_linux.go
return err } body = append(body, []byte(add)...) err = file.SafeWrite("/etc/dhcpcd.conf", body) if err != nil { return err } return nil
</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)
err = maybe.WriteFile("/etc/dhcpcd.conf", body, 0o644)
return err } body = append(body, []byte(add)...) err = maybe.WriteFile("/etc/dhcpcd.conf", body, 0o644) if err != nil { return err } return nil
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/aghnet/net_linux.go
body = append(body, []byte(add)...) err = file.SafeWrite("/etc/dhcpcd.conf", body) if err != nil { return err } return nil }
</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",
return fmt.Errorf("writing conf: %w", err)
body = append(body, []byte(add)...) err = file.SafeWrite("/etc/dhcpcd.conf", body) if err != nil { return fmt.Errorf("writing conf: %w", err) } return nil }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/aghnet/net_linux.go
"net" "os" "time" "github.com/AdguardTeam/golibs/file" "github.com/AdguardTeam/golibs/log" ) const dbFilename = "leases.db"
</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
"net" "os" "time" "github.com/AdguardTeam/golibs/log" ) const dbFilename = "leases.db"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/dhcpd/db.go
"github.com/AdguardTeam/golibs/log" ) const dbFilename = "leases.db"
</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
"github.com/google/renameio/maybe"
"github.com/AdguardTeam/golibs/log" "github.com/google/renameio/maybe" ) const dbFilename = "leases.db"
[ "keep", "add", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/dhcpd/db.go
obj := []leaseJSON{} err = json.Unmarshal(data, &obj) if err != nil { log.Error("DHCP: invalid DB: %v", err) return } numLeases := len(obj) for i := range obj {
</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)
log.Error("dhcp: invalid DB: %v", err)
obj := []leaseJSON{} err = json.Unmarshal(data, &obj) if err != nil { log.Error("dhcp: invalid DB: %v", err) return } numLeases := len(obj) for i := range obj {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/dhcpd/db.go
for i := range obj { obj[i].IP = normalizeIP(obj[i].IP) if !(len(obj[i].IP) == 4 || len(obj[i].IP) == 16) { log.Info("DHCP: invalid IP: %s", obj[i].IP) continue } lease := Lease{ HWAddr: obj[i].HWAddr,
</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)
log.Info("dhcp: invalid IP: %s", obj[i].IP)
for i := range obj { obj[i].IP = normalizeIP(obj[i].IP) if !(len(obj[i].IP) == 4 || len(obj[i].IP) == 16) { log.Info("dhcp: invalid IP: %s", obj[i].IP) continue } lease := Lease{ HWAddr: obj[i].HWAddr,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/dhcpd/db.go
if s.srv6 != nil { s.srv6.ResetLeases(leases6) } log.Info("DHCP: loaded leases v4:%d v6:%d total-read:%d from DB", len(leases4), len(leases6), numLeases) } // Skip duplicate leases // Static leases have a priority over dynamic leases
</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"
log.Info("dhcp: loaded leases v4:%d v6:%d total-read:%d from DB",
if s.srv6 != nil { s.srv6.ResetLeases(leases6) } log.Info("dhcp: loaded leases v4:%d v6:%d total-read:%d from DB", len(leases4), len(leases6), numLeases) } // Skip duplicate leases // Static leases have a priority over dynamic leases
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/dhcpd/db.go
log.Error("json.Marshal: %v", err) return } err = file.SafeWrite(s.conf.DBFilePath, data) if err != nil { log.Error("DHCP: can't store lease table on disk: %v filename: %s", err, s.conf.DBFilePath) return }
</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)
err = maybe.WriteFile(s.conf.DBFilePath, data, 0o644)
log.Error("json.Marshal: %v", err) return } err = maybe.WriteFile(s.conf.DBFilePath, data, 0o644) if err != nil { log.Error("DHCP: can't store lease table on disk: %v filename: %s", err, s.conf.DBFilePath) return }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/dhcpd/db.go
} err = file.SafeWrite(s.conf.DBFilePath, data) if err != nil { log.Error("DHCP: can't store lease table on disk: %v filename: %s", err, s.conf.DBFilePath) return } log.Info("DHCP: stored %d leases in DB", len(leases)) }
</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)
log.Error("dhcp: can't store lease table on disk: %v filename: %s",
} err = file.SafeWrite(s.conf.DBFilePath, data) if err != nil { log.Error("dhcp: can't store lease table on disk: %v filename: %s", err, s.conf.DBFilePath) return } log.Info("DHCP: stored %d leases in DB", len(leases)) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/dhcpd/db.go
log.Error("DHCP: can't store lease table on disk: %v filename: %s", err, s.conf.DBFilePath) return } 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 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)
log.Info("dhcp: stored %d leases in DB", len(leases))
log.Error("DHCP: can't store lease table on disk: %v filename: %s", err, s.conf.DBFilePath) return } log.Info("dhcp: stored %d leases in DB", len(leases)) }
[ "keep", "keep", "keep", "keep", "replace", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/dhcpd/db.go
"github.com/AdguardTeam/AdGuardHome/internal/dnsforward" "github.com/AdguardTeam/AdGuardHome/internal/querylog" "github.com/AdguardTeam/AdGuardHome/internal/stats" "github.com/AdguardTeam/AdGuardHome/internal/version" "github.com/AdguardTeam/golibs/file" "github.com/AdguardTeam/golibs/log" yaml "gopkg.in/yaml.v2" ) const (
</s> remove "github.com/AdguardTeam/golibs/file" </s> add </s> remove "github.com/AdguardTeam/golibs/file" </s> add
"github.com/AdguardTeam/AdGuardHome/internal/dnsforward" "github.com/AdguardTeam/AdGuardHome/internal/querylog" "github.com/AdguardTeam/AdGuardHome/internal/stats" "github.com/AdguardTeam/AdGuardHome/internal/version" "github.com/AdguardTeam/golibs/log" yaml "gopkg.in/yaml.v2" ) const (
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/home/config.go
"github.com/AdguardTeam/AdGuardHome/internal/version" "github.com/AdguardTeam/golibs/log" yaml "gopkg.in/yaml.v2" ) const (
</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"
"github.com/AdguardTeam/AdGuardHome/internal/version" "github.com/AdguardTeam/golibs/log" "github.com/google/renameio/maybe" yaml "gopkg.in/yaml.v2" ) const (
[ "keep", "add", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/home/config.go
if err != nil { log.Error("Couldn't generate YAML file: %s", err) return err } err = file.SafeWrite(configFile, yamlText) if err != nil { log.Error("Couldn't save YAML config: %s", err) return err }
</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)
err = maybe.WriteFile(configFile, yamlText, 0o644)
if err != nil { log.Error("Couldn't generate YAML file: %s", err) return err } err = maybe.WriteFile(configFile, yamlText, 0o644) if err != nil { log.Error("Couldn't save YAML config: %s", err) return err }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/home/config.go
"path" "path/filepath" "runtime" "github.com/AdguardTeam/golibs/file" "github.com/AdguardTeam/golibs/log" "golang.org/x/crypto/bcrypt" yaml "gopkg.in/yaml.v2" )
</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"
"path" "path/filepath" "runtime" "github.com/AdguardTeam/golibs/log" "golang.org/x/crypto/bcrypt" yaml "gopkg.in/yaml.v2" )
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/home/upgrade.go
"github.com/AdguardTeam/golibs/log" "golang.org/x/crypto/bcrypt" yaml "gopkg.in/yaml.v2" ) // currentSchemaVersion is the current schema version.
</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
"github.com/google/renameio/maybe"
"github.com/AdguardTeam/golibs/log" "github.com/google/renameio/maybe" "golang.org/x/crypto/bcrypt" yaml "gopkg.in/yaml.v2" ) // currentSchemaVersion is the current schema version.
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/home/upgrade.go
} config.fileData = body confFile := config.getConfigFilename() err = file.SafeWrite(confFile, body) if err != nil { return fmt.Errorf("saving new config: %w", err) } return nil
</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)
err = maybe.WriteFile(confFile, body, 0o644)
} config.fileData = body confFile := config.getConfigFilename() err = maybe.WriteFile(confFile, body, 0o644) if err != nil { return fmt.Errorf("saving new config: %w", err) } return nil
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/00a61fdea0b974ced597857060798d4ec87f2e29
internal/home/upgrade.go
return } } type ipport struct { IP string `json:"ip,omitempty"` Port int `json:"port"` Warning string `json:"warning"` } type firstRunData struct { Web ipport `json:"web"` DNS ipport `json:"dns"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"`
</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
return } } type firstRunData struct { Web ipport `json:"web"` DNS ipport `json:"dns"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"`
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* control: /install/get_addresses: don't check if ports are available * always use port 80
https://github.com/AdguardTeam/AdGuardHome/commit/00c128f0a4deff119f93d02de03fa3fc47c54ec1
control.go
Warning string `json:"warning"` } type firstRunData struct { Web ipport `json:"web"` DNS ipport `json:"dns"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` Interfaces map[string]interface{} `json:"interfaces"` }
</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
WebPort int `json:"web_port"` DNSPort int `json:"dns_port"`
Warning string `json:"warning"` } type firstRunData struct { WebPort int `json:"web_port"` DNSPort int `json:"dns_port"` WebPort int `json:"web_port"` DNSPort int `json:"dns_port"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` Interfaces map[string]interface{} `json:"interfaces"` }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* control: /install/get_addresses: don't check if ports are available * always use port 80
https://github.com/AdguardTeam/AdGuardHome/commit/00c128f0a4deff119f93d02de03fa3fc47c54ec1
control.go
func handleInstallGetAddresses(w http.ResponseWriter, r *http.Request) { log.Tracef("%s %v", r.Method, r.URL) data := firstRunData{} // 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." } ifaces, err := getValidNetInterfacesForWeb() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return
</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"`
data.WebPort = 80 data.DNSPort = 53
func handleInstallGetAddresses(w http.ResponseWriter, r *http.Request) { log.Tracef("%s %v", r.Method, r.URL) data := firstRunData{} data.WebPort = 80 data.DNSPort = 53 data.WebPort = 80 data.DNSPort = 53 data.WebPort = 80 data.DNSPort = 53 data.WebPort = 80 data.DNSPort = 53 data.WebPort = 80 data.DNSPort = 53 data.WebPort = 80 data.DNSPort = 53 data.WebPort = 80 data.DNSPort = 53 data.WebPort = 80 data.DNSPort = 53 data.WebPort = 80 data.DNSPort = 53 data.WebPort = 80 data.DNSPort = 53 data.WebPort = 80 data.DNSPort = 53 data.WebPort = 80 data.DNSPort = 53 data.WebPort = 80 data.DNSPort = 53 ifaces, err := getValidNetInterfacesForWeb() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
* control: /install/get_addresses: don't check if ports are available * always use port 80
https://github.com/AdguardTeam/AdGuardHome/commit/00c128f0a4deff119f93d02de03fa3fc47c54ec1
control.go
"encryption_private_key_path": "Private key path", "encryption_certificates_source_path": "Set a certificates file path", "encryption_certificates_source_content":"Paste the certificates contents", "encryption_key_source_path": "Set a private key file", "encryption_key_source_content": "Paste the private key contents" }
</s> remove const { settings, services } = state; </s> add const { settings, services, stats } = state;
"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"
"encryption_private_key_path": "Private key path", "encryption_certificates_source_path": "Set a certificates file path", "encryption_certificates_source_content":"Paste the certificates contents", "encryption_key_source_path": "Set a private key file", "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" }
[ "keep", "keep", "keep", "keep", "replace", "keep" ]
+ client: handle time interval for statistics
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/__locales/en.json
height: 23px; min-width: 23px; padding: 5px; }
</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,
.custom-control-label, .custom-control-label:before { transition: 0.3s ease-in-out background-color, 0.3s ease-in-out color; }
height: 23px; min-width: 23px; padding: 5px; } .custom-control-label, .custom-control-label:before { transition: 0.3s ease-in-out background-color, 0.3s ease-in-out color; }
[ "keep", "keep", "keep", "add" ]
+ client: handle time interval for statistics
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/components/Settings/Settings.css
import { withNamespaces, Trans } from 'react-i18next'; import Services from './Services'; import Checkbox from '../ui/Checkbox'; import Loading from '../ui/Loading'; import PageTitle from '../ui/PageTitle'; import Card from '../ui/Card';
</s> remove const { settings, services } = state; </s> add const { settings, services, stats } = state;
import StatsConfig from './StatsConfig';
import { withNamespaces, Trans } from 'react-i18next'; import Services from './Services'; import StatsConfig from './StatsConfig'; import Checkbox from '../ui/Checkbox'; import Loading from '../ui/Loading'; import PageTitle from '../ui/PageTitle'; import Card from '../ui/Card';
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
+ client: handle time interval for statistics
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/components/Settings/index.js
this.props.initSettings(this.settings); this.props.getBlockedServices(); } renderSettings = (settings) => { if (Object.keys(settings).length > 0) { return Object.keys(settings).map((key) => {
</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: [], });
this.props.getStatsConfig();
this.props.initSettings(this.settings); this.props.getBlockedServices(); this.props.getStatsConfig(); } renderSettings = (settings) => { if (Object.keys(settings).length > 0) { return Object.keys(settings).map((key) => {
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
+ client: handle time interval for statistics
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/components/Settings/index.js
}; render() { const { settings, services, setBlockedServices, t, } = this.props; return ( <Fragment> <PageTitle title={t('general_settings')} /> {settings.processing && <Loading />}
</s> remove const { settings, services } = state; </s> add const { settings, services, stats } = state;
settings, services, setBlockedServices, setStatsConfig, stats, t,
}; render() { const { settings, services, setBlockedServices, setStatsConfig, stats, t, } = this.props; return ( <Fragment> <PageTitle title={t('general_settings')} /> {settings.processing && <Loading />}
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
+ client: handle time interval for statistics
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/components/Settings/index.js
</div> </Card> </div> <div className="col-md-12"> <Services services={services} setBlockedServices={setBlockedServices} /> </div>
</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: [], });
<div className="col-md-12"> <StatsConfig interval={stats.interval} processing={stats.setConfigProcessing} setStatsConfig={setStatsConfig} /> </div>
</div> </Card> </div> <div className="col-md-12"> <StatsConfig interval={stats.interval} processing={stats.setConfigProcessing} setStatsConfig={setStatsConfig} /> </div> <div className="col-md-12"> <Services services={services} setBlockedServices={setBlockedServices} /> </div>
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
+ client: handle time interval for statistics
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/components/Settings/index.js
initSettings: PropTypes.func, settings: PropTypes.object, settingsList: PropTypes.object, toggleSetting: PropTypes.func, t: PropTypes.func, }; export default withNamespaces()(Settings);
</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;
getStatsConfig: PropTypes.func, setStatsConfig: PropTypes.func,
initSettings: PropTypes.func, settings: PropTypes.object, settingsList: PropTypes.object, toggleSetting: PropTypes.func, getStatsConfig: PropTypes.func, setStatsConfig: PropTypes.func, t: PropTypes.func, }; export default withNamespaces()(Settings);
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
+ client: handle time interval for statistics
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/components/Settings/index.js
import { initSettings, toggleSetting } from '../actions'; import { getBlockedServices, setBlockedServices } from '../actions/services'; import Settings from '../components/Settings'; const mapStateToProps = (state) => { const { settings, services, stats } = state;
</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,
import { getStatsConfig, setStatsConfig } from '../actions/stats';
import { initSettings, toggleSetting } from '../actions'; import { getBlockedServices, setBlockedServices } from '../actions/services'; import { getStatsConfig, setStatsConfig } from '../actions/stats'; import Settings from '../components/Settings'; const mapStateToProps = (state) => { const { settings, services, stats } = state;
[ "keep", "add", "keep", "keep", "keep", "keep" ]
+ client: handle time interval for statistics
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/containers/Settings.js
import { getBlockedServices, setBlockedServices } from '../actions/services'; import Settings from '../components/Settings'; const mapStateToProps = (state) => { const { settings, services } = state; const props = { settings, services, }; return props;
</s> remove settings, services, setBlockedServices, t, </s> add settings, services, setBlockedServices, setStatsConfig, stats, t,
const { settings, services, stats } = state;
import { getBlockedServices, setBlockedServices } from '../actions/services'; import Settings from '../components/Settings'; const mapStateToProps = (state) => { const { settings, services, stats } = state; const props = { settings, services, }; return props;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
+ client: handle time interval for statistics
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/containers/Settings.js
const { settings, services, stats } = state; const props = { settings, services, }; return props; }; const mapDispatchToProps = { initSettings,
</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,
stats,
const { settings, services, stats } = state; const props = { settings, services, stats, }; return props; }; const mapDispatchToProps = { initSettings,
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
+ client: handle time interval for statistics
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/containers/Settings.js
initSettings, toggleSetting, getBlockedServices, setBlockedServices, }; export default connect( mapStateToProps, mapDispatchToProps,
</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;
getStatsConfig, setStatsConfig,
initSettings, toggleSetting, getBlockedServices, setBlockedServices, getStatsConfig, setStatsConfig, }; export default connect( mapStateToProps, mapDispatchToProps,
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
+ client: handle time interval for statistics
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/containers/Settings.js
import access from './access'; import rewrites from './rewrites'; import services from './services'; const settings = handleActions({ [actions.initSettingsRequest]: state => ({ ...state, processing: true }), [actions.initSettingsFailure]: state => ({ ...state, processing: false }),
</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;
import stats from './stats';
import access from './access'; import rewrites from './rewrites'; import services from './services'; import stats from './stats'; const settings = handleActions({ [actions.initSettingsRequest]: state => ({ ...state, processing: true }), [actions.initSettingsFailure]: state => ({ ...state, processing: false }),
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
+ client: handle time interval for statistics
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/reducers/index.js
dnsVersion: '', clients: [], autoClients: [], topStats: [], }); const queryLogs = handleActions({ [actions.getLogsRequest]: state => ({ ...state, getLogsProcessing: true }), [actions.getLogsFailure]: state => ({ ...state, getLogsProcessing: false }),
</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;
stats: { dns_queries: '', blocked_filtering: '', replaced_safebrowsing: '', replaced_parental: '', replaced_safesearch: '', avg_processing_time: '', },
dnsVersion: '', clients: [], autoClients: [], topStats: [], stats: { dns_queries: '', blocked_filtering: '', replaced_safebrowsing: '', replaced_parental: '', replaced_safesearch: '', avg_processing_time: '', }, }); const queryLogs = handleActions({ [actions.getLogsRequest]: state => ({ ...state, getLogsProcessing: true }), [actions.getLogsFailure]: state => ({ ...state, getLogsProcessing: false }),
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
+ client: handle time interval for statistics
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/reducers/index.js
}, [actions.downloadQueryLogRequest]: state => ({ ...state, logsDownloading: true }), [actions.downloadQueryLogFailure]: state => ({ ...state, logsDownloading: false }), [actions.downloadQueryLogSuccess]: state => ({ ...state, logsDownloading: false }), }, { getLogsProcessing: false, logsDownloading: false }); const filtering = handleActions({ [actions.setRulesRequest]: state => ({ ...state, processingRules: true }), [actions.setRulesFailure]: state => ({ ...state, processingRules: false }), [actions.setRulesSuccess]: state => ({ ...state, processingRules: false }),
</s> remove const { settings, services } = state; </s> add const { settings, services, stats } = state;
}, { getLogsProcessing: false, logsDownloading: false, logs: [], });
}, [actions.downloadQueryLogRequest]: state => ({ ...state, logsDownloading: true }), [actions.downloadQueryLogFailure]: state => ({ ...state, logsDownloading: false }), [actions.downloadQueryLogSuccess]: state => ({ ...state, logsDownloading: false }), }, { getLogsProcessing: false, logsDownloading: false, logs: [], }); const filtering = handleActions({ [actions.setRulesRequest]: state => ({ ...state, processingRules: true }), [actions.setRulesFailure]: state => ({ ...state, processingRules: false }), [actions.setRulesSuccess]: state => ({ ...state, processingRules: false }),
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
+ client: handle time interval for statistics
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/reducers/index.js
rewrites, services, loadingBar: loadingBarReducer, form: formReducer, });
</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;
stats,
rewrites, services, stats, loadingBar: loadingBarReducer, form: formReducer, });
[ "keep", "add", "keep", "keep", "keep" ]
+ client: handle time interval for statistics
https://github.com/AdguardTeam/AdGuardHome/commit/011bc3e36bb5ede69f1e459e32004adc748e1f9d
client/src/reducers/index.js
const fs = require('fs'); const request = require('request-promise'); const twoskyConfig = require('../../.twosky.json')[0]; const { project_id: TWOSKY_PROJECT_ID, base_locale: LANGUAGE } = twoskyConfig; const LOCALES_DIR = '../../client/src/__locales'; const BASE_FILE = 'en.json'; const TWOSKY_URI = process.env.TWOSKY_URI; /**
</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`)),
const { project_id: TWOSKY_PROJECT_ID, base_locale: DEFAULT_LANGUAGE } = twoskyConfig;
const fs = require('fs'); const request = require('request-promise'); const twoskyConfig = require('../../.twosky.json')[0]; const { project_id: TWOSKY_PROJECT_ID, base_locale: DEFAULT_LANGUAGE } = twoskyConfig; const LOCALES_DIR = '../../client/src/__locales'; const BASE_FILE = 'en.json'; const TWOSKY_URI = process.env.TWOSKY_URI; /**
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/0122710750ae3c8c5039886cd27ec14c9579c85b
scripts/translations/upload.js
/** * Prepare post params */ const getRequestData = (url, projectId) => { const formData = { format: 'json', language: language, filename: BASE_FILE,
</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`)),
const language = process.env.UPLOAD_LANGUAGE || DEFAULT_LANGUAGE;
/** * Prepare post params */ const getRequestData = (url, projectId) => { const language = process.env.UPLOAD_LANGUAGE || DEFAULT_LANGUAGE; const formData = { format: 'json', language: language, filename: BASE_FILE,
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/0122710750ae3c8c5039886cd27ec14c9579c85b
scripts/translations/upload.js
*/ const getRequestData = (url, projectId) => { const formData = { format: 'json', language: LANGUAGE, filename: BASE_FILE, project: projectId, file: fs.createReadStream(path.resolve(LOCALES_DIR, `${LANGUAGE}.json`)), };
</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;
language: language,
*/ const getRequestData = (url, projectId) => { const formData = { format: 'json', language: language, filename: BASE_FILE, project: projectId, file: fs.createReadStream(path.resolve(LOCALES_DIR, `${LANGUAGE}.json`)), };
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/0122710750ae3c8c5039886cd27ec14c9579c85b
scripts/translations/upload.js
format: 'json', language: LANGUAGE, filename: BASE_FILE, project: projectId, file: fs.createReadStream(path.resolve(LOCALES_DIR, `${LANGUAGE}.json`)), }; return { url: `${url}/upload`, formData
</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;
file: fs.createReadStream(path.resolve(LOCALES_DIR, `${language}.json`)),
format: 'json', language: LANGUAGE, filename: BASE_FILE, project: projectId, file: fs.createReadStream(path.resolve(LOCALES_DIR, `${language}.json`)), }; return { url: `${url}/upload`, formData
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/0122710750ae3c8c5039886cd27ec14c9579c85b
scripts/translations/upload.js
file: fs.createReadStream(path.resolve(LOCALES_DIR, `${language}.json`)), }; return { url: `${url}/upload`, formData }; };
</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;
console.log(`uploading ${language}`);
file: fs.createReadStream(path.resolve(LOCALES_DIR, `${language}.json`)), }; console.log(`uploading ${language}`); return { url: `${url}/upload`, formData }; };
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/0122710750ae3c8c5039886cd27ec14c9579c85b
scripts/translations/upload.js
package rewrite import ( "fmt" "net" "strings" "github.com/miekg/dns" )
</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
"net/netip"
package rewrite import ( "fmt" "net/netip" "strings" "github.com/miekg/dns" )
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/item.go
} else if other == nil { return false } return rw.Domain == other.Domain && rw.Answer == other.Answer } // toRule converts rw to a filter rule. func (rw *Item) toRule() (res string) { domain := strings.ToLower(rw.Domain)
</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) {
return *rw == *other
} else if other == nil { return false } return *rw == *other } // toRule converts rw to a filter rule. func (rw *Item) toRule() (res string) { domain := strings.ToLower(rw.Domain)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/item.go
// toRule converts rw to a filter rule. func (rw *Item) toRule() (res string) { domain := strings.ToLower(rw.Domain) dType, exception := rw.rewriteParams() dTypeKey := dns.TypeToString[dType] if exception { return fmt.Sprintf("@@||%s^$dnstype=%s,dnsrewrite", domain, dTypeKey)
</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) {
if rw == nil { return "" }
// toRule converts rw to a filter rule. func (rw *Item) toRule() (res string) { if rw == nil { return "" } domain := strings.ToLower(rw.Domain) dType, exception := rw.rewriteParams() dTypeKey := dns.TypeToString[dType] if exception { return fmt.Sprintf("@@||%s^$dnstype=%s,dnsrewrite", domain, dTypeKey)
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/item.go
default: // Go on. } ip := net.ParseIP(rw.Answer) if ip == nil { return dns.TypeCNAME, false } ip4 := ip.To4() if ip4 != nil {
</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
addr, err := netip.ParseAddr(rw.Answer) if err != nil { // TODO(d.kolyshev): Validate rw.Answer as a domain name.
default: // Go on. } addr, err := netip.ParseAddr(rw.Answer) if err != nil { // TODO(d.kolyshev): Validate rw.Answer as a domain name. addr, err := netip.ParseAddr(rw.Answer) if err != nil { // TODO(d.kolyshev): Validate rw.Answer as a domain name. return dns.TypeCNAME, false } ip4 := ip.To4() if ip4 != nil {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/item.go
if ip == nil { return dns.TypeCNAME, false } ip4 := ip.To4() if ip4 != nil { dType = dns.TypeA } else { dType = dns.TypeAAAA }
</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)
if addr.Is4() {
if ip == nil { return dns.TypeCNAME, false } if addr.Is4() { if addr.Is4() { dType = dns.TypeA } else { dType = dns.TypeAAAA }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/item.go
"sync" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/urlfilter" "github.com/AdguardTeam/urlfilter/filterlist" "github.com/AdguardTeam/urlfilter/rules" "github.com/miekg/dns" "golang.org/x/exp/slices" )
</s> remove "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> add </s> remove "github.com/AdguardTeam/golibs/log" </s> add
"github.com/AdguardTeam/golibs/stringutil"
"sync" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/stringutil" "github.com/AdguardTeam/urlfilter" "github.com/AdguardTeam/urlfilter/filterlist" "github.com/AdguardTeam/urlfilter/rules" "github.com/miekg/dns" "golang.org/x/exp/slices" )
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage.go
"github.com/AdguardTeam/golibs/stringutil" "github.com/AdguardTeam/urlfilter" "github.com/AdguardTeam/urlfilter/filterlist" "golang.org/x/exp/slices" ) // Storage is a storage for rewrite rules. type Storage interface {
</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
"github.com/AdguardTeam/urlfilter/rules" "github.com/miekg/dns"
"github.com/AdguardTeam/golibs/stringutil" "github.com/AdguardTeam/urlfilter" "github.com/AdguardTeam/urlfilter/filterlist" "github.com/AdguardTeam/urlfilter/rules" "github.com/miekg/dns" "golang.org/x/exp/slices" ) // Storage is a storage for rewrite rules. type Storage interface {
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage.go
) // Storage is a storage for rewrite rules. type Storage interface { // MatchRequest finds a matching rule for the specified request. MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool) // Add adds item to the storage. Add(item *Item) (err error) // Remove deletes item from the storage.
</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
// MatchRequest returns matching dnsrewrites for the specified request. MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite)
) // Storage is a storage for rewrite rules. type Storage interface { // MatchRequest returns matching dnsrewrites for the specified request. MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) // MatchRequest returns matching dnsrewrites for the specified request. MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) // Add adds item to the storage. Add(item *Item) (err error) // Remove deletes item from the storage.
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage.go
ruleList filterlist.RuleList // urlFilterID is the synthetic integer identifier for the urlfilter engine. // // TODO(a.garipov): Change the type to a string in module urlfilter and // remove this crutch. urlFilterID int }
</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)
// rewrites stores the rewrite entries from configuration. rewrites []*Item
ruleList filterlist.RuleList // rewrites stores the rewrite entries from configuration. rewrites []*Item // urlFilterID is the synthetic integer identifier for the urlfilter engine. // // TODO(a.garipov): Change the type to a string in module urlfilter and // remove this crutch. urlFilterID int }
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage.go
// // TODO(a.garipov): Change the type to a string in module urlfilter and // remove this crutch. urlFilterID int // rewrites stores the rewrite entries from configuration. rewrites []*Item } // NewDefaultStorage returns new rewrites storage. listID is used as an // identifier of the underlying rules list. rewrites must not be nil. func NewDefaultStorage(listID int, rewrites []*Item) (s *DefaultStorage, err error) {
</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
// // TODO(a.garipov): Change the type to a string in module urlfilter and // remove this crutch. urlFilterID int } // NewDefaultStorage returns new rewrites storage. listID is used as an // identifier of the underlying rules list. rewrites must not be nil. func NewDefaultStorage(listID int, rewrites []*Item) (s *DefaultStorage, err error) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage.go
// type check var _ Storage = (*DefaultStorage)(nil) // MatchRequest implements the [Storage] interface for *DefaultStorage. func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (res *urlfilter.DNSResult, matched bool) { s.mu.RLock() defer s.mu.RUnlock() return s.engine.MatchRequest(dReq) }
</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
func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) {
// type check var _ Storage = (*DefaultStorage)(nil) // MatchRequest implements the [Storage] interface for *DefaultStorage. func (s *DefaultStorage) MatchRequest(dReq *urlfilter.DNSRequest) (rws []*rules.DNSRewrite) { s.mu.RLock() defer s.mu.RUnlock() return s.engine.MatchRequest(dReq) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage.go
// resetRules resets the filtering rules. func (s *DefaultStorage) resetRules() (err error) { var rulesText []string for _, rewrite := range s.rewrites { rulesText = append(rulesText, rewrite.toRule()) }
</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
// TODO(a.garipov): Use strings.Builder.
// resetRules resets the filtering rules. func (s *DefaultStorage) resetRules() (err error) { // TODO(a.garipov): Use strings.Builder. var rulesText []string for _, rewrite := range s.rewrites { rulesText = append(rulesText, rewrite.toRule()) }
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage.go
s.ruleList = strList s.engine = urlfilter.NewDNSEngine(rs) log.Info("filter %d: reset %d rules", s.urlFilterID, s.engine.RulesCount) return nil }
</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.
log.Info("rewrite: filter %d: reset %d rules", s.urlFilterID, s.engine.RulesCount)
s.ruleList = strList s.engine = urlfilter.NewDNSEngine(rs) log.Info("rewrite: filter %d: reset %d rules", s.urlFilterID, s.engine.RulesCount) return nil }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage.go
package rewrite import ( "testing" "github.com/AdguardTeam/urlfilter" "github.com/AdguardTeam/urlfilter/rules" "github.com/miekg/dns" "github.com/stretchr/testify/assert"
</s> remove "net" </s> add "net/netip" </s> remove "encoding/json" </s> add
"net"
package rewrite import ( "net" "testing" "github.com/AdguardTeam/urlfilter" "github.com/AdguardTeam/urlfilter/rules" "github.com/miekg/dns" "github.com/stretchr/testify/assert"
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage_test.go
"net" "testing" "github.com/stretchr/testify/require" ) func TestNewDefaultStorage(t *testing.T) { items := []*Item{{ Domain: "example.com",
</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"
"github.com/AdguardTeam/urlfilter" "github.com/AdguardTeam/urlfilter/rules" "github.com/miekg/dns" "github.com/stretchr/testify/assert"
"net" "testing" "github.com/AdguardTeam/urlfilter" "github.com/AdguardTeam/urlfilter/rules" "github.com/miekg/dns" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestNewDefaultStorage(t *testing.T) { items := []*Item{{ Domain: "example.com",
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrite/storage_test.go
package filtering import ( "encoding/json" "fmt" "net" "net/http" "sort" "strings"
</s> remove "net/http" </s> add </s> remove "net" </s> add "net/netip" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> add
package filtering import ( "fmt" "net" "net/http" "sort" "strings"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrites.go
import ( "encoding/json" "fmt" "net" "net/http" "sort" "strings" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/errors"
</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
import ( "encoding/json" "fmt" "net" "sort" "strings" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/errors"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrites.go
"net/http" "sort" "strings" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/miekg/dns" "golang.org/x/exp/slices" )
</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"
"net/http" "sort" "strings" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/miekg/dns" "golang.org/x/exp/slices" )
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrites.go
"strings" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/miekg/dns" "golang.org/x/exp/slices" ) // TODO(d.kolyshev): Rename this file to rewritehttp.go.
</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
"strings" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/errors" "github.com/miekg/dns" "golang.org/x/exp/slices" ) // TODO(d.kolyshev): Rename this file to rewritehttp.go.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrites.go
"github.com/miekg/dns" "golang.org/x/exp/slices" ) // TODO(d.kolyshev): Rename this file to rewritehttp.go. // LegacyRewrite is a single legacy DNS rewrite record. // // Instances of *LegacyRewrite must never be nil. type LegacyRewrite struct { // Domain is the domain pattern for which this rewrite should work.
</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
"github.com/miekg/dns" "golang.org/x/exp/slices" ) // LegacyRewrite is a single legacy DNS rewrite record. // // Instances of *LegacyRewrite must never be nil. type LegacyRewrite struct { // Domain is the domain pattern for which this rewrite should work.
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrites.go
} return b } 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> 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
} return b }
[ "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" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrites.go
"github.com/stretchr/testify/require" ) // TODO(e.burkov): All the tests in this file may and should me merged together. // TODO(d.kolyshev): Move these tests to rewrite package. func TestRewrites(t *testing.T) { d, _ := newForTest(t, nil, nil) t.Cleanup(d.Close)
</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
"github.com/stretchr/testify/require" ) // TODO(e.burkov): All the tests in this file may and should me merged together. func TestRewrites(t *testing.T) { d, _ := newForTest(t, nil, nil) t.Cleanup(d.Close)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38
internal/filtering/rewrites_test.go
} log.Info("Stopped") } // 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 } // loadOptions reads command line arguments and initializes configuration func loadOptions() options { o := options{}
</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
func exitWithError() { os.Exit(64)
} log.Info("Stopped") } func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) func exitWithError() { os.Exit(64) } // loadOptions reads command line arguments and initializes configuration func loadOptions() options { o := options{}
[ "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" ]
cli: factor options struct and parsing into home/options.go
https://github.com/AdguardTeam/AdGuardHome/commit/03506df25d5c6af6daf1ba19300d2697ad241bda
home/home.go
} // loadOptions reads command line arguments and initializes configuration func loadOptions() options { 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()) os.Exit(0) }}, {"help", "", "Print this help", nil, func() { printHelp() os.Exit(64)
</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)
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 {
} // loadOptions reads command line arguments and initializes configuration func loadOptions() options { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { os.Exit(0) }}, {"help", "", "Print this help", nil, func() { printHelp() 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" ]
cli: factor options struct and parsing into home/options.go
https://github.com/AdguardTeam/AdGuardHome/commit/03506df25d5c6af6daf1ba19300d2697ad241bda
home/home.go
{"glinet", "", "Run in GL-Inet compatibility mode", nil, func() { o.glinetMode = true }}, {"version", "", "Show the version and exit", nil, func() { fmt.Println(version()) os.Exit(0) }}, {"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) } } return o }
</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)
{"glinet", "", "Run in GL-Inet compatibility mode", nil, func() { o.glinetMode = true }}, {"version", "", "Show the version and exit", nil, func() { fmt.Println(version()) os.Exit(0) } } return o }
[ "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" ]
cli: factor options struct and parsing into home/options.go
https://github.com/AdguardTeam/AdGuardHome/commit/03506df25d5c6af6daf1ba19300d2697ad241bda
home/home.go
go 1.16 require ( github.com/AdguardTeam/dnsproxy v0.37.4 github.com/AdguardTeam/golibs v0.5.0 github.com/AdguardTeam/urlfilter v0.14.5 github.com/NYTimes/gziphandler v1.1.1 github.com/ameshkov/dnscrypt/v2 v2.1.3 github.com/digineo/go-ipset/v2 v2.2.1 github.com/fsnotify/fsnotify v1.4.9
</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")
github.com/AdguardTeam/golibs v0.8.0
go 1.16 require ( github.com/AdguardTeam/dnsproxy v0.37.4 github.com/AdguardTeam/golibs v0.8.0 github.com/AdguardTeam/urlfilter v0.14.5 github.com/NYTimes/gziphandler v1.1.1 github.com/ameshkov/dnscrypt/v2 v2.1.3 github.com/digineo/go-ipset/v2 v2.2.1 github.com/fsnotify/fsnotify v1.4.9
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
go.mod
github.com/AdguardTeam/dnsproxy v0.37.4/go.mod h1:xkJWEuTr550gPDmB9azsciKZzSXjf9wMn+Ji54PQ4gE= github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.4.4/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.5.0 h1:qwhEKjDrT0UcwDnHrNU2Yg/DLR9b/GsUncnXYW6VzAU= github.com/AdguardTeam/golibs v0.5.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU= github.com/AdguardTeam/urlfilter v0.14.5 h1:WyF0hg0MwKevsqNPkoaZFH8f5WRi/yuy/7qePtYt5Ts= github.com/AdguardTeam/urlfilter v0.14.5/go.mod h1:klx4JbOfc4EaNb5lWLqOwfg+pVcyRukmoJRvO55lL5U= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
</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
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=
github.com/AdguardTeam/dnsproxy v0.37.4/go.mod h1:xkJWEuTr550gPDmB9azsciKZzSXjf9wMn+Ji54PQ4gE= github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.4.4/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= 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= 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= github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU= github.com/AdguardTeam/urlfilter v0.14.5 h1:WyF0hg0MwKevsqNPkoaZFH8f5WRi/yuy/7qePtYt5Ts= github.com/AdguardTeam/urlfilter v0.14.5/go.mod h1:klx4JbOfc4EaNb5lWLqOwfg+pVcyRukmoJRvO55lL5U= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
go.sum
"net" "strconv" "strings" "github.com/AdguardTeam/AdGuardHome/internal/agherr" "golang.org/x/net/idna" ) // IsValidHostOuterRune returns true if r is a valid initial or final rune for // a hostname label.
</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"
"github.com/AdguardTeam/golibs/errors"
"net" "strconv" "strings" "github.com/AdguardTeam/golibs/errors" "golang.org/x/net/idna" ) // IsValidHostOuterRune returns true if r is a valid initial or final rune for // a hostname label.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/addr.go
// ValidateHardwareAddress returns an error if hwa is not a valid EUI-48, // EUI-64, or 20-octet InfiniBand link-layer address. func ValidateHardwareAddress(hwa net.HardwareAddr) (err error) { defer agherr.Annotate("validating hardware address %q: %w", &err, hwa) switch l := len(hwa); l { case 0: return agherr.Error("address is empty") case 6, 8, 20:
</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) }()
defer func() { err = errors.Annotate(err, "validating hardware address %q: %w", hwa) }()
// ValidateHardwareAddress returns an error if hwa is not a valid EUI-48, // EUI-64, or 20-octet InfiniBand link-layer address. func ValidateHardwareAddress(hwa net.HardwareAddr) (err error) { defer func() { err = errors.Annotate(err, "validating hardware address %q: %w", hwa) }() switch l := len(hwa); l { case 0: return agherr.Error("address is empty") case 6, 8, 20:
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/addr.go
defer agherr.Annotate("validating hardware address %q: %w", &err, hwa) switch l := len(hwa); l { case 0: return agherr.Error("address is empty") case 6, 8, 20: return nil default: return fmt.Errorf("bad len: %d", l) }
</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) {
return errors.Error("address is empty")
defer agherr.Annotate("validating hardware address %q: %w", &err, hwa) switch l := len(hwa); l { case 0: return errors.Error("address is empty") case 6, 8, 20: return nil default: return fmt.Errorf("bad len: %d", l) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/addr.go
// ValidateDomainNameLabel returns an error if label is not a valid label of // a domain name. func ValidateDomainNameLabel(label string) (err error) { defer agherr.Annotate("validating label %q: %w", &err, label) l := len(label) if l > maxDomainLabelLen { return fmt.Errorf("label is too long, max: %d", maxDomainLabelLen) } else if l == 0 {
</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) }()
defer func() { err = errors.Annotate(err, "validating label %q: %w", label) }()
// ValidateDomainNameLabel returns an error if label is not a valid label of // a domain name. func ValidateDomainNameLabel(label string) (err error) { defer func() { err = errors.Annotate(err, "validating label %q: %w", label) }() l := len(label) if l > maxDomainLabelLen { return fmt.Errorf("label is too long, max: %d", maxDomainLabelLen) } else if l == 0 {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/addr.go
l := len(label) if l > maxDomainLabelLen { return fmt.Errorf("label is too long, max: %d", maxDomainLabelLen) } else if l == 0 { return agherr.Error("label is empty") } if r := label[0]; !IsValidHostOuterRune(rune(r)) { return fmt.Errorf("invalid char %q at index %d", r, 0) } else if l == 1 {
</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")
return errors.Error("label is empty")
l := len(label) if l > maxDomainLabelLen { return fmt.Errorf("label is too long, max: %d", maxDomainLabelLen) } else if l == 0 { return errors.Error("label is empty") } if r := label[0]; !IsValidHostOuterRune(rune(r)) { return fmt.Errorf("invalid char %q at index %d", r, 0) } else if l == 1 {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/addr.go
// // TODO(a.garipov): After making sure that this works correctly, port this into // module golibs. func ValidateDomainName(name string) (err error) { defer agherr.Annotate("validating domain name %q: %w", &err, name) name, err = idna.ToASCII(name) if err != nil { return err }
</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) }()
defer func() { err = errors.Annotate(err, "validating domain name %q: %w", name) }()
// // TODO(a.garipov): After making sure that this works correctly, port this into // module golibs. func ValidateDomainName(name string) (err error) { defer func() { err = errors.Annotate(err, "validating domain name %q: %w", name) }() name, err = idna.ToASCII(name) if err != nil { return err }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/addr.go
} l := len(name) if l == 0 { return agherr.Error("domain name is empty") } else if l > maxDomainNameLen { return fmt.Errorf("too long, max: %d", maxDomainNameLen) } labels := strings.Split(name, ".")
</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")
return errors.Error("domain name is empty")
} l := len(name) if l == 0 { return errors.Error("domain name is empty") } else if l > maxDomainNameLen { return fmt.Errorf("too long, max: %d", maxDomainNameLen) } labels := strings.Split(name, ".")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/addr.go
package aghnet import ( "bufio" "errors" "io" "net" "os" "path/filepath" "runtime"
</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
package aghnet import ( "bufio" "io" "net" "os" "path/filepath" "runtime"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/etchostscontainer.go
"github.com/AdguardTeam/AdGuardHome/internal/aghos" "github.com/AdguardTeam/golibs/log" "github.com/fsnotify/fsnotify" "github.com/miekg/dns" )
</s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
"github.com/AdguardTeam/golibs/errors"
"github.com/AdguardTeam/AdGuardHome/internal/aghos" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/fsnotify/fsnotify" "github.com/miekg/dns" )
[ "keep", "add", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/etchostscontainer.go
if err != nil { log.Error("etchostscontainer: %s", err) return } defer f.Close() r := bufio.NewReader(f) log.Debug("etchostscontainer: loading hosts from file %s", fn) for done := false; !done; { var line string
</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)
defer func() { derr := f.Close() if derr != nil { log.Error("etchostscontainer: closing file: %s", err) } }()
if err != nil { log.Error("etchostscontainer: %s", err) return } defer func() { derr := f.Close() if derr != nil { log.Error("etchostscontainer: closing file: %s", err) } }() r := bufio.NewReader(f) log.Debug("etchostscontainer: loading hosts from file %s", fn) for done := false; !done; { var line string
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/etchostscontainer.go
package aghnet import ( "encoding/json" "errors" "fmt" "net" "os" "os/exec" "runtime"
</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
package aghnet import ( "encoding/json" "fmt" "net" "os" "os/exec" "runtime"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/net.go
"strings" "syscall" "time" "github.com/AdguardTeam/AdGuardHome/internal/agherr" "github.com/AdguardTeam/AdGuardHome/internal/aghstrings" "github.com/AdguardTeam/golibs/log" ) // ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about
</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
"strings" "syscall" "time" "github.com/AdguardTeam/AdGuardHome/internal/aghstrings" "github.com/AdguardTeam/golibs/log" ) // ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/net.go
"time" "github.com/AdguardTeam/AdGuardHome/internal/aghstrings" "github.com/AdguardTeam/golibs/log" ) // ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about // the IP being static is available. const ErrNoStaticIPInfo errors.Error = "no information about static ip"
</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"
"github.com/AdguardTeam/golibs/errors"
"time" "github.com/AdguardTeam/AdGuardHome/internal/aghstrings" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" ) // ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about // the IP being static is available. const ErrNoStaticIPInfo errors.Error = "no information about static ip"
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/net.go
) // ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about // the IP being static is available. const ErrNoStaticIPInfo agherr.Error = "no information about static ip" // IfaceHasStaticIP checks if interface is configured to have static IP address. // If it can't give a definitive answer, it returns false and an error for which // errors.Is(err, ErrNoStaticIPInfo) is true. func IfaceHasStaticIP(ifaceName string) (has bool, err error) {
</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"
const ErrNoStaticIPInfo errors.Error = "no information about static ip"
) // ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about // the IP being static is available. const ErrNoStaticIPInfo errors.Error = "no information about static ip" // IfaceHasStaticIP checks if interface is configured to have static IP address. // If it can't give a definitive answer, it returns false and an error for which // errors.Is(err, ErrNoStaticIPInfo) is true. func IfaceHasStaticIP(ifaceName string) (has bool, err error) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/net.go
if err != nil { return nil, fmt.Errorf("couldn't get interfaces: %w", err) } if len(ifaces) == 0 { return nil, errors.New("couldn't find any legible interface") } var netInterfaces []*NetInterface for _, iface := range ifaces {
</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)
return nil, errors.Error("couldn't find any legible interface")
if err != nil { return nil, fmt.Errorf("couldn't get interfaces: %w", err) } if len(ifaces) == 0 { return nil, errors.Error("couldn't find any legible interface") } var netInterfaces []*NetInterface for _, iface := range ifaces {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/net.go
package aghnet import ( "errors" "fmt" "os" "regexp" "strings"
</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
package aghnet import ( "fmt" "os" "regexp" "strings"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/net_darwin.go
"regexp" "strings" "github.com/AdguardTeam/AdGuardHome/internal/aghos" ) // hardwarePortInfo - information obtained using MacOS networksetup // about the current state of the internet connection
</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"
"github.com/AdguardTeam/golibs/errors"
"regexp" "strings" "github.com/AdguardTeam/AdGuardHome/internal/aghos" "github.com/AdguardTeam/golibs/errors" ) // hardwarePortInfo - information obtained using MacOS networksetup // about the current state of the internet connection
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/aghnet/net_darwin.go