docstring_tokens
stringlengths
0
76.5k
code_tokens
stringlengths
75
1.81M
label_window
sequencelengths
4
2.12k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
"io/fs"
<mask> package aghnet <mask> <mask> import ( <mask> "net" <mask> "os" <mask> "testing" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghtest" </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove "os" </s> add </s> remove "os/exec" "runtime" </s> add </s> remove "strings" </s> add </s> remove testdata := os.DirFS("./testdata") </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/aghnet/net_test.go
"os"
<mask> "io/fs" <mask> "net" <mask> "testing" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghtest" <mask> "github.com/AdguardTeam/golibs/netutil" <mask> "github.com/AdguardTeam/golibs/testutil" </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove "os" </s> add </s> remove "strings" </s> add </s> remove "os/exec" "runtime" </s> add </s> remove testdata := os.DirFS("./testdata") </s> add
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/aghnet/net_test.go
// testdata is the filesystem containing data for testing the package. var testdata fs.FS = os.DirFS("./testdata")
<mask> "github.com/stretchr/testify/require" <mask> ) <mask> <mask> func TestMain(m *testing.M) { <mask> aghtest.DiscardLogOutput(m) <mask> } <mask> </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove testdata := os.DirFS("./testdata") </s> add </s> remove return 1, "", fmt.Errorf("exec.Command(%s) failed: %w: %s", command, err, string(out)) </s> add return 1, "", fmt.Errorf("command %q failed: %w: %s", command, err, out) </s> remove n := 0 // TODO(a.garipov): Rewrite to use bufio.Scanner. lines := strings.Split(string(data), "\n") for _, ln := range lines { lparen := strings.Index(ln, " (") rparen := strings.Index(ln, ") ") if lparen == -1 || rparen == -1 || lparen >= rparen { continue } host := ln[:lparen] ipStr := ln[lparen+2 : rparen] ip := net.ParseIP(ipStr) if netutil.ValidateDomainName(host) != nil || ip == nil { continue } ok := clients.addHostLocked(ip, host, ClientSourceARP) if ok { n++ </s> add added := 0 for _, n := range ns { if clients.addHostLocked(n.IP, "", ClientSourceARP) { added++ </s> remove Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts) </s> add var arpdb aghnet.ARPDB arpdb, err = aghnet.NewARPDB() if err != nil { log.Info("warning: creating arpdb: %s; using stub", err) arpdb = aghnet.EmptyARPDB{} } Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts, arpdb)
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/aghnet/net_test.go
// MaxCmdOutputSize is the maximum length of performed shell command output in // bytes. const MaxCmdOutputSize = 64 * 1024
<mask> func HaveAdminRights() (bool, error) { <mask> return haveAdminRights() <mask> } <mask> <mask> // MaxCmdOutputSize is the maximum length of performed shell command output. <mask> const MaxCmdOutputSize = 2 * 1024 <mask> <mask> // RunCommand runs shell command. <mask> func RunCommand(command string, arguments ...string) (int, string, error) { <mask> cmd := exec.Command(command, arguments...) <mask> out, err := cmd.Output() </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove func RunCommand(command string, arguments ...string) (int, string, error) { </s> add func RunCommand(command string, arguments ...string) (code int, output string, err error) { </s> remove if runtime.GOOS == "windows" { </s> add if err := clients.arpdb.Refresh(); err != nil { log.Error("refreshing arp container: %s", err) clients.arpdb = aghnet.EmptyARPDB{} </s> remove testdata := os.DirFS("./testdata") </s> add </s> remove cmd := exec.Command("arp", "-a") log.Tracef("executing %q %q", cmd.Path, cmd.Args) data, err := cmd.Output() if err != nil || cmd.ProcessState.ExitCode() != 0 { log.Debug("command %q has failed: %q code:%d", cmd.Path, err, cmd.ProcessState.ExitCode()) </s> add ns := clients.arpdb.Neighbors() if len(ns) == 0 { log.Debug("refreshing arp container: the update is empty") </s> remove testdata := os.DirFS("./testdata") </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/aghos/os.go
func RunCommand(command string, arguments ...string) (code int, output string, err error) {
<mask> // MaxCmdOutputSize is the maximum length of performed shell command output. <mask> const MaxCmdOutputSize = 2 * 1024 <mask> <mask> // RunCommand runs shell command. <mask> func RunCommand(command string, arguments ...string) (int, string, error) { <mask> cmd := exec.Command(command, arguments...) <mask> out, err := cmd.Output() <mask> if len(out) > MaxCmdOutputSize { <mask> out = out[:MaxCmdOutputSize] <mask> } </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove // MaxCmdOutputSize is the maximum length of performed shell command output. const MaxCmdOutputSize = 2 * 1024 </s> add // MaxCmdOutputSize is the maximum length of performed shell command output in // bytes. const MaxCmdOutputSize = 64 * 1024 </s> remove if runtime.GOOS == "windows" { </s> add if err := clients.arpdb.Refresh(); err != nil { log.Error("refreshing arp container: %s", err) clients.arpdb = aghnet.EmptyARPDB{} </s> remove cmd := exec.Command("arp", "-a") log.Tracef("executing %q %q", cmd.Path, cmd.Args) data, err := cmd.Output() if err != nil || cmd.ProcessState.ExitCode() != 0 { log.Debug("command %q has failed: %q code:%d", cmd.Path, err, cmd.ProcessState.ExitCode()) </s> add ns := clients.arpdb.Neighbors() if len(ns) == 0 { log.Debug("refreshing arp container: the update is empty") </s> remove testdata := os.DirFS("./testdata") </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/aghos/os.go
return 1, "", fmt.Errorf("command %q failed: %w: %s", command, err, out)
<mask> <mask> if errors.As(err, new(*exec.ExitError)) { <mask> return cmd.ProcessState.ExitCode(), string(out), nil <mask> } else if err != nil { <mask> return 1, "", fmt.Errorf("exec.Command(%s) failed: %w: %s", command, err, string(out)) <mask> } <mask> <mask> return cmd.ProcessState.ExitCode(), string(out), nil <mask> } <mask> </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove cmd := exec.Command("arp", "-a") log.Tracef("executing %q %q", cmd.Path, cmd.Args) data, err := cmd.Output() if err != nil || cmd.ProcessState.ExitCode() != 0 { log.Debug("command %q has failed: %q code:%d", cmd.Path, err, cmd.ProcessState.ExitCode()) </s> add ns := clients.arpdb.Neighbors() if len(ns) == 0 { log.Debug("refreshing arp container: the update is empty") </s> remove Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts) </s> add var arpdb aghnet.ARPDB arpdb, err = aghnet.NewARPDB() if err != nil { log.Info("warning: creating arpdb: %s; using stub", err) arpdb = aghnet.EmptyARPDB{} } Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts, arpdb) </s> remove if runtime.GOOS == "windows" { </s> add if err := clients.arpdb.Refresh(); err != nil { log.Error("refreshing arp container: %s", err) clients.arpdb = aghnet.EmptyARPDB{} </s> remove testdata := os.DirFS("./testdata") </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/aghos/os.go
<mask> import ( <mask> "bytes" <mask> "fmt" <mask> "net" <mask> "os/exec" <mask> "runtime" <mask> "sort" <mask> "strings" <mask> "sync" <mask> "time" <mask> </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove "strings" </s> add </s> remove "os" </s> add </s> remove testdata := os.DirFS("./testdata") </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/home/clients.go
<mask> "net" <mask> "os/exec" <mask> "runtime" <mask> "sort" <mask> "strings" <mask> "sync" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghnet" <mask> "github.com/AdguardTeam/AdGuardHome/internal/dhcpd" </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove "os/exec" "runtime" </s> add </s> remove "os" </s> add </s> remove testdata := os.DirFS("./testdata") </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/home/clients.go
// arpdb stores the neighbors retrieved from ARP. arpdb aghnet.ARPDB
<mask> // etcHosts contains list of rewrite rules taken from the operating system's <mask> // hosts database. <mask> etcHosts *aghnet.HostsContainer <mask> <mask> testing bool // if TRUE, this object is used for internal tests <mask> } <mask> <mask> // Init initializes clients container </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove log.Debug("clients: added %d client aliases from 'arp -a' command output", n) </s> add log.Debug("clients: added %d client aliases from arp neighborhood", added) </s> remove // MaxCmdOutputSize is the maximum length of performed shell command output. const MaxCmdOutputSize = 2 * 1024 </s> add // MaxCmdOutputSize is the maximum length of performed shell command output in // bytes. const MaxCmdOutputSize = 64 * 1024 </s> remove if runtime.GOOS == "windows" { </s> add if err := clients.arpdb.Refresh(); err != nil { log.Error("refreshing arp container: %s", err) clients.arpdb = aghnet.EmptyARPDB{}
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/home/clients.go
arpdb aghnet.ARPDB,
<mask> objects []*clientObject, <mask> dhcpServer *dhcpd.Server, <mask> etcHosts *aghnet.HostsContainer, <mask> ) { <mask> if clients.list != nil { <mask> log.Fatal("clients.list != nil") <mask> } </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts) </s> add var arpdb aghnet.ARPDB arpdb, err = aghnet.NewARPDB() if err != nil { log.Info("warning: creating arpdb: %s; using stub", err) arpdb = aghnet.EmptyARPDB{} } Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts, arpdb) </s> remove return 1, "", fmt.Errorf("exec.Command(%s) failed: %w: %s", command, err, string(out)) </s> add return 1, "", fmt.Errorf("command %q failed: %w: %s", command, err, out) </s> remove cmd := exec.Command("arp", "-a") log.Tracef("executing %q %q", cmd.Path, cmd.Args) data, err := cmd.Output() if err != nil || cmd.ProcessState.ExitCode() != 0 { log.Debug("command %q has failed: %q code:%d", cmd.Path, err, cmd.ProcessState.ExitCode()) </s> add ns := clients.arpdb.Neighbors() if len(ns) == 0 { log.Debug("refreshing arp container: the update is empty") </s> remove if runtime.GOOS == "windows" { </s> add if err := clients.arpdb.Refresh(); err != nil { log.Error("refreshing arp container: %s", err) clients.arpdb = aghnet.EmptyARPDB{}
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/home/clients.go
clients.arpdb = arpdb
<mask> clients.allTags = stringutil.NewSet(clientTags...) <mask> <mask> clients.dhcpServer = dhcpServer <mask> clients.etcHosts = etcHosts <mask> clients.addFromConfig(objects) <mask> <mask> if clients.testing { <mask> return </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove clients.Init(nil, nil, nil) </s> add clients.Init(nil, nil, nil, nil) </s> remove Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts) </s> add var arpdb aghnet.ARPDB arpdb, err = aghnet.NewARPDB() if err != nil { log.Info("warning: creating arpdb: %s; using stub", err) arpdb = aghnet.EmptyARPDB{} } Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts, arpdb) </s> remove if runtime.GOOS == "windows" { </s> add if err := clients.arpdb.Refresh(); err != nil { log.Error("refreshing arp container: %s", err) clients.arpdb = aghnet.EmptyARPDB{} </s> remove func RunCommand(command string, arguments ...string) (int, string, error) { </s> add func RunCommand(command string, arguments ...string) (code int, output string, err error) {
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/home/clients.go
if err := clients.arpdb.Refresh(); err != nil { log.Error("refreshing arp container: %s", err) clients.arpdb = aghnet.EmptyARPDB{}
<mask> <mask> // addFromSystemARP adds the IP-hostname pairings from the output of the arp -a <mask> // command. <mask> func (clients *clientsContainer) addFromSystemARP() { <mask> if runtime.GOOS == "windows" { <mask> return <mask> } <mask> <mask> cmd := exec.Command("arp", "-a") <mask> log.Tracef("executing %q %q", cmd.Path, cmd.Args) </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove cmd := exec.Command("arp", "-a") log.Tracef("executing %q %q", cmd.Path, cmd.Args) data, err := cmd.Output() if err != nil || cmd.ProcessState.ExitCode() != 0 { log.Debug("command %q has failed: %q code:%d", cmd.Path, err, cmd.ProcessState.ExitCode()) </s> add ns := clients.arpdb.Neighbors() if len(ns) == 0 { log.Debug("refreshing arp container: the update is empty") </s> remove log.Debug("clients: added %d client aliases from 'arp -a' command output", n) </s> add log.Debug("clients: added %d client aliases from arp neighborhood", added) </s> remove // MaxCmdOutputSize is the maximum length of performed shell command output. const MaxCmdOutputSize = 2 * 1024 </s> add // MaxCmdOutputSize is the maximum length of performed shell command output in // bytes. const MaxCmdOutputSize = 64 * 1024 </s> remove func RunCommand(command string, arguments ...string) (int, string, error) { </s> add func RunCommand(command string, arguments ...string) (code int, output string, err error) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/home/clients.go
ns := clients.arpdb.Neighbors() if len(ns) == 0 { log.Debug("refreshing arp container: the update is empty")
<mask> if runtime.GOOS == "windows" { <mask> return <mask> } <mask> <mask> cmd := exec.Command("arp", "-a") <mask> log.Tracef("executing %q %q", cmd.Path, cmd.Args) <mask> data, err := cmd.Output() <mask> if err != nil || cmd.ProcessState.ExitCode() != 0 { <mask> log.Debug("command %q has failed: %q code:%d", <mask> cmd.Path, err, cmd.ProcessState.ExitCode()) <mask> return <mask> } <mask> <mask> clients.lock.Lock() <mask> defer clients.lock.Unlock() </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove if runtime.GOOS == "windows" { </s> add if err := clients.arpdb.Refresh(); err != nil { log.Error("refreshing arp container: %s", err) clients.arpdb = aghnet.EmptyARPDB{} </s> remove return 1, "", fmt.Errorf("exec.Command(%s) failed: %w: %s", command, err, string(out)) </s> add return 1, "", fmt.Errorf("command %q failed: %w: %s", command, err, out) </s> remove n := 0 // TODO(a.garipov): Rewrite to use bufio.Scanner. lines := strings.Split(string(data), "\n") for _, ln := range lines { lparen := strings.Index(ln, " (") rparen := strings.Index(ln, ") ") if lparen == -1 || rparen == -1 || lparen >= rparen { continue } host := ln[:lparen] ipStr := ln[lparen+2 : rparen] ip := net.ParseIP(ipStr) if netutil.ValidateDomainName(host) != nil || ip == nil { continue } ok := clients.addHostLocked(ip, host, ClientSourceARP) if ok { n++ </s> add added := 0 for _, n := range ns { if clients.addHostLocked(n.IP, "", ClientSourceARP) { added++ </s> remove Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts) </s> add var arpdb aghnet.ARPDB arpdb, err = aghnet.NewARPDB() if err != nil { log.Info("warning: creating arpdb: %s; using stub", err) arpdb = aghnet.EmptyARPDB{} } Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts, arpdb) </s> remove func RunCommand(command string, arguments ...string) (int, string, error) { </s> add func RunCommand(command string, arguments ...string) (code int, output string, err error) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/home/clients.go
added := 0 for _, n := range ns { if clients.addHostLocked(n.IP, "", ClientSourceARP) { added++
<mask> defer clients.lock.Unlock() <mask> <mask> clients.rmHostsBySrc(ClientSourceARP) <mask> <mask> n := 0 <mask> // TODO(a.garipov): Rewrite to use bufio.Scanner. <mask> lines := strings.Split(string(data), "\n") <mask> for _, ln := range lines { <mask> lparen := strings.Index(ln, " (") <mask> rparen := strings.Index(ln, ") ") <mask> if lparen == -1 || rparen == -1 || lparen >= rparen { <mask> continue <mask> } <mask> <mask> host := ln[:lparen] <mask> ipStr := ln[lparen+2 : rparen] <mask> ip := net.ParseIP(ipStr) <mask> if netutil.ValidateDomainName(host) != nil || ip == nil { <mask> continue <mask> } <mask> <mask> ok := clients.addHostLocked(ip, host, ClientSourceARP) <mask> if ok { <mask> n++ <mask> } <mask> } <mask> <mask> log.Debug("clients: added %d client aliases from 'arp -a' command output", n) <mask> } </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove cmd := exec.Command("arp", "-a") log.Tracef("executing %q %q", cmd.Path, cmd.Args) data, err := cmd.Output() if err != nil || cmd.ProcessState.ExitCode() != 0 { log.Debug("command %q has failed: %q code:%d", cmd.Path, err, cmd.ProcessState.ExitCode()) </s> add ns := clients.arpdb.Neighbors() if len(ns) == 0 { log.Debug("refreshing arp container: the update is empty") </s> remove log.Debug("clients: added %d client aliases from 'arp -a' command output", n) </s> add log.Debug("clients: added %d client aliases from arp neighborhood", added) </s> remove if runtime.GOOS == "windows" { </s> add if err := clients.arpdb.Refresh(); err != nil { log.Error("refreshing arp container: %s", err) clients.arpdb = aghnet.EmptyARPDB{} </s> remove clients.Init(nil, nil, nil) </s> add clients.Init(nil, nil, nil, nil) </s> remove Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts) </s> add var arpdb aghnet.ARPDB arpdb, err = aghnet.NewARPDB() if err != nil { log.Info("warning: creating arpdb: %s; using stub", err) arpdb = aghnet.EmptyARPDB{} } Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts, arpdb)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/home/clients.go
log.Debug("clients: added %d client aliases from arp neighborhood", added)
<mask> n++ <mask> } <mask> } <mask> <mask> log.Debug("clients: added %d client aliases from 'arp -a' command output", n) <mask> } <mask> <mask> // updateFromDHCP adds the clients that have a non-empty hostname from the DHCP <mask> // server. <mask> func (clients *clientsContainer) updateFromDHCP(add bool) { </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove n := 0 // TODO(a.garipov): Rewrite to use bufio.Scanner. lines := strings.Split(string(data), "\n") for _, ln := range lines { lparen := strings.Index(ln, " (") rparen := strings.Index(ln, ") ") if lparen == -1 || rparen == -1 || lparen >= rparen { continue } host := ln[:lparen] ipStr := ln[lparen+2 : rparen] ip := net.ParseIP(ipStr) if netutil.ValidateDomainName(host) != nil || ip == nil { continue } ok := clients.addHostLocked(ip, host, ClientSourceARP) if ok { n++ </s> add added := 0 for _, n := range ns { if clients.addHostLocked(n.IP, "", ClientSourceARP) { added++ </s> remove if runtime.GOOS == "windows" { </s> add if err := clients.arpdb.Refresh(); err != nil { log.Error("refreshing arp container: %s", err) clients.arpdb = aghnet.EmptyARPDB{} </s> remove clients.Init(nil, nil, nil) </s> add clients.Init(nil, nil, nil, nil) </s> remove // MaxCmdOutputSize is the maximum length of performed shell command output. const MaxCmdOutputSize = 2 * 1024 </s> add // MaxCmdOutputSize is the maximum length of performed shell command output in // bytes. const MaxCmdOutputSize = 64 * 1024
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/home/clients.go
clients.Init(nil, nil, nil, nil)
<mask> func TestClients(t *testing.T) { <mask> clients := clientsContainer{} <mask> clients.testing = true <mask> <mask> clients.Init(nil, nil, nil) <mask> <mask> t.Run("add_success", func(t *testing.T) { <mask> c := &Client{ <mask> IDs: []string{"1.1.1.1", "1:2:3::4", "aa:aa:aa:aa:aa:aa"}, <mask> Name: "client1", </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove clients.Init(nil, nil, nil) </s> add clients.Init(nil, nil, nil, nil) </s> remove clients.Init(nil, nil, nil) </s> add clients.Init(nil, nil, nil, nil) </s> remove clients.Init(nil, nil, nil) </s> add clients.Init(nil, nil, nil, nil) </s> remove testdata := os.DirFS("./testdata") </s> add </s> remove testdata := os.DirFS("./testdata") </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/home/clients_test.go
clients.Init(nil, nil, nil, nil)
<mask> func TestClientsWHOIS(t *testing.T) { <mask> clients := clientsContainer{ <mask> testing: true, <mask> } <mask> clients.Init(nil, nil, nil) <mask> whois := &RuntimeClientWHOISInfo{ <mask> Country: "AU", <mask> Orgname: "Example Org", <mask> } <mask> </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove clients.Init(nil, nil, nil) </s> add clients.Init(nil, nil, nil, nil) </s> remove clients.Init(nil, nil, nil) </s> add clients.Init(nil, nil, nil, nil) </s> remove clients.Init(nil, nil, nil) </s> add clients.Init(nil, nil, nil, nil) </s> remove testdata := os.DirFS("./testdata") </s> add </s> remove n := 0 // TODO(a.garipov): Rewrite to use bufio.Scanner. lines := strings.Split(string(data), "\n") for _, ln := range lines { lparen := strings.Index(ln, " (") rparen := strings.Index(ln, ") ") if lparen == -1 || rparen == -1 || lparen >= rparen { continue } host := ln[:lparen] ipStr := ln[lparen+2 : rparen] ip := net.ParseIP(ipStr) if netutil.ValidateDomainName(host) != nil || ip == nil { continue } ok := clients.addHostLocked(ip, host, ClientSourceARP) if ok { n++ </s> add added := 0 for _, n := range ns { if clients.addHostLocked(n.IP, "", ClientSourceARP) { added++
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/home/clients_test.go
clients.Init(nil, nil, nil, nil)
<mask> func TestClientsAddExisting(t *testing.T) { <mask> clients := clientsContainer{ <mask> testing: true, <mask> } <mask> clients.Init(nil, nil, nil) <mask> <mask> t.Run("simple", func(t *testing.T) { <mask> ip := net.IP{1, 1, 1, 1} <mask> <mask> // Add a client. </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove clients.Init(nil, nil, nil) </s> add clients.Init(nil, nil, nil, nil) </s> remove clients.Init(nil, nil, nil) </s> add clients.Init(nil, nil, nil, nil) </s> remove clients.Init(nil, nil, nil) </s> add clients.Init(nil, nil, nil, nil) </s> remove return 1, "", fmt.Errorf("exec.Command(%s) failed: %w: %s", command, err, string(out)) </s> add return 1, "", fmt.Errorf("command %q failed: %w: %s", command, err, out) </s> remove n := 0 // TODO(a.garipov): Rewrite to use bufio.Scanner. lines := strings.Split(string(data), "\n") for _, ln := range lines { lparen := strings.Index(ln, " (") rparen := strings.Index(ln, ") ") if lparen == -1 || rparen == -1 || lparen >= rparen { continue } host := ln[:lparen] ipStr := ln[lparen+2 : rparen] ip := net.ParseIP(ipStr) if netutil.ValidateDomainName(host) != nil || ip == nil { continue } ok := clients.addHostLocked(ip, host, ClientSourceARP) if ok { n++ </s> add added := 0 for _, n := range ns { if clients.addHostLocked(n.IP, "", ClientSourceARP) { added++
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/home/clients_test.go
clients.Init(nil, nil, nil, nil)
<mask> func TestClientsCustomUpstream(t *testing.T) { <mask> clients := clientsContainer{ <mask> testing: true, <mask> } <mask> clients.Init(nil, nil, nil) <mask> <mask> // Add client with upstreams. <mask> ok, err := clients.Add(&Client{ <mask> IDs: []string{"1.1.1.1", "1:2:3::4", "aa:aa:aa:aa:aa:aa"}, <mask> Name: "client1", </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove clients.Init(nil, nil, nil) </s> add clients.Init(nil, nil, nil, nil) </s> remove clients.Init(nil, nil, nil) </s> add clients.Init(nil, nil, nil, nil) </s> remove clients.Init(nil, nil, nil) </s> add clients.Init(nil, nil, nil, nil) </s> remove log.Debug("clients: added %d client aliases from 'arp -a' command output", n) </s> add log.Debug("clients: added %d client aliases from arp neighborhood", added) </s> remove n := 0 // TODO(a.garipov): Rewrite to use bufio.Scanner. lines := strings.Split(string(data), "\n") for _, ln := range lines { lparen := strings.Index(ln, " (") rparen := strings.Index(ln, ") ") if lparen == -1 || rparen == -1 || lparen >= rparen { continue } host := ln[:lparen] ipStr := ln[lparen+2 : rparen] ip := net.ParseIP(ipStr) if netutil.ValidateDomainName(host) != nil || ip == nil { continue } ok := clients.addHostLocked(ip, host, ClientSourceARP) if ok { n++ </s> add added := 0 for _, n := range ns { if clients.addHostLocked(n.IP, "", ClientSourceARP) { added++
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/home/clients_test.go
var arpdb aghnet.ARPDB arpdb, err = aghnet.NewARPDB() if err != nil { log.Info("warning: creating arpdb: %s; using stub", err) arpdb = aghnet.EmptyARPDB{} } Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts, arpdb)
<mask> return err <mask> } <mask> } <mask> <mask> Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts) <mask> <mask> if args.bindPort != 0 { <mask> uc := aghalg.UniqChecker{} <mask> addPorts( <mask> uc, </s> Pull request: 3597 arpdb Merge in DNS/adguard-home from 3597-wrt-netlink to master Updates #3597. Squashed commit of the following: commit 1709582cd204bb80c84775feabae8723ed3340f6 Merge: 0507b6ed e7b3c996 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:25:18 2022 +0300 Merge branch 'master' into 3597-wrt-netlink commit 0507b6ede1162554ca8ac7399d827264aca64f98 Author: Eugene Burkov <[email protected]> Date: Tue Mar 15 20:21:29 2022 +0300 all: imp code commit 71f9758d854b3e2cf90cbd3655ae4818cfbcf528 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 18:03:48 2022 +0500 aghnet: imp naming commit c949e765104f130aa3e5ba465bdebc3286bebe44 Author: Eugene Burkov <[email protected]> Date: Wed Mar 9 17:26:30 2022 +0500 all: imp code, docs commit cf605ddb401b6e7b0a7a4bb1b175a4dc588d253a Author: Eugene Burkov <[email protected]> Date: Tue Mar 8 15:33:52 2022 +0500 all: imp code, docs commit 2960c6549a7e4944cc0072ca47a0cd4e82ec850e Author: Eugene Burkov <[email protected]> Date: Sun Mar 6 21:34:58 2022 +0500 all: imp code & docs, fix tests commit 29c049f3aee91a826c3416961686396d562a7066 Author: Eugene Burkov <[email protected]> Date: Wed Mar 2 20:45:34 2022 +0300 all: add arpdb </s> remove cmd := exec.Command("arp", "-a") log.Tracef("executing %q %q", cmd.Path, cmd.Args) data, err := cmd.Output() if err != nil || cmd.ProcessState.ExitCode() != 0 { log.Debug("command %q has failed: %q code:%d", cmd.Path, err, cmd.ProcessState.ExitCode()) </s> add ns := clients.arpdb.Neighbors() if len(ns) == 0 { log.Debug("refreshing arp container: the update is empty") </s> remove return 1, "", fmt.Errorf("exec.Command(%s) failed: %w: %s", command, err, string(out)) </s> add return 1, "", fmt.Errorf("command %q failed: %w: %s", command, err, out) </s> remove n := 0 // TODO(a.garipov): Rewrite to use bufio.Scanner. lines := strings.Split(string(data), "\n") for _, ln := range lines { lparen := strings.Index(ln, " (") rparen := strings.Index(ln, ") ") if lparen == -1 || rparen == -1 || lparen >= rparen { continue } host := ln[:lparen] ipStr := ln[lparen+2 : rparen] ip := net.ParseIP(ipStr) if netutil.ValidateDomainName(host) != nil || ip == nil { continue } ok := clients.addHostLocked(ip, host, ClientSourceARP) if ok { n++ </s> add added := 0 for _, n := range ns { if clients.addHostLocked(n.IP, "", ClientSourceARP) { added++ </s> remove if runtime.GOOS == "windows" { </s> add if err := clients.arpdb.Refresh(); err != nil { log.Error("refreshing arp container: %s", err) clients.arpdb = aghnet.EmptyARPDB{}
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/573cbafe3f2f222d7c6413d8fe30c90ae295882d
internal/home/home.go
<mask> <mask> const COLUMN_MIN_WIDTH = 200; <mask> <mask> class AutoClients extends Component { <mask> getStats = (ip, stats) => { <mask> if (stats) { <mask> const statsForCurrentIP = stats.find(item => item.name === ip); <mask> return statsForCurrentIP && statsForCurrentIP.count; <mask> } <mask> <mask> return ''; <mask> }; <mask> <mask> columns = [ <mask> { <mask> Header: this.props.t('table_client'), <mask> accessor: 'ip', <mask> minWidth: COLUMN_MIN_WIDTH, </s> - client: sort clients table by requests count by default </s> remove getStats = (name, stats) => { if (stats) { const currentStats = stats.find(item => item.info && item.info.name === name); return currentStats && currentStats.count; } return ''; }; </s> add </s> remove const clientIP = row.original.ip; const clientStats = clientIP && this.getStats(clientIP, this.props.topClients); </s> add const { value: clientStats } = row; </s> remove const { name } = row.original; const clientStats = this.getStats(name, this.props.topClients); </s> add const { value: clientStats } = row; </s> remove accessor: 'statistics', </s> add accessor: row => this.props.normalizedTopClients[row.ip] || 0, sortMethod: (a, b) => b - a, id: 'statistics',
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c031c1c6eb765ad4d32da6d4744cecfdc19a41
client/src/components/Settings/Clients/AutoClients.js
accessor: row => this.props.normalizedTopClients[row.ip] || 0, sortMethod: (a, b) => b - a, id: 'statistics',
<mask> Cell: whoisCell(this.props.t), <mask> }, <mask> { <mask> Header: this.props.t('requests_count'), <mask> accessor: 'statistics', <mask> minWidth: COLUMN_MIN_WIDTH, <mask> Cell: (row) => { <mask> const clientIP = row.original.ip; <mask> const clientStats = clientIP && this.getStats(clientIP, this.props.topClients); <mask> </s> - client: sort clients table by requests count by default </s> remove const clientIP = row.original.ip; const clientStats = clientIP && this.getStats(clientIP, this.props.topClients); </s> add const { value: clientStats } = row; </s> remove accessor: 'statistics', </s> add id: 'statistics', accessor: row => this.props.normalizedTopClients[row.name] || 0, sortMethod: (a, b) => b - a, </s> remove const { name } = row.original; const clientStats = this.getStats(name, this.props.topClients); </s> add const { value: clientStats } = row; </s> remove getStats = (ip, stats) => { if (stats) { const statsForCurrentIP = stats.find(item => item.name === ip); return statsForCurrentIP && statsForCurrentIP.count; } return ''; }; </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c031c1c6eb765ad4d32da6d4744cecfdc19a41
client/src/components/Settings/Clients/AutoClients.js
const { value: clientStats } = row;
<mask> Header: this.props.t('requests_count'), <mask> accessor: 'statistics', <mask> minWidth: COLUMN_MIN_WIDTH, <mask> Cell: (row) => { <mask> const clientIP = row.original.ip; <mask> const clientStats = clientIP && this.getStats(clientIP, this.props.topClients); <mask> <mask> if (clientStats) { <mask> return ( <mask> <div className="logs__row"> <mask> <div className="logs__text" title={clientStats}> </s> - client: sort clients table by requests count by default </s> remove const { name } = row.original; const clientStats = this.getStats(name, this.props.topClients); </s> add const { value: clientStats } = row; </s> remove accessor: 'statistics', </s> add accessor: row => this.props.normalizedTopClients[row.ip] || 0, sortMethod: (a, b) => b - a, id: 'statistics', </s> remove accessor: 'statistics', </s> add id: 'statistics', accessor: row => this.props.normalizedTopClients[row.name] || 0, sortMethod: (a, b) => b - a, </s> remove getStats = (ip, stats) => { if (stats) { const statsForCurrentIP = stats.find(item => item.name === ip); return statsForCurrentIP && statsForCurrentIP.count; } return ''; }; </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c031c1c6eb765ad4d32da6d4744cecfdc19a41
client/src/components/Settings/Clients/AutoClients.js
defaultSorted={[ { id: 'statistics', asc: true, }, ]}
<mask> <ReactTable <mask> data={autoClients || []} <mask> columns={this.columns} <mask> className="-striped -highlight card-table-overflow" <mask> showPagination={true} <mask> defaultPageSize={10} <mask> minRows={5} </s> - client: sort clients table by requests count by default </s> remove accessor: 'statistics', </s> add id: 'statistics', accessor: row => this.props.normalizedTopClients[row.name] || 0, sortMethod: (a, b) => b - a, </s> remove accessor: 'statistics', </s> add accessor: row => this.props.normalizedTopClients[row.ip] || 0, sortMethod: (a, b) => b - a, id: 'statistics',
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c031c1c6eb765ad4d32da6d4744cecfdc19a41
client/src/components/Settings/Clients/AutoClients.js
normalizedTopClients: PropTypes.object.isRequired,
<mask> <mask> AutoClients.propTypes = { <mask> t: PropTypes.func.isRequired, <mask> autoClients: PropTypes.array.isRequired, <mask> topClients: PropTypes.array.isRequired, <mask> }; <mask> <mask> export default withNamespaces()(AutoClients); </s> - client: sort clients table by requests count by default </s> remove topClients: PropTypes.array.isRequired, </s> add normalizedTopClients: PropTypes.object.isRequired, </s> remove getStats = (name, stats) => { if (stats) { const currentStats = stats.find(item => item.info && item.info.name === name); return currentStats && currentStats.count; } return ''; }; </s> add </s> remove getStats = (ip, stats) => { if (stats) { const statsForCurrentIP = stats.find(item => item.name === ip); return statsForCurrentIP && statsForCurrentIP.count; } return ''; }; </s> add </s> remove const { name } = row.original; const clientStats = this.getStats(name, this.props.topClients); </s> add const { value: clientStats } = row;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c031c1c6eb765ad4d32da6d4744cecfdc19a41
client/src/components/Settings/Clients/AutoClients.js
<mask> use_global_blocked_services: true, <mask> }; <mask> }; <mask> <mask> getStats = (name, stats) => { <mask> if (stats) { <mask> const currentStats = stats.find(item => item.info && item.info.name === name); <mask> return currentStats && currentStats.count; <mask> } <mask> <mask> return ''; <mask> }; <mask> <mask> handleDelete = (data) => { <mask> // eslint-disable-next-line no-alert <mask> if (window.confirm(this.props.t('client_confirm_delete', { key: data.name }))) { <mask> this.props.deleteClient(data); <mask> } </s> - client: sort clients table by requests count by default </s> remove getStats = (ip, stats) => { if (stats) { const statsForCurrentIP = stats.find(item => item.name === ip); return statsForCurrentIP && statsForCurrentIP.count; } return ''; }; </s> add </s> remove const clientIP = row.original.ip; const clientStats = clientIP && this.getStats(clientIP, this.props.topClients); </s> add const { value: clientStats } = row; </s> remove const { name } = row.original; const clientStats = this.getStats(name, this.props.topClients); </s> add const { value: clientStats } = row; </s> remove topClients: PropTypes.array.isRequired, </s> add normalizedTopClients: PropTypes.object.isRequired,
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c031c1c6eb765ad4d32da6d4744cecfdc19a41
client/src/components/Settings/Clients/ClientsTable.js
id: 'statistics', accessor: row => this.props.normalizedTopClients[row.name] || 0, sortMethod: (a, b) => b - a,
<mask> Cell: whoisCell(this.props.t), <mask> }, <mask> { <mask> Header: this.props.t('requests_count'), <mask> accessor: 'statistics', <mask> minWidth: 120, <mask> Cell: (row) => { <mask> const { name } = row.original; <mask> const clientStats = this.getStats(name, this.props.topClients); <mask> </s> - client: sort clients table by requests count by default </s> remove const { name } = row.original; const clientStats = this.getStats(name, this.props.topClients); </s> add const { value: clientStats } = row; </s> remove accessor: 'statistics', </s> add accessor: row => this.props.normalizedTopClients[row.ip] || 0, sortMethod: (a, b) => b - a, id: 'statistics', </s> remove const clientIP = row.original.ip; const clientStats = clientIP && this.getStats(clientIP, this.props.topClients); </s> add const { value: clientStats } = row; </s> remove getStats = (ip, stats) => { if (stats) { const statsForCurrentIP = stats.find(item => item.name === ip); return statsForCurrentIP && statsForCurrentIP.count; } return ''; }; </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c031c1c6eb765ad4d32da6d4744cecfdc19a41
client/src/components/Settings/Clients/ClientsTable.js
const { value: clientStats } = row;
<mask> Header: this.props.t('requests_count'), <mask> accessor: 'statistics', <mask> minWidth: 120, <mask> Cell: (row) => { <mask> const { name } = row.original; <mask> const clientStats = this.getStats(name, this.props.topClients); <mask> <mask> if (clientStats) { <mask> return ( <mask> <div className="logs__row"> <mask> <div className="logs__text" title={clientStats}> </s> - client: sort clients table by requests count by default </s> remove const clientIP = row.original.ip; const clientStats = clientIP && this.getStats(clientIP, this.props.topClients); </s> add const { value: clientStats } = row; </s> remove accessor: 'statistics', </s> add id: 'statistics', accessor: row => this.props.normalizedTopClients[row.name] || 0, sortMethod: (a, b) => b - a, </s> remove accessor: 'statistics', </s> add accessor: row => this.props.normalizedTopClients[row.ip] || 0, sortMethod: (a, b) => b - a, id: 'statistics', </s> remove getStats = (ip, stats) => { if (stats) { const statsForCurrentIP = stats.find(item => item.name === ip); return statsForCurrentIP && statsForCurrentIP.count; } return ''; }; </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c031c1c6eb765ad4d32da6d4744cecfdc19a41
client/src/components/Settings/Clients/ClientsTable.js
defaultSorted={[ { id: 'statistics', asc: true, }, ]}
<mask> data={clients || []} <mask> columns={this.columns} <mask> className="-striped -highlight card-table-overflow" <mask> showPagination={true} <mask> defaultPageSize={10} <mask> minRows={5} </s> - client: sort clients table by requests count by default </s> remove accessor: 'statistics', </s> add id: 'statistics', accessor: row => this.props.normalizedTopClients[row.name] || 0, sortMethod: (a, b) => b - a, </s> remove accessor: 'statistics', </s> add accessor: row => this.props.normalizedTopClients[row.ip] || 0, sortMethod: (a, b) => b - a, id: 'statistics',
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c031c1c6eb765ad4d32da6d4744cecfdc19a41
client/src/components/Settings/Clients/ClientsTable.js
normalizedTopClients: PropTypes.object.isRequired,
<mask> <mask> ClientsTable.propTypes = { <mask> t: PropTypes.func.isRequired, <mask> clients: PropTypes.array.isRequired, <mask> topClients: PropTypes.array.isRequired, <mask> toggleClientModal: PropTypes.func.isRequired, <mask> deleteClient: PropTypes.func.isRequired, <mask> addClient: PropTypes.func.isRequired, <mask> updateClient: PropTypes.func.isRequired, <mask> isModalOpen: PropTypes.bool.isRequired, </s> - client: sort clients table by requests count by default </s> remove topClients: PropTypes.array.isRequired, </s> add normalizedTopClients: PropTypes.object.isRequired, </s> remove getStats = (ip, stats) => { if (stats) { const statsForCurrentIP = stats.find(item => item.name === ip); return statsForCurrentIP && statsForCurrentIP.count; } return ''; }; </s> add </s> remove const { name } = row.original; const clientStats = this.getStats(name, this.props.topClients); </s> add const { value: clientStats } = row; </s> remove getStats = (name, stats) => { if (stats) { const currentStats = stats.find(item => item.info && item.info.name === name); return currentStats && currentStats.count; } return ''; }; </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c031c1c6eb765ad4d32da6d4744cecfdc19a41
client/src/components/Settings/Clients/ClientsTable.js
normalizedTopClients={stats.normalizedTopClients}
<mask> {!stats.processingStats && !dashboard.processingClients && ( <mask> <Fragment> <mask> <ClientsTable <mask> clients={dashboard.clients} <mask> topClients={stats.topClients} <mask> isModalOpen={clients.isModalOpen} <mask> modalClientName={clients.modalClientName} <mask> modalType={clients.modalType} <mask> addClient={addClient} <mask> updateClient={updateClient} </s> - client: sort clients table by requests count by default </s> remove topClients={stats.topClients} </s> add normalizedTopClients={stats.normalizedTopClients} </s> remove const clientIP = row.original.ip; const clientStats = clientIP && this.getStats(clientIP, this.props.topClients); </s> add const { value: clientStats } = row; </s> remove const { name } = row.original; const clientStats = this.getStats(name, this.props.topClients); </s> add const { value: clientStats } = row; </s> remove getStats = (name, stats) => { if (stats) { const currentStats = stats.find(item => item.info && item.info.name === name); return currentStats && currentStats.count; } return ''; }; </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c031c1c6eb765ad4d32da6d4744cecfdc19a41
client/src/components/Settings/Clients/index.js
normalizedTopClients={stats.normalizedTopClients}
<mask> processingUpdating={clients.processingUpdating} <mask> /> <mask> <AutoClients <mask> autoClients={dashboard.autoClients} <mask> topClients={stats.topClients} <mask> /> <mask> </Fragment> <mask> )} <mask> </Fragment> <mask> ); </s> - client: sort clients table by requests count by default </s> remove topClients={stats.topClients} </s> add normalizedTopClients={stats.normalizedTopClients} </s> remove topClients: PropTypes.array.isRequired, </s> add normalizedTopClients: PropTypes.object.isRequired,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c031c1c6eb765ad4d32da6d4744cecfdc19a41
client/src/components/Settings/Clients/index.js
export const normalizeTopClients = clients => clients.reduce((accumulator, clientObj) => { const { name, count } = clientObj; const idToCountMap = accumulator; idToCountMap[name] = count; return idToCountMap; }, {});
<mask> <mask> export const normalizeTextarea = text => text && text.replace(/[;, ]/g, '\n').split('\n').filter(n => n); <mask> <mask> export const getClientInfo = (clients, ip) => { <mask> const client = clients <mask> .find(item => item.ip_addrs && item.ip_addrs.find(clientIp => clientIp === ip)); <mask> <mask> if (!client) { <mask> return ''; </s> - client: sort clients table by requests count by default </s> remove getStats = (ip, stats) => { if (stats) { const statsForCurrentIP = stats.find(item => item.name === ip); return statsForCurrentIP && statsForCurrentIP.count; } return ''; }; </s> add </s> remove getStats = (name, stats) => { if (stats) { const currentStats = stats.find(item => item.info && item.info.name === name); return currentStats && currentStats.count; } return ''; }; </s> add </s> remove const clientIP = row.original.ip; const clientStats = clientIP && this.getStats(clientIP, this.props.topClients); </s> add const { value: clientStats } = row; </s> remove const { name } = row.original; const clientStats = this.getStats(name, this.props.topClients); </s> add const { value: clientStats } = row; </s> remove topClients: PropTypes.array.isRequired, </s> add normalizedTopClients: PropTypes.object.isRequired,
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c031c1c6eb765ad4d32da6d4744cecfdc19a41
client/src/helpers/helpers.js
import { normalizeTopClients } from '../helpers/helpers';
<mask> import { handleActions } from 'redux-actions'; <mask> <mask> import * as actions from '../actions/stats'; <mask> <mask> const defaultStats = { <mask> dnsQueries: [], <mask> blockedFiltering: [], </s> - client: sort clients table by requests count by default </s> remove const { name } = row.original; const clientStats = this.getStats(name, this.props.topClients); </s> add const { value: clientStats } = row; </s> remove const clientIP = row.original.ip; const clientStats = clientIP && this.getStats(clientIP, this.props.topClients); </s> add const { value: clientStats } = row; </s> remove getStats = (ip, stats) => { if (stats) { const statsForCurrentIP = stats.find(item => item.name === ip); return statsForCurrentIP && statsForCurrentIP.count; } return ''; }; </s> add </s> remove getStats = (name, stats) => { if (stats) { const currentStats = stats.find(item => item.info && item.info.name === name); return currentStats && currentStats.count; } return ''; }; </s> add
[ "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c031c1c6eb765ad4d32da6d4744cecfdc19a41
client/src/reducers/stats.js
normalizedTopClients: normalizeTopClients(topClients),
<mask> topBlockedDomains, <mask> topClients, <mask> topQueriedDomains, <mask> numBlockedFiltering, <mask> numDnsQueries, <mask> numReplacedParental, </s> - client: sort clients table by requests count by default </s> remove topClients={stats.topClients} </s> add normalizedTopClients={stats.normalizedTopClients} </s> remove topClients={stats.topClients} </s> add normalizedTopClients={stats.normalizedTopClients} </s> remove topClients: PropTypes.array.isRequired, </s> add normalizedTopClients: PropTypes.object.isRequired,
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c031c1c6eb765ad4d32da6d4744cecfdc19a41
client/src/reducers/stats.js
if gctx.safebrowsingCache == nil {
<mask> func New(c *Config, filters map[int]string) *Dnsfilter { <mask> <mask> if c != nil { <mask> // initialize objects only once <mask> if c.SafeBrowsingEnabled && gctx.safebrowsingCache == nil { <mask> gctx.safebrowsingCache = gcache.New(defaultCacheSize).LRU().Expiration(defaultCacheTime).Build() <mask> } <mask> if c.SafeSearchEnabled && gctx.safeSearchCache == nil { <mask> gctx.safeSearchCache = gcache.New(defaultCacheSize).LRU().Expiration(defaultCacheTime).Build() <mask> } </s> - dnsfilter: fix crash when global setting 'SafeSearch' is off but per-client setting is on </s> remove if c.ParentalEnabled && gctx.parentalCache == nil { </s> add if gctx.parentalCache == nil { </s> remove if c.SafeSearchEnabled && gctx.safeSearchCache == nil { </s> add if gctx.safeSearchCache == nil {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c510631e44d8a36a7fb086b23143b36110a956
dnsfilter/dnsfilter.go
if gctx.safeSearchCache == nil {
<mask> // initialize objects only once <mask> if c.SafeBrowsingEnabled && gctx.safebrowsingCache == nil { <mask> gctx.safebrowsingCache = gcache.New(defaultCacheSize).LRU().Expiration(defaultCacheTime).Build() <mask> } <mask> if c.SafeSearchEnabled && gctx.safeSearchCache == nil { <mask> gctx.safeSearchCache = gcache.New(defaultCacheSize).LRU().Expiration(defaultCacheTime).Build() <mask> } <mask> if c.ParentalEnabled && gctx.parentalCache == nil { <mask> gctx.parentalCache = gcache.New(defaultCacheSize).LRU().Expiration(defaultCacheTime).Build() <mask> } </s> - dnsfilter: fix crash when global setting 'SafeSearch' is off but per-client setting is on </s> remove if c.ParentalEnabled && gctx.parentalCache == nil { </s> add if gctx.parentalCache == nil { </s> remove if c.SafeBrowsingEnabled && gctx.safebrowsingCache == nil { </s> add if gctx.safebrowsingCache == nil {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c510631e44d8a36a7fb086b23143b36110a956
dnsfilter/dnsfilter.go
if gctx.parentalCache == nil {
<mask> } <mask> if c.SafeSearchEnabled && gctx.safeSearchCache == nil { <mask> gctx.safeSearchCache = gcache.New(defaultCacheSize).LRU().Expiration(defaultCacheTime).Build() <mask> } <mask> if c.ParentalEnabled && gctx.parentalCache == nil { <mask> gctx.parentalCache = gcache.New(defaultCacheSize).LRU().Expiration(defaultCacheTime).Build() <mask> } <mask> if len(c.ResolverAddress) != 0 && gctx.dialCache == nil { <mask> gctx.dialCache = gcache.New(maxDialCacheSize).LRU().Expiration(defaultCacheTime).Build() <mask> } </s> - dnsfilter: fix crash when global setting 'SafeSearch' is off but per-client setting is on </s> remove if c.SafeBrowsingEnabled && gctx.safebrowsingCache == nil { </s> add if gctx.safebrowsingCache == nil { </s> remove if c.SafeSearchEnabled && gctx.safeSearchCache == nil { </s> add if gctx.safeSearchCache == nil {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/57c510631e44d8a36a7fb086b23143b36110a956
dnsfilter/dnsfilter.go
github.com/AdguardTeam/dnsproxy v0.49.1
<mask> <mask> go 1.19 <mask> <mask> require ( <mask> github.com/AdguardTeam/dnsproxy v0.48.3 <mask> github.com/AdguardTeam/golibs v0.13.2 <mask> github.com/AdguardTeam/urlfilter v0.16.1 <mask> github.com/NYTimes/gziphandler v1.1.1 <mask> github.com/ameshkov/dnscrypt/v2 v2.2.7 <mask> github.com/digineo/go-ipset/v2 v2.2.1 </s> Pull request 1835: bootstrap-plain Merge in DNS/adguard-home from bootstrap-plain to master Updates AdguardTeam/dnsproxy#324. Squashed commit of the following: commit bd5d569dc26154985857977e81650eb0a51559a5 Author: Eugene Burkov <[email protected]> Date: Tue Apr 18 17:41:53 2023 +0300 querylog: rm proxyutil dep commit 9db4053555e06eba264f7d3e6c75c747f8d73b56 Author: Eugene Burkov <[email protected]> Date: Tue Apr 18 17:34:29 2023 +0300 all: upd proxy </s> remove github.com/AdguardTeam/dnsproxy v0.48.3 h1:h9xgDSmd1MqsPFNApyaPVXolmSTtzOWOcfWvPeDEP6s= github.com/AdguardTeam/dnsproxy v0.48.3/go.mod h1:Y7g7jRTd/u7+KJ/QvnGI2PCE8vnisp6EsW47/Sz0DZw= </s> add github.com/AdguardTeam/dnsproxy v0.49.1 h1:JpStBK05uCgA3ldleaNLRmIwE9V7vRg7/kVJQSdnQYg= github.com/AdguardTeam/dnsproxy v0.49.1/go.mod h1:Y7g7jRTd/u7+KJ/QvnGI2PCE8vnisp6EsW47/Sz0DZw= </s> remove ip := proxyutil.IPFromRR(msg.Answer[0]).To16() assert.Equal(t, answer, ip) </s> add a := testutil.RequireTypeAssert[*dns.A](t, msg.Answer[0]) assert.Equal(t, answer, a.A.To16()) </s> remove "github.com/AdguardTeam/dnsproxy/proxyutil" </s> add </s> remove assert.True(t, strings.HasSuffix(s, tc.want), "got %q", s) </s> add assert.True(t, strings.HasSuffix(s, tc.want), "got %q", s) </s> remove wantSet: `checking bootstrap a: invalid address: ` + `Resolver a is not eligible to be a bootstrap DNS server`, </s> add wantSet: `checking bootstrap a: invalid address: bootstrap a:53: ` + `ParseAddr("a"): unable to parse IP`,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/584182e2649fb3617fb423d7838592608ab8612d
go.mod
github.com/AdguardTeam/dnsproxy v0.49.1 h1:JpStBK05uCgA3ldleaNLRmIwE9V7vRg7/kVJQSdnQYg= github.com/AdguardTeam/dnsproxy v0.49.1/go.mod h1:Y7g7jRTd/u7+KJ/QvnGI2PCE8vnisp6EsW47/Sz0DZw=
<mask> github.com/AdguardTeam/dnsproxy v0.48.3 h1:h9xgDSmd1MqsPFNApyaPVXolmSTtzOWOcfWvPeDEP6s= <mask> github.com/AdguardTeam/dnsproxy v0.48.3/go.mod h1:Y7g7jRTd/u7+KJ/QvnGI2PCE8vnisp6EsW47/Sz0DZw= <mask> github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= <mask> github.com/AdguardTeam/golibs v0.10.4/go.mod h1:rSfQRGHIdgfxriDDNgNJ7HmE5zRoURq8R+VdR81Zuzw= <mask> github.com/AdguardTeam/golibs v0.13.2 h1:BPASsyQKmb+b8VnvsNOHp7bKfcZl9Z+Z2UhPjOiupSc= <mask> github.com/AdguardTeam/golibs v0.13.2/go.mod h1:7ylQLv2Lqsc3UW3jHoITynYk6Y1tYtgEMkR09ppfsN8= <mask> github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU= </s> Pull request 1835: bootstrap-plain Merge in DNS/adguard-home from bootstrap-plain to master Updates AdguardTeam/dnsproxy#324. Squashed commit of the following: commit bd5d569dc26154985857977e81650eb0a51559a5 Author: Eugene Burkov <[email protected]> Date: Tue Apr 18 17:41:53 2023 +0300 querylog: rm proxyutil dep commit 9db4053555e06eba264f7d3e6c75c747f8d73b56 Author: Eugene Burkov <[email protected]> Date: Tue Apr 18 17:34:29 2023 +0300 all: upd proxy </s> remove github.com/AdguardTeam/dnsproxy v0.48.3 </s> add github.com/AdguardTeam/dnsproxy v0.49.1 </s> remove ip := proxyutil.IPFromRR(msg.Answer[0]).To16() assert.Equal(t, answer, ip) </s> add a := testutil.RequireTypeAssert[*dns.A](t, msg.Answer[0]) assert.Equal(t, answer, a.A.To16()) </s> remove "github.com/AdguardTeam/dnsproxy/proxyutil" </s> add </s> remove assert.True(t, strings.HasSuffix(s, tc.want), "got %q", s) </s> add assert.True(t, strings.HasSuffix(s, tc.want), "got %q", s) </s> remove wantSet: `checking bootstrap a: invalid address: ` + `Resolver a is not eligible to be a bootstrap DNS server`, </s> add wantSet: `checking bootstrap a: invalid address: bootstrap a:53: ` + `ParseAddr("a"): unable to parse IP`,
[ "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/584182e2649fb3617fb423d7838592608ab8612d
go.sum
wantSet: `checking bootstrap a: invalid address: bootstrap a:53: ` + `ParseAddr("a"): unable to parse IP`,
<mask> name: "upstream_dns_bad", <mask> wantSet: `validating upstream servers: validating upstream "!!!": not an ip:port`, <mask> }, { <mask> name: "bootstraps_bad", <mask> wantSet: `checking bootstrap a: invalid address: ` + <mask> `Resolver a is not eligible to be a bootstrap DNS server`, <mask> }, { <mask> name: "cache_bad_ttl", <mask> wantSet: `cache_ttl_min must be less or equal than cache_ttl_max`, <mask> }, { <mask> name: "upstream_mode_bad", </s> Pull request 1835: bootstrap-plain Merge in DNS/adguard-home from bootstrap-plain to master Updates AdguardTeam/dnsproxy#324. Squashed commit of the following: commit bd5d569dc26154985857977e81650eb0a51559a5 Author: Eugene Burkov <[email protected]> Date: Tue Apr 18 17:41:53 2023 +0300 querylog: rm proxyutil dep commit 9db4053555e06eba264f7d3e6c75c747f8d73b56 Author: Eugene Burkov <[email protected]> Date: Tue Apr 18 17:34:29 2023 +0300 all: upd proxy </s> remove assert.True(t, strings.HasSuffix(s, tc.want), "got %q", s) </s> add assert.True(t, strings.HasSuffix(s, tc.want), "got %q", s) </s> remove ip := proxyutil.IPFromRR(msg.Answer[0]).To16() assert.Equal(t, answer, ip) </s> add a := testutil.RequireTypeAssert[*dns.A](t, msg.Answer[0]) assert.Equal(t, answer, a.A.To16()) </s> remove "github.com/AdguardTeam/dnsproxy/proxyutil" </s> add </s> remove github.com/AdguardTeam/dnsproxy v0.48.3 h1:h9xgDSmd1MqsPFNApyaPVXolmSTtzOWOcfWvPeDEP6s= github.com/AdguardTeam/dnsproxy v0.48.3/go.mod h1:Y7g7jRTd/u7+KJ/QvnGI2PCE8vnisp6EsW47/Sz0DZw= </s> add github.com/AdguardTeam/dnsproxy v0.49.1 h1:JpStBK05uCgA3ldleaNLRmIwE9V7vRg7/kVJQSdnQYg= github.com/AdguardTeam/dnsproxy v0.49.1/go.mod h1:Y7g7jRTd/u7+KJ/QvnGI2PCE8vnisp6EsW47/Sz0DZw= </s> remove github.com/AdguardTeam/dnsproxy v0.48.3 </s> add github.com/AdguardTeam/dnsproxy v0.49.1
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/584182e2649fb3617fb423d7838592608ab8612d
internal/dnsforward/http_test.go
assert.True(t, strings.HasSuffix(s, tc.want), "got %q", s)
<mask> s := logOutput.String() <mask> if tc.want == "" { <mask> assert.Empty(t, s) <mask> } else { <mask> assert.True(t, strings.HasSuffix(s, tc.want), <mask> "got %q", s) <mask> } <mask> <mask> logOutput.Reset() <mask> }) <mask> } </s> Pull request 1835: bootstrap-plain Merge in DNS/adguard-home from bootstrap-plain to master Updates AdguardTeam/dnsproxy#324. Squashed commit of the following: commit bd5d569dc26154985857977e81650eb0a51559a5 Author: Eugene Burkov <[email protected]> Date: Tue Apr 18 17:41:53 2023 +0300 querylog: rm proxyutil dep commit 9db4053555e06eba264f7d3e6c75c747f8d73b56 Author: Eugene Burkov <[email protected]> Date: Tue Apr 18 17:34:29 2023 +0300 all: upd proxy </s> remove ip := proxyutil.IPFromRR(msg.Answer[0]).To16() assert.Equal(t, answer, ip) </s> add a := testutil.RequireTypeAssert[*dns.A](t, msg.Answer[0]) assert.Equal(t, answer, a.A.To16()) </s> remove wantSet: `checking bootstrap a: invalid address: ` + `Resolver a is not eligible to be a bootstrap DNS server`, </s> add wantSet: `checking bootstrap a: invalid address: bootstrap a:53: ` + `ParseAddr("a"): unable to parse IP`, </s> remove "github.com/AdguardTeam/dnsproxy/proxyutil" </s> add </s> remove github.com/AdguardTeam/dnsproxy v0.48.3 h1:h9xgDSmd1MqsPFNApyaPVXolmSTtzOWOcfWvPeDEP6s= github.com/AdguardTeam/dnsproxy v0.48.3/go.mod h1:Y7g7jRTd/u7+KJ/QvnGI2PCE8vnisp6EsW47/Sz0DZw= </s> add github.com/AdguardTeam/dnsproxy v0.49.1 h1:JpStBK05uCgA3ldleaNLRmIwE9V7vRg7/kVJQSdnQYg= github.com/AdguardTeam/dnsproxy v0.49.1/go.mod h1:Y7g7jRTd/u7+KJ/QvnGI2PCE8vnisp6EsW47/Sz0DZw= </s> remove github.com/AdguardTeam/dnsproxy v0.48.3 </s> add github.com/AdguardTeam/dnsproxy v0.49.1
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/584182e2649fb3617fb423d7838592608ab8612d
internal/querylog/decode_test.go
<mask> "net" <mask> "testing" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/filtering" <mask> "github.com/AdguardTeam/dnsproxy/proxyutil" <mask> "github.com/AdguardTeam/golibs/stringutil" <mask> "github.com/AdguardTeam/golibs/testutil" <mask> "github.com/AdguardTeam/golibs/timeutil" <mask> "github.com/miekg/dns" <mask> "github.com/stretchr/testify/assert" </s> Pull request 1835: bootstrap-plain Merge in DNS/adguard-home from bootstrap-plain to master Updates AdguardTeam/dnsproxy#324. Squashed commit of the following: commit bd5d569dc26154985857977e81650eb0a51559a5 Author: Eugene Burkov <[email protected]> Date: Tue Apr 18 17:41:53 2023 +0300 querylog: rm proxyutil dep commit 9db4053555e06eba264f7d3e6c75c747f8d73b56 Author: Eugene Burkov <[email protected]> Date: Tue Apr 18 17:34:29 2023 +0300 all: upd proxy </s> remove ip := proxyutil.IPFromRR(msg.Answer[0]).To16() assert.Equal(t, answer, ip) </s> add a := testutil.RequireTypeAssert[*dns.A](t, msg.Answer[0]) assert.Equal(t, answer, a.A.To16()) </s> remove assert.True(t, strings.HasSuffix(s, tc.want), "got %q", s) </s> add assert.True(t, strings.HasSuffix(s, tc.want), "got %q", s) </s> remove wantSet: `checking bootstrap a: invalid address: ` + `Resolver a is not eligible to be a bootstrap DNS server`, </s> add wantSet: `checking bootstrap a: invalid address: bootstrap a:53: ` + `ParseAddr("a"): unable to parse IP`, </s> remove github.com/AdguardTeam/dnsproxy v0.48.3 h1:h9xgDSmd1MqsPFNApyaPVXolmSTtzOWOcfWvPeDEP6s= github.com/AdguardTeam/dnsproxy v0.48.3/go.mod h1:Y7g7jRTd/u7+KJ/QvnGI2PCE8vnisp6EsW47/Sz0DZw= </s> add github.com/AdguardTeam/dnsproxy v0.49.1 h1:JpStBK05uCgA3ldleaNLRmIwE9V7vRg7/kVJQSdnQYg= github.com/AdguardTeam/dnsproxy v0.49.1/go.mod h1:Y7g7jRTd/u7+KJ/QvnGI2PCE8vnisp6EsW47/Sz0DZw= </s> remove github.com/AdguardTeam/dnsproxy v0.48.3 </s> add github.com/AdguardTeam/dnsproxy v0.49.1
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/584182e2649fb3617fb423d7838592608ab8612d
internal/querylog/qlog_test.go
a := testutil.RequireTypeAssert[*dns.A](t, msg.Answer[0]) assert.Equal(t, answer, a.A.To16())
<mask> msg := &dns.Msg{} <mask> require.NoError(t, msg.Unpack(entry.Answer)) <mask> require.Len(t, msg.Answer, 1) <mask> <mask> ip := proxyutil.IPFromRR(msg.Answer[0]).To16() <mask> assert.Equal(t, answer, ip) <mask> } </s> Pull request 1835: bootstrap-plain Merge in DNS/adguard-home from bootstrap-plain to master Updates AdguardTeam/dnsproxy#324. Squashed commit of the following: commit bd5d569dc26154985857977e81650eb0a51559a5 Author: Eugene Burkov <[email protected]> Date: Tue Apr 18 17:41:53 2023 +0300 querylog: rm proxyutil dep commit 9db4053555e06eba264f7d3e6c75c747f8d73b56 Author: Eugene Burkov <[email protected]> Date: Tue Apr 18 17:34:29 2023 +0300 all: upd proxy </s> remove assert.True(t, strings.HasSuffix(s, tc.want), "got %q", s) </s> add assert.True(t, strings.HasSuffix(s, tc.want), "got %q", s) </s> remove "github.com/AdguardTeam/dnsproxy/proxyutil" </s> add </s> remove wantSet: `checking bootstrap a: invalid address: ` + `Resolver a is not eligible to be a bootstrap DNS server`, </s> add wantSet: `checking bootstrap a: invalid address: bootstrap a:53: ` + `ParseAddr("a"): unable to parse IP`, </s> remove github.com/AdguardTeam/dnsproxy v0.48.3 h1:h9xgDSmd1MqsPFNApyaPVXolmSTtzOWOcfWvPeDEP6s= github.com/AdguardTeam/dnsproxy v0.48.3/go.mod h1:Y7g7jRTd/u7+KJ/QvnGI2PCE8vnisp6EsW47/Sz0DZw= </s> add github.com/AdguardTeam/dnsproxy v0.49.1 h1:JpStBK05uCgA3ldleaNLRmIwE9V7vRg7/kVJQSdnQYg= github.com/AdguardTeam/dnsproxy v0.49.1/go.mod h1:Y7g7jRTd/u7+KJ/QvnGI2PCE8vnisp6EsW47/Sz0DZw= </s> remove github.com/AdguardTeam/dnsproxy v0.48.3 </s> add github.com/AdguardTeam/dnsproxy v0.49.1
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/584182e2649fb3617fb423d7838592608ab8612d
internal/querylog/qlog_test.go
// override bind host/port from the console
<mask> err = parseConfig() <mask> if err != nil { <mask> log.Fatal(err) <mask> } <mask> if bindHost != nil { <mask> config.BindHost = *bindHost <mask> } <mask> if bindPort != nil { <mask> config.BindPort = *bindPort </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove err = writeFileSafe(corefile, []byte(configtext)) </s> add err = writeFileSafe(coreFile, []byte(configText)) </s> remove err = writeFileSafe(configfile, yamlText) </s> add err = writeFileSafe(configFile, yamlText) </s> remove jsonentry["status"] = status.String() </s> add jsonEntry["status"] = status.String()
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
app.go
runFiltersUpdatesTimer()
<mask> } <mask> <mask> address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) <mask> <mask> runFilterRefreshers() <mask> <mask> http.Handle("/", optionalAuthHandler(http.FileServer(box))) <mask> registerControlHandlers() <mask> <mask> err = startDNSServer() </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove data = append(data, jsonentry) </s> add data = append(data, jsonEntry) </s> remove if force != "" { config.Lock() for i := range config.Filters { filter := &config.Filters[i] // otherwise we will be operating on a copy filter.LastUpdated = time.Unix(0, 0) } config.Unlock() // not defer because refreshFiltersIfNeccessary locks it too } updated := refreshFiltersIfNeccessary() </s> add updated := checkFiltersUpdates(force != "") </s> remove for range time.Tick(time.Second) { refreshFiltersIfNeccessary() </s> add for range time.Tick(time.Minute) { checkFiltersUpdates(false) </s> remove func runFilterRefreshers() { </s> add // Sets up a timer that will be checking for filters updates periodically func runFiltersUpdatesTimer() {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
app.go
// Saving it to the filters dir now err = filter.save() if err != nil { log.Fatal(err) }
<mask> _, err := filter.update(true) <mask> if err != nil { <mask> log.Fatal(err) <mask> } <mask> } <mask> <mask> // No more "dnsfilter.txt", filters are now loaded from config.ourDataDir/filters/ <mask> dnsFilterPath := filepath.Join(config.ourBinaryDir, "dnsfilter.txt") <mask> _, err := os.Stat(dnsFilterPath) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Reading YAML file: %s", configfile) if _, err := os.Stat(configfile); os.IsNotExist(err) { </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Reading YAML file: %s", configFile) if _, err := os.Stat(configFile); os.IsNotExist(err) { </s> remove hosts := []string{} </s> add hosts := make([]string, 0) </s> remove log.Printf("YAML file doesn't exist, skipping: %s", configfile) </s> add log.Printf("YAML file doesn't exist, skipping: %s", configFile)
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
app.go
url, enabled, lastUpdated: lastUpdated = Date.now(), name = 'Default name', rulesCount: rulesCount = 0,
<mask> export const normalizeFilteringStatus = (filteringStatus) => { <mask> const { enabled, filters, user_rules: userRules } = filteringStatus; <mask> const newFilters = filters ? filters.map((filter) => { <mask> const { <mask> url, enabled, last_updated: lastUpdated = Date.now(), name = 'Default name', rules_count: rulesCount = 0, <mask> } = filter; <mask> <mask> return { <mask> url, enabled, lastUpdated: formatTime(lastUpdated), name, rulesCount, <mask> }; </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove coredns_plugin "github.com/AdguardTeam/AdGuardHome/coredns_plugin" </s> add coreDnsPlugin "github.com/AdguardTeam/AdGuardHome/coredns_plugin" </s> remove var filterTitle = regexp.MustCompile(`^! Title: +(.*)$`) </s> add var filterTitleRegexp = regexp.MustCompile(`^! Title: +(.*)$`) </s> remove log.Printf("Filter %d length is %d", filter.ID, len(filterFile)) filter.contents = filterFile </s> add log.Printf("Filter %d length is %d", filter.ID, len(filterFileContents)) filter.contents = filterFileContents // Now extract the rules count rulesCount, _ := parseFilterContents(filter.contents) filter.RulesCount = rulesCount </s> remove jsonentry["status"] = status.String() </s> add jsonEntry["status"] = status.String() </s> remove jsonentry["rule"] = entry.Result.Rule </s> add jsonEntry["rule"] = entry.Result.Rule jsonEntry["filterId"] = entry.Result.FilterID
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
client/src/helpers/helpers.js
// Just a counter that we use for incrementing the filter ID var NextFilterId int
<mask> <mask> // Directory where we'll store all downloaded filters contents <mask> const FiltersDir = "filters" <mask> <mask> // configuration is loaded from YAML <mask> type configuration struct { <mask> // Config filename (can be overriden via the command line arguments) <mask> ourConfigFilename string <mask> // Basically, this is our working directory <mask> ourBinaryDir string </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove ourBinaryDir string </s> add // Basically, this is our working directory ourBinaryDir string </s> remove ID int `json:"ID"` // auto-assigned when filter is added </s> add ID int `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId) </s> remove LastUpdated time.Time `json:"last_updated" yaml:"-"` </s> add LastUpdated time.Time `json:"lastUpdated" yaml:"last_updated"` </s> remove log.Printf("Filter %d length is %d", filter.ID, len(filterFile)) filter.contents = filterFile </s> add log.Printf("Filter %d length is %d", filter.ID, len(filterFileContents)) filter.contents = filterFileContents // Now extract the rules count rulesCount, _ := parseFilterContents(filter.contents) filter.RulesCount = rulesCount
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
// Config filename (can be overriden via the command line arguments)
<mask> var NextFilterId int <mask> <mask> // configuration is loaded from YAML <mask> type configuration struct { <mask> ourConfigFilename string <mask> // Basically, this is our working directory <mask> ourBinaryDir string <mask> // Directory to store data (i.e. filters contents) <mask> ourDataDir string </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove ourBinaryDir string </s> add // Basically, this is our working directory ourBinaryDir string </s> remove ID int `json:"ID"` // auto-assigned when filter is added </s> add ID int `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId) </s> remove RulesCount int `json:"rules_count" yaml:"-"` </s> add RulesCount int `json:"rulesCount" yaml:"-"` </s> remove log.Printf("Filter %d length is %d", filter.ID, len(filterFile)) filter.contents = filterFile </s> add log.Printf("Filter %d length is %d", filter.ID, len(filterFileContents)) filter.contents = filterFileContents // Now extract the rules count rulesCount, _ := parseFilterContents(filter.contents) filter.RulesCount = rulesCount
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
// Basically, this is our working directory ourBinaryDir string
<mask> <mask> // configuration is loaded from YAML <mask> type configuration struct { <mask> ourConfigFilename string <mask> ourBinaryDir string <mask> // Directory to store data (i.e. filters contents) <mask> ourDataDir string <mask> <mask> // Schema version of the config file. This value is used when performing the app updates. <mask> SchemaVersion int `yaml:"schema_version"` </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove ID int `json:"ID"` // auto-assigned when filter is added </s> add ID int `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId) </s> remove RulesCount int `json:"rules_count" yaml:"-"` </s> add RulesCount int `json:"rulesCount" yaml:"-"` </s> remove func refreshFiltersIfNeccessary() int { </s> add // Checks filters updates if necessary // If force is true, it ignores the filter.LastUpdated field value func checkFiltersUpdates(force bool) int {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
ID int `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId)
<mask> UpstreamDNS []string `yaml:"upstream_dns"` <mask> } <mask> <mask> type filter struct { <mask> ID int `json:"ID"` // auto-assigned when filter is added <mask> URL string `json:"url"` <mask> Name string `json:"name" yaml:"name"` <mask> Enabled bool `json:"enabled"` <mask> RulesCount int `json:"rules_count" yaml:"-"` <mask> contents []byte </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove RulesCount int `json:"rules_count" yaml:"-"` </s> add RulesCount int `json:"rulesCount" yaml:"-"` </s> remove LastUpdated time.Time `json:"last_updated" yaml:"-"` </s> add LastUpdated time.Time `json:"lastUpdated" yaml:"last_updated"` </s> remove ourBinaryDir string </s> add // Basically, this is our working directory ourBinaryDir string
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
RulesCount int `json:"rulesCount" yaml:"-"`
<mask> ID int `json:"ID"` // auto-assigned when filter is added <mask> URL string `json:"url"` <mask> Name string `json:"name" yaml:"name"` <mask> Enabled bool `json:"enabled"` <mask> RulesCount int `json:"rules_count" yaml:"-"` <mask> contents []byte <mask> LastUpdated time.Time `json:"last_updated" yaml:"-"` <mask> } <mask> <mask> var defaultDNS = []string{"tls://1.1.1.1", "tls://1.0.0.1"} </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove ID int `json:"ID"` // auto-assigned when filter is added </s> add ID int `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId) </s> remove LastUpdated time.Time `json:"last_updated" yaml:"-"` </s> add LastUpdated time.Time `json:"lastUpdated" yaml:"last_updated"` </s> remove ourBinaryDir string </s> add // Basically, this is our working directory ourBinaryDir string
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
LastUpdated time.Time `json:"lastUpdated" yaml:"last_updated"`
<mask> Name string `json:"name" yaml:"name"` <mask> Enabled bool `json:"enabled"` <mask> RulesCount int `json:"rules_count" yaml:"-"` <mask> contents []byte <mask> LastUpdated time.Time `json:"last_updated" yaml:"-"` <mask> } <mask> <mask> var defaultDNS = []string{"tls://1.1.1.1", "tls://1.0.0.1"} <mask> <mask> // initialize to default values, will be changed later when reading config or parsing command line </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove RulesCount int `json:"rules_count" yaml:"-"` </s> add RulesCount int `json:"rulesCount" yaml:"-"` </s> remove ID int `json:"ID"` // auto-assigned when filter is added </s> add ID int `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId) </s> remove contents := []byte{} </s> add var contents []byte
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
var contents []byte
<mask> // Creates a helper object for working with the user rules <mask> func getUserFilter() filter { <mask> <mask> // TODO: This should be calculated when UserRules are set <mask> contents := []byte{} <mask> for _, rule := range config.UserRules { <mask> contents = append(contents, []byte(rule)...) <mask> contents = append(contents, '\n') <mask> } <mask> </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove // deduplicate // TODO: move it somewhere else { i := 0 // output index, used for deletion later urls := map[string]bool{} for _, filter := range config.Filters { if _, ok := urls[filter.URL]; !ok { // we didn't see it before, keep it urls[filter.URL] = true // remember the URL config.Filters[i] = filter i++ } } // all entries we want to keep are at front, delete the rest config.Filters = config.Filters[:i] } </s> add </s> remove lines := strings.Split(string(body), "\n") rulesCount := 0 seenTitle := false </s> add rulesCount, filterName := parseFilterContents(body) </s> remove func runFilterRefreshers() { </s> add // Sets up a timer that will be checking for filters updates periodically func runFiltersUpdatesTimer() {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
// Loads configuration from the YAML file
<mask> <mask> return userFilter <mask> } <mask> <mask> func parseConfig() error { <mask> configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) <mask> log.Printf("Reading YAML file: %s", configFile) <mask> if _, err := os.Stat(configFile); os.IsNotExist(err) { </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Reading YAML file: %s", configfile) if _, err := os.Stat(configfile); os.IsNotExist(err) { </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Reading YAML file: %s", configFile) if _, err := os.Stat(configFile); os.IsNotExist(err) { </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configfile) </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configFile) </s> remove log.Printf("YAML file doesn't exist, skipping: %s", configfile) </s> add log.Printf("YAML file doesn't exist, skipping: %s", configFile) </s> remove corefile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", corefile) configtext, err := generateCoreDNSConfigText() </s> add coreFile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", coreFile) configText, err := generateCoreDNSConfigText()
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Reading YAML file: %s", configFile) if _, err := os.Stat(configFile); os.IsNotExist(err) {
<mask> return userFilter <mask> } <mask> <mask> func parseConfig() error { <mask> configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) <mask> log.Printf("Reading YAML file: %s", configfile) <mask> if _, err := os.Stat(configfile); os.IsNotExist(err) { <mask> // do nothing, file doesn't exist <mask> log.Printf("YAML file doesn't exist, skipping: %s", configfile) <mask> return nil <mask> } <mask> yamlFile, err := ioutil.ReadFile(configfile) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove log.Printf("YAML file doesn't exist, skipping: %s", configfile) </s> add log.Printf("YAML file doesn't exist, skipping: %s", configFile) </s> remove yamlFile, err := ioutil.ReadFile(configfile) </s> add yamlFile, err := ioutil.ReadFile(configFile) </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configfile) </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configFile) </s> remove filterFile, err := ioutil.ReadFile(filterFilePath) </s> add filterFileContents, err := ioutil.ReadFile(filterFilePath)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
log.Printf("YAML file doesn't exist, skipping: %s", configFile)
<mask> configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) <mask> log.Printf("Reading YAML file: %s", configfile) <mask> if _, err := os.Stat(configfile); os.IsNotExist(err) { <mask> // do nothing, file doesn't exist <mask> log.Printf("YAML file doesn't exist, skipping: %s", configfile) <mask> return nil <mask> } <mask> yamlFile, err := ioutil.ReadFile(configfile) <mask> if err != nil { <mask> log.Printf("Couldn't read config file: %s", err) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Reading YAML file: %s", configfile) if _, err := os.Stat(configfile); os.IsNotExist(err) { </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Reading YAML file: %s", configFile) if _, err := os.Stat(configFile); os.IsNotExist(err) { </s> remove yamlFile, err := ioutil.ReadFile(configfile) </s> add yamlFile, err := ioutil.ReadFile(configFile) </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configfile) </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configFile) </s> remove filterFile, err := ioutil.ReadFile(filterFilePath) </s> add filterFileContents, err := ioutil.ReadFile(filterFilePath)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
yamlFile, err := ioutil.ReadFile(configFile)
<mask> // do nothing, file doesn't exist <mask> log.Printf("YAML file doesn't exist, skipping: %s", configfile) <mask> return nil <mask> } <mask> yamlFile, err := ioutil.ReadFile(configfile) <mask> if err != nil { <mask> log.Printf("Couldn't read config file: %s", err) <mask> return err <mask> } <mask> err = yaml.Unmarshal(yamlFile, &config) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove log.Printf("YAML file doesn't exist, skipping: %s", configfile) </s> add log.Printf("YAML file doesn't exist, skipping: %s", configFile) </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Reading YAML file: %s", configfile) if _, err := os.Stat(configfile); os.IsNotExist(err) { </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Reading YAML file: %s", configFile) if _, err := os.Stat(configFile); os.IsNotExist(err) { </s> remove filterFile, err := ioutil.ReadFile(filterFilePath) </s> add filterFileContents, err := ioutil.ReadFile(filterFilePath) </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configfile) </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configFile) </s> remove err = writeFileSafe(configfile, yamlText) </s> add err = writeFileSafe(configFile, yamlText)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
// Saves configuration to the YAML file and also saves the user filter contents to a file
<mask> return nil <mask> } <mask> <mask> func writeConfig() error { <mask> configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) <mask> log.Printf("Writing YAML file: %s", configFile) <mask> yamlText, err := yaml.Marshal(&config) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configfile) </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configFile) </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Reading YAML file: %s", configfile) if _, err := os.Stat(configfile); os.IsNotExist(err) { </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Reading YAML file: %s", configFile) if _, err := os.Stat(configFile); os.IsNotExist(err) { </s> remove log.Printf("YAML file doesn't exist, skipping: %s", configfile) </s> add log.Printf("YAML file doesn't exist, skipping: %s", configFile) </s> remove corefile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", corefile) configtext, err := generateCoreDNSConfigText() </s> add coreFile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", coreFile) configText, err := generateCoreDNSConfigText()
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configFile)
<mask> return nil <mask> } <mask> <mask> func writeConfig() error { <mask> configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) <mask> log.Printf("Writing YAML file: %s", configfile) <mask> yamlText, err := yaml.Marshal(&config) <mask> if err != nil { <mask> log.Printf("Couldn't generate YAML file: %s", err) <mask> return err <mask> } </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Reading YAML file: %s", configfile) if _, err := os.Stat(configfile); os.IsNotExist(err) { </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Reading YAML file: %s", configFile) if _, err := os.Stat(configFile); os.IsNotExist(err) { </s> remove log.Printf("YAML file doesn't exist, skipping: %s", configfile) </s> add log.Printf("YAML file doesn't exist, skipping: %s", configFile) </s> remove err = writeFileSafe(configfile, yamlText) </s> add err = writeFileSafe(configFile, yamlText)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
err = writeFileSafe(configFile, yamlText)
<mask> if err != nil { <mask> log.Printf("Couldn't generate YAML file: %s", err) <mask> return err <mask> } <mask> err = writeFileSafe(configfile, yamlText) <mask> if err != nil { <mask> log.Printf("Couldn't save YAML config: %s", err) <mask> return err <mask> } <mask> </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove err = writeFileSafe(corefile, []byte(configtext)) </s> add err = writeFileSafe(coreFile, []byte(configText)) </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configfile) </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configFile) </s> remove configtext := configBytes.String() </s> add configText := configBytes.String() </s> remove // generate config text </s> add // generate CoreDNS config text </s> remove corefile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", corefile) configtext, err := generateCoreDNSConfigText() </s> add coreFile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", coreFile) configText, err := generateCoreDNSConfigText()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
coreFile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", coreFile) configText, err := generateCoreDNSConfigText()
<mask> // -------------- <mask> // coredns config <mask> // -------------- <mask> func writeCoreDNSConfig() error { <mask> corefile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) <mask> log.Printf("Writing DNS config: %s", corefile) <mask> configtext, err := generateCoreDNSConfigText() <mask> if err != nil { <mask> log.Printf("Couldn't generate DNS config: %s", err) <mask> return err <mask> } <mask> err = writeFileSafe(corefile, []byte(configtext)) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove err = writeFileSafe(corefile, []byte(configtext)) </s> add err = writeFileSafe(coreFile, []byte(configText)) </s> remove // generate config text </s> add // generate CoreDNS config text </s> remove configtext := configBytes.String() </s> add configText := configBytes.String() </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configfile) </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configFile) </s> remove err = writeFileSafe(configfile, yamlText) </s> add err = writeFileSafe(configFile, yamlText)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
err = writeFileSafe(coreFile, []byte(configText))
<mask> if err != nil { <mask> log.Printf("Couldn't generate DNS config: %s", err) <mask> return err <mask> } <mask> err = writeFileSafe(corefile, []byte(configtext)) <mask> if err != nil { <mask> log.Printf("Couldn't save DNS config: %s", err) <mask> return err <mask> } <mask> return nil </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove corefile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", corefile) configtext, err := generateCoreDNSConfigText() </s> add coreFile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", coreFile) configText, err := generateCoreDNSConfigText() </s> remove err = writeFileSafe(configfile, yamlText) </s> add err = writeFileSafe(configFile, yamlText) </s> remove configtext := configBytes.String() </s> add configText := configBytes.String() </s> remove // generate config text </s> add // generate CoreDNS config text </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configfile) </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configFile)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
// generate CoreDNS config text
<mask> ` <mask> <mask> var removeEmptyLines = regexp.MustCompile("([\t ]*\n)+") <mask> <mask> // generate config text <mask> func generateCoreDNSConfigText() (string, error) { <mask> t, err := template.New("config").Parse(coreDNSConfigTemplate) <mask> if err != nil { <mask> log.Printf("Couldn't generate DNS config: %s", err) <mask> return "", err </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove corefile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", corefile) configtext, err := generateCoreDNSConfigText() </s> add coreFile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", coreFile) configText, err := generateCoreDNSConfigText() </s> remove configtext := configBytes.String() </s> add configText := configBytes.String() </s> remove err = writeFileSafe(corefile, []byte(configtext)) </s> add err = writeFileSafe(coreFile, []byte(configText)) </s> remove err = writeFileSafe(configfile, yamlText) </s> add err = writeFileSafe(configFile, yamlText) </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configfile) </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configFile)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
configText := configBytes.String()
<mask> if err != nil { <mask> log.Printf("Couldn't generate DNS config: %s", err) <mask> return "", err <mask> } <mask> configtext := configBytes.String() <mask> <mask> // remove empty lines from generated config <mask> configtext = removeEmptyLines.ReplaceAllString(configtext, "\n") <mask> return configtext, nil <mask> } </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove configtext = removeEmptyLines.ReplaceAllString(configtext, "\n") return configtext, nil </s> add configText = removeEmptyLines.ReplaceAllString(configText, "\n") return configText, nil </s> remove corefile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", corefile) configtext, err := generateCoreDNSConfigText() </s> add coreFile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", coreFile) configText, err := generateCoreDNSConfigText() </s> remove // generate config text </s> add // generate CoreDNS config text </s> remove err = writeFileSafe(corefile, []byte(configtext)) </s> add err = writeFileSafe(coreFile, []byte(configText)) </s> remove err = writeFileSafe(configfile, yamlText) </s> add err = writeFileSafe(configFile, yamlText)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
configText = removeEmptyLines.ReplaceAllString(configText, "\n") return configText, nil
<mask> } <mask> configtext := configBytes.String() <mask> <mask> // remove empty lines from generated config <mask> configtext = removeEmptyLines.ReplaceAllString(configtext, "\n") <mask> return configtext, nil <mask> } </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove configtext := configBytes.String() </s> add configText := configBytes.String() </s> remove // Count lines in the filter for _, line := range lines { line = strings.TrimSpace(line) if len(line) > 0 && line[0] == '!' { if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle { filter.Name = m[0][1] seenTitle = true } } else if len(line) != 0 { rulesCount++ } </s> add if filterName != "" { filter.Name = filterName </s> remove lines := strings.Split(string(body), "\n") rulesCount := 0 seenTitle := false </s> add rulesCount, filterName := parseFilterContents(body) </s> remove errortext := fmt.Sprintf("Couldn't remove the filter file: %s", err) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't remove the filter file: %s", err) http.Error(w, errorText, http.StatusInternalServerError) </s> remove corefile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", corefile) configtext, err := generateCoreDNSConfigText() </s> add coreFile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", coreFile) configText, err := generateCoreDNSConfigText()
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
config.go
coreDnsPlugin "github.com/AdguardTeam/AdGuardHome/coredns_plugin"
<mask> "strconv" <mask> "strings" <mask> "time" <mask> <mask> coredns_plugin "github.com/AdguardTeam/AdGuardHome/coredns_plugin" <mask> "github.com/miekg/dns" <mask> "gopkg.in/asaskevich/govalidator.v4" <mask> ) <mask> <mask> const updatePeriod = time.Minute * 30 </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove var filterTitle = regexp.MustCompile(`^! Title: +(.*)$`) </s> add var filterTitleRegexp = regexp.MustCompile(`^! Title: +(.*)$`) </s> remove queryLogAPIPort = "8618" // 8618 is sha512sum of "querylog" then each byte summed </s> add </s> remove url, enabled, last_updated: lastUpdated = Date.now(), name = 'Default name', rules_count: rulesCount = 0, </s> add url, enabled, lastUpdated: lastUpdated = Date.now(), name = 'Default name', rulesCount: rulesCount = 0, </s> remove log.Printf("Downloading update for filter %d", filter.ID) </s> add log.Printf("Downloading update for filter %d from %s", filter.ID, filter.URL) </s> remove queryLogTime time.Time </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
var filterTitleRegexp = regexp.MustCompile(`^! Title: +(.*)$`)
<mask> ) <mask> <mask> const updatePeriod = time.Minute * 30 <mask> <mask> var filterTitle = regexp.MustCompile(`^! Title: +(.*)$`) <mask> <mask> // cached version.json to avoid hammering github.io for each page reload <mask> var versionCheckJSON []byte <mask> var versionCheckLastTime time.Time <mask> </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove coredns_plugin "github.com/AdguardTeam/AdGuardHome/coredns_plugin" </s> add coreDnsPlugin "github.com/AdguardTeam/AdGuardHome/coredns_plugin" </s> remove queryLogAPIPort = "8618" // 8618 is sha512sum of "querylog" then each byte summed </s> add </s> remove LastUpdated time.Time `json:"last_updated" yaml:"-"` </s> add LastUpdated time.Time `json:"lastUpdated" yaml:"last_updated"` </s> remove RulesCount int `json:"rules_count" yaml:"-"` </s> add RulesCount int `json:"rulesCount" yaml:"-"` </s> remove contents := []byte{} </s> add var contents []byte
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
coreDnsPlugin.Reload <- true
<mask> // ------------------- <mask> // coredns run control <mask> // ------------------- <mask> func tellCoreDNSToReload() { <mask> coredns_plugin.Reload <- true <mask> } <mask> <mask> func writeAllConfigsAndReloadCoreDNS() error { <mask> err := writeAllConfigs() <mask> if err != nil { </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove corefile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", corefile) configtext, err := generateCoreDNSConfigText() </s> add coreFile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", coreFile) configText, err := generateCoreDNSConfigText() </s> remove errortext := fmt.Sprintf("Couldn't write config file: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write config file: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove return nil; </s> add return nil </s> remove errortext := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
//noinspection GoUnusedParameter
<mask> returnOK(w, r) <mask> } <mask> <mask> func returnOK(w http.ResponseWriter, r *http.Request) { <mask> _, err := fmt.Fprintf(w, "OK\n") <mask> if err != nil { <mask> errortext := fmt.Sprintf("Couldn't write body: %s", err) <mask> log.Println(errortext) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add </s> remove errortext := fmt.Sprintf("Failed to read request body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("Failed to read request body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove // TODO: Start using filter ID </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
//noinspection GoUnusedParameter
<mask> http.Error(w, errortext, http.StatusInternalServerError) <mask> } <mask> } <mask> <mask> func handleStatus(w http.ResponseWriter, r *http.Request) { <mask> data := map[string]interface{}{ <mask> "dns_address": config.BindHost, <mask> "dns_port": config.CoreDNS.Port, <mask> "protection_enabled": config.CoreDNS.ProtectionEnabled, <mask> "querylog_enabled": config.CoreDNS.QueryLogEnabled, </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove // TODO: Start using filter ID </s> add
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
return fmt.Errorf("couldn't communicate with DNS server %s: %s", input, err)
<mask> } <mask> <mask> resp, rtt, err := c.Exchange(&req, host) <mask> if err != nil { <mask> return fmt.Errorf("Couldn't communicate with DNS server %s: %s", input, err) <mask> } <mask> trace("exchange with %s took %v", input, rtt) <mask> if len(resp.Answer) != 1 { <mask> return fmt.Errorf("DNS server %s returned wrong answer", input) <mask> } </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove return "", fmt.Errorf("Invalid DNS server field: %s", h) </s> add return "", fmt.Errorf("invalid DNS server field: %s", h) </s> remove errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove err = writeFileSafe(corefile, []byte(configtext)) </s> add err = writeFileSafe(coreFile, []byte(configText)) </s> remove // use same update period for failed filter downloads to avoid flooding with requests </s> add // use the same update period for failed filter downloads to avoid flooding with requests </s> remove log.Printf("Downloading update for filter %d", filter.ID) </s> add log.Printf("Downloading update for filter %d from %s", filter.ID, filter.URL)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
hosts := make([]string, 0)
<mask> } <mask> <mask> func sanitiseDNSServers(input string) ([]string, error) { <mask> fields := strings.Fields(input) <mask> hosts := []string{} <mask> for _, field := range fields { <mask> sanitized, err := sanitizeDNSServer(field) <mask> if err != nil { <mask> return hosts, err <mask> } </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove updated, err := filter.update(false) </s> add updated, err := filter.update(force) </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Reading YAML file: %s", configfile) if _, err := os.Stat(configfile); os.IsNotExist(err) { </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Reading YAML file: %s", configFile) if _, err := os.Stat(configFile); os.IsNotExist(err) { </s> remove // deduplicate // TODO: move it somewhere else { i := 0 // output index, used for deletion later urls := map[string]bool{} for _, filter := range config.Filters { if _, ok := urls[filter.URL]; !ok { // we didn't see it before, keep it urls[filter.URL] = true // remember the URL config.Filters[i] = filter i++ } } // all entries we want to keep are at front, delete the rest config.Filters = config.Filters[:i] } </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
return "", fmt.Errorf("invalid DNS server field: %s", h)
<mask> return "", err <mask> } <mask> ip := net.ParseIP(h) <mask> if ip == nil { <mask> return "", fmt.Errorf("Invalid DNS server field: %s", h) <mask> } <mask> } <mask> return prefix + host, nil <mask> } <mask> </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove configtext := configBytes.String() </s> add configText := configBytes.String() </s> remove return fmt.Errorf("Couldn't communicate with DNS server %s: %s", input, err) </s> add return fmt.Errorf("couldn't communicate with DNS server %s: %s", input, err) </s> remove err = writeFileSafe(corefile, []byte(configtext)) </s> add err = writeFileSafe(coreFile, []byte(configText)) </s> remove // generate config text </s> add // generate CoreDNS config text </s> remove corefile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", corefile) configtext, err := generateCoreDNSConfigText() </s> add coreFile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", coreFile) configText, err := generateCoreDNSConfigText()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
//noinspection GoUnusedParameter
<mask> } <mask> return net.JoinHostPort(input, port) <mask> } <mask> <mask> func handleGetVersionJSON(w http.ResponseWriter, r *http.Request) { <mask> now := time.Now() <mask> if now.Sub(versionCheckLastTime) <= versionCheckPeriod && len(versionCheckJSON) != 0 { <mask> // return cached copy <mask> w.Header().Set("Content-Type", "application/json") </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove // Count lines in the filter for _, line := range lines { line = strings.TrimSpace(line) if len(line) > 0 && line[0] == '!' { if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle { filter.Name = m[0][1] seenTitle = true } } else if len(line) != 0 { rulesCount++ } </s> add if filterName != "" { filter.Name = filterName </s> remove if force != "" { config.Lock() for i := range config.Filters { filter := &config.Filters[i] // otherwise we will be operating on a copy filter.LastUpdated = time.Unix(0, 0) } config.Unlock() // not defer because refreshFiltersIfNeccessary locks it too } updated := refreshFiltersIfNeccessary() </s> add updated := checkFiltersUpdates(force != "") </s> remove log.Printf("Downloading update for filter %d", filter.ID) </s> add log.Printf("Downloading update for filter %d from %s", filter.ID, filter.URL) </s> remove errortext := fmt.Sprintf("Unable to write response json: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Unable to write response json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError)
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
//noinspection GoUnusedParameter
<mask> config.CoreDNS.FilteringEnabled = false <mask> httpUpdateConfigReloadDNSReturnOK(w, r) <mask> } <mask> <mask> func handleFilteringStatus(w http.ResponseWriter, r *http.Request) { <mask> data := map[string]interface{}{ <mask> "enabled": config.CoreDNS.FilteringEnabled, <mask> } <mask> </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove // TODO: Start using filter ID </s> add
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
<mask> httpError(w, http.StatusBadRequest, "Failed to parse request body json: %s", err) <mask> return <mask> } <mask> <mask> filter.Enabled = true <mask> if len(filter.URL) == 0 { <mask> http.Error(w, "URL parameter was not specified", 400) <mask> return <mask> } <mask> </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove // check for duplicates </s> add // Check for duplicates </s> remove errortext := fmt.Sprintf("Failed to read request body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("Failed to read request body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove // Count lines in the filter for _, line := range lines { line = strings.TrimSpace(line) if len(line) > 0 && line[0] == '!' { if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle { filter.Name = m[0][1] seenTitle = true } } else if len(line) != 0 { rulesCount++ } </s> add if filterName != "" { filter.Name = filterName </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
// Check for duplicates
<mask> http.Error(w, "URL parameter is not valid request URL", 400) <mask> return <mask> } <mask> <mask> // check for duplicates <mask> for i := range config.Filters { <mask> if config.Filters[i].URL == filter.URL { <mask> errortext := fmt.Sprintf("Filter URL already added -- %s", filter.URL) <mask> log.Println(errortext) <mask> http.Error(w, errortext, http.StatusBadRequest) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("Filter URL already added -- %s", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter URL already added -- %s", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Filter at url %s has no rules (maybe it points to blank page?)", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter at the url %s has no rules (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove filter.Enabled = true </s> add </s> remove errortext := fmt.Sprintf("Filter at url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter at the url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) return } // Save the filter contents err = filter.save() if err != nil { errorText := fmt.Sprintf("Failed to save filter %d due to %s", filter.ID, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
errorText := fmt.Sprintf("Filter URL already added -- %s", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest)
<mask> <mask> // check for duplicates <mask> for i := range config.Filters { <mask> if config.Filters[i].URL == filter.URL { <mask> errortext := fmt.Sprintf("Filter URL already added -- %s", filter.URL) <mask> log.Println(errortext) <mask> http.Error(w, errortext, http.StatusBadRequest) <mask> return <mask> } <mask> } <mask> <mask> ok, err := filter.update(true) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove // check for duplicates </s> add // Check for duplicates </s> remove errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Filter at url %s has no rules (maybe it points to blank page?)", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter at the url %s has no rules (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Filter at url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter at the url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) return } // Save the filter contents err = filter.save() if err != nil { errorText := fmt.Sprintf("Failed to save filter %d due to %s", filter.ID, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove // deduplicate // TODO: move it somewhere else { i := 0 // output index, used for deletion later urls := map[string]bool{} for _, filter := range config.Filters { if _, ok := urls[filter.URL]; !ok { // we didn't see it before, keep it urls[filter.URL] = true // remember the URL config.Filters[i] = filter i++ } } // all entries we want to keep are at front, delete the rest config.Filters = config.Filters[:i] } </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
// Set necessary properties filter.ID = NextFilterId filter.Enabled = true NextFilterId++ // Download the filter contents
<mask> return <mask> } <mask> } <mask> <mask> ok, err := filter.update(true) <mask> if err != nil { <mask> errorText := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) <mask> log.Println(errorText) <mask> http.Error(w, errorText, http.StatusBadRequest) <mask> return </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Filter URL already added -- %s", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter URL already added -- %s", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Filter at url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter at the url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) return } // Save the filter contents err = filter.save() if err != nil { errorText := fmt.Sprintf("Failed to save filter %d due to %s", filter.ID, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError)
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
errorText := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest)
<mask> } <mask> <mask> ok, err := filter.update(true) <mask> if err != nil { <mask> errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, http.StatusBadRequest) <mask> return <mask> } <mask> if filter.RulesCount == 0 { <mask> errortext := fmt.Sprintf("Filter at url %s has no rules (maybe it points to blank page?)", filter.URL) <mask> log.Println(errortext) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("Filter at url %s has no rules (maybe it points to blank page?)", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter at the url %s has no rules (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Filter at url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter at the url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) return } // Save the filter contents err = filter.save() if err != nil { errorText := fmt.Sprintf("Failed to save filter %d due to %s", filter.ID, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Filter URL already added -- %s", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter URL already added -- %s", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove // check for duplicates </s> add // Check for duplicates
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
errorText := fmt.Sprintf("Filter at the url %s has no rules (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest)
<mask> http.Error(w, errortext, http.StatusBadRequest) <mask> return <mask> } <mask> if filter.RulesCount == 0 { <mask> errortext := fmt.Sprintf("Filter at url %s has no rules (maybe it points to blank page?)", filter.URL) <mask> log.Println(errortext) <mask> http.Error(w, errortext, http.StatusBadRequest) <mask> return <mask> } <mask> if !ok { <mask> errortext := fmt.Sprintf("Filter at url %s is invalid (maybe it points to blank page?)", filter.URL) <mask> log.Println(errortext) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Filter at url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter at the url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) return } // Save the filter contents err = filter.save() if err != nil { errorText := fmt.Sprintf("Failed to save filter %d due to %s", filter.ID, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Filter URL already added -- %s", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter URL already added -- %s", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove // check for duplicates </s> add // Check for duplicates </s> remove errortext := fmt.Sprintf("Unable to write response json: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Unable to write response json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
errorText := fmt.Sprintf("Filter at the url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) return } // Save the filter contents err = filter.save() if err != nil { errorText := fmt.Sprintf("Failed to save filter %d due to %s", filter.ID, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest)
<mask> http.Error(w, errortext, http.StatusBadRequest) <mask> return <mask> } <mask> if !ok { <mask> errortext := fmt.Sprintf("Filter at url %s is invalid (maybe it points to blank page?)", filter.URL) <mask> log.Println(errortext) <mask> http.Error(w, errortext, http.StatusBadRequest) <mask> return <mask> } <mask> <mask> // URL is deemed valid, append it to filters, update config, write new filter file and tell coredns to reload it <mask> config.Filters = append(config.Filters, filter) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("Filter at url %s has no rules (maybe it points to blank page?)", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter at the url %s has no rules (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Couldn't write config file: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write config file: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Filter URL already added -- %s", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter URL already added -- %s", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove // check for duplicates </s> add // Check for duplicates
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
errorText := fmt.Sprintf("Couldn't write config file: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError)
<mask> // URL is deemed valid, append it to filters, update config, write new filter file and tell coredns to reload it <mask> config.Filters = append(config.Filters, filter) <mask> err = writeAllConfigs() <mask> if err != nil { <mask> errortext := fmt.Sprintf("Couldn't write config file: %s", err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, http.StatusInternalServerError) <mask> return <mask> } <mask> <mask> tellCoreDNSToReload() <mask> </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("Filter at url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter at the url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) return } // Save the filter contents err = filter.save() if err != nil { errorText := fmt.Sprintf("Failed to save filter %d due to %s", filter.ID, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Unable to write response json: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Unable to write response json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't remove the filter file: %s", err) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't remove the filter file: %s", err) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
errorText := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError)
<mask> tellCoreDNSToReload() <mask> <mask> _, err = fmt.Fprintf(w, "OK %d rules\n", filter.RulesCount) <mask> if err != nil { <mask> errortext := fmt.Sprintf("Couldn't write body: %s", err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, http.StatusInternalServerError) <mask> } <mask> } <mask> <mask> // TODO: Start using filter ID <mask> func handleFilteringRemoveURL(w http.ResponseWriter, r *http.Request) { </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove // TODO: Start using filter ID </s> add </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
<mask> http.Error(w, errortext, http.StatusInternalServerError) <mask> } <mask> } <mask> <mask> // TODO: Start using filter ID <mask> func handleFilteringRemoveURL(w http.ResponseWriter, r *http.Request) { <mask> parameters, err := parseParametersFromBody(r.Body) <mask> if err != nil { <mask> errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) <mask> log.Println(errortext) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400)
<mask> // TODO: Start using filter ID <mask> func handleFilteringRemoveURL(w http.ResponseWriter, r *http.Request) { <mask> parameters, err := parseParametersFromBody(r.Body) <mask> if err != nil { <mask> errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, 400) <mask> return <mask> } <mask> <mask> url, ok := parameters["url"] <mask> if !ok { </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
errorText := fmt.Sprintf("Couldn't remove the filter file: %s", err) http.Error(w, errorText, http.StatusInternalServerError)
<mask> } else { <mask> // Remove the filter file <mask> err := os.Remove(filter.getFilterFilePath()) <mask> if err != nil { <mask> errortext := fmt.Sprintf("Couldn't remove the filter file: %s", err) <mask> http.Error(w, errortext, http.StatusInternalServerError) <mask> return <mask> } <mask> } <mask> } <mask> // Update the configuration after removing filter files </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("Couldn't write config file: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write config file: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove // TODO: Start using filter ID </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
<mask> config.Filters = newFilters <mask> httpUpdateConfigReloadDNSReturnOK(w, r) <mask> } <mask> <mask> // TODO: Start using filter ID <mask> func handleFilteringEnableURL(w http.ResponseWriter, r *http.Request) { <mask> parameters, err := parseParametersFromBody(r.Body) <mask> if err != nil { <mask> errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) <mask> log.Println(errortext) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove // TODO: Start using filter ID </s> add </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove // TODO: Start using filter ID </s> add </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400)
<mask> // TODO: Start using filter ID <mask> func handleFilteringEnableURL(w http.ResponseWriter, r *http.Request) { <mask> parameters, err := parseParametersFromBody(r.Body) <mask> if err != nil { <mask> errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, 400) <mask> return <mask> } <mask> <mask> url, ok := parameters["url"] <mask> if !ok { </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
checkFiltersUpdates(false)
<mask> return <mask> } <mask> <mask> // kick off refresh of rules from new URLs <mask> refreshFiltersIfNeccessary() <mask> httpUpdateConfigReloadDNSReturnOK(w, r) <mask> } <mask> <mask> // TODO: Start using filter ID <mask> func handleFilteringDisableURL(w http.ResponseWriter, r *http.Request) { </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
<mask> refreshFiltersIfNeccessary() <mask> httpUpdateConfigReloadDNSReturnOK(w, r) <mask> } <mask> <mask> // TODO: Start using filter ID <mask> func handleFilteringDisableURL(w http.ResponseWriter, r *http.Request) { <mask> parameters, err := parseParametersFromBody(r.Body) <mask> if err != nil { <mask> errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) <mask> log.Println(errortext) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove // TODO: Start using filter ID </s> add </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove // TODO: Start using filter ID </s> add </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400)
<mask> // TODO: Start using filter ID <mask> func handleFilteringDisableURL(w http.ResponseWriter, r *http.Request) { <mask> parameters, err := parseParametersFromBody(r.Body) <mask> if err != nil { <mask> errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, 400) <mask> return <mask> } <mask> <mask> url, ok := parameters["url"] <mask> if !ok { </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
errorText := fmt.Sprintf("Failed to read request body: %s", err) log.Println(errorText) http.Error(w, errorText, 400)
<mask> <mask> func handleFilteringSetRules(w http.ResponseWriter, r *http.Request) { <mask> body, err := ioutil.ReadAll(r.Body) <mask> if err != nil { <mask> errortext := fmt.Sprintf("Failed to read request body: %s", err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, 400) <mask> return <mask> } <mask> <mask> config.UserRules = strings.Split(string(body), "\n") <mask> httpUpdateConfigReloadDNSReturnOK(w, r) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
updated := checkFiltersUpdates(force != "")
<mask> } <mask> <mask> func handleFilteringRefresh(w http.ResponseWriter, r *http.Request) { <mask> force := r.URL.Query().Get("force") <mask> if force != "" { <mask> config.Lock() <mask> for i := range config.Filters { <mask> filter := &config.Filters[i] // otherwise we will be operating on a copy <mask> filter.LastUpdated = time.Unix(0, 0) <mask> } <mask> config.Unlock() // not defer because refreshFiltersIfNeccessary locks it too <mask> } <mask> updated := refreshFiltersIfNeccessary() <mask> fmt.Fprintf(w, "OK %d filters updated\n", updated) <mask> } <mask> <mask> func runFilterRefreshers() { <mask> go func() { </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove func runFilterRefreshers() { </s> add // Sets up a timer that will be checking for filters updates periodically func runFiltersUpdatesTimer() { </s> remove updated, err := filter.update(false) </s> add updated, err := filter.update(force) </s> remove // deduplicate // TODO: move it somewhere else { i := 0 // output index, used for deletion later urls := map[string]bool{} for _, filter := range config.Filters { if _, ok := urls[filter.URL]; !ok { // we didn't see it before, keep it urls[filter.URL] = true // remember the URL config.Filters[i] = filter i++ } } // all entries we want to keep are at front, delete the rest config.Filters = config.Filters[:i] } </s> add </s> remove func refreshFiltersIfNeccessary() int { </s> add // Checks filters updates if necessary // If force is true, it ignores the filter.LastUpdated field value func checkFiltersUpdates(force bool) int { </s> remove for range time.Tick(time.Second) { refreshFiltersIfNeccessary() </s> add for range time.Tick(time.Minute) { checkFiltersUpdates(false)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
// Sets up a timer that will be checking for filters updates periodically func runFiltersUpdatesTimer() {
<mask> updated := refreshFiltersIfNeccessary() <mask> fmt.Fprintf(w, "OK %d filters updated\n", updated) <mask> } <mask> <mask> func runFilterRefreshers() { <mask> go func() { <mask> for range time.Tick(time.Second) { <mask> refreshFiltersIfNeccessary() <mask> } <mask> }() </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove for range time.Tick(time.Second) { refreshFiltersIfNeccessary() </s> add for range time.Tick(time.Minute) { checkFiltersUpdates(false) </s> remove if force != "" { config.Lock() for i := range config.Filters { filter := &config.Filters[i] // otherwise we will be operating on a copy filter.LastUpdated = time.Unix(0, 0) } config.Unlock() // not defer because refreshFiltersIfNeccessary locks it too } updated := refreshFiltersIfNeccessary() </s> add updated := checkFiltersUpdates(force != "") </s> remove func refreshFiltersIfNeccessary() int { </s> add // Checks filters updates if necessary // If force is true, it ignores the filter.LastUpdated field value func checkFiltersUpdates(force bool) int { </s> remove errortext := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove // deduplicate // TODO: move it somewhere else { i := 0 // output index, used for deletion later urls := map[string]bool{} for _, filter := range config.Filters { if _, ok := urls[filter.URL]; !ok { // we didn't see it before, keep it urls[filter.URL] = true // remember the URL config.Filters[i] = filter i++ } } // all entries we want to keep are at front, delete the rest config.Filters = config.Filters[:i] } </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
for range time.Tick(time.Minute) { checkFiltersUpdates(false)
<mask> } <mask> <mask> func runFilterRefreshers() { <mask> go func() { <mask> for range time.Tick(time.Second) { <mask> refreshFiltersIfNeccessary() <mask> } <mask> }() <mask> } <mask> <mask> func refreshFiltersIfNeccessary() int { </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove func runFilterRefreshers() { </s> add // Sets up a timer that will be checking for filters updates periodically func runFiltersUpdatesTimer() { </s> remove if force != "" { config.Lock() for i := range config.Filters { filter := &config.Filters[i] // otherwise we will be operating on a copy filter.LastUpdated = time.Unix(0, 0) } config.Unlock() // not defer because refreshFiltersIfNeccessary locks it too } updated := refreshFiltersIfNeccessary() </s> add updated := checkFiltersUpdates(force != "") </s> remove func refreshFiltersIfNeccessary() int { </s> add // Checks filters updates if necessary // If force is true, it ignores the filter.LastUpdated field value func checkFiltersUpdates(force bool) int { </s> remove // deduplicate // TODO: move it somewhere else { i := 0 // output index, used for deletion later urls := map[string]bool{} for _, filter := range config.Filters { if _, ok := urls[filter.URL]; !ok { // we didn't see it before, keep it urls[filter.URL] = true // remember the URL config.Filters[i] = filter i++ } } // all entries we want to keep are at front, delete the rest config.Filters = config.Filters[:i] } </s> add </s> remove refreshFiltersIfNeccessary() </s> add checkFiltersUpdates(false)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
// Checks filters updates if necessary // If force is true, it ignores the filter.LastUpdated field value func checkFiltersUpdates(force bool) int {
<mask> } <mask> }() <mask> } <mask> <mask> func refreshFiltersIfNeccessary() int { <mask> config.Lock() <mask> <mask> // deduplicate <mask> // TODO: move it somewhere else <mask> { </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove // deduplicate // TODO: move it somewhere else { i := 0 // output index, used for deletion later urls := map[string]bool{} for _, filter := range config.Filters { if _, ok := urls[filter.URL]; !ok { // we didn't see it before, keep it urls[filter.URL] = true // remember the URL config.Filters[i] = filter i++ } } // all entries we want to keep are at front, delete the rest config.Filters = config.Filters[:i] } </s> add </s> remove for range time.Tick(time.Second) { refreshFiltersIfNeccessary() </s> add for range time.Tick(time.Minute) { checkFiltersUpdates(false) </s> remove func runFilterRefreshers() { </s> add // Sets up a timer that will be checking for filters updates periodically func runFiltersUpdatesTimer() { </s> remove if force != "" { config.Lock() for i := range config.Filters { filter := &config.Filters[i] // otherwise we will be operating on a copy filter.LastUpdated = time.Unix(0, 0) } config.Unlock() // not defer because refreshFiltersIfNeccessary locks it too } updated := refreshFiltersIfNeccessary() </s> add updated := checkFiltersUpdates(force != "") </s> remove refreshFiltersIfNeccessary() </s> add checkFiltersUpdates(false)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
<mask> <mask> func refreshFiltersIfNeccessary() int { <mask> config.Lock() <mask> <mask> // deduplicate <mask> // TODO: move it somewhere else <mask> { <mask> i := 0 // output index, used for deletion later <mask> urls := map[string]bool{} <mask> for _, filter := range config.Filters { <mask> if _, ok := urls[filter.URL]; !ok { <mask> // we didn't see it before, keep it <mask> urls[filter.URL] = true // remember the URL <mask> config.Filters[i] = filter <mask> i++ <mask> } <mask> } <mask> // all entries we want to keep are at front, delete the rest <mask> config.Filters = config.Filters[:i] <mask> } <mask> <mask> // fetch URLs <mask> updateCount := 0 <mask> for i := range config.Filters { <mask> filter := &config.Filters[i] // otherwise we will be operating on a copy <mask> updated, err := filter.update(false) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove updated, err := filter.update(false) </s> add updated, err := filter.update(force) </s> remove if force != "" { config.Lock() for i := range config.Filters { filter := &config.Filters[i] // otherwise we will be operating on a copy filter.LastUpdated = time.Unix(0, 0) } config.Unlock() // not defer because refreshFiltersIfNeccessary locks it too } updated := refreshFiltersIfNeccessary() </s> add updated := checkFiltersUpdates(force != "") </s> remove func refreshFiltersIfNeccessary() int { </s> add // Checks filters updates if necessary // If force is true, it ignores the filter.LastUpdated field value func checkFiltersUpdates(force bool) int { </s> remove contents := []byte{} </s> add var contents []byte </s> remove // Count lines in the filter for _, line := range lines { line = strings.TrimSpace(line) if len(line) > 0 && line[0] == '!' { if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle { filter.Name = m[0][1] seenTitle = true } } else if len(line) != 0 { rulesCount++ } </s> add if filterName != "" { filter.Name = filterName
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go