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
|
---|---|---|---|---|
} else if code != 0 { | <mask> // Setting DNS servers is necessary when configuring a static IP
<mask> code, _, err := aghos.RunCommand("networksetup", args...)
<mask> if err != nil {
<mask> return err
<mask> }
<mask> if code != 0 {
<mask> return fmt.Errorf("failed to set DNS servers, code=%d", code)
<mask> }
<mask>
<mask> // Actually configures hardware port to have static IP
<mask> code, _, err = aghos.RunCommand("networksetup", "-setmanual",
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove code, _, err := aghos.RunCommand("networksetup", args...)
</s> add code, _, err := aghosRunCommand("networksetup", args...) </s> remove code, _, err = aghos.RunCommand("networksetup", "-setmanual",
portInfo.name, portInfo.ip, portInfo.subnet, portInfo.gatewayIP)
</s> add code, _, err = aghosRunCommand(
"networksetup",
"-setmanual",
portInfo.name,
portInfo.ip,
portInfo.subnet,
portInfo.gatewayIP,
) </s> remove }
if code != 0 {
</s> add } else if code != 0 { </s> remove args := make([]string, 0)
args = append(args, "-setdnsservers", portInfo.name)
args = append(args, dnsAddrs...)
</s> add args := append([]string{"-setdnsservers", portInfo.name}, dnsAddrs...) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
code, _, err = aghosRunCommand(
"networksetup",
"-setmanual",
portInfo.name,
portInfo.ip,
portInfo.subnet,
portInfo.gatewayIP,
) | <mask> return fmt.Errorf("failed to set DNS servers, code=%d", code)
<mask> }
<mask>
<mask> // Actually configures hardware port to have static IP
<mask> code, _, err = aghos.RunCommand("networksetup", "-setmanual",
<mask> portInfo.name, portInfo.ip, portInfo.subnet, portInfo.gatewayIP)
<mask> if err != nil {
<mask> return err
<mask> }
<mask> if code != 0 {
<mask> return fmt.Errorf("failed to set DNS servers, code=%d", code)
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove }
if code != 0 {
</s> add } else if code != 0 { </s> remove }
if code != 0 {
</s> add } else if code != 0 { </s> remove code, _, err := aghos.RunCommand("networksetup", args...)
</s> add code, _, err := aghosRunCommand("networksetup", args...) </s> remove args := make([]string, 0)
args = append(args, "-setdnsservers", portInfo.name)
args = append(args, dnsAddrs...)
</s> add args := append([]string{"-setdnsservers", portInfo.name}, dnsAddrs...) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
} else if code != 0 { | <mask> code, _, err = aghos.RunCommand("networksetup", "-setmanual",
<mask> portInfo.name, portInfo.ip, portInfo.subnet, portInfo.gatewayIP)
<mask> if err != nil {
<mask> return err
<mask> }
<mask> if code != 0 {
<mask> return fmt.Errorf("failed to set DNS servers, code=%d", code)
<mask> }
<mask>
<mask> return nil
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove code, _, err = aghos.RunCommand("networksetup", "-setmanual",
portInfo.name, portInfo.ip, portInfo.subnet, portInfo.gatewayIP)
</s> add code, _, err = aghosRunCommand(
"networksetup",
"-setmanual",
portInfo.name,
portInfo.ip,
portInfo.subnet,
portInfo.gatewayIP,
) </s> remove }
if code != 0 {
</s> add } else if code != 0 { </s> remove code, _, err := aghos.RunCommand("networksetup", args...)
</s> add code, _, err := aghosRunCommand("networksetup", args...) </s> remove args := make([]string, 0)
args = append(args, "-setdnsservers", portInfo.name)
args = append(args, dnsAddrs...)
</s> add args := append([]string{"-setdnsservers", portInfo.name}, dnsAddrs...) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
// etcResolvConfReg is the regular expression matching the lines of resolv.conf
// file containing a name server information.
var etcResolvConfReg = regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
| <mask>
<mask> return nil
<mask> }
<mask>
<mask> // getEtcResolvConfServers returns a list of nameservers configured in
<mask> // /etc/resolv.conf.
<mask> func getEtcResolvConfServers() (addrs []string, err error) {
<mask> const filename = "etc/resolv.conf"
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove func getEtcResolvConfServers() ([]string, error) {
body, err := os.ReadFile("/etc/resolv.conf")
</s> add func getEtcResolvConfServers() (addrs []string, err error) {
const filename = "etc/resolv.conf"
_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {
sc := bufio.NewScanner(r)
for sc.Scan() {
matches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)
if len(matches) == 0 {
continue
}
for _, m := range matches {
addrs = append(addrs, m[1])
}
}
return nil, false, sc.Err()
}).Walk(rootDirFS, filename) </s> remove return aghos.FileWalker(hostnameIfStaticConfig).Walk(aghos.RootDirFS(), filename)
</s> add return aghos.FileWalker(hostnameIfStaticConfig).Walk(rootDirFS, filename) </s> remove return walker.Walk(aghos.RootDirFS(), rcConfFilename)
</s> add return walker.Walk(rootDirFS, rcConfFilename) </s> remove return nil, err
}
re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
matches := re.FindAllStringSubmatch(string(body), -1)
if len(matches) == 0 {
return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
}
addrs := make([]string, 0)
for i := range matches {
addrs = append(addrs, matches[i][1])
</s> add return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) </s> remove ifaceFound := findIfaceLine(s, string(n))
if !ifaceFound {
</s> add if !findIfaceLine(s, string(n)) { | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
func getEtcResolvConfServers() (addrs []string, err error) {
const filename = "etc/resolv.conf"
_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {
sc := bufio.NewScanner(r)
for sc.Scan() {
matches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)
if len(matches) == 0 {
continue
}
for _, m := range matches {
addrs = append(addrs, m[1])
}
}
return nil, false, sc.Err()
}).Walk(rootDirFS, filename) | <mask> }
<mask>
<mask> // getEtcResolvConfServers returns a list of nameservers configured in
<mask> // /etc/resolv.conf.
<mask> func getEtcResolvConfServers() ([]string, error) {
<mask> body, err := os.ReadFile("/etc/resolv.conf")
<mask> if err != nil {
<mask> return nil, err
<mask> }
<mask>
<mask> re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove return nil, err
}
re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
matches := re.FindAllStringSubmatch(string(body), -1)
if len(matches) == 0 {
return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
}
addrs := make([]string, 0)
for i := range matches {
addrs = append(addrs, matches[i][1])
</s> add return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) </s> remove ifaceFound := findIfaceLine(s, string(n))
if !ifaceFound {
</s> add if !findIfaceLine(s, string(n)) { </s> remove func GetValidNetInterfacesForWeb() ([]*NetInterface, error) {
</s> add func GetValidNetInterfacesForWeb() (netInterfaces []*NetInterface, err error) { </s> remove func GatewayIP(ifaceName string) net.IP {
cmd := exec.Command("ip", "route", "show", "dev", ifaceName)
log.Tracef("executing %s %v", cmd.Path, cmd.Args)
d, err := cmd.Output()
if err != nil || cmd.ProcessState.ExitCode() != 0 {
</s> add //
// TODO(e.burkov): Investigate if the gateway address may be fetched in another
// way since not every machine has the software installed.
func GatewayIP(ifaceName string) (ip net.IP) {
code, out, err := aghosRunCommand("ip", "route", "show", "dev", ifaceName)
if err != nil {
log.Debug("%s", err)
return nil
} else if code != 0 {
log.Debug("fetching gateway ip: unexpected exit code: %d", code)
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) | <mask> // /etc/resolv.conf.
<mask> func getEtcResolvConfServers() ([]string, error) {
<mask> body, err := os.ReadFile("/etc/resolv.conf")
<mask> if err != nil {
<mask> return nil, err
<mask> }
<mask>
<mask> re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
<mask>
<mask> matches := re.FindAllStringSubmatch(string(body), -1)
<mask> if len(matches) == 0 {
<mask> return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
<mask> }
<mask>
<mask> addrs := make([]string, 0)
<mask> for i := range matches {
<mask> addrs = append(addrs, matches[i][1])
<mask> }
<mask>
<mask> return addrs, nil
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove func getEtcResolvConfServers() ([]string, error) {
body, err := os.ReadFile("/etc/resolv.conf")
</s> add func getEtcResolvConfServers() (addrs []string, err error) {
const filename = "etc/resolv.conf"
_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {
sc := bufio.NewScanner(r)
for sc.Scan() {
matches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)
if len(matches) == 0 {
continue
}
for _, m := range matches {
addrs = append(addrs, m[1])
}
}
return nil, false, sc.Err()
}).Walk(rootDirFS, filename) </s> remove m := make(map[string]string)
</s> add reports = make(map[string]string) </s> remove matches := re.FindAllStringSubmatch(out, -1)
for i := range matches {
port := matches[i][1]
device := matches[i][2]
m[device] = port
</s> add matches := hardwareReportsReg.FindAllSubmatch(out, -1)
for _, m := range matches {
reports[string(m[2])] = string(m[1]) </s> remove var netInterfaces []*NetInterface
</s> add </s> remove args := make([]string, 0)
args = append(args, "-setdnsservers", portInfo.name)
args = append(args, dnsAddrs...)
</s> add args := append([]string{"-setdnsservers", portInfo.name}, dnsAddrs...) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
return walker.Walk(rootDirFS, rcConfFilename) | <mask> const rcConfFilename = "etc/rc.conf"
<mask>
<mask> walker := aghos.FileWalker(interfaceName(ifaceName).rcConfStaticConfig)
<mask>
<mask> return walker.Walk(aghos.RootDirFS(), rcConfFilename)
<mask> }
<mask>
<mask> // rcConfStaticConfig checks if the interface is configured by /etc/rc.conf to
<mask> // have a static IP.
<mask> func (n interfaceName) rcConfStaticConfig(r io.Reader) (_ []string, cont bool, err error) {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove ifaceFound := findIfaceLine(s, string(n))
if !ifaceFound {
</s> add if !findIfaceLine(s, string(n)) { </s> remove return aghos.FileWalker(hostnameIfStaticConfig).Walk(aghos.RootDirFS(), filename)
</s> add return aghos.FileWalker(hostnameIfStaticConfig).Walk(rootDirFS, filename) </s> remove func getEtcResolvConfServers() ([]string, error) {
body, err := os.ReadFile("/etc/resolv.conf")
</s> add func getEtcResolvConfServers() (addrs []string, err error) {
const filename = "etc/resolv.conf"
_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {
sc := bufio.NewScanner(r)
for sc.Scan() {
matches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)
if len(matches) == 0 {
continue
}
for _, m := range matches {
addrs = append(addrs, m[1])
}
}
return nil, false, sc.Err()
}).Walk(rootDirFS, filename) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_freebsd.go |
"io/fs" | <mask>
<mask> package aghnet
<mask>
<mask> import (
<mask> "strings"
<mask> "testing"
<mask>
<mask> "github.com/stretchr/testify/assert"
<mask> "github.com/stretchr/testify/require"
<mask> )
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "strings"
</s> add "fmt"
"io/fs" </s> remove "bytes"
</s> add "io/fs" </s> remove "io"
</s> add </s> remove "io"
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_freebsd_test.go |
"testing/fstest" | <mask> "io/fs"
<mask> "testing"
<mask>
<mask> "github.com/stretchr/testify/assert"
<mask> "github.com/stretchr/testify/require"
<mask> )
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "strings"
</s> add "io/fs" </s> remove "strings"
</s> add "fmt"
"io/fs" </s> remove "bytes"
</s> add "io/fs" | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_freebsd_test.go |
const (
ifaceName = `em0`
rcConf = "etc/rc.conf"
) | <mask> "github.com/stretchr/testify/require"
<mask> )
<mask>
<mask> func TestRcConfStaticConfig(t *testing.T) {
<mask> const iface interfaceName = `em0`
<mask> const nl = "\n"
<mask>
<mask> testCases := []struct {
<mask> name string
<mask> rcconfData string
<mask> wantCont bool
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove name string
rcconfData string
wantCont bool
</s> add name string
rootFsys fs.FS
wantHas assert.BoolAssertionFunc </s> remove func TestHostnameIfStaticConfig(t *testing.T) {
const nl = "\n"
</s> add func TestIfaceHasStaticIP(t *testing.T) {
const ifaceName = "em0"
confFile := fmt.Sprintf("etc/hostname.%s", ifaceName) </s> remove func TestDHCPCDStaticConfig(t *testing.T) {
const iface interfaceName = `wlan0`
</s> add func TestHasStaticIP(t *testing.T) {
const ifaceName = "wlan0" </s> remove name string
rcconfData string
wantHas bool
</s> add name string
rootFsys fs.FS
wantHas assert.BoolAssertionFunc </s> remove name string
data []byte
wantCont bool
wantPatterns []string
</s> add rootFsys fs.FS
name string
wantHas assert.BoolAssertionFunc
wantErrMsg string | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_freebsd_test.go |
name string
rootFsys fs.FS
wantHas assert.BoolAssertionFunc | <mask> const iface interfaceName = `em0`
<mask> const nl = "\n"
<mask>
<mask> testCases := []struct {
<mask> name string
<mask> rcconfData string
<mask> wantCont bool
<mask> }{{
<mask> name: "simple",
<mask> rcconfData: `ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
<mask> wantCont: false,
<mask> }, {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove name: "simple",
rcconfData: `ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add name: "simple",
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl),
}},
wantHas: assert.True, </s> remove const iface interfaceName = `em0`
const nl = "\n"
</s> add const (
ifaceName = `em0`
rcConf = "etc/rc.conf"
) </s> remove name string
rcconfData string
wantHas bool
</s> add name string
rootFsys fs.FS
wantHas assert.BoolAssertionFunc </s> remove name string
data []byte
wantCont bool
wantPatterns []string
</s> add rootFsys fs.FS
name string
wantHas assert.BoolAssertionFunc
wantErrMsg string </s> remove rcconfData: `ifconfig_em0_alias="inet 127.0.0.1/24"` + nl +
`ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `_alias="inet 127.0.0.1/24"` + nl +
`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl,
),
}},
wantHas: assert.True, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_freebsd_test.go |
name: "simple",
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl),
}},
wantHas: assert.True, | <mask> name string
<mask> rcconfData string
<mask> wantCont bool
<mask> }{{
<mask> name: "simple",
<mask> rcconfData: `ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
<mask> wantCont: false,
<mask> }, {
<mask> name: "case_insensitiveness",
<mask> rcconfData: `ifconfig_em0="InEt 127.0.0.253 NeTmAsK 0xffffffff"` + nl,
<mask> wantCont: false,
<mask> }, {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove name: "case_insensitiveness",
rcconfData: `ifconfig_em0="InEt 127.0.0.253 NeTmAsK 0xffffffff"` + nl,
wantCont: false,
</s> add name: "case_insensitiveness",
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `="InEt 127.0.0.253 NeTmAsK 0xffffffff"` + nl),
}},
wantHas: assert.True, </s> remove name string
rcconfData string
wantCont bool
</s> add name string
rootFsys fs.FS
wantHas assert.BoolAssertionFunc </s> remove rcconfData: `# comment 1` + nl +
`` + nl +
`# comment 2` + nl +
`ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`# comment 1` + nl +
`` + nl +
`# comment 2` + nl +
`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl,
),
}},
wantHas: assert.True, </s> remove rcconfData: `ifconfig_em0_alias="inet 127.0.0.1/24"` + nl +
`ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `_alias="inet 127.0.0.1/24"` + nl +
`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl,
),
}},
wantHas: assert.True, </s> remove rcconfData: `ifconfig_em0="inet6 127.0.0.253 netmask 0xffffffff"` + nl +
`ifconfig_em0="inet 256.256.256.256 netmask 0xffffffff"` + nl +
`ifconfig_em0=""` + nl,
wantCont: true,
</s> add rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(
`ifconfig_` + ifaceName + `="inet6 127.0.0.253 netmask 0xffffffff"` + nl +
`ifconfig_` + ifaceName + `="inet 256.256.256.256 netmask 0xffffffff"` + nl +
`ifconfig_` + ifaceName + `=""` + nl,
),
}},
wantHas: assert.False, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_freebsd_test.go |
name: "case_insensitiveness",
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `="InEt 127.0.0.253 NeTmAsK 0xffffffff"` + nl),
}},
wantHas: assert.True, | <mask> name: "simple",
<mask> rcconfData: `ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
<mask> wantCont: false,
<mask> }, {
<mask> name: "case_insensitiveness",
<mask> rcconfData: `ifconfig_em0="InEt 127.0.0.253 NeTmAsK 0xffffffff"` + nl,
<mask> wantCont: false,
<mask> }, {
<mask> name: "comments_and_trash",
<mask> rcconfData: `# comment 1` + nl +
<mask> `` + nl +
<mask> `# comment 2` + nl +
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove rcconfData: `# comment 1` + nl +
`` + nl +
`# comment 2` + nl +
`ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`# comment 1` + nl +
`` + nl +
`# comment 2` + nl +
`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl,
),
}},
wantHas: assert.True, </s> remove name: "simple",
rcconfData: `ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add name: "simple",
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl),
}},
wantHas: assert.True, </s> remove rcconfData: `ifconfig_em0_alias="inet 127.0.0.1/24"` + nl +
`ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `_alias="inet 127.0.0.1/24"` + nl +
`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl,
),
}},
wantHas: assert.True, </s> remove rcconfData: `# comment 1` + nl +
`` + nl +
`# inet 127.0.0.253` + nl +
`inet` + nl,
wantHas: false,
</s> add rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`# comment 1` + nl + nl +
`# inet 127.0.0.253` + nl +
`inet` + nl,
),
},
},
wantHas: assert.False, </s> remove name: "case_sensitiveness",
rcconfData: `InEt 127.0.0.253` + nl,
wantHas: false,
</s> add name: "case_sensitiveness",
rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`InEt 127.0.0.253` + nl),
},
},
wantHas: assert.False, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_freebsd_test.go |
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`# comment 1` + nl +
`` + nl +
`# comment 2` + nl +
`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl,
),
}},
wantHas: assert.True, | <mask> rcconfData: `ifconfig_em0="InEt 127.0.0.253 NeTmAsK 0xffffffff"` + nl,
<mask> wantCont: false,
<mask> }, {
<mask> name: "comments_and_trash",
<mask> rcconfData: `# comment 1` + nl +
<mask> `` + nl +
<mask> `# comment 2` + nl +
<mask> `ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
<mask> wantCont: false,
<mask> }, {
<mask> name: "aliases",
<mask> rcconfData: `ifconfig_em0_alias="inet 127.0.0.1/24"` + nl +
<mask> `ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
<mask> wantCont: false,
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove name: "case_insensitiveness",
rcconfData: `ifconfig_em0="InEt 127.0.0.253 NeTmAsK 0xffffffff"` + nl,
wantCont: false,
</s> add name: "case_insensitiveness",
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `="InEt 127.0.0.253 NeTmAsK 0xffffffff"` + nl),
}},
wantHas: assert.True, </s> remove rcconfData: `ifconfig_em0_alias="inet 127.0.0.1/24"` + nl +
`ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `_alias="inet 127.0.0.1/24"` + nl +
`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl,
),
}},
wantHas: assert.True, </s> remove name: "simple",
rcconfData: `ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add name: "simple",
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl),
}},
wantHas: assert.True, </s> remove rcconfData: `ifconfig_em0="inet6 127.0.0.253 netmask 0xffffffff"` + nl +
`ifconfig_em0="inet 256.256.256.256 netmask 0xffffffff"` + nl +
`ifconfig_em0=""` + nl,
wantCont: true,
</s> add rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(
`ifconfig_` + ifaceName + `="inet6 127.0.0.253 netmask 0xffffffff"` + nl +
`ifconfig_` + ifaceName + `="inet 256.256.256.256 netmask 0xffffffff"` + nl +
`ifconfig_` + ifaceName + `=""` + nl,
),
}},
wantHas: assert.False, </s> remove rcconfData: `# comment 1` + nl +
`` + nl +
`# inet 127.0.0.253` + nl +
`inet` + nl,
wantHas: false,
</s> add rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`# comment 1` + nl + nl +
`# inet 127.0.0.253` + nl +
`inet` + nl,
),
},
},
wantHas: assert.False, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_freebsd_test.go |
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `_alias="inet 127.0.0.1/24"` + nl +
`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl,
),
}},
wantHas: assert.True, | <mask> `ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
<mask> wantCont: false,
<mask> }, {
<mask> name: "aliases",
<mask> rcconfData: `ifconfig_em0_alias="inet 127.0.0.1/24"` + nl +
<mask> `ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
<mask> wantCont: false,
<mask> }, {
<mask> name: "incorrect_config",
<mask> rcconfData: `ifconfig_em0="inet6 127.0.0.253 netmask 0xffffffff"` + nl +
<mask> `ifconfig_em0="inet 256.256.256.256 netmask 0xffffffff"` + nl +
<mask> `ifconfig_em0=""` + nl,
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove rcconfData: `# comment 1` + nl +
`` + nl +
`# comment 2` + nl +
`ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`# comment 1` + nl +
`` + nl +
`# comment 2` + nl +
`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl,
),
}},
wantHas: assert.True, </s> remove rcconfData: `ifconfig_em0="inet6 127.0.0.253 netmask 0xffffffff"` + nl +
`ifconfig_em0="inet 256.256.256.256 netmask 0xffffffff"` + nl +
`ifconfig_em0=""` + nl,
wantCont: true,
</s> add rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(
`ifconfig_` + ifaceName + `="inet6 127.0.0.253 netmask 0xffffffff"` + nl +
`ifconfig_` + ifaceName + `="inet 256.256.256.256 netmask 0xffffffff"` + nl +
`ifconfig_` + ifaceName + `=""` + nl,
),
}},
wantHas: assert.False, </s> remove name: "case_insensitiveness",
rcconfData: `ifconfig_em0="InEt 127.0.0.253 NeTmAsK 0xffffffff"` + nl,
wantCont: false,
</s> add name: "case_insensitiveness",
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `="InEt 127.0.0.253 NeTmAsK 0xffffffff"` + nl),
}},
wantHas: assert.True, </s> remove name: "simple",
rcconfData: `ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add name: "simple",
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl),
}},
wantHas: assert.True, </s> remove name string
rcconfData string
wantCont bool
</s> add name string
rootFsys fs.FS
wantHas assert.BoolAssertionFunc | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_freebsd_test.go |
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(
`ifconfig_` + ifaceName + `="inet6 127.0.0.253 netmask 0xffffffff"` + nl +
`ifconfig_` + ifaceName + `="inet 256.256.256.256 netmask 0xffffffff"` + nl +
`ifconfig_` + ifaceName + `=""` + nl,
),
}},
wantHas: assert.False, | <mask> `ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
<mask> wantCont: false,
<mask> }, {
<mask> name: "incorrect_config",
<mask> rcconfData: `ifconfig_em0="inet6 127.0.0.253 netmask 0xffffffff"` + nl +
<mask> `ifconfig_em0="inet 256.256.256.256 netmask 0xffffffff"` + nl +
<mask> `ifconfig_em0=""` + nl,
<mask> wantCont: true,
<mask> }}
<mask>
<mask> for _, tc := range testCases {
<mask> r := strings.NewReader(tc.rcconfData)
<mask> t.Run(tc.name, func(t *testing.T) {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove rcconfData: `ifconfig_em0_alias="inet 127.0.0.1/24"` + nl +
`ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `_alias="inet 127.0.0.1/24"` + nl +
`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl,
),
}},
wantHas: assert.True, </s> remove rcconfData: `# comment 1` + nl +
`` + nl +
`# comment 2` + nl +
`ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`# comment 1` + nl +
`` + nl +
`# comment 2` + nl +
`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl,
),
}},
wantHas: assert.True, </s> remove name: "case_insensitiveness",
rcconfData: `ifconfig_em0="InEt 127.0.0.253 NeTmAsK 0xffffffff"` + nl,
wantCont: false,
</s> add name: "case_insensitiveness",
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `="InEt 127.0.0.253 NeTmAsK 0xffffffff"` + nl),
}},
wantHas: assert.True, </s> remove name: "simple",
rcconfData: `ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add name: "simple",
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl),
}},
wantHas: assert.True, </s> remove name string
rcconfData string
wantCont bool
</s> add name string
rootFsys fs.FS
wantHas assert.BoolAssertionFunc | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_freebsd_test.go |
<mask> wantCont: true,
<mask> }}
<mask>
<mask> for _, tc := range testCases {
<mask> r := strings.NewReader(tc.rcconfData)
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> _, cont, err := iface.rcConfStaticConfig(r)
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, tc.wantCont, cont)
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove _, cont, err := iface.rcConfStaticConfig(r)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName) </s> remove r := strings.NewReader(tc.rcconfData)
</s> add </s> remove r := bytes.NewReader(tc.data)
</s> add </s> remove assert.Equal(t, tc.wantCont, cont)
</s> add tc.wantHas(t, has) </s> remove _, has, err := hostnameIfStaticConfig(r)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_freebsd_test.go |
|
substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName) | <mask>
<mask> for _, tc := range testCases {
<mask> r := strings.NewReader(tc.rcconfData)
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> _, cont, err := iface.rcConfStaticConfig(r)
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, tc.wantCont, cont)
<mask> })
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove r := strings.NewReader(tc.rcconfData)
</s> add </s> remove assert.Equal(t, tc.wantCont, cont)
</s> add tc.wantHas(t, has) </s> remove _, has, err := hostnameIfStaticConfig(r)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName) </s> remove r := strings.NewReader(tc.rcconfData)
</s> add </s> remove r := bytes.NewReader(tc.data)
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_freebsd_test.go |
tc.wantHas(t, has) | <mask> t.Run(tc.name, func(t *testing.T) {
<mask> _, cont, err := iface.rcConfStaticConfig(r)
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, tc.wantCont, cont)
<mask> })
<mask> }
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove _, cont, err := iface.rcConfStaticConfig(r)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName) </s> remove r := strings.NewReader(tc.rcconfData)
</s> add </s> remove assert.Equal(t, tc.wantCont, has)
assert.ElementsMatch(t, tc.wantPatterns, patterns)
</s> add tc.wantHas(t, has) </s> remove assert.Equal(t, tc.wantHas, has)
</s> add tc.wantHas(t, has) </s> remove patterns, has, err := iface.ifacesStaticConfig(r)
require.NoError(t, err)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName)
testutil.AssertErrorMsg(t, tc.wantErrMsg, err) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_freebsd_test.go |
if !findIfaceLine(s, string(n)) { | <mask> // dhcpcdStaticConfig checks if interface is configured by /etc/dhcpcd.conf to
<mask> // have a static IP.
<mask> func (n interfaceName) dhcpcdStaticConfig(r io.Reader) (subsources []string, cont bool, err error) {
<mask> s := bufio.NewScanner(r)
<mask> ifaceFound := findIfaceLine(s, string(n))
<mask> if !ifaceFound {
<mask> return nil, true, s.Err()
<mask> }
<mask>
<mask> for s.Scan() {
<mask> line := strings.TrimSpace(s.Text())
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove return walker.Walk(aghos.RootDirFS(), rcConfFilename)
</s> add return walker.Walk(rootDirFS, rcConfFilename) </s> remove return aghos.FileWalker(hostnameIfStaticConfig).Walk(aghos.RootDirFS(), filename)
</s> add return aghos.FileWalker(hostnameIfStaticConfig).Walk(rootDirFS, filename) </s> remove func getEtcResolvConfServers() ([]string, error) {
body, err := os.ReadFile("/etc/resolv.conf")
</s> add func getEtcResolvConfServers() (addrs []string, err error) {
const filename = "etc/resolv.conf"
_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {
sc := bufio.NewScanner(r)
for sc.Scan() {
matches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)
if len(matches) == 0 {
continue
}
for _, m := range matches {
addrs = append(addrs, m[1])
}
}
return nil, false, sc.Err()
}).Walk(rootDirFS, filename) </s> remove // TODO(a.garipov): Currently, this function returns the first
// definitive result. So if /etc/dhcpcd.conf has a static IP while
// /etc/network/interfaces doesn't, it will return true. Perhaps this
// is not the most desirable behavior.
</s> add // TODO(a.garipov): Currently, this function returns the first definitive
// result. So if /etc/dhcpcd.conf has and /etc/network/interfaces has no
// static IP configuration, it will return true. Perhaps this is not the
// most desirable behavior. </s> remove }
if code != 0 {
</s> add } else if code != 0 { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux.go |
// Man page interfaces(5) declares that interface definition should
// consist of the key word "iface" followed by interface name, and
// method at fourth field. | <mask>
<mask> fields := strings.Fields(line)
<mask> fieldsNum := len(fields)
<mask>
<mask> // Man page interfaces(5) declares that interface definition
<mask> // should consist of the key word "iface" followed by interface
<mask> // name, and method at fourth field.
<mask> if fieldsNum >= 4 &&
<mask> fields[0] == "iface" && fields[1] == string(n) && fields[3] == "static" {
<mask> return nil, false, nil
<mask> }
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove fields := strings.Fields(string(d))
</s> add fields := bytes.Fields(out) </s> remove if len(fields) < 3 || fields[0] != "default" {
</s> add if len(fields) < 3 || string(fields[0]) != "default" { </s> remove if l := len(arp.arps); l > 0 && arp.last < l {
return arp.arps[arp.last].Neighbors()
}
return nil
</s> add return arp.clone() </s> remove func GetValidNetInterfacesForWeb() ([]*NetInterface, error) {
</s> add func GetValidNetInterfacesForWeb() (netInterfaces []*NetInterface, err error) { </s> remove return nil, err
}
re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
matches := re.FindAllStringSubmatch(string(body), -1)
if len(matches) == 0 {
return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
}
addrs := make([]string, 0)
for i := range matches {
addrs = append(addrs, matches[i][1])
</s> add return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux.go |
// TODO(a.garipov): Currently, this function returns the first definitive
// result. So if /etc/dhcpcd.conf has and /etc/network/interfaces has no
// static IP configuration, it will return true. Perhaps this is not the
// most desirable behavior. | <mask> return sub, true, s.Err()
<mask> }
<mask>
<mask> func ifaceHasStaticIP(ifaceName string) (has bool, err error) {
<mask> // TODO(a.garipov): Currently, this function returns the first
<mask> // definitive result. So if /etc/dhcpcd.conf has a static IP while
<mask> // /etc/network/interfaces doesn't, it will return true. Perhaps this
<mask> // is not the most desirable behavior.
<mask>
<mask> iface := interfaceName(ifaceName)
<mask>
<mask> for _, pair := range [...]struct {
<mask> aghos.FileWalker
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove return nil, fmt.Errorf("got iface.Addrs() element %s that is not net.IPNet, it is %T", addr, addr)
</s> add return nil, fmt.Errorf("got %s that is not net.IPNet, it is %T", addr, addr) </s> remove ifaceFound := findIfaceLine(s, string(n))
if !ifaceFound {
</s> add if !findIfaceLine(s, string(n)) { </s> remove return aghos.FileWalker(hostnameIfStaticConfig).Walk(aghos.RootDirFS(), filename)
</s> add return aghos.FileWalker(hostnameIfStaticConfig).Walk(rootDirFS, filename) </s> remove func ifaceHasStaticIP(ifaceName string) (bool, error) {
</s> add func ifaceHasStaticIP(ifaceName string) (ok bool, err error) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux.go |
has, err = pair.Walk(rootDirFS, pair.filename) | <mask> }, {
<mask> FileWalker: iface.ifacesStaticConfig,
<mask> filename: "etc/network/interfaces",
<mask> }} {
<mask> has, err = pair.Walk(aghos.RootDirFS(), pair.filename)
<mask> if err != nil {
<mask> return false, err
<mask> }
<mask>
<mask> if has {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove }
if has {
</s> add } else if has { </s> remove r := strings.NewReader(tc.rcconfData)
</s> add </s> remove func ifaceHasStaticIP(ifaceName string) (bool, error) {
</s> add func ifaceHasStaticIP(ifaceName string) (ok bool, err error) { </s> remove }
if code != 0 {
</s> add } else if code != 0 { </s> remove if errors.As(err, new(*exec.ExitError)) {
return cmd.ProcessState.ExitCode(), string(out), nil
} else if err != nil {
return 1, "", fmt.Errorf("command %q failed: %w: %s", command, err, out)
</s> add if err != nil {
if eerr := new(exec.ExitError); errors.As(err, &eerr) {
return eerr.ExitCode(), eerr.Stderr, nil
}
return 1, nil, fmt.Errorf("command %q failed: %w: %s", command, err, out) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux.go |
} else if has { | <mask> }} {
<mask> has, err = pair.Walk(aghos.RootDirFS(), pair.filename)
<mask> if err != nil {
<mask> return false, err
<mask> }
<mask>
<mask> if has {
<mask> return true, nil
<mask> }
<mask> }
<mask>
<mask> return false, ErrNoStaticIPInfo
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove has, err = pair.Walk(aghos.RootDirFS(), pair.filename)
</s> add has, err = pair.Walk(rootDirFS, pair.filename) </s> remove func ifaceHasStaticIP(ifaceName string) (bool, error) {
</s> add func ifaceHasStaticIP(ifaceName string) (ok bool, err error) { </s> remove }
if code != 0 {
</s> add } else if code != 0 { </s> remove if errors.As(err, new(*exec.ExitError)) {
return cmd.ProcessState.ExitCode(), string(out), nil
} else if err != nil {
return 1, "", fmt.Errorf("command %q failed: %w: %s", command, err, out)
</s> add if err != nil {
if eerr := new(exec.ExitError); errors.As(err, &eerr) {
return eerr.ExitCode(), eerr.Stderr, nil
}
return 1, nil, fmt.Errorf("command %q failed: %w: %s", command, err, out) </s> remove func getEtcResolvConfServers() ([]string, error) {
body, err := os.ReadFile("/etc/resolv.conf")
</s> add func getEtcResolvConfServers() (addrs []string, err error) {
const filename = "etc/resolv.conf"
_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {
sc := bufio.NewScanner(r)
for sc.Scan() {
matches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)
if len(matches) == 0 {
continue
}
for _, m := range matches {
addrs = append(addrs, m[1])
}
}
return nil, false, sc.Err()
}).Walk(rootDirFS, filename) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux.go |
const filename = "/etc/dhcpcd.conf"
body, err := os.ReadFile(filename) | <mask>
<mask> gatewayIP := GatewayIP(ifaceName)
<mask> add := dhcpcdConfIface(ifaceName, ipNet, gatewayIP, ipNet.IP)
<mask>
<mask> body, err := os.ReadFile("/etc/dhcpcd.conf")
<mask> if err != nil && !errors.Is(err, os.ErrNotExist) {
<mask> return err
<mask> }
<mask>
<mask> body = append(body, []byte(add)...)
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove err = maybe.WriteFile("/etc/dhcpcd.conf", body, 0o644)
</s> add err = maybe.WriteFile(filename, body, 0o644) </s> remove return nil, err
}
re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
matches := re.FindAllStringSubmatch(string(body), -1)
if len(matches) == 0 {
return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
}
addrs := make([]string, 0)
for i := range matches {
addrs = append(addrs, matches[i][1])
</s> add return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) </s> remove func getEtcResolvConfServers() ([]string, error) {
body, err := os.ReadFile("/etc/resolv.conf")
</s> add func getEtcResolvConfServers() (addrs []string, err error) {
const filename = "etc/resolv.conf"
_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {
sc := bufio.NewScanner(r)
for sc.Scan() {
matches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)
if len(matches) == 0 {
continue
}
for _, m := range matches {
addrs = append(addrs, m[1])
}
}
return nil, false, sc.Err()
}).Walk(rootDirFS, filename) </s> remove sc := bufio.NewScanner(r)
</s> add sc := bufio.NewScanner(bytes.NewReader(out)) </s> remove m := make(map[string]string)
</s> add reports = make(map[string]string) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux.go |
err = maybe.WriteFile(filename, body, 0o644) | <mask> return err
<mask> }
<mask>
<mask> body = append(body, []byte(add)...)
<mask> err = maybe.WriteFile("/etc/dhcpcd.conf", body, 0o644)
<mask> if err != nil {
<mask> return fmt.Errorf("writing conf: %w", err)
<mask> }
<mask>
<mask> return nil
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove body, err := os.ReadFile("/etc/dhcpcd.conf")
</s> add const filename = "/etc/dhcpcd.conf"
body, err := os.ReadFile(filename) </s> remove sc := bufio.NewScanner(r)
</s> add sc := bufio.NewScanner(bytes.NewReader(out)) </s> remove return nil, err
}
re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
matches := re.FindAllStringSubmatch(string(body), -1)
if len(matches) == 0 {
return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
}
addrs := make([]string, 0)
for i := range matches {
addrs = append(addrs, matches[i][1])
</s> add return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux.go |
"io/fs" | <mask>
<mask> package aghnet
<mask>
<mask> import (
<mask> "bytes"
<mask> "net"
<mask> "testing"
<mask>
<mask> "github.com/stretchr/testify/assert"
<mask> "github.com/stretchr/testify/require"
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "strings"
</s> add "io/fs" </s> remove "strings"
</s> add "fmt"
"io/fs" </s> remove "io"
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux_test.go |
"testing/fstest" | <mask> "io/fs"
<mask> "net"
<mask> "testing"
<mask>
<mask> "github.com/AdguardTeam/golibs/testutil"
<mask> "github.com/stretchr/testify/assert"
<mask> )
<mask>
<mask> func TestHasStaticIP(t *testing.T) {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "testing/iotest"
</s> add </s> remove "github.com/stretchr/testify/require"
</s> add </s> remove "bytes"
</s> add "io/fs" | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux_test.go |
"github.com/AdguardTeam/golibs/testutil" | <mask> "net"
<mask> "testing"
<mask> "testing/fstest"
<mask>
<mask> "github.com/stretchr/testify/assert"
<mask> )
<mask>
<mask> func TestHasStaticIP(t *testing.T) {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "github.com/stretchr/testify/require"
</s> add | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux_test.go |
<mask> "net"
<mask> "testing"
<mask>
<mask> "github.com/stretchr/testify/assert"
<mask> "github.com/stretchr/testify/require"
<mask> )
<mask>
<mask> func TestDHCPCDStaticConfig(t *testing.T) {
<mask> const iface interfaceName = `wlan0`
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove func TestDHCPCDStaticConfig(t *testing.T) {
const iface interfaceName = `wlan0`
</s> add func TestHasStaticIP(t *testing.T) {
const ifaceName = "wlan0" </s> remove const iface interfaceName = `em0`
const nl = "\n"
</s> add const (
ifaceName = `em0`
rcConf = "etc/rc.conf"
) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux_test.go |
|
func TestHasStaticIP(t *testing.T) {
const ifaceName = "wlan0" | <mask> "github.com/stretchr/testify/assert"
<mask> "github.com/stretchr/testify/require"
<mask> )
<mask>
<mask> func TestDHCPCDStaticConfig(t *testing.T) {
<mask> const iface interfaceName = `wlan0`
<mask>
<mask> testCases := []struct {
<mask> name string
<mask> data []byte
<mask> wantCont bool
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove const iface interfaceName = `em0`
const nl = "\n"
</s> add const (
ifaceName = `em0`
rcConf = "etc/rc.conf"
) </s> remove "github.com/stretchr/testify/require"
</s> add </s> remove name string
data []byte
wantCont bool
wantPatterns []string
</s> add rootFsys fs.FS
name string
wantHas assert.BoolAssertionFunc
wantErrMsg string </s> remove testCases := []struct {
name string
data []byte
wantCont bool
}{{
name: "has_not",
data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + iface + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
wantCont: true,
}, {
name: "has",
data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + iface + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl +
`interface ` + iface + nl +
`# comment` + nl +
`static ip_address=192.168.2.1/24` + nl,
),
wantCont: false,
}}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
r := bytes.NewReader(tc.data)
_, cont, err := iface.dhcpcdStaticConfig(r)
require.NoError(t, err)
assert.Equal(t, tc.wantCont, cont)
})
}
}
func TestIfacesStaticConfig(t *testing.T) {
const iface interfaceName = `enp0s3`
</s> add const (
dhcpcd = "etc/dhcpcd.conf"
netifaces = "etc/network/interfaces"
) </s> remove func TestHostnameIfStaticConfig(t *testing.T) {
const nl = "\n"
</s> add func TestIfaceHasStaticIP(t *testing.T) {
const ifaceName = "em0"
confFile := fmt.Sprintf("etc/hostname.%s", ifaceName) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux_test.go |
const (
dhcpcd = "etc/dhcpcd.conf"
netifaces = "etc/network/interfaces"
) | <mask>
<mask> func TestDHCPCDStaticConfig(t *testing.T) {
<mask> const iface interfaceName = `wlan0`
<mask>
<mask> testCases := []struct {
<mask> name string
<mask> data []byte
<mask> wantCont bool
<mask> }{{
<mask> name: "has_not",
<mask> data: []byte(`#comment` + nl +
<mask> `# comment` + nl +
<mask> `interface eth0` + nl +
<mask> `static ip_address=192.168.0.1/24` + nl +
<mask> `# interface ` + iface + nl +
<mask> `static ip_address=192.168.1.1/24` + nl +
<mask> `# comment` + nl,
<mask> ),
<mask> wantCont: true,
<mask> }, {
<mask> name: "has",
<mask> data: []byte(`#comment` + nl +
<mask> `# comment` + nl +
<mask> `interface eth0` + nl +
<mask> `static ip_address=192.168.0.1/24` + nl +
<mask> `# interface ` + iface + nl +
<mask> `static ip_address=192.168.1.1/24` + nl +
<mask> `# comment` + nl +
<mask> `interface ` + iface + nl +
<mask> `# comment` + nl +
<mask> `static ip_address=192.168.2.1/24` + nl,
<mask> ),
<mask> wantCont: false,
<mask> }}
<mask>
<mask> for _, tc := range testCases {
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> r := bytes.NewReader(tc.data)
<mask> _, cont, err := iface.dhcpcdStaticConfig(r)
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, tc.wantCont, cont)
<mask> })
<mask> }
<mask> }
<mask>
<mask> func TestIfacesStaticConfig(t *testing.T) {
<mask> const iface interfaceName = `enp0s3`
<mask>
<mask> testCases := []struct {
<mask> name string
<mask> data []byte
<mask> wantCont bool
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove name: "has_not",
data: []byte(`allow-hotplug ` + iface + nl +
`#iface enp0s3 inet static` + nl +
`# address 192.168.0.200` + nl +
`# netmask 255.255.255.0` + nl +
`# gateway 192.168.0.1` + nl +
`iface ` + iface + ` inet dhcp` + nl,
),
wantCont: true,
wantPatterns: []string{},
</s> add rootFsys: fstest.MapFS{
dhcpcd: &fstest.MapFile{
Data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + ifaceName + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
},
},
name: "dhcpcd_has_not",
wantHas: assert.False,
wantErrMsg: `no information about static ip`,
}, {
rootFsys: fstest.MapFS{
dhcpcd: &fstest.MapFile{
Data: []byte(`#comment` + nl +
`# comment` + nl +
`interface ` + ifaceName + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + ifaceName + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
},
},
name: "dhcpcd_has",
wantHas: assert.True,
wantErrMsg: ``, </s> remove name string
data []byte
wantCont bool
wantPatterns []string
</s> add rootFsys fs.FS
name string
wantHas assert.BoolAssertionFunc
wantErrMsg string </s> remove name: "has",
data: []byte(`allow-hotplug ` + iface + nl +
`iface ` + iface + ` inet static` + nl +
` address 192.168.0.200` + nl +
` netmask 255.255.255.0` + nl +
` gateway 192.168.0.1` + nl +
`#iface ` + iface + ` inet dhcp` + nl,
),
wantCont: false,
wantPatterns: []string{},
</s> add rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`allow-hotplug ` + ifaceName + nl +
`#iface enp0s3 inet static` + nl +
`# address 192.168.0.200` + nl +
`# netmask 255.255.255.0` + nl +
`# gateway 192.168.0.1` + nl +
`iface ` + ifaceName + ` inet dhcp` + nl,
),
},
},
name: "netifaces_has_not",
wantHas: assert.False,
wantErrMsg: `no information about static ip`, </s> remove rcconfData: `# comment 1` + nl +
`` + nl +
`# comment 2` + nl +
`ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`# comment 1` + nl +
`` + nl +
`# comment 2` + nl +
`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl,
),
}},
wantHas: assert.True, </s> remove rcconfData: `# comment 1` + nl +
`` + nl +
`# inet 127.0.0.253` + nl +
`inet` + nl,
wantHas: false,
</s> add rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`# comment 1` + nl + nl +
`# inet 127.0.0.253` + nl +
`inet` + nl,
),
},
},
wantHas: assert.False, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux_test.go |
rootFsys fs.FS
name string
wantHas assert.BoolAssertionFunc
wantErrMsg string | <mask> func TestIfacesStaticConfig(t *testing.T) {
<mask> const iface interfaceName = `enp0s3`
<mask>
<mask> testCases := []struct {
<mask> name string
<mask> data []byte
<mask> wantCont bool
<mask> wantPatterns []string
<mask> }{{
<mask> name: "has_not",
<mask> data: []byte(`allow-hotplug ` + iface + nl +
<mask> `#iface enp0s3 inet static` + nl +
<mask> `# address 192.168.0.200` + nl +
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove testCases := []struct {
name string
data []byte
wantCont bool
}{{
name: "has_not",
data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + iface + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
wantCont: true,
}, {
name: "has",
data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + iface + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl +
`interface ` + iface + nl +
`# comment` + nl +
`static ip_address=192.168.2.1/24` + nl,
),
wantCont: false,
}}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
r := bytes.NewReader(tc.data)
_, cont, err := iface.dhcpcdStaticConfig(r)
require.NoError(t, err)
assert.Equal(t, tc.wantCont, cont)
})
}
}
func TestIfacesStaticConfig(t *testing.T) {
const iface interfaceName = `enp0s3`
</s> add const (
dhcpcd = "etc/dhcpcd.conf"
netifaces = "etc/network/interfaces"
) </s> remove name: "has_not",
data: []byte(`allow-hotplug ` + iface + nl +
`#iface enp0s3 inet static` + nl +
`# address 192.168.0.200` + nl +
`# netmask 255.255.255.0` + nl +
`# gateway 192.168.0.1` + nl +
`iface ` + iface + ` inet dhcp` + nl,
),
wantCont: true,
wantPatterns: []string{},
</s> add rootFsys: fstest.MapFS{
dhcpcd: &fstest.MapFile{
Data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + ifaceName + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
},
},
name: "dhcpcd_has_not",
wantHas: assert.False,
wantErrMsg: `no information about static ip`,
}, {
rootFsys: fstest.MapFS{
dhcpcd: &fstest.MapFile{
Data: []byte(`#comment` + nl +
`# comment` + nl +
`interface ` + ifaceName + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + ifaceName + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
},
},
name: "dhcpcd_has",
wantHas: assert.True,
wantErrMsg: ``, </s> remove name: "has",
data: []byte(`allow-hotplug ` + iface + nl +
`iface ` + iface + ` inet static` + nl +
` address 192.168.0.200` + nl +
` netmask 255.255.255.0` + nl +
` gateway 192.168.0.1` + nl +
`#iface ` + iface + ` inet dhcp` + nl,
),
wantCont: false,
wantPatterns: []string{},
</s> add rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`allow-hotplug ` + ifaceName + nl +
`#iface enp0s3 inet static` + nl +
`# address 192.168.0.200` + nl +
`# netmask 255.255.255.0` + nl +
`# gateway 192.168.0.1` + nl +
`iface ` + ifaceName + ` inet dhcp` + nl,
),
},
},
name: "netifaces_has_not",
wantHas: assert.False,
wantErrMsg: `no information about static ip`, </s> remove name: "return_patterns",
data: []byte(`source hello` + nl +
`source world` + nl +
`#iface ` + iface + ` inet static` + nl,
),
wantCont: true,
wantPatterns: []string{"hello", "world"},
</s> add rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`allow-hotplug ` + ifaceName + nl +
`iface ` + ifaceName + ` inet static` + nl +
` address 192.168.0.200` + nl +
` netmask 255.255.255.0` + nl +
` gateway 192.168.0.1` + nl +
`#iface ` + ifaceName + ` inet dhcp` + nl,
),
},
},
name: "netifaces_has",
wantHas: assert.True,
wantErrMsg: ``, </s> remove // This one tests if the first found valid interface prevents
// checking files under the `source` directive.
name: "ignore_patterns",
data: []byte(`source hello` + nl +
`source world` + nl +
`iface ` + iface + ` inet static` + nl,
),
wantCont: false,
wantPatterns: []string{},
</s> add rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`source hello` + nl +
`#iface ` + ifaceName + ` inet static` + nl,
),
},
"hello": &fstest.MapFile{
Data: []byte(`iface ` + ifaceName + ` inet static` + nl),
},
},
name: "netifaces_another_file",
wantHas: assert.True,
wantErrMsg: ``,
}, {
rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`source hello` + nl +
`iface ` + ifaceName + ` inet static` + nl,
),
},
},
name: "netifaces_ignore_another",
wantHas: assert.True,
wantErrMsg: ``, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux_test.go |
rootFsys: fstest.MapFS{
dhcpcd: &fstest.MapFile{
Data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + ifaceName + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
},
},
name: "dhcpcd_has_not",
wantHas: assert.False,
wantErrMsg: `no information about static ip`,
}, {
rootFsys: fstest.MapFS{
dhcpcd: &fstest.MapFile{
Data: []byte(`#comment` + nl +
`# comment` + nl +
`interface ` + ifaceName + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + ifaceName + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
},
},
name: "dhcpcd_has",
wantHas: assert.True,
wantErrMsg: ``, | <mask> data []byte
<mask> wantCont bool
<mask> wantPatterns []string
<mask> }{{
<mask> name: "has_not",
<mask> data: []byte(`allow-hotplug ` + iface + nl +
<mask> `#iface enp0s3 inet static` + nl +
<mask> `# address 192.168.0.200` + nl +
<mask> `# netmask 255.255.255.0` + nl +
<mask> `# gateway 192.168.0.1` + nl +
<mask> `iface ` + iface + ` inet dhcp` + nl,
<mask> ),
<mask> wantCont: true,
<mask> wantPatterns: []string{},
<mask> }, {
<mask> name: "has",
<mask> data: []byte(`allow-hotplug ` + iface + nl +
<mask> `iface ` + iface + ` inet static` + nl +
<mask> ` address 192.168.0.200` + nl +
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove name: "has",
data: []byte(`allow-hotplug ` + iface + nl +
`iface ` + iface + ` inet static` + nl +
` address 192.168.0.200` + nl +
` netmask 255.255.255.0` + nl +
` gateway 192.168.0.1` + nl +
`#iface ` + iface + ` inet dhcp` + nl,
),
wantCont: false,
wantPatterns: []string{},
</s> add rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`allow-hotplug ` + ifaceName + nl +
`#iface enp0s3 inet static` + nl +
`# address 192.168.0.200` + nl +
`# netmask 255.255.255.0` + nl +
`# gateway 192.168.0.1` + nl +
`iface ` + ifaceName + ` inet dhcp` + nl,
),
},
},
name: "netifaces_has_not",
wantHas: assert.False,
wantErrMsg: `no information about static ip`, </s> remove name: "return_patterns",
data: []byte(`source hello` + nl +
`source world` + nl +
`#iface ` + iface + ` inet static` + nl,
),
wantCont: true,
wantPatterns: []string{"hello", "world"},
</s> add rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`allow-hotplug ` + ifaceName + nl +
`iface ` + ifaceName + ` inet static` + nl +
` address 192.168.0.200` + nl +
` netmask 255.255.255.0` + nl +
` gateway 192.168.0.1` + nl +
`#iface ` + ifaceName + ` inet dhcp` + nl,
),
},
},
name: "netifaces_has",
wantHas: assert.True,
wantErrMsg: ``, </s> remove name string
data []byte
wantCont bool
wantPatterns []string
</s> add rootFsys fs.FS
name string
wantHas assert.BoolAssertionFunc
wantErrMsg string </s> remove // This one tests if the first found valid interface prevents
// checking files under the `source` directive.
name: "ignore_patterns",
data: []byte(`source hello` + nl +
`source world` + nl +
`iface ` + iface + ` inet static` + nl,
),
wantCont: false,
wantPatterns: []string{},
</s> add rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`source hello` + nl +
`#iface ` + ifaceName + ` inet static` + nl,
),
},
"hello": &fstest.MapFile{
Data: []byte(`iface ` + ifaceName + ` inet static` + nl),
},
},
name: "netifaces_another_file",
wantHas: assert.True,
wantErrMsg: ``,
}, {
rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`source hello` + nl +
`iface ` + ifaceName + ` inet static` + nl,
),
},
},
name: "netifaces_ignore_another",
wantHas: assert.True,
wantErrMsg: ``, </s> remove testCases := []struct {
name string
data []byte
wantCont bool
}{{
name: "has_not",
data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + iface + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
wantCont: true,
}, {
name: "has",
data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + iface + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl +
`interface ` + iface + nl +
`# comment` + nl +
`static ip_address=192.168.2.1/24` + nl,
),
wantCont: false,
}}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
r := bytes.NewReader(tc.data)
_, cont, err := iface.dhcpcdStaticConfig(r)
require.NoError(t, err)
assert.Equal(t, tc.wantCont, cont)
})
}
}
func TestIfacesStaticConfig(t *testing.T) {
const iface interfaceName = `enp0s3`
</s> add const (
dhcpcd = "etc/dhcpcd.conf"
netifaces = "etc/network/interfaces"
) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux_test.go |
rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`allow-hotplug ` + ifaceName + nl +
`#iface enp0s3 inet static` + nl +
`# address 192.168.0.200` + nl +
`# netmask 255.255.255.0` + nl +
`# gateway 192.168.0.1` + nl +
`iface ` + ifaceName + ` inet dhcp` + nl,
),
},
},
name: "netifaces_has_not",
wantHas: assert.False,
wantErrMsg: `no information about static ip`, | <mask> ),
<mask> wantCont: true,
<mask> wantPatterns: []string{},
<mask> }, {
<mask> name: "has",
<mask> data: []byte(`allow-hotplug ` + iface + nl +
<mask> `iface ` + iface + ` inet static` + nl +
<mask> ` address 192.168.0.200` + nl +
<mask> ` netmask 255.255.255.0` + nl +
<mask> ` gateway 192.168.0.1` + nl +
<mask> `#iface ` + iface + ` inet dhcp` + nl,
<mask> ),
<mask> wantCont: false,
<mask> wantPatterns: []string{},
<mask> }, {
<mask> name: "return_patterns",
<mask> data: []byte(`source hello` + nl +
<mask> `source world` + nl +
<mask> `#iface ` + iface + ` inet static` + nl,
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove name: "return_patterns",
data: []byte(`source hello` + nl +
`source world` + nl +
`#iface ` + iface + ` inet static` + nl,
),
wantCont: true,
wantPatterns: []string{"hello", "world"},
</s> add rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`allow-hotplug ` + ifaceName + nl +
`iface ` + ifaceName + ` inet static` + nl +
` address 192.168.0.200` + nl +
` netmask 255.255.255.0` + nl +
` gateway 192.168.0.1` + nl +
`#iface ` + ifaceName + ` inet dhcp` + nl,
),
},
},
name: "netifaces_has",
wantHas: assert.True,
wantErrMsg: ``, </s> remove name: "has_not",
data: []byte(`allow-hotplug ` + iface + nl +
`#iface enp0s3 inet static` + nl +
`# address 192.168.0.200` + nl +
`# netmask 255.255.255.0` + nl +
`# gateway 192.168.0.1` + nl +
`iface ` + iface + ` inet dhcp` + nl,
),
wantCont: true,
wantPatterns: []string{},
</s> add rootFsys: fstest.MapFS{
dhcpcd: &fstest.MapFile{
Data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + ifaceName + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
},
},
name: "dhcpcd_has_not",
wantHas: assert.False,
wantErrMsg: `no information about static ip`,
}, {
rootFsys: fstest.MapFS{
dhcpcd: &fstest.MapFile{
Data: []byte(`#comment` + nl +
`# comment` + nl +
`interface ` + ifaceName + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + ifaceName + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
},
},
name: "dhcpcd_has",
wantHas: assert.True,
wantErrMsg: ``, </s> remove // This one tests if the first found valid interface prevents
// checking files under the `source` directive.
name: "ignore_patterns",
data: []byte(`source hello` + nl +
`source world` + nl +
`iface ` + iface + ` inet static` + nl,
),
wantCont: false,
wantPatterns: []string{},
</s> add rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`source hello` + nl +
`#iface ` + ifaceName + ` inet static` + nl,
),
},
"hello": &fstest.MapFile{
Data: []byte(`iface ` + ifaceName + ` inet static` + nl),
},
},
name: "netifaces_another_file",
wantHas: assert.True,
wantErrMsg: ``,
}, {
rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`source hello` + nl +
`iface ` + ifaceName + ` inet static` + nl,
),
},
},
name: "netifaces_ignore_another",
wantHas: assert.True,
wantErrMsg: ``, </s> remove name string
data []byte
wantCont bool
wantPatterns []string
</s> add rootFsys fs.FS
name string
wantHas assert.BoolAssertionFunc
wantErrMsg string </s> remove testCases := []struct {
name string
data []byte
wantCont bool
}{{
name: "has_not",
data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + iface + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
wantCont: true,
}, {
name: "has",
data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + iface + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl +
`interface ` + iface + nl +
`# comment` + nl +
`static ip_address=192.168.2.1/24` + nl,
),
wantCont: false,
}}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
r := bytes.NewReader(tc.data)
_, cont, err := iface.dhcpcdStaticConfig(r)
require.NoError(t, err)
assert.Equal(t, tc.wantCont, cont)
})
}
}
func TestIfacesStaticConfig(t *testing.T) {
const iface interfaceName = `enp0s3`
</s> add const (
dhcpcd = "etc/dhcpcd.conf"
netifaces = "etc/network/interfaces"
) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux_test.go |
rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`allow-hotplug ` + ifaceName + nl +
`iface ` + ifaceName + ` inet static` + nl +
` address 192.168.0.200` + nl +
` netmask 255.255.255.0` + nl +
` gateway 192.168.0.1` + nl +
`#iface ` + ifaceName + ` inet dhcp` + nl,
),
},
},
name: "netifaces_has",
wantHas: assert.True,
wantErrMsg: ``, | <mask> ),
<mask> wantCont: false,
<mask> wantPatterns: []string{},
<mask> }, {
<mask> name: "return_patterns",
<mask> data: []byte(`source hello` + nl +
<mask> `source world` + nl +
<mask> `#iface ` + iface + ` inet static` + nl,
<mask> ),
<mask> wantCont: true,
<mask> wantPatterns: []string{"hello", "world"},
<mask> }, {
<mask> // This one tests if the first found valid interface prevents
<mask> // checking files under the `source` directive.
<mask> name: "ignore_patterns",
<mask> data: []byte(`source hello` + nl +
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove // This one tests if the first found valid interface prevents
// checking files under the `source` directive.
name: "ignore_patterns",
data: []byte(`source hello` + nl +
`source world` + nl +
`iface ` + iface + ` inet static` + nl,
),
wantCont: false,
wantPatterns: []string{},
</s> add rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`source hello` + nl +
`#iface ` + ifaceName + ` inet static` + nl,
),
},
"hello": &fstest.MapFile{
Data: []byte(`iface ` + ifaceName + ` inet static` + nl),
},
},
name: "netifaces_another_file",
wantHas: assert.True,
wantErrMsg: ``,
}, {
rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`source hello` + nl +
`iface ` + ifaceName + ` inet static` + nl,
),
},
},
name: "netifaces_ignore_another",
wantHas: assert.True,
wantErrMsg: ``, </s> remove name: "has",
data: []byte(`allow-hotplug ` + iface + nl +
`iface ` + iface + ` inet static` + nl +
` address 192.168.0.200` + nl +
` netmask 255.255.255.0` + nl +
` gateway 192.168.0.1` + nl +
`#iface ` + iface + ` inet dhcp` + nl,
),
wantCont: false,
wantPatterns: []string{},
</s> add rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`allow-hotplug ` + ifaceName + nl +
`#iface enp0s3 inet static` + nl +
`# address 192.168.0.200` + nl +
`# netmask 255.255.255.0` + nl +
`# gateway 192.168.0.1` + nl +
`iface ` + ifaceName + ` inet dhcp` + nl,
),
},
},
name: "netifaces_has_not",
wantHas: assert.False,
wantErrMsg: `no information about static ip`, </s> remove name: "has_not",
data: []byte(`allow-hotplug ` + iface + nl +
`#iface enp0s3 inet static` + nl +
`# address 192.168.0.200` + nl +
`# netmask 255.255.255.0` + nl +
`# gateway 192.168.0.1` + nl +
`iface ` + iface + ` inet dhcp` + nl,
),
wantCont: true,
wantPatterns: []string{},
</s> add rootFsys: fstest.MapFS{
dhcpcd: &fstest.MapFile{
Data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + ifaceName + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
},
},
name: "dhcpcd_has_not",
wantHas: assert.False,
wantErrMsg: `no information about static ip`,
}, {
rootFsys: fstest.MapFS{
dhcpcd: &fstest.MapFile{
Data: []byte(`#comment` + nl +
`# comment` + nl +
`interface ` + ifaceName + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + ifaceName + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
},
},
name: "dhcpcd_has",
wantHas: assert.True,
wantErrMsg: ``, </s> remove testCases := []struct {
name string
data []byte
wantCont bool
}{{
name: "has_not",
data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + iface + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
wantCont: true,
}, {
name: "has",
data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + iface + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl +
`interface ` + iface + nl +
`# comment` + nl +
`static ip_address=192.168.2.1/24` + nl,
),
wantCont: false,
}}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
r := bytes.NewReader(tc.data)
_, cont, err := iface.dhcpcdStaticConfig(r)
require.NoError(t, err)
assert.Equal(t, tc.wantCont, cont)
})
}
}
func TestIfacesStaticConfig(t *testing.T) {
const iface interfaceName = `enp0s3`
</s> add const (
dhcpcd = "etc/dhcpcd.conf"
netifaces = "etc/network/interfaces"
) </s> remove name string
data []byte
wantCont bool
wantPatterns []string
</s> add rootFsys fs.FS
name string
wantHas assert.BoolAssertionFunc
wantErrMsg string | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux_test.go |
rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`source hello` + nl +
`#iface ` + ifaceName + ` inet static` + nl,
),
},
"hello": &fstest.MapFile{
Data: []byte(`iface ` + ifaceName + ` inet static` + nl),
},
},
name: "netifaces_another_file",
wantHas: assert.True,
wantErrMsg: ``,
}, {
rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`source hello` + nl +
`iface ` + ifaceName + ` inet static` + nl,
),
},
},
name: "netifaces_ignore_another",
wantHas: assert.True,
wantErrMsg: ``, | <mask> ),
<mask> wantCont: true,
<mask> wantPatterns: []string{"hello", "world"},
<mask> }, {
<mask> // This one tests if the first found valid interface prevents
<mask> // checking files under the `source` directive.
<mask> name: "ignore_patterns",
<mask> data: []byte(`source hello` + nl +
<mask> `source world` + nl +
<mask> `iface ` + iface + ` inet static` + nl,
<mask> ),
<mask> wantCont: false,
<mask> wantPatterns: []string{},
<mask> }}
<mask>
<mask> for _, tc := range testCases {
<mask> r := bytes.NewReader(tc.data)
<mask> t.Run(tc.name, func(t *testing.T) {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove name: "return_patterns",
data: []byte(`source hello` + nl +
`source world` + nl +
`#iface ` + iface + ` inet static` + nl,
),
wantCont: true,
wantPatterns: []string{"hello", "world"},
</s> add rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`allow-hotplug ` + ifaceName + nl +
`iface ` + ifaceName + ` inet static` + nl +
` address 192.168.0.200` + nl +
` netmask 255.255.255.0` + nl +
` gateway 192.168.0.1` + nl +
`#iface ` + ifaceName + ` inet dhcp` + nl,
),
},
},
name: "netifaces_has",
wantHas: assert.True,
wantErrMsg: ``, </s> remove name: "has",
data: []byte(`allow-hotplug ` + iface + nl +
`iface ` + iface + ` inet static` + nl +
` address 192.168.0.200` + nl +
` netmask 255.255.255.0` + nl +
` gateway 192.168.0.1` + nl +
`#iface ` + iface + ` inet dhcp` + nl,
),
wantCont: false,
wantPatterns: []string{},
</s> add rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`allow-hotplug ` + ifaceName + nl +
`#iface enp0s3 inet static` + nl +
`# address 192.168.0.200` + nl +
`# netmask 255.255.255.0` + nl +
`# gateway 192.168.0.1` + nl +
`iface ` + ifaceName + ` inet dhcp` + nl,
),
},
},
name: "netifaces_has_not",
wantHas: assert.False,
wantErrMsg: `no information about static ip`, </s> remove name: "has_not",
data: []byte(`allow-hotplug ` + iface + nl +
`#iface enp0s3 inet static` + nl +
`# address 192.168.0.200` + nl +
`# netmask 255.255.255.0` + nl +
`# gateway 192.168.0.1` + nl +
`iface ` + iface + ` inet dhcp` + nl,
),
wantCont: true,
wantPatterns: []string{},
</s> add rootFsys: fstest.MapFS{
dhcpcd: &fstest.MapFile{
Data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + ifaceName + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
},
},
name: "dhcpcd_has_not",
wantHas: assert.False,
wantErrMsg: `no information about static ip`,
}, {
rootFsys: fstest.MapFS{
dhcpcd: &fstest.MapFile{
Data: []byte(`#comment` + nl +
`# comment` + nl +
`interface ` + ifaceName + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + ifaceName + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
},
},
name: "dhcpcd_has",
wantHas: assert.True,
wantErrMsg: ``, </s> remove testCases := []struct {
name string
data []byte
wantCont bool
}{{
name: "has_not",
data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + iface + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl,
),
wantCont: true,
}, {
name: "has",
data: []byte(`#comment` + nl +
`# comment` + nl +
`interface eth0` + nl +
`static ip_address=192.168.0.1/24` + nl +
`# interface ` + iface + nl +
`static ip_address=192.168.1.1/24` + nl +
`# comment` + nl +
`interface ` + iface + nl +
`# comment` + nl +
`static ip_address=192.168.2.1/24` + nl,
),
wantCont: false,
}}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
r := bytes.NewReader(tc.data)
_, cont, err := iface.dhcpcdStaticConfig(r)
require.NoError(t, err)
assert.Equal(t, tc.wantCont, cont)
})
}
}
func TestIfacesStaticConfig(t *testing.T) {
const iface interfaceName = `enp0s3`
</s> add const (
dhcpcd = "etc/dhcpcd.conf"
netifaces = "etc/network/interfaces"
) </s> remove rcconfData: `ifconfig_em0="inet6 127.0.0.253 netmask 0xffffffff"` + nl +
`ifconfig_em0="inet 256.256.256.256 netmask 0xffffffff"` + nl +
`ifconfig_em0=""` + nl,
wantCont: true,
</s> add rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(
`ifconfig_` + ifaceName + `="inet6 127.0.0.253 netmask 0xffffffff"` + nl +
`ifconfig_` + ifaceName + `="inet 256.256.256.256 netmask 0xffffffff"` + nl +
`ifconfig_` + ifaceName + `=""` + nl,
),
}},
wantHas: assert.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/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux_test.go |
<mask> wantPatterns: []string{},
<mask> }}
<mask>
<mask> for _, tc := range testCases {
<mask> r := bytes.NewReader(tc.data)
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> patterns, has, err := iface.ifacesStaticConfig(r)
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, tc.wantCont, has)
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove patterns, has, err := iface.ifacesStaticConfig(r)
require.NoError(t, err)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName)
testutil.AssertErrorMsg(t, tc.wantErrMsg, err) </s> remove r := strings.NewReader(tc.rcconfData)
</s> add </s> remove r := strings.NewReader(tc.rcconfData)
</s> add </s> remove _, has, err := hostnameIfStaticConfig(r)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName) </s> remove assert.Equal(t, tc.wantCont, has)
assert.ElementsMatch(t, tc.wantPatterns, patterns)
</s> add tc.wantHas(t, has) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux_test.go |
|
substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName)
testutil.AssertErrorMsg(t, tc.wantErrMsg, err) | <mask>
<mask> for _, tc := range testCases {
<mask> r := bytes.NewReader(tc.data)
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> patterns, has, err := iface.ifacesStaticConfig(r)
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, tc.wantCont, has)
<mask> assert.ElementsMatch(t, tc.wantPatterns, patterns)
<mask> })
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove assert.Equal(t, tc.wantCont, has)
assert.ElementsMatch(t, tc.wantPatterns, patterns)
</s> add tc.wantHas(t, has) </s> remove r := bytes.NewReader(tc.data)
</s> add </s> remove _, has, err := hostnameIfStaticConfig(r)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName) </s> remove _, cont, err := iface.rcConfStaticConfig(r)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName) </s> remove r := strings.NewReader(tc.rcconfData)
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux_test.go |
tc.wantHas(t, has) | <mask> t.Run(tc.name, func(t *testing.T) {
<mask> patterns, has, err := iface.ifacesStaticConfig(r)
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, tc.wantCont, has)
<mask> assert.ElementsMatch(t, tc.wantPatterns, patterns)
<mask> })
<mask> }
<mask> }
<mask>
<mask> func TestSetStaticIPdhcpcdConf(t *testing.T) {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove patterns, has, err := iface.ifacesStaticConfig(r)
require.NoError(t, err)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName)
testutil.AssertErrorMsg(t, tc.wantErrMsg, err) </s> remove r := bytes.NewReader(tc.data)
</s> add </s> remove assert.Equal(t, tc.wantHas, has)
</s> add tc.wantHas(t, has) </s> remove assert.Equal(t, tc.wantCont, cont)
</s> add tc.wantHas(t, has) </s> remove _, has, err := hostnameIfStaticConfig(r)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux_test.go |
func TestSetStaticIP_dhcpcdConfIface(t *testing.T) { | <mask> })
<mask> }
<mask> }
<mask>
<mask> func TestSetStaticIPdhcpcdConf(t *testing.T) {
<mask> testCases := []struct {
<mask> name string
<mask> dhcpcdConf string
<mask> routers net.IP
<mask> }{{
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove name string
rcconfData string
wantHas bool
</s> add name string
rootFsys fs.FS
wantHas assert.BoolAssertionFunc </s> remove name string
rcconfData string
wantCont bool
</s> add name string
rootFsys fs.FS
wantHas assert.BoolAssertionFunc </s> remove func TestHostnameIfStaticConfig(t *testing.T) {
const nl = "\n"
</s> add func TestIfaceHasStaticIP(t *testing.T) {
const ifaceName = "em0"
confFile := fmt.Sprintf("etc/hostname.%s", ifaceName) </s> remove name string
data []byte
wantCont bool
wantPatterns []string
</s> add rootFsys fs.FS
name string
wantHas assert.BoolAssertionFunc
wantErrMsg string | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_linux_test.go |
return aghos.FileWalker(hostnameIfStaticConfig).Walk(rootDirFS, filename) | <mask>
<mask> func ifaceHasStaticIP(ifaceName string) (ok bool, err error) {
<mask> filename := fmt.Sprintf("etc/hostname.%s", ifaceName)
<mask>
<mask> return aghos.FileWalker(hostnameIfStaticConfig).Walk(aghos.RootDirFS(), filename)
<mask> }
<mask>
<mask> // hostnameIfStaticConfig checks if the interface is configured by
<mask> // /etc/hostname.* to have a static IP.
<mask> func hostnameIfStaticConfig(r io.Reader) (_ []string, ok bool, err error) {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove return walker.Walk(aghos.RootDirFS(), rcConfFilename)
</s> add return walker.Walk(rootDirFS, rcConfFilename) </s> remove ifaceFound := findIfaceLine(s, string(n))
if !ifaceFound {
</s> add if !findIfaceLine(s, string(n)) { </s> remove func ifaceHasStaticIP(ifaceName string) (bool, error) {
</s> add func ifaceHasStaticIP(ifaceName string) (ok bool, err error) { </s> remove func getEtcResolvConfServers() ([]string, error) {
body, err := os.ReadFile("/etc/resolv.conf")
</s> add func getEtcResolvConfServers() (addrs []string, err error) {
const filename = "etc/resolv.conf"
_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {
sc := bufio.NewScanner(r)
for sc.Scan() {
matches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)
if len(matches) == 0 {
continue
}
for _, m := range matches {
addrs = append(addrs, m[1])
}
}
return nil, false, sc.Err()
}).Walk(rootDirFS, filename) </s> remove // TODO(a.garipov): Currently, this function returns the first
// definitive result. So if /etc/dhcpcd.conf has a static IP while
// /etc/network/interfaces doesn't, it will return true. Perhaps this
// is not the most desirable behavior.
</s> add // TODO(a.garipov): Currently, this function returns the first definitive
// result. So if /etc/dhcpcd.conf has and /etc/network/interfaces has no
// static IP configuration, it will return true. Perhaps this is not the
// most desirable behavior. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_openbsd.go |
"fmt"
"io/fs" | <mask>
<mask> package aghnet
<mask>
<mask> import (
<mask> "strings"
<mask> "testing"
<mask>
<mask> "github.com/stretchr/testify/assert"
<mask> "github.com/stretchr/testify/require"
<mask> )
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "strings"
</s> add "io/fs" </s> remove "bytes"
</s> add "io/fs" </s> remove "io"
</s> add </s> remove "io"
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_openbsd_test.go |
"testing/fstest" | <mask> import (
<mask> "fmt"
<mask> "io/fs"
<mask> "testing"
<mask>
<mask> "github.com/stretchr/testify/assert"
<mask> "github.com/stretchr/testify/require"
<mask> )
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "strings"
</s> add "fmt"
"io/fs" </s> remove "strings"
</s> add "io/fs" </s> remove "bytes"
</s> add "io/fs" | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_openbsd_test.go |
func TestIfaceHasStaticIP(t *testing.T) {
const ifaceName = "em0"
confFile := fmt.Sprintf("etc/hostname.%s", ifaceName) | <mask> "github.com/stretchr/testify/assert"
<mask> "github.com/stretchr/testify/require"
<mask> )
<mask>
<mask> func TestHostnameIfStaticConfig(t *testing.T) {
<mask> const nl = "\n"
<mask>
<mask> testCases := []struct {
<mask> name string
<mask> rcconfData string
<mask> wantHas bool
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove name string
rcconfData string
wantHas bool
</s> add name string
rootFsys fs.FS
wantHas assert.BoolAssertionFunc </s> remove const iface interfaceName = `em0`
const nl = "\n"
</s> add const (
ifaceName = `em0`
rcConf = "etc/rc.conf"
) </s> remove name string
rcconfData string
wantCont bool
</s> add name string
rootFsys fs.FS
wantHas assert.BoolAssertionFunc </s> remove func TestDHCPCDStaticConfig(t *testing.T) {
const iface interfaceName = `wlan0`
</s> add func TestHasStaticIP(t *testing.T) {
const ifaceName = "wlan0" </s> remove name string
data []byte
wantCont bool
wantPatterns []string
</s> add rootFsys fs.FS
name string
wantHas assert.BoolAssertionFunc
wantErrMsg string | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_openbsd_test.go |
name string
rootFsys fs.FS
wantHas assert.BoolAssertionFunc | <mask> func TestHostnameIfStaticConfig(t *testing.T) {
<mask> const nl = "\n"
<mask>
<mask> testCases := []struct {
<mask> name string
<mask> rcconfData string
<mask> wantHas bool
<mask> }{{
<mask> name: "simple",
<mask> rcconfData: `inet 127.0.0.253` + nl,
<mask> wantHas: true,
<mask> }, {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove name: "simple",
rcconfData: `inet 127.0.0.253` + nl,
wantHas: true,
</s> add name: "simple",
rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`inet 127.0.0.253` + nl),
},
},
wantHas: assert.True, </s> remove name string
rcconfData string
wantCont bool
</s> add name string
rootFsys fs.FS
wantHas assert.BoolAssertionFunc </s> remove func TestHostnameIfStaticConfig(t *testing.T) {
const nl = "\n"
</s> add func TestIfaceHasStaticIP(t *testing.T) {
const ifaceName = "em0"
confFile := fmt.Sprintf("etc/hostname.%s", ifaceName) </s> remove name: "simple",
rcconfData: `ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add name: "simple",
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl),
}},
wantHas: assert.True, </s> remove name: "case_sensitiveness",
rcconfData: `InEt 127.0.0.253` + nl,
wantHas: false,
</s> add name: "case_sensitiveness",
rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`InEt 127.0.0.253` + nl),
},
},
wantHas: assert.False, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_openbsd_test.go |
name: "simple",
rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`inet 127.0.0.253` + nl),
},
},
wantHas: assert.True, | <mask> name string
<mask> rcconfData string
<mask> wantHas bool
<mask> }{{
<mask> name: "simple",
<mask> rcconfData: `inet 127.0.0.253` + nl,
<mask> wantHas: true,
<mask> }, {
<mask> name: "case_sensitiveness",
<mask> rcconfData: `InEt 127.0.0.253` + nl,
<mask> wantHas: false,
<mask> }, {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove name string
rcconfData string
wantHas bool
</s> add name string
rootFsys fs.FS
wantHas assert.BoolAssertionFunc </s> remove name: "case_sensitiveness",
rcconfData: `InEt 127.0.0.253` + nl,
wantHas: false,
</s> add name: "case_sensitiveness",
rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`InEt 127.0.0.253` + nl),
},
},
wantHas: assert.False, </s> remove name: "simple",
rcconfData: `ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add name: "simple",
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl),
}},
wantHas: assert.True, </s> remove rcconfData: `# comment 1` + nl +
`` + nl +
`# inet 127.0.0.253` + nl +
`inet` + nl,
wantHas: false,
</s> add rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`# comment 1` + nl + nl +
`# inet 127.0.0.253` + nl +
`inet` + nl,
),
},
},
wantHas: assert.False, </s> remove name string
rcconfData string
wantCont bool
</s> add name string
rootFsys fs.FS
wantHas assert.BoolAssertionFunc | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_openbsd_test.go |
name: "case_sensitiveness",
rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`InEt 127.0.0.253` + nl),
},
},
wantHas: assert.False, | <mask> name: "simple",
<mask> rcconfData: `inet 127.0.0.253` + nl,
<mask> wantHas: true,
<mask> }, {
<mask> name: "case_sensitiveness",
<mask> rcconfData: `InEt 127.0.0.253` + nl,
<mask> wantHas: false,
<mask> }, {
<mask> name: "comments_and_trash",
<mask> rcconfData: `# comment 1` + nl +
<mask> `` + nl +
<mask> `# inet 127.0.0.253` + nl +
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove rcconfData: `# comment 1` + nl +
`` + nl +
`# inet 127.0.0.253` + nl +
`inet` + nl,
wantHas: false,
</s> add rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`# comment 1` + nl + nl +
`# inet 127.0.0.253` + nl +
`inet` + nl,
),
},
},
wantHas: assert.False, </s> remove name: "simple",
rcconfData: `inet 127.0.0.253` + nl,
wantHas: true,
</s> add name: "simple",
rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`inet 127.0.0.253` + nl),
},
},
wantHas: assert.True, </s> remove name: "case_insensitiveness",
rcconfData: `ifconfig_em0="InEt 127.0.0.253 NeTmAsK 0xffffffff"` + nl,
wantCont: false,
</s> add name: "case_insensitiveness",
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `="InEt 127.0.0.253 NeTmAsK 0xffffffff"` + nl),
}},
wantHas: assert.True, </s> remove rcconfData: `# comment 1` + nl +
`` + nl +
`# comment 2` + nl +
`ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`# comment 1` + nl +
`` + nl +
`# comment 2` + nl +
`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl,
),
}},
wantHas: assert.True, </s> remove rcconfData: `inet6 127.0.0.253` + nl +
`inet 256.256.256.256` + nl,
wantHas: false,
</s> add rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`inet6 127.0.0.253` + nl + `inet 256.256.256.256` + nl),
},
},
wantHas: assert.False, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_openbsd_test.go |
rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`# comment 1` + nl + nl +
`# inet 127.0.0.253` + nl +
`inet` + nl,
),
},
},
wantHas: assert.False, | <mask> rcconfData: `InEt 127.0.0.253` + nl,
<mask> wantHas: false,
<mask> }, {
<mask> name: "comments_and_trash",
<mask> rcconfData: `# comment 1` + nl +
<mask> `` + nl +
<mask> `# inet 127.0.0.253` + nl +
<mask> `inet` + nl,
<mask> wantHas: false,
<mask> }, {
<mask> name: "incorrect_config",
<mask> rcconfData: `inet6 127.0.0.253` + nl +
<mask> `inet 256.256.256.256` + nl,
<mask> wantHas: false,
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove name: "case_sensitiveness",
rcconfData: `InEt 127.0.0.253` + nl,
wantHas: false,
</s> add name: "case_sensitiveness",
rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`InEt 127.0.0.253` + nl),
},
},
wantHas: assert.False, </s> remove rcconfData: `inet6 127.0.0.253` + nl +
`inet 256.256.256.256` + nl,
wantHas: false,
</s> add rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`inet6 127.0.0.253` + nl + `inet 256.256.256.256` + nl),
},
},
wantHas: assert.False, </s> remove rcconfData: `# comment 1` + nl +
`` + nl +
`# comment 2` + nl +
`ifconfig_em0="inet 127.0.0.253 netmask 0xffffffff"` + nl,
wantCont: false,
</s> add rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`# comment 1` + nl +
`` + nl +
`# comment 2` + nl +
`ifconfig_` + ifaceName + `="inet 127.0.0.253 netmask 0xffffffff"` + nl,
),
}},
wantHas: assert.True, </s> remove name: "case_insensitiveness",
rcconfData: `ifconfig_em0="InEt 127.0.0.253 NeTmAsK 0xffffffff"` + nl,
wantCont: false,
</s> add name: "case_insensitiveness",
rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(`ifconfig_` + ifaceName + `="InEt 127.0.0.253 NeTmAsK 0xffffffff"` + nl),
}},
wantHas: assert.True, </s> remove name: "simple",
rcconfData: `inet 127.0.0.253` + nl,
wantHas: true,
</s> add name: "simple",
rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`inet 127.0.0.253` + nl),
},
},
wantHas: assert.True, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_openbsd_test.go |
rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`inet6 127.0.0.253` + nl + `inet 256.256.256.256` + nl),
},
},
wantHas: assert.False, | <mask> `inet` + nl,
<mask> wantHas: false,
<mask> }, {
<mask> name: "incorrect_config",
<mask> rcconfData: `inet6 127.0.0.253` + nl +
<mask> `inet 256.256.256.256` + nl,
<mask> wantHas: false,
<mask> }}
<mask>
<mask> for _, tc := range testCases {
<mask> r := strings.NewReader(tc.rcconfData)
<mask> t.Run(tc.name, func(t *testing.T) {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove rcconfData: `# comment 1` + nl +
`` + nl +
`# inet 127.0.0.253` + nl +
`inet` + nl,
wantHas: false,
</s> add rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`# comment 1` + nl + nl +
`# inet 127.0.0.253` + nl +
`inet` + nl,
),
},
},
wantHas: assert.False, </s> remove rcconfData: `ifconfig_em0="inet6 127.0.0.253 netmask 0xffffffff"` + nl +
`ifconfig_em0="inet 256.256.256.256 netmask 0xffffffff"` + nl +
`ifconfig_em0=""` + nl,
wantCont: true,
</s> add rootFsys: fstest.MapFS{rcConf: &fstest.MapFile{
Data: []byte(
`ifconfig_` + ifaceName + `="inet6 127.0.0.253 netmask 0xffffffff"` + nl +
`ifconfig_` + ifaceName + `="inet 256.256.256.256 netmask 0xffffffff"` + nl +
`ifconfig_` + ifaceName + `=""` + nl,
),
}},
wantHas: assert.False, </s> remove name: "case_sensitiveness",
rcconfData: `InEt 127.0.0.253` + nl,
wantHas: false,
</s> add name: "case_sensitiveness",
rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`InEt 127.0.0.253` + nl),
},
},
wantHas: assert.False, </s> remove name: "simple",
rcconfData: `inet 127.0.0.253` + nl,
wantHas: true,
</s> add name: "simple",
rootFsys: fstest.MapFS{
confFile: &fstest.MapFile{
Data: []byte(`inet 127.0.0.253` + nl),
},
},
wantHas: assert.True, </s> remove // This one tests if the first found valid interface prevents
// checking files under the `source` directive.
name: "ignore_patterns",
data: []byte(`source hello` + nl +
`source world` + nl +
`iface ` + iface + ` inet static` + nl,
),
wantCont: false,
wantPatterns: []string{},
</s> add rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`source hello` + nl +
`#iface ` + ifaceName + ` inet static` + nl,
),
},
"hello": &fstest.MapFile{
Data: []byte(`iface ` + ifaceName + ` inet static` + nl),
},
},
name: "netifaces_another_file",
wantHas: assert.True,
wantErrMsg: ``,
}, {
rootFsys: fstest.MapFS{
netifaces: &fstest.MapFile{
Data: []byte(`source hello` + nl +
`iface ` + ifaceName + ` inet static` + nl,
),
},
},
name: "netifaces_ignore_another",
wantHas: assert.True,
wantErrMsg: ``, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_openbsd_test.go |
<mask> wantHas: false,
<mask> }}
<mask>
<mask> for _, tc := range testCases {
<mask> r := strings.NewReader(tc.rcconfData)
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> _, has, err := hostnameIfStaticConfig(r)
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, tc.wantHas, has)
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove _, has, err := hostnameIfStaticConfig(r)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName) </s> remove r := bytes.NewReader(tc.data)
</s> add </s> remove r := strings.NewReader(tc.rcconfData)
</s> add </s> remove _, cont, err := iface.rcConfStaticConfig(r)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName) </s> remove assert.Equal(t, tc.wantHas, has)
</s> add tc.wantHas(t, has) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_openbsd_test.go |
|
substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName) | <mask>
<mask> for _, tc := range testCases {
<mask> r := strings.NewReader(tc.rcconfData)
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> _, has, err := hostnameIfStaticConfig(r)
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, tc.wantHas, has)
<mask> })
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove r := strings.NewReader(tc.rcconfData)
</s> add </s> remove assert.Equal(t, tc.wantHas, has)
</s> add tc.wantHas(t, has) </s> remove _, cont, err := iface.rcConfStaticConfig(r)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName) </s> remove patterns, has, err := iface.ifacesStaticConfig(r)
require.NoError(t, err)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName)
testutil.AssertErrorMsg(t, tc.wantErrMsg, err) </s> remove r := bytes.NewReader(tc.data)
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_openbsd_test.go |
tc.wantHas(t, has) | <mask> t.Run(tc.name, func(t *testing.T) {
<mask> _, has, err := hostnameIfStaticConfig(r)
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, tc.wantHas, has)
<mask> })
<mask> }
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove _, has, err := hostnameIfStaticConfig(r)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName) </s> remove r := strings.NewReader(tc.rcconfData)
</s> add </s> remove assert.Equal(t, tc.wantCont, has)
assert.ElementsMatch(t, tc.wantPatterns, patterns)
</s> add tc.wantHas(t, has) </s> remove assert.Equal(t, tc.wantCont, cont)
</s> add tc.wantHas(t, has) </s> remove patterns, has, err := iface.ifacesStaticConfig(r)
require.NoError(t, err)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName)
testutil.AssertErrorMsg(t, tc.wantErrMsg, err) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_openbsd_test.go |
"fmt" | <mask> package aghnet
<mask>
<mask> import (
<mask> "io/fs"
<mask> "net"
<mask> "os"
<mask> "strings"
<mask> "testing"
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "strings"
</s> add "io/fs" </s> remove "strings"
</s> add "fmt"
"io/fs" </s> remove "bytes"
</s> add "io/fs" </s> remove "io"
</s> add </s> remove "io"
</s> add | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_test.go |
"strings" | <mask> "io/fs"
<mask> "net"
<mask> "os"
<mask> "testing"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghtest"
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/netutil"
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "strings"
</s> add </s> remove "os/exec"
"strings"
</s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/aghos"
</s> add | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_test.go |
func TestMain(m *testing.M) {
aghtest.DiscardLogOutput(m)
}
| <mask> "github.com/stretchr/testify/assert"
<mask> "github.com/stretchr/testify/require"
<mask> )
<mask>
<mask> // testdata is the filesystem containing data for testing the package.
<mask> var testdata fs.FS = os.DirFS("./testdata")
<mask>
<mask> // substRootDirFS replaces the aghos.RootDirFS function used throughout the
<mask> // package with fsys for tests ran under t.
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove func TestMain(m *testing.M) {
aghtest.DiscardLogOutput(m)
</s> add // substRootDirFS replaces the aghos.RootDirFS function used throughout the
// package with fsys for tests ran under t.
func substRootDirFS(t testing.TB, fsys fs.FS) {
t.Helper()
prev := rootDirFS
t.Cleanup(func() { rootDirFS = prev })
rootDirFS = fsys
}
// RunCmdFunc is the signature of aghos.RunCommand function.
type RunCmdFunc func(cmd string, args ...string) (code int, out []byte, err error)
// substShell replaces the the aghos.RunCommand function used throughout the
// package with rc for tests ran under t.
func substShell(t testing.TB, rc RunCmdFunc) {
t.Helper()
prev := aghosRunCommand
t.Cleanup(func() { aghosRunCommand = prev })
aghosRunCommand = rc
}
// mapShell is a substitution of aghos.RunCommand that maps the command to it's
// execution result. It's only needed to simplify testing.
//
// TODO(e.burkov): Perhaps put all the shell interactions behind an interface.
type mapShell map[string]struct {
err error
out string
code int
}
// theOnlyCmd returns s that only handles a single command and arguments
// combination from cmd.
func theOnlyCmd(cmd string, code int, out string, err error) (s mapShell) {
return mapShell{cmd: {code: code, out: out, err: err}}
}
// RunCmd is a RunCmdFunc handled by s.
func (s mapShell) RunCmd(cmd string, args ...string) (code int, out []byte, err error) {
key := strings.Join(append([]string{cmd}, args...), " ")
ret, ok := s[key]
if !ok {
return 0, nil, fmt.Errorf("unexpected shell command %q", key)
}
return ret.code, []byte(ret.out), ret.err
}
func TestGatewayIP(t *testing.T) {
testCases := []struct {
name string
shell mapShell
want net.IP
}{{
name: "success_v4",
shell: theOnlyCmd("ip route show dev ifaceName", 0, `default via 1.2.3.4 onlink`, nil),
want: net.IP{1, 2, 3, 4}.To16(),
}, {
name: "success_v6",
shell: theOnlyCmd("ip route show dev ifaceName", 0, `default via ::ffff onlink`, nil),
want: net.IP{
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0xFF, 0xFF,
},
}, {
name: "bad_output",
shell: theOnlyCmd("ip route show dev ifaceName", 0, `non-default via 1.2.3.4 onlink`, nil),
want: nil,
}, {
name: "err_runcmd",
shell: theOnlyCmd("ip route show dev ifaceName", 0, "", errors.Error("can't run command")),
want: nil,
}, {
name: "bad_code",
shell: theOnlyCmd("ip route show dev ifaceName", 1, "", nil),
want: nil,
}}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
substShell(t, tc.shell.RunCmd)
assert.Equal(t, tc.want, GatewayIP("ifaceName"))
})
} </s> remove // runCmdFunc is the function that runs some command and returns its output
// wrapped to be a io.Reader.
type runCmdFunc func() (r io.Reader, err error)
</s> add </s> remove // runCmd runs the cmd with it's args and returns the result wrapped to be an
// io.Reader. The error is returned either if the exit code retured by command
// not equals 0 or the execution itself failed.
func runCmd(cmd string, args ...string) (r io.Reader, err error) {
var code int
var out string
code, out, err = aghos.RunCommand(cmd, args...)
if err != nil {
return nil, err
} else if code != 0 {
return nil, fmt.Errorf("unexpected exit code %d", code)
}
return strings.NewReader(out), nil
}
</s> add | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_test.go |
// substRootDirFS replaces the aghos.RootDirFS function used throughout the
// package with fsys for tests ran under t.
func substRootDirFS(t testing.TB, fsys fs.FS) {
t.Helper()
prev := rootDirFS
t.Cleanup(func() { rootDirFS = prev })
rootDirFS = fsys
}
// RunCmdFunc is the signature of aghos.RunCommand function.
type RunCmdFunc func(cmd string, args ...string) (code int, out []byte, err error)
// substShell replaces the the aghos.RunCommand function used throughout the
// package with rc for tests ran under t.
func substShell(t testing.TB, rc RunCmdFunc) {
t.Helper()
prev := aghosRunCommand
t.Cleanup(func() { aghosRunCommand = prev })
aghosRunCommand = rc
}
// mapShell is a substitution of aghos.RunCommand that maps the command to it's
// execution result. It's only needed to simplify testing.
//
// TODO(e.burkov): Perhaps put all the shell interactions behind an interface.
type mapShell map[string]struct {
err error
out string
code int
}
// theOnlyCmd returns s that only handles a single command and arguments
// combination from cmd.
func theOnlyCmd(cmd string, code int, out string, err error) (s mapShell) {
return mapShell{cmd: {code: code, out: out, err: err}}
}
// RunCmd is a RunCmdFunc handled by s.
func (s mapShell) RunCmd(cmd string, args ...string) (code int, out []byte, err error) {
key := strings.Join(append([]string{cmd}, args...), " ")
ret, ok := s[key]
if !ok {
return 0, nil, fmt.Errorf("unexpected shell command %q", key)
}
return ret.code, []byte(ret.out), ret.err
}
func TestGatewayIP(t *testing.T) {
testCases := []struct {
name string
shell mapShell
want net.IP
}{{
name: "success_v4",
shell: theOnlyCmd("ip route show dev ifaceName", 0, `default via 1.2.3.4 onlink`, nil),
want: net.IP{1, 2, 3, 4}.To16(),
}, {
name: "success_v6",
shell: theOnlyCmd("ip route show dev ifaceName", 0, `default via ::ffff onlink`, nil),
want: net.IP{
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0xFF, 0xFF,
},
}, {
name: "bad_output",
shell: theOnlyCmd("ip route show dev ifaceName", 0, `non-default via 1.2.3.4 onlink`, nil),
want: nil,
}, {
name: "err_runcmd",
shell: theOnlyCmd("ip route show dev ifaceName", 0, "", errors.Error("can't run command")),
want: nil,
}, {
name: "bad_code",
shell: theOnlyCmd("ip route show dev ifaceName", 1, "", nil),
want: nil,
}}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
substShell(t, tc.shell.RunCmd)
assert.Equal(t, tc.want, GatewayIP("ifaceName"))
})
} | <mask>
<mask> // testdata is the filesystem containing data for testing the package.
<mask> var testdata fs.FS = os.DirFS("./testdata")
<mask>
<mask> func TestMain(m *testing.M) {
<mask> aghtest.DiscardLogOutput(m)
<mask> }
<mask>
<mask> func TestGetInterfaceByIP(t *testing.T) {
<mask> ifaces, err := GetValidNetInterfacesForWeb()
<mask> require.NoError(t, err)
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove func GetValidNetInterfacesForWeb() ([]*NetInterface, error) {
</s> add func GetValidNetInterfacesForWeb() (netInterfaces []*NetInterface, err error) { </s> remove func getHardwarePortInfo(hardwarePort string) (hardwarePortInfo, error) {
h := hardwarePortInfo{}
</s> add // hardwarePortReg is the regular expression matching the lines of networksetup
// command output lines containing the port information.
var hardwarePortReg = regexp.MustCompile("IP address: (.*?)\nSubnet mask: (.*?)\nRouter: (.*?)\n") </s> remove l := len(arp.arps)
// Start from the last succeeded implementation.
for i := 0; i < l; i++ {
cur := (arp.last + i) % l
err = arp.arps[cur].Refresh()
if err == nil {
// The succeeded implementation found so update the last succeeded
// index.
arp.last = cur
return nil
</s> add for _, a := range arp.arps {
err = a.Refresh()
if err != nil {
errs = append(errs, err)
continue | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_test.go |
t.Skip("TODO(e.burkov): Substitute the net.Interfaces.")
| <mask> })
<mask> }
<mask>
<mask> func TestCollectAllIfacesAddrs(t *testing.T) {
<mask> addrs, err := CollectAllIfacesAddrs()
<mask> require.NoError(t, err)
<mask>
<mask> assert.NotEmpty(t, addrs)
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove assert.Equal(t, 2, succRefrCount)
</s> add assert.Equal(t, 1, succRefrCount) </s> remove assert.Equal(t, tc.wantCont, has)
assert.ElementsMatch(t, tc.wantPatterns, patterns)
</s> add tc.wantHas(t, has) </s> remove assert.Equal(t, tc.wantHas, has)
</s> add tc.wantHas(t, has) </s> remove assert.Equal(t, tc.wantCont, cont)
</s> add tc.wantHas(t, has) </s> remove _, cont, err := iface.rcConfStaticConfig(r)
</s> add substRootDirFS(t, tc.rootFsys)
has, err := IfaceHasStaticIP(ifaceName) | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_test.go |
func RunCommand(command string, arguments ...string) (code int, output []byte, err error) { | <mask> // bytes.
<mask> const MaxCmdOutputSize = 64 * 1024
<mask>
<mask> // RunCommand runs shell command.
<mask> func RunCommand(command string, arguments ...string) (code int, output string, err 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: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove if errors.As(err, new(*exec.ExitError)) {
return cmd.ProcessState.ExitCode(), string(out), nil
} else if err != nil {
return 1, "", fmt.Errorf("command %q failed: %w: %s", command, err, out)
</s> add if err != nil {
if eerr := new(exec.ExitError); errors.As(err, &eerr) {
return eerr.ExitCode(), eerr.Stderr, nil
}
return 1, nil, fmt.Errorf("command %q failed: %w: %s", command, err, out) </s> remove func TestMain(m *testing.M) {
aghtest.DiscardLogOutput(m)
</s> add // substRootDirFS replaces the aghos.RootDirFS function used throughout the
// package with fsys for tests ran under t.
func substRootDirFS(t testing.TB, fsys fs.FS) {
t.Helper()
prev := rootDirFS
t.Cleanup(func() { rootDirFS = prev })
rootDirFS = fsys
}
// RunCmdFunc is the signature of aghos.RunCommand function.
type RunCmdFunc func(cmd string, args ...string) (code int, out []byte, err error)
// substShell replaces the the aghos.RunCommand function used throughout the
// package with rc for tests ran under t.
func substShell(t testing.TB, rc RunCmdFunc) {
t.Helper()
prev := aghosRunCommand
t.Cleanup(func() { aghosRunCommand = prev })
aghosRunCommand = rc
}
// mapShell is a substitution of aghos.RunCommand that maps the command to it's
// execution result. It's only needed to simplify testing.
//
// TODO(e.burkov): Perhaps put all the shell interactions behind an interface.
type mapShell map[string]struct {
err error
out string
code int
}
// theOnlyCmd returns s that only handles a single command and arguments
// combination from cmd.
func theOnlyCmd(cmd string, code int, out string, err error) (s mapShell) {
return mapShell{cmd: {code: code, out: out, err: err}}
}
// RunCmd is a RunCmdFunc handled by s.
func (s mapShell) RunCmd(cmd string, args ...string) (code int, out []byte, err error) {
key := strings.Join(append([]string{cmd}, args...), " ")
ret, ok := s[key]
if !ok {
return 0, nil, fmt.Errorf("unexpected shell command %q", key)
}
return ret.code, []byte(ret.out), ret.err
}
func TestGatewayIP(t *testing.T) {
testCases := []struct {
name string
shell mapShell
want net.IP
}{{
name: "success_v4",
shell: theOnlyCmd("ip route show dev ifaceName", 0, `default via 1.2.3.4 onlink`, nil),
want: net.IP{1, 2, 3, 4}.To16(),
}, {
name: "success_v6",
shell: theOnlyCmd("ip route show dev ifaceName", 0, `default via ::ffff onlink`, nil),
want: net.IP{
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0xFF, 0xFF,
},
}, {
name: "bad_output",
shell: theOnlyCmd("ip route show dev ifaceName", 0, `non-default via 1.2.3.4 onlink`, nil),
want: nil,
}, {
name: "err_runcmd",
shell: theOnlyCmd("ip route show dev ifaceName", 0, "", errors.Error("can't run command")),
want: nil,
}, {
name: "bad_code",
shell: theOnlyCmd("ip route show dev ifaceName", 1, "", nil),
want: nil,
}}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
substShell(t, tc.shell.RunCmd)
assert.Equal(t, tc.want, GatewayIP("ifaceName"))
})
} </s> remove // runCmd runs the cmd with it's args and returns the result wrapped to be an
// io.Reader. The error is returned either if the exit code retured by command
// not equals 0 or the execution itself failed.
func runCmd(cmd string, args ...string) (r io.Reader, err error) {
var code int
var out string
code, out, err = aghos.RunCommand(cmd, args...)
if err != nil {
return nil, err
} else if code != 0 {
return nil, fmt.Errorf("unexpected exit code %d", code)
}
return strings.NewReader(out), nil
}
</s> add </s> remove return cmd.ProcessState.ExitCode(), string(out), nil
</s> add return cmd.ProcessState.ExitCode(), out, nil </s> remove func GatewayIP(ifaceName string) net.IP {
cmd := exec.Command("ip", "route", "show", "dev", ifaceName)
log.Tracef("executing %s %v", cmd.Path, cmd.Args)
d, err := cmd.Output()
if err != nil || cmd.ProcessState.ExitCode() != 0 {
</s> add //
// TODO(e.burkov): Investigate if the gateway address may be fetched in another
// way since not every machine has the software installed.
func GatewayIP(ifaceName string) (ip net.IP) {
code, out, err := aghosRunCommand("ip", "route", "show", "dev", ifaceName)
if err != nil {
log.Debug("%s", err)
return nil
} else if code != 0 {
log.Debug("fetching gateway ip: unexpected exit code: %d", code)
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghos/os.go |
if err != nil {
if eerr := new(exec.ExitError); errors.As(err, &eerr) {
return eerr.ExitCode(), eerr.Stderr, nil
}
return 1, nil, fmt.Errorf("command %q failed: %w: %s", command, err, out) | <mask> if len(out) > MaxCmdOutputSize {
<mask> out = out[:MaxCmdOutputSize]
<mask> }
<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("command %q failed: %w: %s", command, err, out)
<mask> }
<mask>
<mask> return cmd.ProcessState.ExitCode(), string(out), nil
<mask> }
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove return cmd.ProcessState.ExitCode(), string(out), nil
</s> add return cmd.ProcessState.ExitCode(), out, nil </s> remove func RunCommand(command string, arguments ...string) (code int, output string, err error) {
</s> add func RunCommand(command string, arguments ...string) (code int, output []byte, err error) { </s> remove }
if has {
</s> add } else if has { </s> remove }
if code != 0 {
</s> add } else if code != 0 { </s> remove errs = append(errs, err)
</s> add arp.reset(a.Neighbors())
return nil | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghos/os.go |
return cmd.ProcessState.ExitCode(), out, nil | <mask> } else if err != nil {
<mask> return 1, "", fmt.Errorf("command %q failed: %w: %s", command, err, out)
<mask> }
<mask>
<mask> return cmd.ProcessState.ExitCode(), string(out), nil
<mask> }
<mask>
<mask> // PIDByCommand searches for process named command and returns its PID ignoring
<mask> // the PIDs from except. If no processes found, the error returned.
<mask> func PIDByCommand(command string, except ...int) (pid int, err error) {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove if errors.As(err, new(*exec.ExitError)) {
return cmd.ProcessState.ExitCode(), string(out), nil
} else if err != nil {
return 1, "", fmt.Errorf("command %q failed: %w: %s", command, err, out)
</s> add if err != nil {
if eerr := new(exec.ExitError); errors.As(err, &eerr) {
return eerr.ExitCode(), eerr.Stderr, nil
}
return 1, nil, fmt.Errorf("command %q failed: %w: %s", command, err, out) </s> remove // runCmd runs the cmd with it's args and returns the result wrapped to be an
// io.Reader. The error is returned either if the exit code retured by command
// not equals 0 or the execution itself failed.
func runCmd(cmd string, args ...string) (r io.Reader, err error) {
var code int
var out string
code, out, err = aghos.RunCommand(cmd, args...)
if err != nil {
return nil, err
} else if code != 0 {
return nil, fmt.Errorf("unexpected exit code %d", code)
}
return strings.NewReader(out), nil
}
</s> add </s> remove return nil, err
}
re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
matches := re.FindAllStringSubmatch(string(body), -1)
if len(matches) == 0 {
return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
}
addrs := make([]string, 0)
for i := range matches {
addrs = append(addrs, matches[i][1])
</s> add return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) </s> remove func TestMain(m *testing.M) {
aghtest.DiscardLogOutput(m)
</s> add // substRootDirFS replaces the aghos.RootDirFS function used throughout the
// package with fsys for tests ran under t.
func substRootDirFS(t testing.TB, fsys fs.FS) {
t.Helper()
prev := rootDirFS
t.Cleanup(func() { rootDirFS = prev })
rootDirFS = fsys
}
// RunCmdFunc is the signature of aghos.RunCommand function.
type RunCmdFunc func(cmd string, args ...string) (code int, out []byte, err error)
// substShell replaces the the aghos.RunCommand function used throughout the
// package with rc for tests ran under t.
func substShell(t testing.TB, rc RunCmdFunc) {
t.Helper()
prev := aghosRunCommand
t.Cleanup(func() { aghosRunCommand = prev })
aghosRunCommand = rc
}
// mapShell is a substitution of aghos.RunCommand that maps the command to it's
// execution result. It's only needed to simplify testing.
//
// TODO(e.burkov): Perhaps put all the shell interactions behind an interface.
type mapShell map[string]struct {
err error
out string
code int
}
// theOnlyCmd returns s that only handles a single command and arguments
// combination from cmd.
func theOnlyCmd(cmd string, code int, out string, err error) (s mapShell) {
return mapShell{cmd: {code: code, out: out, err: err}}
}
// RunCmd is a RunCmdFunc handled by s.
func (s mapShell) RunCmd(cmd string, args ...string) (code int, out []byte, err error) {
key := strings.Join(append([]string{cmd}, args...), " ")
ret, ok := s[key]
if !ok {
return 0, nil, fmt.Errorf("unexpected shell command %q", key)
}
return ret.code, []byte(ret.out), ret.err
}
func TestGatewayIP(t *testing.T) {
testCases := []struct {
name string
shell mapShell
want net.IP
}{{
name: "success_v4",
shell: theOnlyCmd("ip route show dev ifaceName", 0, `default via 1.2.3.4 onlink`, nil),
want: net.IP{1, 2, 3, 4}.To16(),
}, {
name: "success_v6",
shell: theOnlyCmd("ip route show dev ifaceName", 0, `default via ::ffff onlink`, nil),
want: net.IP{
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0xFF, 0xFF,
},
}, {
name: "bad_output",
shell: theOnlyCmd("ip route show dev ifaceName", 0, `non-default via 1.2.3.4 onlink`, nil),
want: nil,
}, {
name: "err_runcmd",
shell: theOnlyCmd("ip route show dev ifaceName", 0, "", errors.Error("can't run command")),
want: nil,
}, {
name: "bad_code",
shell: theOnlyCmd("ip route show dev ifaceName", 1, "", nil),
want: nil,
}}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
substShell(t, tc.shell.RunCmd)
assert.Equal(t, tc.want, GatewayIP("ifaceName"))
})
} </s> remove func GetValidNetInterfacesForWeb() ([]*NetInterface, error) {
</s> add func GetValidNetInterfacesForWeb() (netInterfaces []*NetInterface, err error) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghos/os.go |
var outData []byte
_, outData, err = aghos.RunCommand(scriptPath, cmd) | <mask>
<mask> // TODO(e.burkov): It's possible that os.ErrNotExist is caused by
<mask> // something different than the service script's non-existence. Keep it
<mask> // in mind, when replace the aghos.RunCommand.
<mask> _, out, err = aghos.RunCommand(scriptPath, cmd)
<mask> if errors.Is(err, os.ErrNotExist) {
<mask> return "", service.ErrNotInstalled
<mask> }
<mask>
<mask> return out, err
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove return out, err
</s> add return string(outData), err </s> remove func getNetworkSetupHardwareReports() map[string]string {
_, out, err := aghos.RunCommand("networksetup", "-listallhardwareports")
if err != nil {
return nil
}
re, err := regexp.Compile("Hardware Port: (.*?)\nDevice: (.*?)\n")
</s> add func getNetworkSetupHardwareReports() (reports map[string]string) {
_, out, err := aghosRunCommand("networksetup", "-listallhardwareports") </s> remove return nil, fmt.Errorf("got iface.Addrs() element %s that is not net.IPNet, it is %T", addr, addr)
</s> add return nil, fmt.Errorf("got %s that is not net.IPNet, it is %T", addr, addr) </s> remove func getHardwarePortInfo(hardwarePort string) (hardwarePortInfo, error) {
h := hardwarePortInfo{}
</s> add // hardwarePortReg is the regular expression matching the lines of networksetup
// command output lines containing the port information.
var hardwarePortReg = regexp.MustCompile("IP address: (.*?)\nSubnet mask: (.*?)\nRouter: (.*?)\n") | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/home/service_openbsd.go |
return string(outData), err | <mask> if errors.Is(err, os.ErrNotExist) {
<mask> return "", service.ErrNotInstalled
<mask> }
<mask>
<mask> return out, err
<mask> }
<mask>
<mask> // Status implements service.Service interface for *openbsdRunComService.
<mask> func (s *openbsdRunComService) Status() (status service.Status, err error) {
<mask> defer func() { err = s.annotate("getting status of", err) }()
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove var r io.Reader
r, err = arp.runcmd()
</s> add code, out, err := aghosRunCommand(arp.cmd, arp.args...) </s> remove _, out, err = aghos.RunCommand(scriptPath, cmd)
</s> add var outData []byte
_, outData, err = aghos.RunCommand(scriptPath, cmd) </s> remove // runCmd runs the cmd with it's args and returns the result wrapped to be an
// io.Reader. The error is returned either if the exit code retured by command
// not equals 0 or the execution itself failed.
func runCmd(cmd string, args ...string) (r io.Reader, err error) {
var code int
var out string
code, out, err = aghos.RunCommand(cmd, args...)
if err != nil {
return nil, err
} else if code != 0 {
return nil, fmt.Errorf("unexpected exit code %d", code)
}
return strings.NewReader(out), nil
}
</s> add </s> remove if l := len(arp.arps); l > 0 && arp.last < l {
return arp.arps[arp.last].Neighbors()
}
return nil
</s> add return arp.clone() </s> remove l := len(arp.arps)
// Start from the last succeeded implementation.
for i := 0; i < l; i++ {
cur := (arp.last + i) % l
err = arp.arps[cur].Refresh()
if err == nil {
// The succeeded implementation found so update the last succeeded
// index.
arp.last = cur
return nil
</s> add for _, a := range arp.arps {
err = a.Refresh()
if err != nil {
errs = append(errs, err)
continue | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/home/service_openbsd.go |
import { SERVICES, FILTERED_STATUS, TABLE_DEFAULT_PAGE_SIZE, CUSTOM_FILTERING_RULES_ID } from '../../helpers/constants'; | <mask> formatTime,
<mask> formatDateTime,
<mask> isToday,
<mask> } from '../../helpers/helpers';
<mask> import { SERVICES, FILTERED_STATUS, TABLE_DEFAULT_PAGE_SIZE } from '../../helpers/constants';
<mask> import { getTrackerData } from '../../helpers/trackers/trackers';
<mask> import { formatClientCell } from '../../helpers/formatClientCell';
<mask>
<mask> import Filters from './Filters';
<mask> import PageTitle from '../ui/PageTitle';
</s> Merge: + client: show filter name for blocked items in the query log
Closes #993
Squashed commit of the following:
commit 4c5e17226c6efa8a7847a8c565c491a7bae2db59
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:21:40 2020 +0300
- client: use constant
commit 818c07d1cfb210965a6413dc8370fc8867979c7b
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:18:31 2020 +0300
- client: fix filter find
commit 1f9132151c843dacbf26f814faeeea3cfdff9b73
Author: Ildar Kamalov <[email protected]>
Date: Tue Jan 28 15:52:29 2020 +0300
+ client: show filter name for blocked items in the query log </s> remove if (typeof filterItem !== 'undefined' && typeof filters[filterItem] !== 'undefined') {
filterName = filters[filterItem].name;
}
if (!filterName) {
filterName = t('unknown_filter', { filterId });
}
</s> add return (
<div className="logs__row logs__row--column">
<div className="logs__text-wrap">
<span className="logs__text">
<Trans>blocked_by_response</Trans>
</span>
</div>
<div className="logs__list-wrap">
{this.renderResponseList(normalizedAnswer, status)}
</div>
</div>
); </s> remove if (filterId === 0) {
filterName = t('custom_filter_rules');
} else {
const filterItem = Object.keys(filters).filter(key => filters[key].id === filterId)[0];
</s> add if (isBlockedCnameIp) {
const normalizedAnswer = this.normalizeResponse(originalAnswer); </s> remove const filterKey = reason.replace(FILTERED_REASON, '');
const parsedFilteredReason = t('query_log_filtered', { filter: filterKey });
</s> add const isBlackList = this.checkBlackList(reason); </s> remove const normalizedAnswer = originalAnswer && this.normalizeResponse(originalAnswer);
let filterName = '';
</s> add const filterName = this.getFilterName(filters, filterId, t); </s> remove {originalAnswer
? this.renderResponseList(normalizedAnswer, status)
: this.renderResponseList(responses, status)
}
</s> add {this.renderResponseList(responses, status)} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e9c21b0a7917d0b89fe25cbf8b5790029ea2ac6 | client/src/components/Logs/index.js |
checkBlackList = reason => reason === FILTERED_STATUS.FILTERED_BLACK_LIST;
checkBlockedService = reason => reason === FILTERED_STATUS.FILTERED_BLOCKED_SERVICE; | <mask>
<mask> checkWhiteList = reason => reason === FILTERED_STATUS.NOT_FILTERED_WHITE_LIST;
<mask>
<mask>
<mask> getDateCell = row => CellWrap(
<mask> row,
<mask> (isToday(row.value) ? formatTime : formatDateTime),
<mask> formatDateTime,
</s> Merge: + client: show filter name for blocked items in the query log
Closes #993
Squashed commit of the following:
commit 4c5e17226c6efa8a7847a8c565c491a7bae2db59
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:21:40 2020 +0300
- client: use constant
commit 818c07d1cfb210965a6413dc8370fc8867979c7b
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:18:31 2020 +0300
- client: fix filter find
commit 1f9132151c843dacbf26f814faeeea3cfdff9b73
Author: Ildar Kamalov <[email protected]>
Date: Tue Jan 28 15:52:29 2020 +0300
+ client: show filter name for blocked items in the query log </s> remove const normalizedAnswer = originalAnswer && this.normalizeResponse(originalAnswer);
let filterName = '';
</s> add const filterName = this.getFilterName(filters, filterId, t); </s> remove const filterKey = reason.replace(FILTERED_REASON, '');
const parsedFilteredReason = t('query_log_filtered', { filter: filterKey });
</s> add const isBlackList = this.checkBlackList(reason); </s> remove const isBlockedService = reason === FILTERED_STATUS.FILTERED_BLOCKED_SERVICE;
</s> add const isBlockedService = this.checkBlockedService(reason);
const isBlockedCnameIp = originalAnswer;
const filterKey = reason.replace(FILTERED_REASON, '');
const parsedFilteredReason = t('query_log_filtered', { filter: filterKey }); </s> remove if (filterId === 0) {
filterName = t('custom_filter_rules');
} else {
const filterItem = Object.keys(filters).filter(key => filters[key].id === filterId)[0];
</s> add if (isBlockedCnameIp) {
const normalizedAnswer = this.normalizeResponse(originalAnswer); </s> remove if (typeof filterItem !== 'undefined' && typeof filters[filterItem] !== 'undefined') {
filterName = filters[filterItem].name;
}
if (!filterName) {
filterName = t('unknown_filter', { filterId });
}
</s> add return (
<div className="logs__row logs__row--column">
<div className="logs__text-wrap">
<span className="logs__text">
<Trans>blocked_by_response</Trans>
</span>
</div>
<div className="logs__list-wrap">
{this.renderResponseList(normalizedAnswer, status)}
</div>
</div>
); | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e9c21b0a7917d0b89fe25cbf8b5790029ea2ac6 | client/src/components/Logs/index.js |
const isBlackList = this.checkBlackList(reason); | <mask> const { t, filtering } = this.props;
<mask> const { filters } = filtering;
<mask>
<mask> const isFiltered = this.checkFiltered(reason);
<mask> const filterKey = reason.replace(FILTERED_REASON, '');
<mask> const parsedFilteredReason = t('query_log_filtered', { filter: filterKey });
<mask> const isRewrite = this.checkRewrite(reason);
<mask> const isWhiteList = this.checkWhiteList(reason);
<mask> const isBlockedService = reason === FILTERED_STATUS.FILTERED_BLOCKED_SERVICE;
<mask> const currentService = SERVICES.find(service => service.id === original.serviceName);
<mask> const serviceName = currentService && currentService.name;
</s> Merge: + client: show filter name for blocked items in the query log
Closes #993
Squashed commit of the following:
commit 4c5e17226c6efa8a7847a8c565c491a7bae2db59
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:21:40 2020 +0300
- client: use constant
commit 818c07d1cfb210965a6413dc8370fc8867979c7b
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:18:31 2020 +0300
- client: fix filter find
commit 1f9132151c843dacbf26f814faeeea3cfdff9b73
Author: Ildar Kamalov <[email protected]>
Date: Tue Jan 28 15:52:29 2020 +0300
+ client: show filter name for blocked items in the query log </s> remove const isBlockedService = reason === FILTERED_STATUS.FILTERED_BLOCKED_SERVICE;
</s> add const isBlockedService = this.checkBlockedService(reason);
const isBlockedCnameIp = originalAnswer;
const filterKey = reason.replace(FILTERED_REASON, '');
const parsedFilteredReason = t('query_log_filtered', { filter: filterKey }); </s> remove const normalizedAnswer = originalAnswer && this.normalizeResponse(originalAnswer);
let filterName = '';
</s> add const filterName = this.getFilterName(filters, filterId, t); </s> remove if (filterId === 0) {
filterName = t('custom_filter_rules');
} else {
const filterItem = Object.keys(filters).filter(key => filters[key].id === filterId)[0];
</s> add if (isBlockedCnameIp) {
const normalizedAnswer = this.normalizeResponse(originalAnswer); </s> remove if (typeof filterItem !== 'undefined' && typeof filters[filterItem] !== 'undefined') {
filterName = filters[filterItem].name;
}
if (!filterName) {
filterName = t('unknown_filter', { filterId });
}
</s> add return (
<div className="logs__row logs__row--column">
<div className="logs__text-wrap">
<span className="logs__text">
<Trans>blocked_by_response</Trans>
</span>
</div>
<div className="logs__list-wrap">
{this.renderResponseList(normalizedAnswer, status)}
</div>
</div>
); | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e9c21b0a7917d0b89fe25cbf8b5790029ea2ac6 | client/src/components/Logs/index.js |
const isBlockedService = this.checkBlockedService(reason);
const isBlockedCnameIp = originalAnswer;
const filterKey = reason.replace(FILTERED_REASON, '');
const parsedFilteredReason = t('query_log_filtered', { filter: filterKey }); | <mask> const filterKey = reason.replace(FILTERED_REASON, '');
<mask> const parsedFilteredReason = t('query_log_filtered', { filter: filterKey });
<mask> const isRewrite = this.checkRewrite(reason);
<mask> const isWhiteList = this.checkWhiteList(reason);
<mask> const isBlockedService = reason === FILTERED_STATUS.FILTERED_BLOCKED_SERVICE;
<mask> const currentService = SERVICES.find(service => service.id === original.serviceName);
<mask> const serviceName = currentService && currentService.name;
<mask> const normalizedAnswer = originalAnswer && this.normalizeResponse(originalAnswer);
<mask> let filterName = '';
<mask>
</s> Merge: + client: show filter name for blocked items in the query log
Closes #993
Squashed commit of the following:
commit 4c5e17226c6efa8a7847a8c565c491a7bae2db59
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:21:40 2020 +0300
- client: use constant
commit 818c07d1cfb210965a6413dc8370fc8867979c7b
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:18:31 2020 +0300
- client: fix filter find
commit 1f9132151c843dacbf26f814faeeea3cfdff9b73
Author: Ildar Kamalov <[email protected]>
Date: Tue Jan 28 15:52:29 2020 +0300
+ client: show filter name for blocked items in the query log </s> remove const filterKey = reason.replace(FILTERED_REASON, '');
const parsedFilteredReason = t('query_log_filtered', { filter: filterKey });
</s> add const isBlackList = this.checkBlackList(reason); </s> remove const normalizedAnswer = originalAnswer && this.normalizeResponse(originalAnswer);
let filterName = '';
</s> add const filterName = this.getFilterName(filters, filterId, t); </s> remove if (filterId === 0) {
filterName = t('custom_filter_rules');
} else {
const filterItem = Object.keys(filters).filter(key => filters[key].id === filterId)[0];
</s> add if (isBlockedCnameIp) {
const normalizedAnswer = this.normalizeResponse(originalAnswer); </s> remove if (typeof filterItem !== 'undefined' && typeof filters[filterItem] !== 'undefined') {
filterName = filters[filterItem].name;
}
if (!filterName) {
filterName = t('unknown_filter', { filterId });
}
</s> add return (
<div className="logs__row logs__row--column">
<div className="logs__text-wrap">
<span className="logs__text">
<Trans>blocked_by_response</Trans>
</span>
</div>
<div className="logs__list-wrap">
{this.renderResponseList(normalizedAnswer, status)}
</div>
</div>
); | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e9c21b0a7917d0b89fe25cbf8b5790029ea2ac6 | client/src/components/Logs/index.js |
const filterName = this.getFilterName(filters, filterId, t); | <mask> const isWhiteList = this.checkWhiteList(reason);
<mask> const isBlockedService = reason === FILTERED_STATUS.FILTERED_BLOCKED_SERVICE;
<mask> const currentService = SERVICES.find(service => service.id === original.serviceName);
<mask> const serviceName = currentService && currentService.name;
<mask> const normalizedAnswer = originalAnswer && this.normalizeResponse(originalAnswer);
<mask> let filterName = '';
<mask>
<mask> if (filterId === 0) {
<mask> filterName = t('custom_filter_rules');
<mask> } else {
<mask> const filterItem = Object.keys(filters).filter(key => filters[key].id === filterId)[0];
</s> Merge: + client: show filter name for blocked items in the query log
Closes #993
Squashed commit of the following:
commit 4c5e17226c6efa8a7847a8c565c491a7bae2db59
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:21:40 2020 +0300
- client: use constant
commit 818c07d1cfb210965a6413dc8370fc8867979c7b
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:18:31 2020 +0300
- client: fix filter find
commit 1f9132151c843dacbf26f814faeeea3cfdff9b73
Author: Ildar Kamalov <[email protected]>
Date: Tue Jan 28 15:52:29 2020 +0300
+ client: show filter name for blocked items in the query log </s> remove if (filterId === 0) {
filterName = t('custom_filter_rules');
} else {
const filterItem = Object.keys(filters).filter(key => filters[key].id === filterId)[0];
</s> add if (isBlockedCnameIp) {
const normalizedAnswer = this.normalizeResponse(originalAnswer); </s> remove const isBlockedService = reason === FILTERED_STATUS.FILTERED_BLOCKED_SERVICE;
</s> add const isBlockedService = this.checkBlockedService(reason);
const isBlockedCnameIp = originalAnswer;
const filterKey = reason.replace(FILTERED_REASON, '');
const parsedFilteredReason = t('query_log_filtered', { filter: filterKey }); </s> remove const filterKey = reason.replace(FILTERED_REASON, '');
const parsedFilteredReason = t('query_log_filtered', { filter: filterKey });
</s> add const isBlackList = this.checkBlackList(reason); </s> remove if (typeof filterItem !== 'undefined' && typeof filters[filterItem] !== 'undefined') {
filterName = filters[filterItem].name;
}
if (!filterName) {
filterName = t('unknown_filter', { filterId });
}
</s> add return (
<div className="logs__row logs__row--column">
<div className="logs__text-wrap">
<span className="logs__text">
<Trans>blocked_by_response</Trans>
</span>
</div>
<div className="logs__list-wrap">
{this.renderResponseList(normalizedAnswer, status)}
</div>
</div>
); | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e9c21b0a7917d0b89fe25cbf8b5790029ea2ac6 | client/src/components/Logs/index.js |
if (isBlockedCnameIp) {
const normalizedAnswer = this.normalizeResponse(originalAnswer); | <mask> const serviceName = currentService && currentService.name;
<mask> const normalizedAnswer = originalAnswer && this.normalizeResponse(originalAnswer);
<mask> let filterName = '';
<mask>
<mask> if (filterId === 0) {
<mask> filterName = t('custom_filter_rules');
<mask> } else {
<mask> const filterItem = Object.keys(filters).filter(key => filters[key].id === filterId)[0];
<mask>
<mask> if (typeof filterItem !== 'undefined' && typeof filters[filterItem] !== 'undefined') {
<mask> filterName = filters[filterItem].name;
<mask> }
<mask>
</s> Merge: + client: show filter name for blocked items in the query log
Closes #993
Squashed commit of the following:
commit 4c5e17226c6efa8a7847a8c565c491a7bae2db59
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:21:40 2020 +0300
- client: use constant
commit 818c07d1cfb210965a6413dc8370fc8867979c7b
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:18:31 2020 +0300
- client: fix filter find
commit 1f9132151c843dacbf26f814faeeea3cfdff9b73
Author: Ildar Kamalov <[email protected]>
Date: Tue Jan 28 15:52:29 2020 +0300
+ client: show filter name for blocked items in the query log </s> remove if (typeof filterItem !== 'undefined' && typeof filters[filterItem] !== 'undefined') {
filterName = filters[filterItem].name;
}
if (!filterName) {
filterName = t('unknown_filter', { filterId });
}
</s> add return (
<div className="logs__row logs__row--column">
<div className="logs__text-wrap">
<span className="logs__text">
<Trans>blocked_by_response</Trans>
</span>
</div>
<div className="logs__list-wrap">
{this.renderResponseList(normalizedAnswer, status)}
</div>
</div>
); </s> remove const normalizedAnswer = originalAnswer && this.normalizeResponse(originalAnswer);
let filterName = '';
</s> add const filterName = this.getFilterName(filters, filterId, t); </s> remove const isBlockedService = reason === FILTERED_STATUS.FILTERED_BLOCKED_SERVICE;
</s> add const isBlockedService = this.checkBlockedService(reason);
const isBlockedCnameIp = originalAnswer;
const filterKey = reason.replace(FILTERED_REASON, '');
const parsedFilteredReason = t('query_log_filtered', { filter: filterKey }); </s> remove const filterKey = reason.replace(FILTERED_REASON, '');
const parsedFilteredReason = t('query_log_filtered', { filter: filterKey });
</s> add const isBlackList = this.checkBlackList(reason); | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e9c21b0a7917d0b89fe25cbf8b5790029ea2ac6 | client/src/components/Logs/index.js |
return (
<div className="logs__row logs__row--column">
<div className="logs__text-wrap">
<span className="logs__text">
<Trans>blocked_by_response</Trans>
</span>
</div>
<div className="logs__list-wrap">
{this.renderResponseList(normalizedAnswer, status)}
</div>
</div>
); | <mask> filterName = t('custom_filter_rules');
<mask> } else {
<mask> const filterItem = Object.keys(filters).filter(key => filters[key].id === filterId)[0];
<mask>
<mask> if (typeof filterItem !== 'undefined' && typeof filters[filterItem] !== 'undefined') {
<mask> filterName = filters[filterItem].name;
<mask> }
<mask>
<mask> if (!filterName) {
<mask> filterName = t('unknown_filter', { filterId });
<mask> }
<mask> }
<mask>
<mask> return (
<mask> <div className="logs__row logs__row--column">
<mask> <div className="logs__text-wrap">
</s> Merge: + client: show filter name for blocked items in the query log
Closes #993
Squashed commit of the following:
commit 4c5e17226c6efa8a7847a8c565c491a7bae2db59
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:21:40 2020 +0300
- client: use constant
commit 818c07d1cfb210965a6413dc8370fc8867979c7b
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:18:31 2020 +0300
- client: fix filter find
commit 1f9132151c843dacbf26f814faeeea3cfdff9b73
Author: Ildar Kamalov <[email protected]>
Date: Tue Jan 28 15:52:29 2020 +0300
+ client: show filter name for blocked items in the query log </s> remove if (filterId === 0) {
filterName = t('custom_filter_rules');
} else {
const filterItem = Object.keys(filters).filter(key => filters[key].id === filterId)[0];
</s> add if (isBlockedCnameIp) {
const normalizedAnswer = this.normalizeResponse(originalAnswer); </s> remove const normalizedAnswer = originalAnswer && this.normalizeResponse(originalAnswer);
let filterName = '';
</s> add const filterName = this.getFilterName(filters, filterId, t); </s> remove {originalAnswer && (
<span className="logs__text">
<Trans>blocked_by_response</Trans>
</span>
)}
{!originalAnswer && (isFiltered || isBlockedService) && (
</s> add {(isFiltered || isBlockedService) && !isBlackList && ( </s> remove const filterKey = reason.replace(FILTERED_REASON, '');
const parsedFilteredReason = t('query_log_filtered', { filter: filterKey });
</s> add const isBlackList = this.checkBlackList(reason); </s> remove const isBlockedService = reason === FILTERED_STATUS.FILTERED_BLOCKED_SERVICE;
</s> add const isBlockedService = this.checkBlockedService(reason);
const isBlockedCnameIp = originalAnswer;
const filterKey = reason.replace(FILTERED_REASON, '');
const parsedFilteredReason = t('query_log_filtered', { filter: filterKey }); | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e9c21b0a7917d0b89fe25cbf8b5790029ea2ac6 | client/src/components/Logs/index.js |
{(isFiltered || isBlockedService) && !isBlackList && ( | <mask>
<mask> return (
<mask> <div className="logs__row logs__row--column">
<mask> <div className="logs__text-wrap">
<mask> {originalAnswer && (
<mask> <span className="logs__text">
<mask> <Trans>blocked_by_response</Trans>
<mask> </span>
<mask> )}
<mask> {!originalAnswer && (isFiltered || isBlockedService) && (
<mask> <span className="logs__text" title={parsedFilteredReason}>
<mask> {parsedFilteredReason}
<mask> </span>
<mask> )}
<mask> {isBlockedService
</s> Merge: + client: show filter name for blocked items in the query log
Closes #993
Squashed commit of the following:
commit 4c5e17226c6efa8a7847a8c565c491a7bae2db59
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:21:40 2020 +0300
- client: use constant
commit 818c07d1cfb210965a6413dc8370fc8867979c7b
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:18:31 2020 +0300
- client: fix filter find
commit 1f9132151c843dacbf26f814faeeea3cfdff9b73
Author: Ildar Kamalov <[email protected]>
Date: Tue Jan 28 15:52:29 2020 +0300
+ client: show filter name for blocked items in the query log </s> remove if (typeof filterItem !== 'undefined' && typeof filters[filterItem] !== 'undefined') {
filterName = filters[filterItem].name;
}
if (!filterName) {
filterName = t('unknown_filter', { filterId });
}
</s> add return (
<div className="logs__row logs__row--column">
<div className="logs__text-wrap">
<span className="logs__text">
<Trans>blocked_by_response</Trans>
</span>
</div>
<div className="logs__list-wrap">
{this.renderResponseList(normalizedAnswer, status)}
</div>
</div>
); </s> remove {originalAnswer
? this.renderResponseList(normalizedAnswer, status)
: this.renderResponseList(responses, status)
}
</s> add {this.renderResponseList(responses, status)} </s> remove if (filterId === 0) {
filterName = t('custom_filter_rules');
} else {
const filterItem = Object.keys(filters).filter(key => filters[key].id === filterId)[0];
</s> add if (isBlockedCnameIp) {
const normalizedAnswer = this.normalizeResponse(originalAnswer); </s> remove const normalizedAnswer = originalAnswer && this.normalizeResponse(originalAnswer);
let filterName = '';
</s> add const filterName = this.getFilterName(filters, filterId, t); | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e9c21b0a7917d0b89fe25cbf8b5790029ea2ac6 | client/src/components/Logs/index.js |
{isBlackList && (
<span className="logs__text">
<Trans values={{ filter: filterName }}>
query_log_filtered
</Trans>
</span>
)} | <mask> <span className="logs__text" title={parsedFilteredReason}>
<mask> {parsedFilteredReason}
<mask> </span>
<mask> )}
<mask> {isBlockedService
<mask> ? this.renderTooltip(isFiltered, '', '', serviceName)
<mask> : this.renderTooltip(isFiltered, rule, filterName)}
<mask> {isRewrite && (
<mask> <strong>
<mask> <Trans>rewrite_applied</Trans>
</s> Merge: + client: show filter name for blocked items in the query log
Closes #993
Squashed commit of the following:
commit 4c5e17226c6efa8a7847a8c565c491a7bae2db59
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:21:40 2020 +0300
- client: use constant
commit 818c07d1cfb210965a6413dc8370fc8867979c7b
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:18:31 2020 +0300
- client: fix filter find
commit 1f9132151c843dacbf26f814faeeea3cfdff9b73
Author: Ildar Kamalov <[email protected]>
Date: Tue Jan 28 15:52:29 2020 +0300
+ client: show filter name for blocked items in the query log </s> remove {originalAnswer && (
<span className="logs__text">
<Trans>blocked_by_response</Trans>
</span>
)}
{!originalAnswer && (isFiltered || isBlockedService) && (
</s> add {(isFiltered || isBlockedService) && !isBlackList && ( </s> remove {originalAnswer
? this.renderResponseList(normalizedAnswer, status)
: this.renderResponseList(responses, status)
}
</s> add {this.renderResponseList(responses, status)} </s> remove if (typeof filterItem !== 'undefined' && typeof filters[filterItem] !== 'undefined') {
filterName = filters[filterItem].name;
}
if (!filterName) {
filterName = t('unknown_filter', { filterId });
}
</s> add return (
<div className="logs__row logs__row--column">
<div className="logs__text-wrap">
<span className="logs__text">
<Trans>blocked_by_response</Trans>
</span>
</div>
<div className="logs__list-wrap">
{this.renderResponseList(normalizedAnswer, status)}
</div>
</div>
); </s> remove if (filterId === 0) {
filterName = t('custom_filter_rules');
} else {
const filterItem = Object.keys(filters).filter(key => filters[key].id === filterId)[0];
</s> add if (isBlockedCnameIp) {
const normalizedAnswer = this.normalizeResponse(originalAnswer); | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e9c21b0a7917d0b89fe25cbf8b5790029ea2ac6 | client/src/components/Logs/index.js |
{this.renderResponseList(responses, status)} | <mask> </strong>
<mask> )}
<mask> </div>
<mask> <div className="logs__list-wrap">
<mask> {originalAnswer
<mask> ? this.renderResponseList(normalizedAnswer, status)
<mask> : this.renderResponseList(responses, status)
<mask> }
<mask> {isWhiteList && this.renderTooltip(isWhiteList, rule, filterName)}
<mask> </div>
<mask> </div>
<mask> );
<mask> };
</s> Merge: + client: show filter name for blocked items in the query log
Closes #993
Squashed commit of the following:
commit 4c5e17226c6efa8a7847a8c565c491a7bae2db59
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:21:40 2020 +0300
- client: use constant
commit 818c07d1cfb210965a6413dc8370fc8867979c7b
Author: Ildar Kamalov <[email protected]>
Date: Wed Jan 29 12:18:31 2020 +0300
- client: fix filter find
commit 1f9132151c843dacbf26f814faeeea3cfdff9b73
Author: Ildar Kamalov <[email protected]>
Date: Tue Jan 28 15:52:29 2020 +0300
+ client: show filter name for blocked items in the query log </s> remove if (typeof filterItem !== 'undefined' && typeof filters[filterItem] !== 'undefined') {
filterName = filters[filterItem].name;
}
if (!filterName) {
filterName = t('unknown_filter', { filterId });
}
</s> add return (
<div className="logs__row logs__row--column">
<div className="logs__text-wrap">
<span className="logs__text">
<Trans>blocked_by_response</Trans>
</span>
</div>
<div className="logs__list-wrap">
{this.renderResponseList(normalizedAnswer, status)}
</div>
</div>
); </s> remove {originalAnswer && (
<span className="logs__text">
<Trans>blocked_by_response</Trans>
</span>
)}
{!originalAnswer && (isFiltered || isBlockedService) && (
</s> add {(isFiltered || isBlockedService) && !isBlackList && ( </s> remove if (filterId === 0) {
filterName = t('custom_filter_rules');
} else {
const filterItem = Object.keys(filters).filter(key => filters[key].id === filterId)[0];
</s> add if (isBlockedCnameIp) {
const normalizedAnswer = this.normalizeResponse(originalAnswer); | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e9c21b0a7917d0b89fe25cbf8b5790029ea2ac6 | client/src/components/Logs/index.js |
if args.checkConfig {
log.Info("Configuration file is OK")
os.Exit(0)
} | <mask> os.Exit(1)
<mask> }
<mask> }
<mask>
<mask> if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") &&
<mask> config.RlimitNoFile != 0 {
<mask> setRlimit(config.RlimitNoFile)
</s> + app: add --check-config command-line argument | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5fd35254a8f60cd311d8239cbc3f94122b252275 | app.go |
checkConfig bool // Check configuration and exit | <mask> logFile string // Path to the log file. If empty, write to stdout. If "syslog", writes to syslog
<mask> pidFile string // File name to save PID to
<mask>
<mask> // service control action (see service.ControlAction array + "status" command)
<mask> serviceControlAction string
<mask>
</s> + app: add --check-config command-line argument | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5fd35254a8f60cd311d8239cbc3f94122b252275 | app.go |
{"check-config", "", "Check configuration and exit", nil, func() { o.checkConfig = true }}, | <mask> {"logfile", "l", "path to the log file. If empty, writes to stdout, if 'syslog' -- system log", func(value string) {
<mask> o.logFile = value
<mask> }, nil},
<mask> {"pidfile", "", "File name to save PID to", func(value string) { o.pidFile = value }, nil},
<mask> {"verbose", "v", "enable verbose output", nil, func() { o.verbose = true }},
<mask> {"help", "", "print this help", nil, func() {
<mask> printHelp()
<mask> os.Exit(64)
<mask> }},
<mask> }
</s> + app: add --check-config command-line argument | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5fd35254a8f60cd311d8239cbc3f94122b252275 | app.go |
<mask>
<mask> VOLUME /data
<mask>
<mask> ENTRYPOINT ["/AdGuardHome"]
<mask> CMD ["-o", "0.0.0.0"] </s> We'd better keep -h for host </s> remove CMD ["-o", "0.0.0.0"] </s> add </s> remove if v == "--"+opt.longName || v == "-"+opt.shortName {
</s> add if v == "--"+opt.longName || (opt.shortName != "" && v == "-"+opt.shortName) { </s> remove fmt.Printf(" -%s, %-30s %s\n", opt.shortName, "--"+opt.longName, opt.description)
</s> add if opt.shortName != "" {
fmt.Printf(" -%s, %-30s %s\n", opt.shortName, "--"+opt.longName, opt.description)
} else {
fmt.Printf(" %-34s %s\n", "--"+opt.longName, opt.description)
} </s> remove {"help", "h", "print this help", nil, func() {
</s> add {"help", "", "print this help", nil, func() { | [
"keep",
"keep",
"keep",
"keep",
"replace"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5fed5c07184f12ec50bf26c95290de0fa697c1bc | Dockerfile |
|
CMD ["-h", "0.0.0.0"] | <mask> VOLUME /data
<mask>
<mask> ENTRYPOINT ["/AdGuardHome"]
<mask> CMD ["-h", "0.0.0.0"] </s> We'd better keep -h for host </s> remove CMD ["-o", "0.0.0.0"] </s> add </s> remove CMD ["-o", "0.0.0.0"] </s> add </s> remove if v == "--"+opt.longName || v == "-"+opt.shortName {
</s> add if v == "--"+opt.longName || (opt.shortName != "" && v == "-"+opt.shortName) { </s> remove fmt.Printf(" -%s, %-30s %s\n", opt.shortName, "--"+opt.longName, opt.description)
</s> add if opt.shortName != "" {
fmt.Printf(" -%s, %-30s %s\n", opt.shortName, "--"+opt.longName, opt.description)
} else {
fmt.Printf(" %-34s %s\n", "--"+opt.longName, opt.description)
} </s> remove {"help", "h", "print this help", nil, func() {
</s> add {"help", "", "print this help", nil, func() { | [
"keep",
"keep",
"keep",
"add"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5fed5c07184f12ec50bf26c95290de0fa697c1bc | Dockerfile |
<mask>
<mask> VOLUME /data
<mask>
<mask> ENTRYPOINT ["/AdGuardHome"]
<mask> CMD ["-o", "0.0.0.0"] </s> We'd better keep -h for host | [
"keep",
"keep",
"keep",
"keep",
"replace"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5fed5c07184f12ec50bf26c95290de0fa697c1bc | Dockerfile.travis |
|
{"host", "h", "host address to bind HTTP server on", func(value string) { o.bindHost = value }, nil}, | <mask> callbackWithValue func(value string)
<mask> callbackNoValue func()
<mask> }{
<mask> {"config", "c", "path to config file", func(value string) { o.configFilename = value }, nil},
<mask> {"host", "o", "host address to bind HTTP server on", func(value string) { o.bindHost = value }, nil},
<mask> {"port", "p", "port to serve HTTP pages on", func(value string) {
<mask> v, err := strconv.Atoi(value)
<mask> if err != nil {
<mask> panic("Got port that is not a number")
<mask> }
</s> We'd better keep -h for host </s> remove {"help", "h", "print this help", nil, func() {
</s> add {"help", "", "print this help", nil, func() { </s> remove if v == "--"+opt.longName || v == "-"+opt.shortName {
</s> add if v == "--"+opt.longName || (opt.shortName != "" && v == "-"+opt.shortName) { </s> remove fmt.Printf(" -%s, %-30s %s\n", opt.shortName, "--"+opt.longName, opt.description)
</s> add if opt.shortName != "" {
fmt.Printf(" -%s, %-30s %s\n", opt.shortName, "--"+opt.longName, opt.description)
} else {
fmt.Printf(" %-34s %s\n", "--"+opt.longName, opt.description)
} </s> remove CMD ["-o", "0.0.0.0"] </s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5fed5c07184f12ec50bf26c95290de0fa697c1bc | app.go |
{"help", "", "print this help", nil, func() { | <mask> {"logfile", "l", "path to the log file. If empty, writes to stdout, if 'syslog' -- system log", func(value string) {
<mask> o.logFile = value
<mask> }, nil},
<mask> {"verbose", "v", "enable verbose output", nil, func() { o.verbose = true }},
<mask> {"help", "h", "print this help", nil, func() {
<mask> printHelp()
<mask> os.Exit(64)
<mask> }},
<mask> }
<mask> printHelp = func() {
</s> We'd better keep -h for host </s> remove {"host", "o", "host address to bind HTTP server on", func(value string) { o.bindHost = value }, nil},
</s> add {"host", "h", "host address to bind HTTP server on", func(value string) { o.bindHost = value }, nil}, </s> remove if v == "--"+opt.longName || v == "-"+opt.shortName {
</s> add if v == "--"+opt.longName || (opt.shortName != "" && v == "-"+opt.shortName) { </s> remove fmt.Printf(" -%s, %-30s %s\n", opt.shortName, "--"+opt.longName, opt.description)
</s> add if opt.shortName != "" {
fmt.Printf(" -%s, %-30s %s\n", opt.shortName, "--"+opt.longName, opt.description)
} else {
fmt.Printf(" %-34s %s\n", "--"+opt.longName, opt.description)
} </s> remove CMD ["-o", "0.0.0.0"] </s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5fed5c07184f12ec50bf26c95290de0fa697c1bc | app.go |
if opt.shortName != "" {
fmt.Printf(" -%s, %-30s %s\n", opt.shortName, "--"+opt.longName, opt.description)
} else {
fmt.Printf(" %-34s %s\n", "--"+opt.longName, opt.description)
} | <mask> fmt.Printf("Usage:\n\n")
<mask> fmt.Printf("%s [options]\n\n", os.Args[0])
<mask> fmt.Printf("Options:\n")
<mask> for _, opt := range opts {
<mask> fmt.Printf(" -%s, %-30s %s\n", opt.shortName, "--"+opt.longName, opt.description)
<mask> }
<mask> }
<mask> for i := 1; i < len(os.Args); i++ {
<mask> v := os.Args[i]
<mask> knownParam := false
</s> We'd better keep -h for host </s> remove if v == "--"+opt.longName || v == "-"+opt.shortName {
</s> add if v == "--"+opt.longName || (opt.shortName != "" && v == "-"+opt.shortName) { </s> remove {"host", "o", "host address to bind HTTP server on", func(value string) { o.bindHost = value }, nil},
</s> add {"host", "h", "host address to bind HTTP server on", func(value string) { o.bindHost = value }, nil}, </s> remove {"help", "h", "print this help", nil, func() {
</s> add {"help", "", "print this help", nil, func() { </s> remove CMD ["-o", "0.0.0.0"] </s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5fed5c07184f12ec50bf26c95290de0fa697c1bc | app.go |
if v == "--"+opt.longName || (opt.shortName != "" && v == "-"+opt.shortName) { | <mask> for i := 1; i < len(os.Args); i++ {
<mask> v := os.Args[i]
<mask> knownParam := false
<mask> for _, opt := range opts {
<mask> if v == "--"+opt.longName || v == "-"+opt.shortName {
<mask> if opt.callbackWithValue != nil {
<mask> if i+1 >= len(os.Args) {
<mask> log.Printf("ERROR: Got %s without argument\n", v)
<mask> os.Exit(64)
<mask> }
</s> We'd better keep -h for host </s> remove fmt.Printf(" -%s, %-30s %s\n", opt.shortName, "--"+opt.longName, opt.description)
</s> add if opt.shortName != "" {
fmt.Printf(" -%s, %-30s %s\n", opt.shortName, "--"+opt.longName, opt.description)
} else {
fmt.Printf(" %-34s %s\n", "--"+opt.longName, opt.description)
} </s> remove {"host", "o", "host address to bind HTTP server on", func(value string) { o.bindHost = value }, nil},
</s> add {"host", "h", "host address to bind HTTP server on", func(value string) { o.bindHost = value }, nil}, </s> remove {"help", "h", "print this help", nil, func() {
</s> add {"help", "", "print this help", nil, func() { </s> remove CMD ["-o", "0.0.0.0"] </s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5fed5c07184f12ec50bf26c95290de0fa697c1bc | app.go |
"url_added_successfully": "Url added successfully", | <mask> "unblock_btn": "Unblock",
<mask> "block_btn": "Block",
<mask> "time_table_header": "Time",
<mask> "domain_name_table_header": "Domain name",
<mask> "type_table_header": "Type",
<mask> "response_table_header": "Response",
<mask> "client_table_header": "Client",
</s> Fix missing translate key when added new filter url </s> remove <Trans>Url added successfully</Trans>
</s> add <Trans>url_added_successfully</Trans> </s> remove "filter_label": "B\u1ed9 l\u1ecdc"
</s> add "filter_label": "B\u1ed9 l\u1ecdc",
"url_added_successfully": "Th\u00eam b\u1ed9 l\u1ecdc th\u00e0nh c\u00f4ng" | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/607089cd2531e7b30f87663d4fb438d49350c1c7 | client/src/__locales/en.json |
"filter_label": "B\u1ed9 l\u1ecdc",
"url_added_successfully": "Th\u00eam b\u1ed9 l\u1ecdc th\u00e0nh c\u00f4ng" | <mask> "source_label": "Ngu\u1ed3n",
<mask> "found_in_known_domain_db": "T\u00ecm th\u1ea5y trong c\u01a1 s\u1edf d\u1eef li\u1ec7u t\u00ean mi\u1ec1n",
<mask> "category_label": "Th\u1ec3 lo\u1ea1i",
<mask> "rule_label": "Quy t\u1eafc",
<mask> "filter_label": "B\u1ed9 l\u1ecdc"
<mask> } </s> Fix missing translate key when added new filter url </s> remove <Trans>Url added successfully</Trans>
</s> add <Trans>url_added_successfully</Trans> | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/607089cd2531e7b30f87663d4fb438d49350c1c7 | client/src/__locales/vi.json |
<Trans>url_added_successfully</Trans> | <mask> );
<mask> }
<mask> return (
<mask> <div className="description">
<mask> <Trans>Url added successfully</Trans>
<mask> </div>
<mask> );
<mask> };
<mask>
<mask> const isValidForSubmit = !(url.length > 0 && isUrlValid && name.length > 0);
</s> Fix missing translate key when added new filter url </s> remove "filter_label": "B\u1ed9 l\u1ecdc"
</s> add "filter_label": "B\u1ed9 l\u1ecdc",
"url_added_successfully": "Th\u00eam b\u1ed9 l\u1ecdc th\u00e0nh c\u00f4ng" | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/607089cd2531e7b30f87663d4fb438d49350c1c7 | client/src/components/ui/Modal.js |
log.Info("DHCP: listening on 0.0.0.0:67") | <mask> return wrapErrPrint(err, "Couldn't start listening socket on 0.0.0.0:67")
<mask> }
<mask>
<mask> s.conn = c
<mask>
<mask> go func() {
<mask> // operate on c instead of c.conn because c.conn can change over time
<mask> err := dhcp4.Serve(c, s)
</s> * dhcp: refactor; log client's HW addr </s> remove // find a lease, but don't update lease time
log.Tracef("Got from client: Discover")
lease, err := s.reserveLease(p)
if err != nil {
log.Tracef("Couldn't find free lease: %s", err)
// couldn't find lease, don't respond
return nil
}
reply := dhcp4.ReplyPacket(p, dhcp4.Offer, s.ipnet.IP, lease.IP, s.leaseTime, s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList]))
log.Tracef("Replying with offer: offered IP %v for %v with options %+v", lease.IP, s.leaseTime, reply.ParseOptions())
return reply
</s> add return s.handleDiscover(p, options)
</s> remove // Leases returns the list of current DHCP leases
</s> add // Leases returns the list of current DHCP leases (thread-safe) </s> remove foundHWaddr := s.getIPpool(newIP)
</s> add foundHWaddr := s.findReservedHWaddr(newIP) </s> remove return dhcp4.ReplyPacket(p, dhcp4.ACK, s.ipnet.IP, lease.IP, s.leaseTime, s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList]))
</s> add opt := s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList])
return dhcp4.ReplyPacket(p, dhcp4.ACK, s.ipnet.IP, lease.IP, s.leaseTime, opt) | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/60fa3b2e95e5fc111884f13c8bfa465f030a0b40 | dhcpd/dhcpd.go |
foundHWaddr := s.findReservedHWaddr(newIP) | <mask> // go from start to end, find unreserved IP
<mask> var foundIP net.IP
<mask> for i := 0; i < dhcp4.IPRange(s.leaseStart, s.leaseStop); i++ {
<mask> newIP := dhcp4.IPAdd(s.leaseStart, i)
<mask> foundHWaddr := s.getIPpool(newIP)
<mask> log.Tracef("tried IP %v, got hwaddr %v", newIP, foundHWaddr)
<mask> if foundHWaddr != nil && len(foundHWaddr) != 0 {
<mask> // if !bytes.Equal(foundHWaddr, hwaddr) {
<mask> // log.Tracef("SHOULD NOT HAPPEN: hwaddr in IP pool %s is not equal to hwaddr in lease %s", foundHWaddr, hwaddr)
<mask> // }
</s> * dhcp: refactor; log client's HW addr </s> remove hwaddr := s.getIPpool(reqIP)
</s> add hwaddr := s.findReservedHWaddr(reqIP) </s> remove log.Tracef("IP pool:")
for ip, hwaddr := range s.IPpool {
log.Tracef("IP pool entry %s -> %s", net.IPv4(ip[0], ip[1], ip[2], ip[3]), hwaddr)
}
</s> add </s> remove log.Tracef("Got from client: Request")
if server, ok := options[dhcp4.OptionServerIdentifier]; ok && !net.IP(server).Equal(s.ipnet.IP) {
</s> add server := options[dhcp4.OptionServerIdentifier]
if server != nil && !net.IP(server).Equal(s.ipnet.IP) { </s> remove return dhcp4.ReplyPacket(p, dhcp4.ACK, s.ipnet.IP, lease.IP, s.leaseTime, s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList]))
</s> add opt := s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList])
return dhcp4.ReplyPacket(p, dhcp4.ACK, s.ipnet.IP, lease.IP, s.leaseTime, opt) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/60fa3b2e95e5fc111884f13c8bfa465f030a0b40 | dhcpd/dhcpd.go |
func (s *Server) findReservedHWaddr(ip net.IP) net.HardwareAddr { | <mask>
<mask> return foundIP, nil
<mask> }
<mask>
<mask> func (s *Server) getIPpool(ip net.IP) net.HardwareAddr {
<mask> rawIP := []byte(ip)
<mask> IP4 := [4]byte{rawIP[0], rawIP[1], rawIP[2], rawIP[3]}
<mask> return s.IPpool[IP4]
<mask> }
<mask>
</s> * dhcp: refactor; log client's HW addr </s> remove log.Tracef("Got from client: Request")
if server, ok := options[dhcp4.OptionServerIdentifier]; ok && !net.IP(server).Equal(s.ipnet.IP) {
</s> add server := options[dhcp4.OptionServerIdentifier]
if server != nil && !net.IP(server).Equal(s.ipnet.IP) { </s> remove // Leases returns the list of current DHCP leases
</s> add // Leases returns the list of current DHCP leases (thread-safe) </s> remove log.Tracef("Got %v message", msgType)
</s> add log.Tracef("Message from client %s: %d", p.CHAddr(), msgType)
</s> remove // find a lease, but don't update lease time
log.Tracef("Got from client: Discover")
lease, err := s.reserveLease(p)
if err != nil {
log.Tracef("Couldn't find free lease: %s", err)
// couldn't find lease, don't respond
return nil
}
reply := dhcp4.ReplyPacket(p, dhcp4.Offer, s.ipnet.IP, lease.IP, s.leaseTime, s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList]))
log.Tracef("Replying with offer: offered IP %v for %v with options %+v", lease.IP, s.leaseTime, reply.ParseOptions())
return reply
</s> add return s.handleDiscover(p, options)
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/60fa3b2e95e5fc111884f13c8bfa465f030a0b40 | dhcpd/dhcpd.go |
log.Tracef("Message from client %s: %d", p.CHAddr(), msgType)
| <mask> }
<mask>
<mask> // ServeDHCP handles an incoming DHCP request
<mask> func (s *Server) ServeDHCP(p dhcp4.Packet, msgType dhcp4.MessageType, options dhcp4.Options) dhcp4.Packet {
<mask> log.Tracef("Got %v message", msgType)
<mask> log.Tracef("Leases:")
<mask> for i, lease := range s.leases {
<mask> log.Tracef("Lease #%d: hwaddr %s, ip %s, expiry %s", i, lease.HWAddr, lease.IP, lease.Expiry)
<mask> }
<mask> log.Tracef("IP pool:")
</s> * dhcp: refactor; log client's HW addr </s> remove log.Tracef("IP pool:")
for ip, hwaddr := range s.IPpool {
log.Tracef("IP pool entry %s -> %s", net.IPv4(ip[0], ip[1], ip[2], ip[3]), hwaddr)
}
</s> add </s> remove log.Tracef("Got from client: Request")
if server, ok := options[dhcp4.OptionServerIdentifier]; ok && !net.IP(server).Equal(s.ipnet.IP) {
</s> add server := options[dhcp4.OptionServerIdentifier]
if server != nil && !net.IP(server).Equal(s.ipnet.IP) { </s> remove // Leases returns the list of current DHCP leases
</s> add // Leases returns the list of current DHCP leases (thread-safe) </s> remove hwaddr := s.getIPpool(reqIP)
</s> add hwaddr := s.findReservedHWaddr(reqIP) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/60fa3b2e95e5fc111884f13c8bfa465f030a0b40 | dhcpd/dhcpd.go |
<mask> log.Tracef("Leases:")
<mask> for i, lease := range s.leases {
<mask> log.Tracef("Lease #%d: hwaddr %s, ip %s, expiry %s", i, lease.HWAddr, lease.IP, lease.Expiry)
<mask> }
<mask> log.Tracef("IP pool:")
<mask> for ip, hwaddr := range s.IPpool {
<mask> log.Tracef("IP pool entry %s -> %s", net.IPv4(ip[0], ip[1], ip[2], ip[3]), hwaddr)
<mask> }
<mask>
<mask> switch msgType {
<mask> case dhcp4.Discover: // Broadcast Packet From Client - Can I have an IP?
<mask> // find a lease, but don't update lease time
<mask> log.Tracef("Got from client: Discover")
</s> * dhcp: refactor; log client's HW addr </s> remove log.Tracef("Got %v message", msgType)
</s> add log.Tracef("Message from client %s: %d", p.CHAddr(), msgType)
</s> remove // find a lease, but don't update lease time
log.Tracef("Got from client: Discover")
lease, err := s.reserveLease(p)
if err != nil {
log.Tracef("Couldn't find free lease: %s", err)
// couldn't find lease, don't respond
return nil
}
reply := dhcp4.ReplyPacket(p, dhcp4.Offer, s.ipnet.IP, lease.IP, s.leaseTime, s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList]))
log.Tracef("Replying with offer: offered IP %v for %v with options %+v", lease.IP, s.leaseTime, reply.ParseOptions())
return reply
</s> add return s.handleDiscover(p, options)
</s> remove foundHWaddr := s.getIPpool(newIP)
</s> add foundHWaddr := s.findReservedHWaddr(newIP) </s> remove hwaddr := s.getIPpool(reqIP)
</s> add hwaddr := s.findReservedHWaddr(reqIP) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/60fa3b2e95e5fc111884f13c8bfa465f030a0b40 | dhcpd/dhcpd.go |
|
return s.handleDiscover(p, options)
| <mask> }
<mask>
<mask> switch msgType {
<mask> case dhcp4.Discover: // Broadcast Packet From Client - Can I have an IP?
<mask> // find a lease, but don't update lease time
<mask> log.Tracef("Got from client: Discover")
<mask> lease, err := s.reserveLease(p)
<mask> if err != nil {
<mask> log.Tracef("Couldn't find free lease: %s", err)
<mask> // couldn't find lease, don't respond
<mask> return nil
<mask> }
<mask> reply := dhcp4.ReplyPacket(p, dhcp4.Offer, s.ipnet.IP, lease.IP, s.leaseTime, s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList]))
<mask> log.Tracef("Replying with offer: offered IP %v for %v with options %+v", lease.IP, s.leaseTime, reply.ParseOptions())
<mask> return reply
<mask> case dhcp4.Request: // Broadcast From Client - I'll take that IP (Also start for renewals)
<mask> // start/renew a lease -- update lease time
<mask> // some clients (OSX) just go right ahead and do Request first from previously known IP, if they get NAK, they restart full cycle with Discover then Request
<mask> return s.handleDHCP4Request(p, options)
<mask> case dhcp4.Decline: // Broadcast From Client - Sorry I can't use that IP
</s> * dhcp: refactor; log client's HW addr </s> remove log.Tracef("IP pool:")
for ip, hwaddr := range s.IPpool {
log.Tracef("IP pool entry %s -> %s", net.IPv4(ip[0], ip[1], ip[2], ip[3]), hwaddr)
}
</s> add </s> remove return dhcp4.ReplyPacket(p, dhcp4.ACK, s.ipnet.IP, lease.IP, s.leaseTime, s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList]))
</s> add opt := s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList])
return dhcp4.ReplyPacket(p, dhcp4.ACK, s.ipnet.IP, lease.IP, s.leaseTime, opt) </s> remove // do nothing
</s> add </s> remove foundHWaddr := s.getIPpool(newIP)
</s> add foundHWaddr := s.findReservedHWaddr(newIP) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/60fa3b2e95e5fc111884f13c8bfa465f030a0b40 | dhcpd/dhcpd.go |
<mask> log.Tracef("Got from client: Release")
<mask>
<mask> case dhcp4.Inform: // From Client, I have this IP and there's nothing you can do about it
<mask> log.Tracef("Got from client: Inform")
<mask> // do nothing
<mask>
<mask> // from server -- ignore those but enumerate just in case
<mask> case dhcp4.Offer: // Broadcast From Server - Here's an IP
<mask> log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: Offer")
<mask> case dhcp4.ACK: // From Server, Yes you can have that IP
</s> * dhcp: refactor; log client's HW addr </s> remove log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: Offer")
</s> add log.Printf("DHCP: received message from another server: Offer")
</s> remove log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: ACK")
</s> add log.Printf("DHCP: received message from another server: ACK")
</s> remove log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: NAK")
</s> add log.Printf("DHCP: received message from another server: NAK")
</s> remove // find a lease, but don't update lease time
log.Tracef("Got from client: Discover")
lease, err := s.reserveLease(p)
if err != nil {
log.Tracef("Couldn't find free lease: %s", err)
// couldn't find lease, don't respond
return nil
}
reply := dhcp4.ReplyPacket(p, dhcp4.Offer, s.ipnet.IP, lease.IP, s.leaseTime, s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList]))
log.Tracef("Replying with offer: offered IP %v for %v with options %+v", lease.IP, s.leaseTime, reply.ParseOptions())
return reply
</s> add return s.handleDiscover(p, options)
</s> remove log.Printf("Unknown DHCP packet detected, ignoring: %v", msgType)
</s> add log.Printf("DHCP: unknown packet %v from client %s", msgType, p.CHAddr()) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/60fa3b2e95e5fc111884f13c8bfa465f030a0b40 | dhcpd/dhcpd.go |
|
log.Printf("DHCP: received message from another server: Offer")
| <mask> // do nothing
<mask>
<mask> // from server -- ignore those but enumerate just in case
<mask> case dhcp4.Offer: // Broadcast From Server - Here's an IP
<mask> log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: Offer")
<mask> case dhcp4.ACK: // From Server, Yes you can have that IP
<mask> log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: ACK")
<mask> case dhcp4.NAK: // From Server, No you cannot have that IP
<mask> log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: NAK")
<mask> default:
</s> * dhcp: refactor; log client's HW addr </s> remove log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: ACK")
</s> add log.Printf("DHCP: received message from another server: ACK")
</s> remove // do nothing
</s> add </s> remove log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: NAK")
</s> add log.Printf("DHCP: received message from another server: NAK")
</s> remove log.Printf("Unknown DHCP packet detected, ignoring: %v", msgType)
</s> add log.Printf("DHCP: unknown packet %v from client %s", msgType, p.CHAddr()) </s> remove // find a lease, but don't update lease time
log.Tracef("Got from client: Discover")
lease, err := s.reserveLease(p)
if err != nil {
log.Tracef("Couldn't find free lease: %s", err)
// couldn't find lease, don't respond
return nil
}
reply := dhcp4.ReplyPacket(p, dhcp4.Offer, s.ipnet.IP, lease.IP, s.leaseTime, s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList]))
log.Tracef("Replying with offer: offered IP %v for %v with options %+v", lease.IP, s.leaseTime, reply.ParseOptions())
return reply
</s> add return s.handleDiscover(p, options)
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/60fa3b2e95e5fc111884f13c8bfa465f030a0b40 | dhcpd/dhcpd.go |
log.Printf("DHCP: received message from another server: ACK")
| <mask> // from server -- ignore those but enumerate just in case
<mask> case dhcp4.Offer: // Broadcast From Server - Here's an IP
<mask> log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: Offer")
<mask> case dhcp4.ACK: // From Server, Yes you can have that IP
<mask> log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: ACK")
<mask> case dhcp4.NAK: // From Server, No you cannot have that IP
<mask> log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: NAK")
<mask> default:
<mask> log.Printf("Unknown DHCP packet detected, ignoring: %v", msgType)
<mask> return nil
</s> * dhcp: refactor; log client's HW addr </s> remove log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: Offer")
</s> add log.Printf("DHCP: received message from another server: Offer")
</s> remove log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: NAK")
</s> add log.Printf("DHCP: received message from another server: NAK")
</s> remove log.Printf("Unknown DHCP packet detected, ignoring: %v", msgType)
</s> add log.Printf("DHCP: unknown packet %v from client %s", msgType, p.CHAddr()) </s> remove // do nothing
</s> add </s> remove // find a lease, but don't update lease time
log.Tracef("Got from client: Discover")
lease, err := s.reserveLease(p)
if err != nil {
log.Tracef("Couldn't find free lease: %s", err)
// couldn't find lease, don't respond
return nil
}
reply := dhcp4.ReplyPacket(p, dhcp4.Offer, s.ipnet.IP, lease.IP, s.leaseTime, s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList]))
log.Tracef("Replying with offer: offered IP %v for %v with options %+v", lease.IP, s.leaseTime, reply.ParseOptions())
return reply
</s> add return s.handleDiscover(p, options)
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/60fa3b2e95e5fc111884f13c8bfa465f030a0b40 | dhcpd/dhcpd.go |
log.Printf("DHCP: received message from another server: NAK")
| <mask> log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: Offer")
<mask> case dhcp4.ACK: // From Server, Yes you can have that IP
<mask> log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: ACK")
<mask> case dhcp4.NAK: // From Server, No you cannot have that IP
<mask> log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: NAK")
<mask> default:
<mask> log.Printf("Unknown DHCP packet detected, ignoring: %v", msgType)
<mask> return nil
<mask> }
<mask> return nil
</s> * dhcp: refactor; log client's HW addr </s> remove log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: ACK")
</s> add log.Printf("DHCP: received message from another server: ACK")
</s> remove log.Printf("Unknown DHCP packet detected, ignoring: %v", msgType)
</s> add log.Printf("DHCP: unknown packet %v from client %s", msgType, p.CHAddr()) </s> remove log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: Offer")
</s> add log.Printf("DHCP: received message from another server: Offer")
</s> remove // do nothing
</s> add </s> remove // find a lease, but don't update lease time
log.Tracef("Got from client: Discover")
lease, err := s.reserveLease(p)
if err != nil {
log.Tracef("Couldn't find free lease: %s", err)
// couldn't find lease, don't respond
return nil
}
reply := dhcp4.ReplyPacket(p, dhcp4.Offer, s.ipnet.IP, lease.IP, s.leaseTime, s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList]))
log.Tracef("Replying with offer: offered IP %v for %v with options %+v", lease.IP, s.leaseTime, reply.ParseOptions())
return reply
</s> add return s.handleDiscover(p, options)
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/60fa3b2e95e5fc111884f13c8bfa465f030a0b40 | dhcpd/dhcpd.go |
log.Printf("DHCP: unknown packet %v from client %s", msgType, p.CHAddr()) | <mask> log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: ACK")
<mask> case dhcp4.NAK: // From Server, No you cannot have that IP
<mask> log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: NAK")
<mask> default:
<mask> log.Printf("Unknown DHCP packet detected, ignoring: %v", msgType)
<mask> return nil
<mask> }
<mask> return nil
<mask> }
<mask>
</s> * dhcp: refactor; log client's HW addr </s> remove log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: NAK")
</s> add log.Printf("DHCP: received message from another server: NAK")
</s> remove log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: ACK")
</s> add log.Printf("DHCP: received message from another server: ACK")
</s> remove log.Printf("SHOULD NOT HAPPEN -- FROM ANOTHER DHCP SERVER: Offer")
</s> add log.Printf("DHCP: received message from another server: Offer")
</s> remove // do nothing
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/60fa3b2e95e5fc111884f13c8bfa465f030a0b40 | dhcpd/dhcpd.go |
func (s *Server) handleDiscover(p dhcp4.Packet, options dhcp4.Options) dhcp4.Packet {
// find a lease, but don't update lease time
lease, err := s.reserveLease(p)
if err != nil {
log.Tracef("Couldn't find free lease: %s", err)
// couldn't find lease, don't respond
return nil
}
opt := s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList])
reply := dhcp4.ReplyPacket(p, dhcp4.Offer, s.ipnet.IP, lease.IP, s.leaseTime, opt)
log.Tracef("Replying with offer: offered IP %v for %v with options %+v", lease.IP, s.leaseTime, reply.ParseOptions())
return reply
}
| <mask> return nil
<mask> }
<mask>
<mask> func (s *Server) handleDHCP4Request(p dhcp4.Packet, options dhcp4.Options) dhcp4.Packet {
<mask> server := options[dhcp4.OptionServerIdentifier]
<mask> if server != nil && !net.IP(server).Equal(s.ipnet.IP) {
<mask> log.Tracef("Request message not for this DHCP server (%v vs %v)", server, s.ipnet.IP)
<mask> return nil // Message not for this dhcp server
<mask> }
</s> * dhcp: refactor; log client's HW addr </s> remove log.Tracef("Got from client: Request")
if server, ok := options[dhcp4.OptionServerIdentifier]; ok && !net.IP(server).Equal(s.ipnet.IP) {
</s> add server := options[dhcp4.OptionServerIdentifier]
if server != nil && !net.IP(server).Equal(s.ipnet.IP) { </s> remove log.Tracef("Got %v message", msgType)
</s> add log.Tracef("Message from client %s: %d", p.CHAddr(), msgType)
</s> remove func (s *Server) getIPpool(ip net.IP) net.HardwareAddr {
</s> add func (s *Server) findReservedHWaddr(ip net.IP) net.HardwareAddr { </s> remove foundHWaddr := s.getIPpool(newIP)
</s> add foundHWaddr := s.findReservedHWaddr(newIP) </s> remove hwaddr := s.getIPpool(reqIP)
</s> add hwaddr := s.findReservedHWaddr(reqIP) | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/60fa3b2e95e5fc111884f13c8bfa465f030a0b40 | dhcpd/dhcpd.go |
server := options[dhcp4.OptionServerIdentifier]
if server != nil && !net.IP(server).Equal(s.ipnet.IP) { | <mask> return nil
<mask> }
<mask>
<mask> func (s *Server) handleDHCP4Request(p dhcp4.Packet, options dhcp4.Options) dhcp4.Packet {
<mask> log.Tracef("Got from client: Request")
<mask> if server, ok := options[dhcp4.OptionServerIdentifier]; ok && !net.IP(server).Equal(s.ipnet.IP) {
<mask> log.Tracef("Request message not for this DHCP server (%v vs %v)", server, s.ipnet.IP)
<mask> return nil // Message not for this dhcp server
<mask> }
<mask>
<mask> reqIP := net.IP(options[dhcp4.OptionRequestedIPAddress])
</s> * dhcp: refactor; log client's HW addr </s> remove log.Tracef("Got %v message", msgType)
</s> add log.Tracef("Message from client %s: %d", p.CHAddr(), msgType)
</s> remove func (s *Server) getIPpool(ip net.IP) net.HardwareAddr {
</s> add func (s *Server) findReservedHWaddr(ip net.IP) net.HardwareAddr { </s> remove hwaddr := s.getIPpool(reqIP)
</s> add hwaddr := s.findReservedHWaddr(reqIP) </s> remove foundHWaddr := s.getIPpool(newIP)
</s> add foundHWaddr := s.findReservedHWaddr(newIP) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/60fa3b2e95e5fc111884f13c8bfa465f030a0b40 | dhcpd/dhcpd.go |
opt := s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList])
return dhcp4.ReplyPacket(p, dhcp4.ACK, s.ipnet.IP, lease.IP, s.leaseTime, opt) | <mask> if lease.IP.Equal(reqIP) {
<mask> // IP matches lease IP, nothing else to do
<mask> lease.Expiry = time.Now().Add(s.leaseTime)
<mask> log.Tracef("Replying with ACK: request IP matches lease IP, nothing else to do. IP %v for %v", lease.IP, p.CHAddr())
<mask> return dhcp4.ReplyPacket(p, dhcp4.ACK, s.ipnet.IP, lease.IP, s.leaseTime, s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList]))
<mask> }
<mask>
<mask> //
<mask> // requested IP different from lease
<mask> //
</s> * dhcp: refactor; log client's HW addr </s> remove hwaddr := s.getIPpool(reqIP)
</s> add hwaddr := s.findReservedHWaddr(reqIP) </s> remove // find a lease, but don't update lease time
log.Tracef("Got from client: Discover")
lease, err := s.reserveLease(p)
if err != nil {
log.Tracef("Couldn't find free lease: %s", err)
// couldn't find lease, don't respond
return nil
}
reply := dhcp4.ReplyPacket(p, dhcp4.Offer, s.ipnet.IP, lease.IP, s.leaseTime, s.leaseOptions.SelectOrderOrAll(options[dhcp4.OptionParameterRequestList]))
log.Tracef("Replying with offer: offered IP %v for %v with options %+v", lease.IP, s.leaseTime, reply.ParseOptions())
return reply
</s> add return s.handleDiscover(p, options)
</s> remove foundHWaddr := s.getIPpool(newIP)
</s> add foundHWaddr := s.findReservedHWaddr(newIP) </s> remove // do nothing
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/60fa3b2e95e5fc111884f13c8bfa465f030a0b40 | dhcpd/dhcpd.go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.