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

Dataset Card for Dataset Name

Processed version of the code-philia/CoEdPilot-generator for the next edit prediction task from the paper CoEdPilot.

Dataset Structure

  • code_before - initial code to be modified
  • edits - previous edits
  • next_edit - next edit to be done
  • code_after - code after the edit
  • label_window - labels of happened with each line in the code before. There are three options: keep (nothing changes), add (adds new content after the line), replace (replaces all lines with new content).
  • instruction - presumably commit message from the commit that was used for a datapoint
  • html_url - commit url
  • file_name - changed file

Reproduction script

https://github.com/JetBrains-Research/comment_resolution/blob/main/notebooks/coedpilot_dataset.ipynb

Downloads last month
68