code_before stringlengths 16 1.81M | edits stringlengths 4 328k | next_edit stringlengths 0 76.5k | code_after stringlengths 3 49.9M | label_window listlengths 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.RemoveStati... | 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.Se... | 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 | 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[... | </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)
... | "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": ... | </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(... | 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 := ... | [
"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.Remov... | 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 = con... | 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 := d... | 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(new... | 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)... | 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> ... | 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 =... | 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.ServerCo... | 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... | 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
gith... | </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> ad... | 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-202103101... | [
"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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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=
githu... | </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.co... | 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=
g... | [
"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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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... | 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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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... | 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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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... | 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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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)
<... | 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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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... | 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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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(... | 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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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-r... | 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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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: loa... | 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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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 "go... | </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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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> remov... | 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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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, 0o6... | 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 <A.Garipov@AdGuard.COM>
Date: Tue Apr 6 19:54:21 2021 +0300
all: use renameio instead of golibs/... | 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 ... | </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 checkPortAvai... | 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[s... | </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... | 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 ... | [
"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
... | </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"`
... | 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... | [
"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": "Pa... | </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": "Past... | [
"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,
... | .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,
... | 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')} />
... | [
"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}
... | </s> remove settings, services, setBlockedServices, t,
</s> add settings,
services,
setBlockedServices,
setStatsConfig,
stats,
t, </s> remove }, { getLogsProcessing: false, logsDownloading: false });
</s> add }, {
getLogsProcessin... | <div className="col-md-12">
<StatsConfig
interval={stats.interval}
processing={stats.setConfigProcessing}
setStatsConfig={setStatsConfig}
... | </div>
</Card>
</div>
<div className="col-md-12">
<StatsConfig
interval={stats.interval}
... | [
"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 } =... | 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,
... | 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... | [
"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,
... | 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 } =... | 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, process... | [
"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 =... | [
"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, logsDownl... | </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,
log... | [
"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,
... | 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 = p... | </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_U... | [
"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 <A.Garipov@AdGuard.COM>
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.res... | 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 <A.Garipov@AdGuard.COM>
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_PROJEC... | 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 <A.Garipov@AdGuard.COM>
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 <A.Garipov@AdGuard.COM>
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_... | 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 <A.Garipov@AdGuard.COM>
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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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 `j... | 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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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 rewriteEn... | 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... | [
"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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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) handleRewri... | 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 := ... | [
"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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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 rewriteEn... | 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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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> rem... | "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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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 de... | </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... | // 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 *urlfilt... | [
"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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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 t... | // 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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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 unde... | </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 requ... | //
// 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,... | [
"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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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(... | </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> rem... | 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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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(dRe... | // 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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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 _, ... | 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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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()
... | "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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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 r... | </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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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 {
js... | </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 ==... | }
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",
"re... | 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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | 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 <dkolyshev@adguard.com>
Date: Mon Dec 5 13:38:01 2022 +0200
Merge remote-track... | https://github.com/AdguardTeam/AdGuardHome/commit/01652e6ab23c46a1553cc6d8b157c5821057ee38 | internal/filtering/rewrites_test.go | |
}
log.Info("Stopped")
}
// command-line arguments
type options struct {
verbose bool // is verbose logging enabled
configFilename string // path to the config file
workDir string // path to the working directory where we will store the filters data and the querylog
bindHost ... | </s> remove o := options{}
var printHelp func()
var opts = []struct {
longName string
shortName string
description string
callbackWithValue func(value string)
callbackNoValue func()
}{
{"config", "c", "Path to the config file", func(value string) { o.configFilename = value }, n... | func exitWithError() {
os.Exit(64) | }
log.Info("Stopped")
}
func exitWithError() {
os.Exit(64)
func exitWithError() {
os.Exit(64)
func exitWithError() {
os.Exit(64)
func exitWithError() {
os.Exit(64)
func exitWithError() {
os.Exit(64)
func exitWithError() {
os.Exit(64)
func exitWithError() {
os.Exit(64)
func exitWithError() {
os.Exit(6... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
... | cli: factor options struct and parsing into home/options.go | https://github.com/AdguardTeam/AdGuardHome/commit/03506df25d5c6af6daf1ba19300d2697ad241bda | home/home.go |
}
// loadOptions reads command line arguments and initializes configuration
func loadOptions() options {
o := options{}
var printHelp func()
var opts = []struct {
longName string
shortName string
description string
callbackWithValue func(value string)
call... | </s> remove }},
{"help", "", "Print this help", nil, func() {
printHelp()
os.Exit(64)
}},
}
printHelp = func() {
fmt.Printf("Usage:\n\n")
fmt.Printf("%s [options]\n\n", os.Args[0])
fmt.Printf("Options:\n")
for _, opt := range opts {
val := ""
if opt.callbackWithValue != nil {
val = " VAL... | o, f, err := parse(os.Args[0], os.Args[1:])
if err != nil {
log.Error(err.Error())
_ = printHelp(os.Args[0])
exitWithError()
} else if f != nil {
err = f()
if err != nil {
log.Error(err.Error())
exitWithError()
} else { | }
// loadOptions reads command line arguments and initializes configuration
func loadOptions() options {
o, f, err := parse(os.Args[0], os.Args[1:])
if err != nil {
log.Error(err.Error())
_ = printHelp(os.Args[0])
exitWithError()
} else if f != nil {
err = f()
if err != nil {
log.Error(err.Err... | [
"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",
"re... | cli: factor options struct and parsing into home/options.go | https://github.com/AdguardTeam/AdGuardHome/commit/03506df25d5c6af6daf1ba19300d2697ad241bda | home/home.go |
{"glinet", "", "Run in GL-Inet compatibility mode", nil, func() { o.glinetMode = true }},
{"version", "", "Show the version and exit", nil, func() {
fmt.Println(version())
os.Exit(0)
}},
{"help", "", "Print this help", nil, func() {
printHelp()
os.Exit(64)
}},
}
printHelp =... | </s> remove o := options{}
var printHelp func()
var opts = []struct {
longName string
shortName string
description string
callbackWithValue func(value string)
callbackNoValue func()
}{
{"config", "c", "Path to the config file", func(value string) { o.configFilename = value }, n... | {"glinet", "", "Run in GL-Inet compatibility mode", nil, func() { o.glinetMode = true }},
{"version", "", "Show the version and exit", nil, func() {
fmt.Println(version())
os.Exit(0)
}
}
return o
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"re... | cli: factor options struct and parsing into home/options.go | https://github.com/AdguardTeam/AdGuardHome/commit/03506df25d5c6af6daf1ba19300d2697ad241bda | home/home.go | |
go 1.16
require (
github.com/AdguardTeam/dnsproxy v0.37.4
github.com/AdguardTeam/golibs v0.5.0
github.com/AdguardTeam/urlfilter v0.14.5
github.com/NYTimes/gziphandler v1.1.1
github.com/ameshkov/dnscrypt/v2 v2.1.3
github.com/digineo/go-ipset/v2 v2.2.1
github.com/fsnotify/fsnotify v1.4.9
| </s> remove github.com/AdguardTeam/golibs v0.5.0 h1:qwhEKjDrT0UcwDnHrNU2Yg/DLR9b/GsUncnXYW6VzAU=
github.com/AdguardTeam/golibs v0.5.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
</s> add github.com/AdguardTeam/golibs v0.8.0 h1:rHo+yIgT2fivFG0yW2Cwk/DPc2+t/Aw6QvzPpiIFre0=
github.com/AdguardTeam/golibs v0.8.0... | github.com/AdguardTeam/golibs v0.8.0 | go 1.16
require (
github.com/AdguardTeam/dnsproxy v0.37.4
github.com/AdguardTeam/golibs v0.8.0
github.com/AdguardTeam/urlfilter v0.14.5
github.com/NYTimes/gziphandler v1.1.1
github.com/ameshkov/dnscrypt/v2 v2.1.3
github.com/digineo/go-ipset/v2 v2.2.1
github.com/fsnotify/fsnotify v1.4.9 | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | go.mod |
github.com/AdguardTeam/dnsproxy v0.37.4/go.mod h1:xkJWEuTr550gPDmB9azsciKZzSXjf9wMn+Ji54PQ4gE=
github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
github.com/AdguardTeam/golibs v0.... | </s> remove github.com/AdguardTeam/golibs v0.5.0
</s> add github.com/AdguardTeam/golibs v0.8.0 </s> remove "errors"
</s> add </s> remove "errors"
</s> add | github.com/AdguardTeam/golibs v0.8.0 h1:rHo+yIgT2fivFG0yW2Cwk/DPc2+t/Aw6QvzPpiIFre0=
github.com/AdguardTeam/golibs v0.8.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= | github.com/AdguardTeam/dnsproxy v0.37.4/go.mod h1:xkJWEuTr550gPDmB9azsciKZzSXjf9wMn+Ji54PQ4gE=
github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
github.com/AdguardTeam/golibs v0.... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | go.sum |
"net"
"strconv"
"strings"
"github.com/AdguardTeam/AdGuardHome/internal/agherr"
"golang.org/x/net/idna"
)
// IsValidHostOuterRune returns true if r is a valid initial or final rune for
// a hostname label.
| </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add "github.com/AdguardTeam/golibs/errors" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add </s> remove defer agherr.Annotate("validating hardware address %q: %w", &err, hwa)
</s> add defer func() { err = errors.Anno... | "github.com/AdguardTeam/golibs/errors" | "net"
"strconv"
"strings"
"github.com/AdguardTeam/golibs/errors"
"golang.org/x/net/idna"
)
// IsValidHostOuterRune returns true if r is a valid initial or final rune for
// a hostname label. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/addr.go |
// ValidateHardwareAddress returns an error if hwa is not a valid EUI-48,
// EUI-64, or 20-octet InfiniBand link-layer address.
func ValidateHardwareAddress(hwa net.HardwareAddr) (err error) {
defer agherr.Annotate("validating hardware address %q: %w", &err, hwa)
switch l := len(hwa); l {
case 0:
... | </s> remove return agherr.Error("address is empty")
</s> add return errors.Error("address is empty") </s> remove defer agherr.Annotate("validating label %q: %w", &err, label)
</s> add defer func() { err = errors.Annotate(err, "validating label %q: %w", label) }() </s> remove return agherr.Error("question is n... | defer func() { err = errors.Annotate(err, "validating hardware address %q: %w", hwa) }() |
// ValidateHardwareAddress returns an error if hwa is not a valid EUI-48,
// EUI-64, or 20-octet InfiniBand link-layer address.
func ValidateHardwareAddress(hwa net.HardwareAddr) (err error) {
defer func() { err = errors.Annotate(err, "validating hardware address %q: %w", hwa) }()
switch l := len(hwa); ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/addr.go |
defer agherr.Annotate("validating hardware address %q: %w", &err, hwa)
switch l := len(hwa); l {
case 0:
return agherr.Error("address is empty")
case 6, 8, 20:
return nil
default:
return fmt.Errorf("bad len: %d", l)
}
| </s> remove defer agherr.Annotate("validating hardware address %q: %w", &err, hwa)
</s> add defer func() { err = errors.Annotate(err, "validating hardware address %q: %w", hwa) }() </s> remove defer agherr.Annotate("validating label %q: %w", &err, label)
</s> add defer func() { err = errors.Annotate(err, "validat... | return errors.Error("address is empty") | defer agherr.Annotate("validating hardware address %q: %w", &err, hwa)
switch l := len(hwa); l {
case 0:
return errors.Error("address is empty")
case 6, 8, 20:
return nil
default:
return fmt.Errorf("bad len: %d", l)
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/addr.go |
// ValidateDomainNameLabel returns an error if label is not a valid label of
// a domain name.
func ValidateDomainNameLabel(label string) (err error) {
defer agherr.Annotate("validating label %q: %w", &err, label)
l := len(label)
if l > maxDomainLabelLen {
return fmt.Errorf("label is too long, ... | </s> remove return agherr.Error("label is empty")
</s> add return errors.Error("label is empty") </s> remove return agherr.Error("domain name is empty")
</s> add return errors.Error("domain name is empty") </s> remove defer agherr.Annotate("validating hardware address %q: %w", &err, hwa)
</s> add defer fun... | defer func() { err = errors.Annotate(err, "validating label %q: %w", label) }() |
// ValidateDomainNameLabel returns an error if label is not a valid label of
// a domain name.
func ValidateDomainNameLabel(label string) (err error) {
defer func() { err = errors.Annotate(err, "validating label %q: %w", label) }()
l := len(label)
if l > maxDomainLabelLen {
return fmt.Errorf("lab... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/addr.go |
l := len(label)
if l > maxDomainLabelLen {
return fmt.Errorf("label is too long, max: %d", maxDomainLabelLen)
} else if l == 0 {
return agherr.Error("label is empty")
}
if r := label[0]; !IsValidHostOuterRune(rune(r)) {
return fmt.Errorf("invalid char %q at index %d", r, 0)
} else if l ... | </s> remove return agherr.Error("domain name is empty")
</s> add return errors.Error("domain name is empty") </s> remove defer agherr.Annotate("validating label %q: %w", &err, label)
</s> add defer func() { err = errors.Annotate(err, "validating label %q: %w", label) }() </s> remove return agherr.Error("addre... | return errors.Error("label is empty") | l := len(label)
if l > maxDomainLabelLen {
return fmt.Errorf("label is too long, max: %d", maxDomainLabelLen)
} else if l == 0 {
return errors.Error("label is empty")
}
if r := label[0]; !IsValidHostOuterRune(rune(r)) {
return fmt.Errorf("invalid char %q at index %d", r, 0)
} else if l ==... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/addr.go |
//
// TODO(a.garipov): After making sure that this works correctly, port this into
// module golibs.
func ValidateDomainName(name string) (err error) {
defer agherr.Annotate("validating domain name %q: %w", &err, name)
name, err = idna.ToASCII(name)
if err != nil {
return err
}
| </s> remove defer agherr.Annotate("validating label %q: %w", &err, label)
</s> add defer func() { err = errors.Annotate(err, "validating label %q: %w", label) }() </s> remove defer agherr.Annotate("bad upstream for domain spec %q: %w", &err, upstreamStr)
</s> add defer func() { err = errors.Annotate(err, "bad ups... | defer func() { err = errors.Annotate(err, "validating domain name %q: %w", name) }() | //
// TODO(a.garipov): After making sure that this works correctly, port this into
// module golibs.
func ValidateDomainName(name string) (err error) {
defer func() { err = errors.Annotate(err, "validating domain name %q: %w", name) }()
name, err = idna.ToASCII(name)
if err != nil {
return err
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/addr.go |
}
l := len(name)
if l == 0 {
return agherr.Error("domain name is empty")
} else if l > maxDomainNameLen {
return fmt.Errorf("too long, max: %d", maxDomainNameLen)
}
labels := strings.Split(name, ".")
| </s> remove return agherr.Error("label is empty")
</s> add return errors.Error("label is empty") </s> remove defer agherr.Annotate("validating label %q: %w", &err, label)
</s> add defer func() { err = errors.Annotate(err, "validating label %q: %w", label) }() </s> remove return agherr.Error("address is empty"... | return errors.Error("domain name is empty") | }
l := len(name)
if l == 0 {
return errors.Error("domain name is empty")
} else if l > maxDomainNameLen {
return fmt.Errorf("too long, max: %d", maxDomainNameLen)
}
labels := strings.Split(name, ".") | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/addr.go |
package aghnet
import (
"bufio"
"errors"
"io"
"net"
"os"
"path/filepath"
"runtime"
| </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add | package aghnet
import (
"bufio"
"io"
"net"
"os"
"path/filepath"
"runtime" | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/etchostscontainer.go | |
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
"github.com/AdguardTeam/golibs/log"
"github.com/fsnotify/fsnotify"
"github.com/miekg/dns"
)
| </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add | "github.com/AdguardTeam/golibs/errors" |
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
"github.com/AdguardTeam/golibs/errors"
"github.com/AdguardTeam/golibs/log"
"github.com/fsnotify/fsnotify"
"github.com/miekg/dns"
) | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/etchostscontainer.go |
if err != nil {
log.Error("etchostscontainer: %s", err)
return
}
defer f.Close()
r := bufio.NewReader(f)
log.Debug("etchostscontainer: loading hosts from file %s", fn)
for done := false; !done; {
var line string
| </s> remove defer f.Close()
fileReadCloser, err := aghio.LimitReadCloser(f, MaxFileSize)
</s> add defer func() {
derr := f.Close()
if derr != nil {
log.Error("glinet: closing file: %s", err)
}
}()
fileReader, err := aghio.LimitReader(f, MaxFileSize) </s> remove defer f.Close()
</s> add defer func() ... | defer func() {
derr := f.Close()
if derr != nil {
log.Error("etchostscontainer: closing file: %s", err)
}
}()
| if err != nil {
log.Error("etchostscontainer: %s", err)
return
}
defer func() {
derr := f.Close()
if derr != nil {
log.Error("etchostscontainer: closing file: %s", err)
}
}()
r := bufio.NewReader(f)
log.Debug("etchostscontainer: loading hosts from file %s", fn)
for done := false; !... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/etchostscontainer.go |
package aghnet
import (
"encoding/json"
"errors"
"fmt"
"net"
"os"
"os/exec"
"runtime"
| </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add | package aghnet
import (
"encoding/json"
"fmt"
"net"
"os"
"os/exec"
"runtime" | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net.go | |
"strings"
"syscall"
"time"
"github.com/AdguardTeam/AdGuardHome/internal/agherr"
"github.com/AdguardTeam/AdGuardHome/internal/aghstrings"
"github.com/AdguardTeam/golibs/log"
)
// ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about
| </s> remove const ErrNoStaticIPInfo agherr.Error = "no information about static ip"
</s> add const ErrNoStaticIPInfo errors.Error = "no information about static ip" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add </s> remove rDNSEmptyAnswerErr agherr.Error = "the answer section is empty"
... | "strings"
"syscall"
"time"
"github.com/AdguardTeam/AdGuardHome/internal/aghstrings"
"github.com/AdguardTeam/golibs/log"
)
// ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net.go | |
"time"
"github.com/AdguardTeam/AdGuardHome/internal/aghstrings"
"github.com/AdguardTeam/golibs/log"
)
// ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about
// the IP being static is available.
const ErrNoStaticIPInfo errors.Error = "no information about static ip"
| </s> remove const ErrNoStaticIPInfo agherr.Error = "no information about static ip"
</s> add const ErrNoStaticIPInfo errors.Error = "no information about static ip" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add </s> remove errBadAddrPassed agherr.Error = "the passed string is not a vali... | "github.com/AdguardTeam/golibs/errors" | "time"
"github.com/AdguardTeam/AdGuardHome/internal/aghstrings"
"github.com/AdguardTeam/golibs/errors"
"github.com/AdguardTeam/golibs/log"
)
// ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about
// the IP being static is available.
const ErrNoStaticIPInfo errors.Error = ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net.go |
)
// ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about
// the IP being static is available.
const ErrNoStaticIPInfo agherr.Error = "no information about static ip"
// IfaceHasStaticIP checks if interface is configured to have static IP address.
// If it can't give a definitiv... | </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add </s> remove errBadAddrPassed agherr.Error = "the passed string is not a valid IP address"
</s> add errBadAddrPassed errors.Error = "the passed string is not a valid IP address" </s> remove errFakeDial agherr.Error = "this error signals the... | const ErrNoStaticIPInfo errors.Error = "no information about static ip" | )
// ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about
// the IP being static is available.
const ErrNoStaticIPInfo errors.Error = "no information about static ip"
// IfaceHasStaticIP checks if interface is configured to have static IP address.
// If it can't give a definitive ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net.go |
if err != nil {
return nil, fmt.Errorf("couldn't get interfaces: %w", err)
}
if len(ifaces) == 0 {
return nil, errors.New("couldn't find any legible interface")
}
var netInterfaces []*NetInterface
for _, iface := range ifaces {
| </s> remove var files []string
var err2 error
var zr io.ReadCloser
for _, zf := range r.File {
zr, err = zf.Open()
</s> add for _, zf := range zrc.File {
var name string
name, err = zipFileUnpackOne(outDir, zf) </s> remove defer r.Close()
</s> add defer func() { err = errors.WithDeferred(err, zrc.Close()... | return nil, errors.Error("couldn't find any legible interface") | if err != nil {
return nil, fmt.Errorf("couldn't get interfaces: %w", err)
}
if len(ifaces) == 0 {
return nil, errors.Error("couldn't find any legible interface")
}
var netInterfaces []*NetInterface
for _, iface := range ifaces { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net.go |
package aghnet
import (
"errors"
"fmt"
"os"
"regexp"
"strings"
| </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add </s> remove "errors"
</s> add |
package aghnet
import (
"fmt"
"os"
"regexp"
"strings"
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net_darwin.go | |
"regexp"
"strings"
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
)
// hardwarePortInfo - information obtained using MacOS networksetup
// about the current state of the internet connection
| </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr"
</s> add </s> remove const ErrNoStaticIPInfo agherr.Error = "no information about static ip"
</s> add const ErrNoStaticIPInfo errors.Error = "no information about static ip" | "github.com/AdguardTeam/golibs/errors" | "regexp"
"strings"
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
"github.com/AdguardTeam/golibs/errors"
)
// hardwarePortInfo - information obtained using MacOS networksetup
// about the current state of the internet connection | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | Pull request: replace agherr with golibs' errors
Merge in DNS/adguard-home from golibs-errors to master
Squashed commit of the following:
commit 5aba278a31c5a213bd9e08273ce7277c57713b22
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon May 24 17:05:18 2021 +0300
all: imp code
commit f447eb875b81779fa9... | https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38 | internal/aghnet/net_darwin.go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.