code_before
stringlengths 16
1.81M
| edits
stringlengths 4
328k
| next_edit
stringlengths 0
76.5k
| code_after
stringlengths 3
49.9M
| label_window
sequencelengths 4
1.81k
| instruction
stringlengths 20
51.9k
| html_url
stringlengths 74
116
| file_name
stringlengths 3
311
|
---|---|---|---|---|---|---|---|
continue
}
if !privateNets.Contains(subnet.IP) {
errs = append(
errs,
fmt.Errorf("arpa domain %q should point to a locally-served network", domain),
)
}
| </s> remove var subnet *net.IPNet
subnet, err = netutil.SubnetFromReversedAddr(domain)
</s> add var subnet netip.Prefix
subnet, err = extractARPASubnet(domain) </s> remove `"bad arpa domain name \"non.arpa\": not a reversed ip network"`,
</s> add `"bad arpa domain name \"non.arpa.\": not a reversed ip network"`, </s> remove log.Debug("dnsforward: addr %s is from locally served network", ip)
</s> add log.Debug("dnsforward: addr %s is from locally served network", subnetAddr) </s> remove `bad arpa domain name "hello.world": not a reversed ip network`,
</s> add `bad arpa domain name "hello.world.": not a reversed ip network`, | if !privateNets.Contains(subnet.Addr().AsSlice()) { |
continue
}
if !privateNets.Contains(subnet.Addr().AsSlice()) {
errs = append(
errs,
fmt.Errorf("arpa domain %q should point to a locally-served network", domain),
)
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request #1770: 5567-extract-subnet-arpa
Merge in DNS/adguard-home from 5567-extract-subnet-arpa to master
Updates #5567.
Squashed commit of the following:
commit 288fb405b82eff2a95d75f8c557100908a998a08
Merge: e16b3ce5 9f7a582d
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 17 14:01:39 2023 +0300
Merge branch 'master' into 5567-extract-subnet-arpa
commit e16b3ce57ba41a9f4a7743dbdb93c2320e650140
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 17 13:58:58 2023 +0300
dnsforward: use netip
commit 265b08c5f82f8df555ab1a5f01c2e9ef8caef64a
Author: Eugene Burkov <[email protected]>
Date: Thu Mar 16 19:11:49 2023 +0300
dnsforward: imp tests more
commit 53a839cb6dd924cabf0552386f76aa8775c88983
Author: Eugene Burkov <[email protected]>
Date: Thu Mar 16 19:09:15 2023 +0300
dnsforward: imp naming in tests
commit 74dcccbdda217422260579e331289003a024695e
Author: Eugene Burkov <[email protected]>
Date: Thu Mar 16 18:59:12 2023 +0300
dnsforward: imp code & tests more
commit da8badfaa75a0a67c10ce6f347e551dcfd4c0589
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 15 14:52:48 2023 +0300
all: log changes
commit c491cbfb3fd8d716303224c1f73329a47087753a
Merge: 74a93179 2b5e4850
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 15 14:44:31 2023 +0300
Merge branch 'master' into 5567-extract-subnet-arpa
commit 74a93179d7fb7f005455ce02f7f0c16b796c3914
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 15 14:42:55 2023 +0300
dnsforward: imp code, docs
commit 17df1a0ce461335649c6dab65c984eb0cce0bdf0
Author: Eugene Burkov <[email protected]>
Date: Tue Mar 14 19:49:10 2023 +0300
dnsforward: extract subnet from arpa | https://github.com/AdguardTeam/AdGuardHome/commit/48431f8b86a1e4dde8aebb7539682eb8d043c556 | internal/dnsforward/http.go |
wantSet: "",
}, {
name: "local_ptr_upstreams_bad",
wantSet: `validating private upstream servers: checking domain-specific upstreams: ` +
`bad arpa domain name "non.arpa": not a reversed ip network`,
}, {
name: "local_ptr_upstreams_null",
wantSet: "",
}}
| </s> remove `bad arpa domain name "hello.world": not a reversed ip network`,
</s> add `bad arpa domain name "hello.world.": not a reversed ip network`, </s> remove `"bad arpa domain name \"non.arpa\": not a reversed ip network"`,
</s> add `"bad arpa domain name \"non.arpa.\": not a reversed ip network"`, </s> remove if !privateNets.Contains(subnet.IP) {
</s> add if !privateNets.Contains(subnet.Addr().AsSlice()) { </s> remove log.Debug("dnsforward: parsing reversed addr: %s", err)
</s> add if errors.Is(err, netutil.ErrNotAReversedSubnet) {
log.Debug("dnsforward: request is not for arpa domain") | `bad arpa domain name "non.arpa.": not a reversed ip network`, | wantSet: "",
}, {
name: "local_ptr_upstreams_bad",
wantSet: `validating private upstream servers: checking domain-specific upstreams: ` +
`bad arpa domain name "non.arpa.": not a reversed ip network`,
}, {
name: "local_ptr_upstreams_null",
wantSet: "",
}}
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request #1770: 5567-extract-subnet-arpa
Merge in DNS/adguard-home from 5567-extract-subnet-arpa to master
Updates #5567.
Squashed commit of the following:
commit 288fb405b82eff2a95d75f8c557100908a998a08
Merge: e16b3ce5 9f7a582d
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 17 14:01:39 2023 +0300
Merge branch 'master' into 5567-extract-subnet-arpa
commit e16b3ce57ba41a9f4a7743dbdb93c2320e650140
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 17 13:58:58 2023 +0300
dnsforward: use netip
commit 265b08c5f82f8df555ab1a5f01c2e9ef8caef64a
Author: Eugene Burkov <[email protected]>
Date: Thu Mar 16 19:11:49 2023 +0300
dnsforward: imp tests more
commit 53a839cb6dd924cabf0552386f76aa8775c88983
Author: Eugene Burkov <[email protected]>
Date: Thu Mar 16 19:09:15 2023 +0300
dnsforward: imp naming in tests
commit 74dcccbdda217422260579e331289003a024695e
Author: Eugene Burkov <[email protected]>
Date: Thu Mar 16 18:59:12 2023 +0300
dnsforward: imp code & tests more
commit da8badfaa75a0a67c10ce6f347e551dcfd4c0589
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 15 14:52:48 2023 +0300
all: log changes
commit c491cbfb3fd8d716303224c1f73329a47087753a
Merge: 74a93179 2b5e4850
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 15 14:44:31 2023 +0300
Merge branch 'master' into 5567-extract-subnet-arpa
commit 74a93179d7fb7f005455ce02f7f0c16b796c3914
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 15 14:42:55 2023 +0300
dnsforward: imp code, docs
commit 17df1a0ce461335649c6dab65c984eb0cce0bdf0
Author: Eugene Burkov <[email protected]>
Date: Tue Mar 14 19:49:10 2023 +0300
dnsforward: extract subnet from arpa | https://github.com/AdguardTeam/AdGuardHome/commit/48431f8b86a1e4dde8aebb7539682eb8d043c556 | internal/dnsforward/http_test.go |
u: "[/127.in-addr.arpa/]#",
}, {
name: "not_arpa_subnet",
wantErr: `checking domain-specific upstreams: ` +
`bad arpa domain name "hello.world": not a reversed ip network`,
u: "[/hello.world/]#",
}, {
name: "non-private_arpa_address",
wantErr: `checking domain-specific upstreams: ` +
`arpa domain "1.2.3.4.in-addr.arpa." should point to a locally-served network`,
| </s> remove `"bad arpa domain name \"non.arpa\": not a reversed ip network"`,
</s> add `"bad arpa domain name \"non.arpa.\": not a reversed ip network"`, </s> remove `bad arpa domain name "non.arpa": not a reversed ip network`,
</s> add `bad arpa domain name "non.arpa.": not a reversed ip network`, </s> remove if !privateNets.Contains(subnet.IP) {
</s> add if !privateNets.Contains(subnet.Addr().AsSlice()) { </s> remove log.Debug("dnsforward: parsing reversed addr: %s", err)
</s> add if errors.Is(err, netutil.ErrNotAReversedSubnet) {
log.Debug("dnsforward: request is not for arpa domain") | `bad arpa domain name "hello.world.": not a reversed ip network`, | u: "[/127.in-addr.arpa/]#",
}, {
name: "not_arpa_subnet",
wantErr: `checking domain-specific upstreams: ` +
`bad arpa domain name "hello.world.": not a reversed ip network`,
u: "[/hello.world/]#",
}, {
name: "non-private_arpa_address",
wantErr: `checking domain-specific upstreams: ` +
`arpa domain "1.2.3.4.in-addr.arpa." should point to a locally-served network`, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request #1770: 5567-extract-subnet-arpa
Merge in DNS/adguard-home from 5567-extract-subnet-arpa to master
Updates #5567.
Squashed commit of the following:
commit 288fb405b82eff2a95d75f8c557100908a998a08
Merge: e16b3ce5 9f7a582d
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 17 14:01:39 2023 +0300
Merge branch 'master' into 5567-extract-subnet-arpa
commit e16b3ce57ba41a9f4a7743dbdb93c2320e650140
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 17 13:58:58 2023 +0300
dnsforward: use netip
commit 265b08c5f82f8df555ab1a5f01c2e9ef8caef64a
Author: Eugene Burkov <[email protected]>
Date: Thu Mar 16 19:11:49 2023 +0300
dnsforward: imp tests more
commit 53a839cb6dd924cabf0552386f76aa8775c88983
Author: Eugene Burkov <[email protected]>
Date: Thu Mar 16 19:09:15 2023 +0300
dnsforward: imp naming in tests
commit 74dcccbdda217422260579e331289003a024695e
Author: Eugene Burkov <[email protected]>
Date: Thu Mar 16 18:59:12 2023 +0300
dnsforward: imp code & tests more
commit da8badfaa75a0a67c10ce6f347e551dcfd4c0589
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 15 14:52:48 2023 +0300
all: log changes
commit c491cbfb3fd8d716303224c1f73329a47087753a
Merge: 74a93179 2b5e4850
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 15 14:44:31 2023 +0300
Merge branch 'master' into 5567-extract-subnet-arpa
commit 74a93179d7fb7f005455ce02f7f0c16b796c3914
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 15 14:42:55 2023 +0300
dnsforward: imp code, docs
commit 17df1a0ce461335649c6dab65c984eb0cce0bdf0
Author: Eugene Burkov <[email protected]>
Date: Tue Mar 14 19:49:10 2023 +0300
dnsforward: extract subnet from arpa | https://github.com/AdguardTeam/AdGuardHome/commit/48431f8b86a1e4dde8aebb7539682eb8d043c556 | internal/dnsforward/http_test.go |
}, {
name: "several_bad",
wantErr: `checking domain-specific upstreams: 2 errors: ` +
`"arpa domain \"1.2.3.4.in-addr.arpa.\" should point to a locally-served network", ` +
`"bad arpa domain name \"non.arpa\": not a reversed ip network"`,
u: "[/non.arpa/1.2.3.4.in-addr.arpa/127.in-addr.arpa/]#",
}}
for _, tc := range testCases {
set := []string{"192.168.0.1", tc.u}
| </s> remove `bad arpa domain name "hello.world": not a reversed ip network`,
</s> add `bad arpa domain name "hello.world.": not a reversed ip network`, </s> remove `bad arpa domain name "non.arpa": not a reversed ip network`,
</s> add `bad arpa domain name "non.arpa.": not a reversed ip network`, </s> remove if !privateNets.Contains(subnet.IP) {
</s> add if !privateNets.Contains(subnet.Addr().AsSlice()) { </s> remove var subnet *net.IPNet
subnet, err = netutil.SubnetFromReversedAddr(domain)
</s> add var subnet netip.Prefix
subnet, err = extractARPASubnet(domain) | `"bad arpa domain name \"non.arpa.\": not a reversed ip network"`, | }, {
name: "several_bad",
wantErr: `checking domain-specific upstreams: 2 errors: ` +
`"arpa domain \"1.2.3.4.in-addr.arpa.\" should point to a locally-served network", ` +
`"bad arpa domain name \"non.arpa.\": not a reversed ip network"`,
u: "[/non.arpa/1.2.3.4.in-addr.arpa/127.in-addr.arpa/]#",
}}
for _, tc := range testCases {
set := []string{"192.168.0.1", tc.u} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request #1770: 5567-extract-subnet-arpa
Merge in DNS/adguard-home from 5567-extract-subnet-arpa to master
Updates #5567.
Squashed commit of the following:
commit 288fb405b82eff2a95d75f8c557100908a998a08
Merge: e16b3ce5 9f7a582d
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 17 14:01:39 2023 +0300
Merge branch 'master' into 5567-extract-subnet-arpa
commit e16b3ce57ba41a9f4a7743dbdb93c2320e650140
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 17 13:58:58 2023 +0300
dnsforward: use netip
commit 265b08c5f82f8df555ab1a5f01c2e9ef8caef64a
Author: Eugene Burkov <[email protected]>
Date: Thu Mar 16 19:11:49 2023 +0300
dnsforward: imp tests more
commit 53a839cb6dd924cabf0552386f76aa8775c88983
Author: Eugene Burkov <[email protected]>
Date: Thu Mar 16 19:09:15 2023 +0300
dnsforward: imp naming in tests
commit 74dcccbdda217422260579e331289003a024695e
Author: Eugene Burkov <[email protected]>
Date: Thu Mar 16 18:59:12 2023 +0300
dnsforward: imp code & tests more
commit da8badfaa75a0a67c10ce6f347e551dcfd4c0589
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 15 14:52:48 2023 +0300
all: log changes
commit c491cbfb3fd8d716303224c1f73329a47087753a
Merge: 74a93179 2b5e4850
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 15 14:44:31 2023 +0300
Merge branch 'master' into 5567-extract-subnet-arpa
commit 74a93179d7fb7f005455ce02f7f0c16b796c3914
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 15 14:42:55 2023 +0300
dnsforward: imp code, docs
commit 17df1a0ce461335649c6dab65c984eb0cce0bdf0
Author: Eugene Burkov <[email protected]>
Date: Tue Mar 14 19:49:10 2023 +0300
dnsforward: extract subnet from arpa | https://github.com/AdguardTeam/AdGuardHome/commit/48431f8b86a1e4dde8aebb7539682eb8d043c556 | internal/dnsforward/http_test.go |
wantErr: `checking domain-specific upstreams: 2 errors: ` +
`"arpa domain \"1.2.3.4.in-addr.arpa.\" should point to a locally-served network", ` +
`"bad arpa domain name \"non.arpa.\": not a reversed ip network"`,
u: "[/non.arpa/1.2.3.4.in-addr.arpa/127.in-addr.arpa/]#",
}}
for _, tc := range testCases {
set := []string{"192.168.0.1", tc.u}
| </s> remove `"bad arpa domain name \"non.arpa\": not a reversed ip network"`,
</s> add `"bad arpa domain name \"non.arpa.\": not a reversed ip network"`, </s> remove `bad arpa domain name "hello.world": not a reversed ip network`,
</s> add `bad arpa domain name "hello.world.": not a reversed ip network`, </s> remove `bad arpa domain name "non.arpa": not a reversed ip network`,
</s> add `bad arpa domain name "non.arpa.": not a reversed ip network`, </s> remove if !privateNets.Contains(subnet.IP) {
</s> add if !privateNets.Contains(subnet.Addr().AsSlice()) { </s> remove var subnet *net.IPNet
subnet, err = netutil.SubnetFromReversedAddr(domain)
</s> add var subnet netip.Prefix
subnet, err = extractARPASubnet(domain) | }, {
name: "partial_good",
wantErr: "",
u: "[/a.1.2.3.10.in-addr.arpa/a.10.in-addr.arpa/]#", | wantErr: `checking domain-specific upstreams: 2 errors: ` +
`"arpa domain \"1.2.3.4.in-addr.arpa.\" should point to a locally-served network", ` +
`"bad arpa domain name \"non.arpa.\": not a reversed ip network"`,
u: "[/non.arpa/1.2.3.4.in-addr.arpa/127.in-addr.arpa/]#",
}, {
name: "partial_good",
wantErr: "",
u: "[/a.1.2.3.10.in-addr.arpa/a.10.in-addr.arpa/]#",
}}
for _, tc := range testCases {
set := []string{"192.168.0.1", tc.u} | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | Pull request #1770: 5567-extract-subnet-arpa
Merge in DNS/adguard-home from 5567-extract-subnet-arpa to master
Updates #5567.
Squashed commit of the following:
commit 288fb405b82eff2a95d75f8c557100908a998a08
Merge: e16b3ce5 9f7a582d
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 17 14:01:39 2023 +0300
Merge branch 'master' into 5567-extract-subnet-arpa
commit e16b3ce57ba41a9f4a7743dbdb93c2320e650140
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 17 13:58:58 2023 +0300
dnsforward: use netip
commit 265b08c5f82f8df555ab1a5f01c2e9ef8caef64a
Author: Eugene Burkov <[email protected]>
Date: Thu Mar 16 19:11:49 2023 +0300
dnsforward: imp tests more
commit 53a839cb6dd924cabf0552386f76aa8775c88983
Author: Eugene Burkov <[email protected]>
Date: Thu Mar 16 19:09:15 2023 +0300
dnsforward: imp naming in tests
commit 74dcccbdda217422260579e331289003a024695e
Author: Eugene Burkov <[email protected]>
Date: Thu Mar 16 18:59:12 2023 +0300
dnsforward: imp code & tests more
commit da8badfaa75a0a67c10ce6f347e551dcfd4c0589
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 15 14:52:48 2023 +0300
all: log changes
commit c491cbfb3fd8d716303224c1f73329a47087753a
Merge: 74a93179 2b5e4850
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 15 14:44:31 2023 +0300
Merge branch 'master' into 5567-extract-subnet-arpa
commit 74a93179d7fb7f005455ce02f7f0c16b796c3914
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 15 14:42:55 2023 +0300
dnsforward: imp code, docs
commit 17df1a0ce461335649c6dab65c984eb0cce0bdf0
Author: Eugene Burkov <[email protected]>
Date: Tue Mar 14 19:49:10 2023 +0300
dnsforward: extract subnet from arpa | https://github.com/AdguardTeam/AdGuardHome/commit/48431f8b86a1e4dde8aebb7539682eb8d043c556 | internal/dnsforward/http_test.go |
host := fields[i]
if len(host) == 0 {
break
}
a.updateTable(table, host, ipAddr)
a.updateTableRev(tableRev, host, ipAddr)
if sharp >= 0 {
break // skip the rest of the line after #
}
}
| </s> remove _, _ = f.WriteString(" 127.0.0.1 host localhost \n")
_, _ = f.WriteString(" ::1 localhost \n")
</s> add _, _ = f.WriteString(" 127.0.0.1 host localhost # comment \n")
_, _ = f.WriteString(" ::1 localhost#comment \n") | sharp := strings.IndexByte(host, '#')
if sharp == 0 {
break // skip the rest of the line after #
} else if sharp > 0 {
host = host[:sharp]
}
| host := fields[i]
if len(host) == 0 {
break
}
sharp := strings.IndexByte(host, '#')
if sharp == 0 {
break // skip the rest of the line after #
} else if sharp > 0 {
host = host[:sharp]
}
a.updateTable(table, host, ipAddr)
a.updateTableRev(tableRev, host, ipAddr)
if sharp >= 0 {
break // skip the rest of the line after #
}
} | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * auto-hosts: support '#' comments after ip and hosts
Close #1807
Squashed commit of the following:
commit 9d3e2809df056354bb6195abf8106616c1e214b1
Author: Simon Zolin <[email protected]>
Date: Wed Jun 17 19:23:15 2020 +0300
improve
commit 9b8c7104560c9c80f848f15818d49a065a38e498
Author: Simon Zolin <[email protected]>
Date: Wed Jun 17 11:07:56 2020 +0300
* auto-hosts: support '#' comments after ip and hosts | https://github.com/AdguardTeam/AdGuardHome/commit/4870da7f94e040fea63f2ff99bf1b79ee5da457e | util/auto_hosts.go |
a.updateTable(table, host, ipAddr)
a.updateTableRev(tableRev, host, ipAddr)
}
}
}
// Receive notifications from fsnotify package
| </s> remove _, _ = f.WriteString(" 127.0.0.1 host localhost \n")
_, _ = f.WriteString(" ::1 localhost \n")
</s> add _, _ = f.WriteString(" 127.0.0.1 host localhost # comment \n")
_, _ = f.WriteString(" ::1 localhost#comment \n") | if sharp >= 0 {
break // skip the rest of the line after #
} | a.updateTable(table, host, ipAddr)
a.updateTableRev(tableRev, host, ipAddr)
if sharp >= 0 {
break // skip the rest of the line after #
}
}
}
}
// Receive notifications from fsnotify package | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * auto-hosts: support '#' comments after ip and hosts
Close #1807
Squashed commit of the following:
commit 9d3e2809df056354bb6195abf8106616c1e214b1
Author: Simon Zolin <[email protected]>
Date: Wed Jun 17 19:23:15 2020 +0300
improve
commit 9b8c7104560c9c80f848f15818d49a065a38e498
Author: Simon Zolin <[email protected]>
Date: Wed Jun 17 11:07:56 2020 +0300
* auto-hosts: support '#' comments after ip and hosts | https://github.com/AdguardTeam/AdGuardHome/commit/4870da7f94e040fea63f2ff99bf1b79ee5da457e | util/auto_hosts.go |
f, _ := ioutil.TempFile(dir, "")
defer func() { _ = os.Remove(f.Name()) }()
defer f.Close()
_, _ = f.WriteString(" 127.0.0.1 host localhost \n")
_, _ = f.WriteString(" ::1 localhost \n")
ah.Init(f.Name())
// Update from the hosts file
ah.updateHosts()
| </s> | _, _ = f.WriteString(" 127.0.0.1 host localhost # comment \n")
_, _ = f.WriteString(" ::1 localhost#comment \n") | f, _ := ioutil.TempFile(dir, "")
defer func() { _ = os.Remove(f.Name()) }()
defer f.Close()
_, _ = f.WriteString(" 127.0.0.1 host localhost # comment \n")
_, _ = f.WriteString(" ::1 localhost#comment \n")
_, _ = f.WriteString(" 127.0.0.1 host localhost # comment \n")
_, _ = f.WriteString(" ::1 localhost#comment \n")
ah.Init(f.Name())
// Update from the hosts file
ah.updateHosts() | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * auto-hosts: support '#' comments after ip and hosts
Close #1807
Squashed commit of the following:
commit 9d3e2809df056354bb6195abf8106616c1e214b1
Author: Simon Zolin <[email protected]>
Date: Wed Jun 17 19:23:15 2020 +0300
improve
commit 9b8c7104560c9c80f848f15818d49a065a38e498
Author: Simon Zolin <[email protected]>
Date: Wed Jun 17 11:07:56 2020 +0300
* auto-hosts: support '#' comments after ip and hosts | https://github.com/AdguardTeam/AdGuardHome/commit/4870da7f94e040fea63f2ff99bf1b79ee5da457e | util/auto_hosts_test.go |
ips = ah.Process("newhost", dns.TypeA)
assert.Nil(t, ips)
// Test hosts file
table := ah.List()
name, ok := table["127.0.0.1"]
assert.True(t, ok)
| </s> remove _, _ = f.WriteString(" 127.0.0.1 host localhost \n")
_, _ = f.WriteString(" ::1 localhost \n")
</s> add _, _ = f.WriteString(" 127.0.0.1 host localhost # comment \n")
_, _ = f.WriteString(" ::1 localhost#comment \n") | // Unknown host (comment)
ips = ah.Process("comment", dns.TypeA)
assert.Nil(t, ips)
| ips = ah.Process("newhost", dns.TypeA)
assert.Nil(t, ips)
// Unknown host (comment)
ips = ah.Process("comment", dns.TypeA)
assert.Nil(t, ips)
// Test hosts file
table := ah.List()
name, ok := table["127.0.0.1"]
assert.True(t, ok) | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | * auto-hosts: support '#' comments after ip and hosts
Close #1807
Squashed commit of the following:
commit 9d3e2809df056354bb6195abf8106616c1e214b1
Author: Simon Zolin <[email protected]>
Date: Wed Jun 17 19:23:15 2020 +0300
improve
commit 9b8c7104560c9c80f848f15818d49a065a38e498
Author: Simon Zolin <[email protected]>
Date: Wed Jun 17 11:07:56 2020 +0300
* auto-hosts: support '#' comments after ip and hosts | https://github.com/AdguardTeam/AdGuardHome/commit/4870da7f94e040fea63f2ff99bf1b79ee5da457e | util/auto_hosts_test.go |
req *urlfilter.DNSRequest,
) (res *urlfilter.DNSResult, ok bool) {
switch req.DNSType {
case dns.TypeA, dns.TypeAAAA, dns.TypePTR:
log.Debug("%s: handling the request for %s", hostsContainerPref, req.Hostname)
default:
return nil, false
}
rm.stateLock.RLock()
| </s> remove log.Error("%s: %s", hostsContainerPref, err)
</s> add log.Error("%s: %s", hostsContainerPrefix, err) </s> remove ok, eventsCh := true, hc.w.Events()
</s> add ok, eventsCh := true, hc.watcher.Events() </s> remove log.Debug("%s: watcher closed the events channel", hostsContainerPref)
</s> add log.Debug("%s: watcher closed the events channel", hostsContainerPrefix) </s> remove defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPref))
</s> add defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPrefix)) </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add | log.Debug("%s: handling the request for %s", hostsContainerPrefix, req.Hostname) | req *urlfilter.DNSRequest,
) (res *urlfilter.DNSResult, ok bool) {
switch req.DNSType {
case dns.TypeA, dns.TypeAAAA, dns.TypePTR:
log.Debug("%s: handling the request for %s", hostsContainerPrefix, req.Hostname)
default:
return nil, false
}
rm.stateLock.RLock() | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
rm.translator = tr
}
// hostsContainerPref is a prefix for logging and wrapping errors in
// HostsContainer's methods.
const hostsContainerPref = "hosts container"
// HostsContainer stores the relevant hosts database provided by the OS and
// processes both A/AAAA and PTR DNS requests for those.
| </s> remove const hostsContainerPref = "hosts container"
</s> add const hostsContainerPrefix = "hosts container" </s> remove // w tracks the changes in specified files and directories.
w aghos.FSWatcher
</s> add // watcher tracks the changes in specified files and directories.
watcher aghos.FSWatcher </s> remove // Close implements the io.Closer interface for *HostsContainer. Close must
// only be called once. The returned err is always nil.
</s> add // Close implements the [io.Closer] interface for *HostsContainer. It closes
// both itself and its [aghos.FSWatcher]. Close must only be called once. </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add </s> remove // etcHosts is an IP-hostname pairs set taken from system configuration
// (e.g. /etc/hosts) files.
</s> add // etcHosts contains IP-hostname mappings taken from the OS-specific hosts
// configuration files, for example /etc/hosts. | // hostsContainerPrefix is a prefix for logging and wrapping errors in |
rm.translator = tr
}
// hostsContainerPrefix is a prefix for logging and wrapping errors in
// HostsContainer's methods.
const hostsContainerPref = "hosts container"
// HostsContainer stores the relevant hosts database provided by the OS and
// processes both A/AAAA and PTR DNS requests for those. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
}
// hostsContainerPref is a prefix for logging and wrapping errors in
// HostsContainer's methods.
const hostsContainerPref = "hosts container"
// HostsContainer stores the relevant hosts database provided by the OS and
// processes both A/AAAA and PTR DNS requests for those.
type HostsContainer struct {
// requestMatcher matches the requests and translates the rules. It's
| </s> remove // hostsContainerPref is a prefix for logging and wrapping errors in
</s> add // hostsContainerPrefix is a prefix for logging and wrapping errors in </s> remove // w tracks the changes in specified files and directories.
w aghos.FSWatcher
</s> add // watcher tracks the changes in specified files and directories.
watcher aghos.FSWatcher </s> remove defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPref))
</s> add defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPrefix)) </s> remove // Close implements the io.Closer interface for *HostsContainer. Close must
// only be called once. The returned err is always nil.
</s> add // Close implements the [io.Closer] interface for *HostsContainer. It closes
// both itself and its [aghos.FSWatcher]. Close must only be called once. </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add | const hostsContainerPrefix = "hosts container" | }
// hostsContainerPref is a prefix for logging and wrapping errors in
// HostsContainer's methods.
const hostsContainerPrefix = "hosts container"
// HostsContainer stores the relevant hosts database provided by the OS and
// processes both A/AAAA and PTR DNS requests for those.
type HostsContainer struct {
// requestMatcher matches the requests and translates the rules. It's | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
// fsys is the working file system to read hosts files from.
fsys fs.FS
// w tracks the changes in specified files and directories.
w aghos.FSWatcher
// patterns stores specified paths in the fs.Glob-compatible form.
patterns []string
// listID is the identifier for the list of generated rules.
| </s> remove // hostsWatcher is the watcher to detect changes in the hosts files.
hostsWatcher aghos.FSWatcher
</s> add </s> remove const hostsContainerPref = "hosts container"
</s> add const hostsContainerPrefix = "hosts container" </s> remove // etcHosts is an IP-hostname pairs set taken from system configuration
// (e.g. /etc/hosts) files.
</s> add // etcHosts contains IP-hostname mappings taken from the OS-specific hosts
// configuration files, for example /etc/hosts. </s> remove // hostsContainerPref is a prefix for logging and wrapping errors in
</s> add // hostsContainerPrefix is a prefix for logging and wrapping errors in </s> remove transport *http.Transport
</s> add | // watcher tracks the changes in specified files and directories.
watcher aghos.FSWatcher |
// fsys is the working file system to read hosts files from.
fsys fs.FS
// watcher tracks the changes in specified files and directories.
watcher aghos.FSWatcher
// watcher tracks the changes in specified files and directories.
watcher aghos.FSWatcher
// patterns stores specified paths in the fs.Glob-compatible form.
patterns []string
// listID is the identifier for the list of generated rules. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
fsys fs.FS,
w aghos.FSWatcher,
paths ...string,
) (hc *HostsContainer, err error) {
defer func() { err = errors.Annotate(err, "%s: %w", hostsContainerPref) }()
if len(paths) == 0 {
return nil, ErrNoHostsPaths
}
| </s> remove cerr := Context.hostsWatcher.Close()
if errors.Is(err, aghnet.ErrNoHostsPaths) && cerr == nil {
</s> add closeErr := hostsWatcher.Close()
if errors.Is(err, aghnet.ErrNoHostsPaths) && closeErr == nil { </s> remove Context.hostsWatcher,
</s> add hostsWatcher, </s> remove log.Debug("%s: refreshing", hostsContainerPref)
</s> add log.Debug("%s: refreshing", hostsContainerPrefix) </s> remove log.Debug("%s: closing", hostsContainerPref)
</s> add log.Debug("%s: closing", hostsContainerPrefix)
err = hc.watcher.Close()
if err != nil {
err = fmt.Errorf("closing fs watcher: %w", err)
// Go on and close the container either way.
} </s> remove log.Debug("%s: starting", hostsContainerPref)
</s> add log.Debug("%s: starting", hostsContainerPrefix) | defer func() { err = errors.Annotate(err, "%s: %w", hostsContainerPrefix) }() | fsys fs.FS,
w aghos.FSWatcher,
paths ...string,
) (hc *HostsContainer, err error) {
defer func() { err = errors.Annotate(err, "%s: %w", hostsContainerPrefix) }()
if len(paths) == 0 {
return nil, ErrNoHostsPaths
}
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
listID: listID,
done: make(chan struct{}, 1),
updates: make(chan HostsRecords, 1),
fsys: fsys,
w: w,
patterns: patterns,
}
log.Debug("%s: starting", hostsContainerPref)
| </s> remove log.Debug("%s: starting", hostsContainerPref)
</s> add log.Debug("%s: starting", hostsContainerPrefix) </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove log.Debug("%s: no changes detected", hostsContainerPref)
</s> add log.Debug("%s: no changes detected", hostsContainerPrefix) </s> remove log.Error("%s: the updates channel is broken", hostsContainerPref)
</s> add log.Error("%s: the updates channel is broken", hostsContainerPrefix) </s> remove log.Debug("%s: watcher closed the events channel", hostsContainerPref)
</s> add log.Debug("%s: watcher closed the events channel", hostsContainerPrefix) | watcher: w, | listID: listID,
done: make(chan struct{}, 1),
updates: make(chan HostsRecords, 1),
fsys: fsys,
watcher: w,
patterns: patterns,
}
log.Debug("%s: starting", hostsContainerPref)
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
w: w,
patterns: patterns,
}
log.Debug("%s: starting", hostsContainerPref)
// Load initially.
if err = hc.refresh(); err != nil {
return nil, err
}
| </s> remove w: w,
</s> add watcher: w, </s> remove log.Error("%s: %s", hostsContainerPref, err)
</s> add log.Error("%s: %s", hostsContainerPrefix, err) </s> remove log.Debug("%s: watcher closed the events channel", hostsContainerPref)
</s> add log.Debug("%s: watcher closed the events channel", hostsContainerPrefix) </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add </s> remove log.Debug("%s: closing", hostsContainerPref)
</s> add log.Debug("%s: closing", hostsContainerPrefix)
err = hc.watcher.Close()
if err != nil {
err = fmt.Errorf("closing fs watcher: %w", err)
// Go on and close the container either way.
} | log.Debug("%s: starting", hostsContainerPrefix) | w: w,
patterns: patterns,
}
log.Debug("%s: starting", hostsContainerPrefix)
// Load initially.
if err = hc.refresh(); err != nil {
return nil, err
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
if !errors.Is(err, fs.ErrNotExist) {
return nil, fmt.Errorf("adding path: %w", err)
}
log.Debug("%s: %s is expected to exist but doesn't", hostsContainerPref, p)
}
}
go hc.handleEvents()
| </s> remove log.Error("%s: %s", hostsContainerPref, err)
</s> add log.Error("%s: %s", hostsContainerPrefix, err) </s> remove defer func() { err = errors.Annotate(err, "%s: %w", hostsContainerPref) }()
</s> add defer func() { err = errors.Annotate(err, "%s: %w", hostsContainerPrefix) }() </s> remove log.Debug("%s: handling the request for %s", hostsContainerPref, req.Hostname)
</s> add log.Debug("%s: handling the request for %s", hostsContainerPrefix, req.Hostname) </s> remove log.Debug("%s: refreshing", hostsContainerPref)
</s> add log.Debug("%s: refreshing", hostsContainerPrefix) </s> remove log.Debug("%s: starting", hostsContainerPref)
</s> add log.Debug("%s: starting", hostsContainerPrefix) | log.Debug("%s: %s is expected to exist but doesn't", hostsContainerPrefix, p) | if !errors.Is(err, fs.ErrNotExist) {
return nil, fmt.Errorf("adding path: %w", err)
}
log.Debug("%s: %s is expected to exist but doesn't", hostsContainerPrefix, p)
}
}
go hc.handleEvents()
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
return hc, nil
}
// Close implements the io.Closer interface for *HostsContainer. Close must
// only be called once. The returned err is always nil.
func (hc *HostsContainer) Close() (err error) {
log.Debug("%s: closing", hostsContainerPref)
close(hc.done)
| </s> remove log.Debug("%s: closing", hostsContainerPref)
</s> add log.Debug("%s: closing", hostsContainerPrefix)
err = hc.watcher.Close()
if err != nil {
err = fmt.Errorf("closing fs watcher: %w", err)
// Go on and close the container either way.
} </s> remove return nil
</s> add return err </s> remove log.Debug("%s: refreshing", hostsContainerPref)
</s> add log.Debug("%s: refreshing", hostsContainerPrefix) </s> remove defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPref))
</s> add defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPrefix)) </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add | // Close implements the [io.Closer] interface for *HostsContainer. It closes
// both itself and its [aghos.FSWatcher]. Close must only be called once. |
return hc, nil
}
// Close implements the [io.Closer] interface for *HostsContainer. It closes
// both itself and its [aghos.FSWatcher]. Close must only be called once.
// Close implements the [io.Closer] interface for *HostsContainer. It closes
// both itself and its [aghos.FSWatcher]. Close must only be called once.
func (hc *HostsContainer) Close() (err error) {
log.Debug("%s: closing", hostsContainerPref)
close(hc.done)
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
// Close implements the io.Closer interface for *HostsContainer. Close must
// only be called once. The returned err is always nil.
func (hc *HostsContainer) Close() (err error) {
log.Debug("%s: closing", hostsContainerPref)
close(hc.done)
return nil
}
| </s> remove // Close implements the io.Closer interface for *HostsContainer. Close must
// only be called once. The returned err is always nil.
</s> add // Close implements the [io.Closer] interface for *HostsContainer. It closes
// both itself and its [aghos.FSWatcher]. Close must only be called once. </s> remove return nil
</s> add return err </s> remove log.Debug("%s: refreshing", hostsContainerPref)
</s> add log.Debug("%s: refreshing", hostsContainerPrefix) </s> remove defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPref))
</s> add defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPrefix)) </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add | log.Debug("%s: closing", hostsContainerPrefix)
err = hc.watcher.Close()
if err != nil {
err = fmt.Errorf("closing fs watcher: %w", err)
// Go on and close the container either way.
} |
// Close implements the io.Closer interface for *HostsContainer. Close must
// only be called once. The returned err is always nil.
func (hc *HostsContainer) Close() (err error) {
log.Debug("%s: closing", hostsContainerPrefix)
err = hc.watcher.Close()
if err != nil {
err = fmt.Errorf("closing fs watcher: %w", err)
// Go on and close the container either way.
}
close(hc.done)
return nil
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
log.Debug("%s: closing", hostsContainerPref)
close(hc.done)
return nil
}
// Upd returns the channel into which the updates are sent.
func (hc *HostsContainer) Upd() (updates <-chan HostsRecords) {
return hc.updates
| </s> remove log.Debug("%s: closing", hostsContainerPref)
</s> add log.Debug("%s: closing", hostsContainerPrefix)
err = hc.watcher.Close()
if err != nil {
err = fmt.Errorf("closing fs watcher: %w", err)
// Go on and close the container either way.
} </s> remove // Close implements the io.Closer interface for *HostsContainer. Close must
// only be called once. The returned err is always nil.
</s> add // Close implements the [io.Closer] interface for *HostsContainer. It closes
// both itself and its [aghos.FSWatcher]. Close must only be called once. </s> remove log.Error("%s: the updates channel is broken", hostsContainerPref)
</s> add log.Error("%s: the updates channel is broken", hostsContainerPrefix) </s> remove log.Debug("%s: sending upd", hostsContainerPref)
</s> add log.Debug("%s: sending upd", hostsContainerPrefix) </s> remove log.Debug("%s: replaced the last update", hostsContainerPref)
</s> add log.Debug("%s: replaced the last update", hostsContainerPrefix) | return err | log.Debug("%s: closing", hostsContainerPref)
close(hc.done)
return err
}
// Upd returns the channel into which the updates are sent.
func (hc *HostsContainer) Upd() (updates <-chan HostsRecords) {
return hc.updates | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
// handleEvents concurrently handles the file system events. It closes the
// update channel of HostsContainer when finishes. It's used to be called
// within a separate goroutine.
func (hc *HostsContainer) handleEvents() {
defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPref))
defer close(hc.updates)
ok, eventsCh := true, hc.w.Events()
for ok {
| </s> remove ok, eventsCh := true, hc.w.Events()
</s> add ok, eventsCh := true, hc.watcher.Events() </s> remove // Close implements the io.Closer interface for *HostsContainer. Close must
// only be called once. The returned err is always nil.
</s> add // Close implements the [io.Closer] interface for *HostsContainer. It closes
// both itself and its [aghos.FSWatcher]. Close must only be called once. </s> remove const hostsContainerPref = "hosts container"
</s> add const hostsContainerPrefix = "hosts container" </s> remove transport *http.Transport
</s> add </s> remove log.Debug("%s: closing", hostsContainerPref)
</s> add log.Debug("%s: closing", hostsContainerPrefix)
err = hc.watcher.Close()
if err != nil {
err = fmt.Errorf("closing fs watcher: %w", err)
// Go on and close the container either way.
} | defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPrefix)) | // handleEvents concurrently handles the file system events. It closes the
// update channel of HostsContainer when finishes. It's used to be called
// within a separate goroutine.
func (hc *HostsContainer) handleEvents() {
defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPrefix))
defer close(hc.updates)
ok, eventsCh := true, hc.w.Events()
for ok { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPref))
defer close(hc.updates)
ok, eventsCh := true, hc.w.Events()
for ok {
select {
case _, ok = <-eventsCh:
if !ok {
log.Debug("%s: watcher closed the events channel", hostsContainerPref)
| </s> remove log.Debug("%s: watcher closed the events channel", hostsContainerPref)
</s> add log.Debug("%s: watcher closed the events channel", hostsContainerPrefix) </s> remove defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPref))
</s> add defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPrefix)) </s> remove log.Debug("%s: handling the request for %s", hostsContainerPref, req.Hostname)
</s> add log.Debug("%s: handling the request for %s", hostsContainerPrefix, req.Hostname) </s> remove log.Error("%s: %s", hostsContainerPref, err)
</s> add log.Error("%s: %s", hostsContainerPrefix, err) </s> remove defer func() { err = errors.Annotate(err, "%s: %w", hostsContainerPref) }()
</s> add defer func() { err = errors.Annotate(err, "%s: %w", hostsContainerPrefix) }() | ok, eventsCh := true, hc.watcher.Events() | defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPref))
defer close(hc.updates)
ok, eventsCh := true, hc.watcher.Events()
for ok {
select {
case _, ok = <-eventsCh:
if !ok {
log.Debug("%s: watcher closed the events channel", hostsContainerPref) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
for ok {
select {
case _, ok = <-eventsCh:
if !ok {
log.Debug("%s: watcher closed the events channel", hostsContainerPref)
continue
}
if err := hc.refresh(); err != nil {
| </s> remove ok, eventsCh := true, hc.w.Events()
</s> add ok, eventsCh := true, hc.watcher.Events() </s> remove log.Error("%s: %s", hostsContainerPref, err)
</s> add log.Error("%s: %s", hostsContainerPrefix, err) </s> remove log.Debug("%s: starting", hostsContainerPref)
</s> add log.Debug("%s: starting", hostsContainerPrefix) </s> remove log.Debug("%s: handling the request for %s", hostsContainerPref, req.Hostname)
</s> add log.Debug("%s: handling the request for %s", hostsContainerPrefix, req.Hostname) </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add | log.Debug("%s: watcher closed the events channel", hostsContainerPrefix) | for ok {
select {
case _, ok = <-eventsCh:
if !ok {
log.Debug("%s: watcher closed the events channel", hostsContainerPrefix)
continue
}
if err := hc.refresh(); err != nil { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
continue
}
if err := hc.refresh(); err != nil {
log.Error("%s: %s", hostsContainerPref, err)
}
case _, ok = <-hc.done:
// Go on.
}
}
| </s> remove log.Debug("%s: watcher closed the events channel", hostsContainerPref)
</s> add log.Debug("%s: watcher closed the events channel", hostsContainerPrefix) </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add </s> remove log.Error("%s: host %q is invalid, ignoring", hostsContainerPref, f)
</s> add log.Error("%s: host %q is invalid, ignoring", hostsContainerPrefix, f) </s> remove log.Debug("%s: starting", hostsContainerPref)
</s> add log.Debug("%s: starting", hostsContainerPrefix) </s> remove log.Error("%s: the updates channel is broken", hostsContainerPref)
</s> add log.Error("%s: the updates channel is broken", hostsContainerPrefix) | log.Error("%s: %s", hostsContainerPrefix, err) | continue
}
if err := hc.refresh(); err != nil {
log.Error("%s: %s", hostsContainerPrefix, err)
}
case _, ok = <-hc.done:
// Go on.
}
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
//
// TODO(e.burkov): Investigate if hosts may contain DNS-SD domains.
err = netutil.ValidateHostname(f)
if err != nil {
log.Error("%s: host %q is invalid, ignoring", hostsContainerPref, f)
continue
}
hosts = append(hosts, f)
| </s> remove log.Error("%s: %s", hostsContainerPref, err)
</s> add log.Error("%s: %s", hostsContainerPrefix, err) </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add </s> remove Context.hostsWatcher, err = aghos.NewOSWritesWatcher()
</s> add hostsWatcher, err := aghos.NewOSWritesWatcher() </s> remove log.Debug("%s: refreshing", hostsContainerPref)
</s> add log.Debug("%s: refreshing", hostsContainerPrefix) </s> remove log.Debug("%s: watcher closed the events channel", hostsContainerPref)
</s> add log.Debug("%s: watcher closed the events channel", hostsContainerPrefix) | log.Error("%s: host %q is invalid, ignoring", hostsContainerPrefix, f) | //
// TODO(e.burkov): Investigate if hosts may contain DNS-SD domains.
err = netutil.ValidateHostname(f)
if err != nil {
log.Error("%s: host %q is invalid, ignoring", hostsContainerPrefix, f)
continue
}
hosts = append(hosts, f) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
func (hp *hostsParser) addRules(ip netip.Addr, host, line string) {
rule, rulePtr := hp.writeRules(host, ip)
hp.translations[rule], hp.translations[rulePtr] = line, line
log.Debug("%s: added ip-host pair %q-%q", hostsContainerPref, ip, host)
}
// writeRules writes the actual rule for the qtype and the PTR for the host-ip
// pair into internal builders.
func (hp *hostsParser) writeRules(host string, ip netip.Addr) (rule, rulePtr string) {
| </s> remove log.Debug("%s: sending upd", hostsContainerPref)
</s> add log.Debug("%s: sending upd", hostsContainerPrefix) </s> remove log.Error("%s: the updates channel is broken", hostsContainerPref)
</s> add log.Error("%s: the updates channel is broken", hostsContainerPrefix) </s> remove const hostsContainerPref = "hosts container"
</s> add const hostsContainerPrefix = "hosts container" </s> remove return nil
</s> add return err </s> remove // hostsContainerPref is a prefix for logging and wrapping errors in
</s> add // hostsContainerPrefix is a prefix for logging and wrapping errors in | log.Debug("%s: added ip-host pair %q-%q", hostsContainerPrefix, ip, host) | func (hp *hostsParser) addRules(ip netip.Addr, host, line string) {
rule, rulePtr := hp.writeRules(host, ip)
hp.translations[rule], hp.translations[rulePtr] = line, line
log.Debug("%s: added ip-host pair %q-%q", hostsContainerPrefix, ip, host)
}
// writeRules writes the actual rule for the qtype and the PTR for the host-ip
// pair into internal builders.
func (hp *hostsParser) writeRules(host string, ip netip.Addr) (rule, rulePtr string) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
}
// sendUpd tries to send the parsed data to the ch.
func (hp *hostsParser) sendUpd(ch chan HostsRecords) {
log.Debug("%s: sending upd", hostsContainerPref)
upd := hp.table
select {
case ch <- upd:
// Updates are delivered. Go on.
| </s> remove log.Debug("%s: replaced the last update", hostsContainerPref)
</s> add log.Debug("%s: replaced the last update", hostsContainerPrefix) </s> remove log.Error("%s: the updates channel is broken", hostsContainerPref)
</s> add log.Error("%s: the updates channel is broken", hostsContainerPrefix) </s> remove return nil
</s> add return err </s> remove log.Debug("%s: added ip-host pair %q-%q", hostsContainerPref, ip, host)
</s> add log.Debug("%s: added ip-host pair %q-%q", hostsContainerPrefix, ip, host) </s> remove log.Debug("%s: refreshing", hostsContainerPref)
</s> add log.Debug("%s: refreshing", hostsContainerPrefix) | log.Debug("%s: sending upd", hostsContainerPrefix) | }
// sendUpd tries to send the parsed data to the ch.
func (hp *hostsParser) sendUpd(ch chan HostsRecords) {
log.Debug("%s: sending upd", hostsContainerPrefix)
upd := hp.table
select {
case ch <- upd:
// Updates are delivered. Go on. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
case ch <- upd:
// Updates are delivered. Go on.
case <-ch:
ch <- upd
log.Debug("%s: replaced the last update", hostsContainerPref)
case ch <- upd:
// The previous update was just read and the next one pushed. Go on.
default:
log.Error("%s: the updates channel is broken", hostsContainerPref)
}
| </s> remove log.Error("%s: the updates channel is broken", hostsContainerPref)
</s> add log.Error("%s: the updates channel is broken", hostsContainerPrefix) </s> remove log.Debug("%s: sending upd", hostsContainerPref)
</s> add log.Debug("%s: sending upd", hostsContainerPrefix) </s> remove log.Error("%s: %s", hostsContainerPref, err)
</s> add log.Error("%s: %s", hostsContainerPrefix, err) </s> remove return nil
</s> add return err </s> remove log.Debug("%s: closing", hostsContainerPref)
</s> add log.Debug("%s: closing", hostsContainerPrefix)
err = hc.watcher.Close()
if err != nil {
err = fmt.Errorf("closing fs watcher: %w", err)
// Go on and close the container either way.
} | log.Debug("%s: replaced the last update", hostsContainerPrefix) | case ch <- upd:
// Updates are delivered. Go on.
case <-ch:
ch <- upd
log.Debug("%s: replaced the last update", hostsContainerPrefix)
case ch <- upd:
// The previous update was just read and the next one pushed. Go on.
default:
log.Error("%s: the updates channel is broken", hostsContainerPref)
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
log.Debug("%s: replaced the last update", hostsContainerPref)
case ch <- upd:
// The previous update was just read and the next one pushed. Go on.
default:
log.Error("%s: the updates channel is broken", hostsContainerPref)
}
}
// newStrg creates a new rules storage from parsed data.
func (hp *hostsParser) newStrg(id int) (s *filterlist.RuleStorage, err error) {
| </s> remove log.Debug("%s: replaced the last update", hostsContainerPref)
</s> add log.Debug("%s: replaced the last update", hostsContainerPrefix) </s> remove log.Debug("%s: sending upd", hostsContainerPref)
</s> add log.Debug("%s: sending upd", hostsContainerPrefix) </s> remove return nil
</s> add return err </s> remove log.Debug("%s: closing", hostsContainerPref)
</s> add log.Debug("%s: closing", hostsContainerPrefix)
err = hc.watcher.Close()
if err != nil {
err = fmt.Errorf("closing fs watcher: %w", err)
// Go on and close the container either way.
} </s> remove log.Error("%s: %s", hostsContainerPref, err)
</s> add log.Error("%s: %s", hostsContainerPrefix, err) | log.Error("%s: the updates channel is broken", hostsContainerPrefix) | log.Debug("%s: replaced the last update", hostsContainerPref)
case ch <- upd:
// The previous update was just read and the next one pushed. Go on.
default:
log.Error("%s: the updates channel is broken", hostsContainerPrefix)
}
}
// newStrg creates a new rules storage from parsed data.
func (hp *hostsParser) newStrg(id int) (s *filterlist.RuleStorage, err error) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
// needed.
//
// TODO(e.burkov): Accept a parameter to specify the files to refresh.
func (hc *HostsContainer) refresh() (err error) {
log.Debug("%s: refreshing", hostsContainerPref)
hp := hc.newHostsParser()
if _, err = aghos.FileWalker(hp.parseFile).Walk(hc.fsys, hc.patterns...); err != nil {
return fmt.Errorf("refreshing : %w", err)
}
| </s> remove log.Debug("%s: closing", hostsContainerPref)
</s> add log.Debug("%s: closing", hostsContainerPrefix)
err = hc.watcher.Close()
if err != nil {
err = fmt.Errorf("closing fs watcher: %w", err)
// Go on and close the container either way.
} </s> remove Context.hostsWatcher, err = aghos.NewOSWritesWatcher()
</s> add hostsWatcher, err := aghos.NewOSWritesWatcher() </s> remove return nil
</s> add return err </s> remove // Close implements the io.Closer interface for *HostsContainer. Close must
// only be called once. The returned err is always nil.
</s> add // Close implements the [io.Closer] interface for *HostsContainer. It closes
// both itself and its [aghos.FSWatcher]. Close must only be called once. </s> remove log.Error("%s: %s", hostsContainerPref, err)
</s> add log.Error("%s: %s", hostsContainerPrefix, err) | log.Debug("%s: refreshing", hostsContainerPrefix) | // needed.
//
// TODO(e.burkov): Accept a parameter to specify the files to refresh.
func (hc *HostsContainer) refresh() (err error) {
log.Debug("%s: refreshing", hostsContainerPrefix)
hp := hc.newHostsParser()
if _, err = aghos.FileWalker(hp.parseFile).Walk(hc.fsys, hc.patterns...); err != nil {
return fmt.Errorf("refreshing : %w", err)
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
}
// hc.last is nil on the first refresh, so let that one through.
if hc.last != nil && maps.EqualFunc(hp.table, hc.last, (*HostsRecord).equal) {
log.Debug("%s: no changes detected", hostsContainerPref)
return nil
}
defer hp.sendUpd(hc.updates)
| </s> remove log.Debug("%s: closing", hostsContainerPref)
</s> add log.Debug("%s: closing", hostsContainerPrefix)
err = hc.watcher.Close()
if err != nil {
err = fmt.Errorf("closing fs watcher: %w", err)
// Go on and close the container either way.
} </s> remove cerr := Context.hostsWatcher.Close()
if errors.Is(err, aghnet.ErrNoHostsPaths) && cerr == nil {
</s> add closeErr := hostsWatcher.Close()
if errors.Is(err, aghnet.ErrNoHostsPaths) && closeErr == nil { </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add </s> remove log.Debug("%s: starting", hostsContainerPref)
</s> add log.Debug("%s: starting", hostsContainerPrefix) </s> remove Context.hostsWatcher,
</s> add hostsWatcher, | log.Debug("%s: no changes detected", hostsContainerPrefix) | }
// hc.last is nil on the first refresh, so let that one through.
if hc.last != nil && maps.EqualFunc(hp.table, hc.last, (*HostsRecord).equal) {
log.Debug("%s: no changes detected", hostsContainerPrefix)
return nil
}
defer hp.sendUpd(hc.updates)
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
hc, err := NewHostsContainer(0, testFS, &aghtest.FSWatcher{
OnEvents: onEvents,
OnAdd: onAdd,
OnClose: func() (err error) { panic("not implemented") },
}, tc.paths...)
if tc.wantErr != nil {
require.ErrorIs(t, err, tc.wantErr)
assert.Nil(t, hc)
| </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove Timeout: time.Minute * 5,
Transport: Context.transport,
</s> add Timeout: time.Minute * 5,
Transport: &http.Transport{
DialContext: customDialContext,
Proxy: getHTTPProxy,
TLSClientConfig: &tls.Config{
RootCAs: Context.tlsRoots,
CipherSuites: Context.tlsCipherIDs,
MinVersion: tls.VersionTLS12,
},
}, | OnClose: func() (err error) { return nil }, |
hc, err := NewHostsContainer(0, testFS, &aghtest.FSWatcher{
OnEvents: onEvents,
OnAdd: onAdd,
OnClose: func() (err error) { return nil },
}, tc.paths...)
if tc.wantErr != nil {
require.ErrorIs(t, err, tc.wantErr)
assert.Nil(t, hc) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer_test.go |
errWatcher := &aghtest.FSWatcher{
OnEvents: func() (e <-chan struct{}) { panic("not implemented") },
OnAdd: func(name string) (err error) { return errOnAdd },
OnClose: func() (err error) { panic("not implemented") },
}
hc, err := NewHostsContainer(0, testFS, errWatcher, p)
require.ErrorIs(t, err, errOnAdd)
| </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove defer func() { err = errors.Annotate(err, "%s: %w", hostsContainerPref) }()
</s> add defer func() { err = errors.Annotate(err, "%s: %w", hostsContainerPrefix) }() | OnClose: func() (err error) { return nil }, |
errWatcher := &aghtest.FSWatcher{
OnEvents: func() (e <-chan struct{}) { panic("not implemented") },
OnAdd: func(name string) (err error) { return errOnAdd },
OnClose: func() (err error) { return nil },
}
hc, err := NewHostsContainer(0, testFS, errWatcher, p)
require.ErrorIs(t, err, errOnAdd)
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer_test.go |
assert.Equal(t, "dir", name)
return nil
},
OnClose: func() (err error) { panic("not implemented") },
}
hc, err := NewHostsContainer(0, testFS, w, "dir")
require.NoError(t, err)
testutil.CleanupAndRequireSuccess(t, hc.Close)
| </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove Timeout: time.Minute * 5,
Transport: Context.transport,
</s> add Timeout: time.Minute * 5,
Transport: &http.Transport{
DialContext: customDialContext,
Proxy: getHTTPProxy,
TLSClientConfig: &tls.Config{
RootCAs: Context.tlsRoots,
CipherSuites: Context.tlsCipherIDs,
MinVersion: tls.VersionTLS12,
},
}, | OnClose: func() (err error) { return nil }, | assert.Equal(t, "dir", name)
return nil
},
OnClose: func() (err error) { return nil },
}
hc, err := NewHostsContainer(0, testFS, w, "dir")
require.NoError(t, err)
testutil.CleanupAndRequireSuccess(t, hc.Close) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer_test.go |
func TestHostsContainer_Translate(t *testing.T) {
stubWatcher := aghtest.FSWatcher{
OnEvents: func() (e <-chan struct{}) { return nil },
OnAdd: func(name string) (err error) { return nil },
OnClose: func() (err error) { panic("not implemented") },
}
require.NoError(t, fstest.TestFS(testdata, "etc_hosts"))
hc, err := NewHostsContainer(0, testdata, &stubWatcher, "etc_hosts")
| </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove defer func() { err = errors.Annotate(err, "%s: %w", hostsContainerPref) }()
</s> add defer func() { err = errors.Annotate(err, "%s: %w", hostsContainerPrefix) }() | OnClose: func() (err error) { return nil }, | func TestHostsContainer_Translate(t *testing.T) {
stubWatcher := aghtest.FSWatcher{
OnEvents: func() (e <-chan struct{}) { return nil },
OnAdd: func(name string) (err error) { return nil },
OnClose: func() (err error) { return nil },
}
require.NoError(t, fstest.TestFS(testdata, "etc_hosts"))
hc, err := NewHostsContainer(0, testdata, &stubWatcher, "etc_hosts") | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer_test.go |
stubWatcher := aghtest.FSWatcher{
OnEvents: func() (e <-chan struct{}) { return nil },
OnAdd: func(name string) (err error) { return nil },
OnClose: func() (err error) { panic("not implemented") },
}
hc, err := NewHostsContainer(listID, testdata, &stubWatcher, "etc_hosts")
require.NoError(t, err)
testutil.CleanupAndRequireSuccess(t, hc.Close)
| </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove defer func() { err = errors.Annotate(err, "%s: %w", hostsContainerPref) }()
</s> add defer func() { err = errors.Annotate(err, "%s: %w", hostsContainerPrefix) }() | OnClose: func() (err error) { return nil }, |
stubWatcher := aghtest.FSWatcher{
OnEvents: func() (e <-chan struct{}) { return nil },
OnAdd: func(name string) (err error) { return nil },
OnClose: func() (err error) { return nil },
}
hc, err := NewHostsContainer(listID, testdata, &stubWatcher, "etc_hosts")
require.NoError(t, err)
testutil.CleanupAndRequireSuccess(t, hc.Close) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer_test.go |
auth *Auth // HTTP authentication module
filters *filtering.DNSFilter // DNS filtering module
web *Web // Web (HTTP, HTTPS) module
tls *tlsManager // TLS module
// etcHosts is an IP-hostname pairs set taken from system configuration
// (e.g. /etc/hosts) files.
etcHosts *aghnet.HostsContainer
// hostsWatcher is the watcher to detect changes in the hosts files.
hostsWatcher aghos.FSWatcher
updater *updater.Updater
| </s> remove // hostsWatcher is the watcher to detect changes in the hosts files.
hostsWatcher aghos.FSWatcher
</s> add </s> remove // w tracks the changes in specified files and directories.
w aghos.FSWatcher
</s> add // watcher tracks the changes in specified files and directories.
watcher aghos.FSWatcher </s> remove // hostsContainerPref is a prefix for logging and wrapping errors in
</s> add // hostsContainerPrefix is a prefix for logging and wrapping errors in </s> remove const hostsContainerPref = "hosts container"
</s> add const hostsContainerPrefix = "hosts container" </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add | // etcHosts contains IP-hostname mappings taken from the OS-specific hosts
// configuration files, for example /etc/hosts. | auth *Auth // HTTP authentication module
filters *filtering.DNSFilter // DNS filtering module
web *Web // Web (HTTP, HTTPS) module
tls *tlsManager // TLS module
// etcHosts contains IP-hostname mappings taken from the OS-specific hosts
// configuration files, for example /etc/hosts.
// etcHosts contains IP-hostname mappings taken from the OS-specific hosts
// configuration files, for example /etc/hosts.
etcHosts *aghnet.HostsContainer
// hostsWatcher is the watcher to detect changes in the hosts files.
hostsWatcher aghos.FSWatcher
updater *updater.Updater | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go |
tls *tlsManager // TLS module
// etcHosts is an IP-hostname pairs set taken from system configuration
// (e.g. /etc/hosts) files.
etcHosts *aghnet.HostsContainer
// hostsWatcher is the watcher to detect changes in the hosts files.
hostsWatcher aghos.FSWatcher
updater *updater.Updater
// mux is our custom http.ServeMux.
mux *http.ServeMux
| </s> remove // etcHosts is an IP-hostname pairs set taken from system configuration
// (e.g. /etc/hosts) files.
</s> add // etcHosts contains IP-hostname mappings taken from the OS-specific hosts
// configuration files, for example /etc/hosts. </s> remove // w tracks the changes in specified files and directories.
w aghos.FSWatcher
</s> add // watcher tracks the changes in specified files and directories.
watcher aghos.FSWatcher </s> remove // hostsContainerPref is a prefix for logging and wrapping errors in
</s> add // hostsContainerPrefix is a prefix for logging and wrapping errors in </s> remove const hostsContainerPref = "hosts container"
</s> add const hostsContainerPrefix = "hosts container" </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add | tls *tlsManager // TLS module
// etcHosts is an IP-hostname pairs set taken from system configuration
// (e.g. /etc/hosts) files.
etcHosts *aghnet.HostsContainer
updater *updater.Updater
// mux is our custom http.ServeMux.
mux *http.ServeMux | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go |
|
workDir string // Location of our directory, used to protect against CWD being somewhere else
pidFileName string // PID file name. Empty if no PID file was created.
controlLock sync.Mutex
tlsRoots *x509.CertPool // list of root CAs for TLSv1.2
transport *http.Transport
client *http.Client
appSignalChannel chan os.Signal // Channel for receiving OS signals by the console app
// tlsCipherIDs are the ID of the cipher suites that AdGuard Home must use.
tlsCipherIDs []uint16
| </s> remove // w tracks the changes in specified files and directories.
w aghos.FSWatcher
</s> add // watcher tracks the changes in specified files and directories.
watcher aghos.FSWatcher </s> remove defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPref))
</s> add defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPrefix)) </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add </s> remove const hostsContainerPref = "hosts container"
</s> add const hostsContainerPrefix = "hosts container" </s> remove // hostsContainerPref is a prefix for logging and wrapping errors in
</s> add // hostsContainerPrefix is a prefix for logging and wrapping errors in | workDir string // Location of our directory, used to protect against CWD being somewhere else
pidFileName string // PID file name. Empty if no PID file was created.
controlLock sync.Mutex
tlsRoots *x509.CertPool // list of root CAs for TLSv1.2
client *http.Client
appSignalChannel chan os.Signal // Channel for receiving OS signals by the console app
// tlsCipherIDs are the ID of the cipher suites that AdGuard Home must use.
tlsCipherIDs []uint16 | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go |
|
func setupContext(opts options) {
setupContextFlags(opts)
Context.tlsRoots = aghtls.SystemRootCAs()
Context.transport = &http.Transport{
DialContext: customDialContext,
Proxy: getHTTPProxy,
TLSClientConfig: &tls.Config{
RootCAs: Context.tlsRoots,
CipherSuites: Context.tlsCipherIDs,
MinVersion: tls.VersionTLS12,
},
}
Context.client = &http.Client{
Timeout: time.Minute * 5,
Transport: Context.transport,
}
| </s> remove Timeout: time.Minute * 5,
Transport: Context.transport,
</s> add Timeout: time.Minute * 5,
Transport: &http.Transport{
DialContext: customDialContext,
Proxy: getHTTPProxy,
TLSClientConfig: &tls.Config{
RootCAs: Context.tlsRoots,
CipherSuites: Context.tlsCipherIDs,
MinVersion: tls.VersionTLS12,
},
}, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, </s> remove OnClose: func() (err error) { panic("not implemented") },
</s> add OnClose: func() (err error) { return nil }, | func setupContext(opts options) {
setupContextFlags(opts)
Context.tlsRoots = aghtls.SystemRootCAs()
Context.client = &http.Client{
Timeout: time.Minute * 5,
Transport: Context.transport,
}
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go |
|
MinVersion: tls.VersionTLS12,
},
}
Context.client = &http.Client{
Timeout: time.Minute * 5,
Transport: Context.transport,
}
if !Context.firstRun {
// Do the upgrade if necessary.
err := upgradeConfig()
| </s> remove Context.transport = &http.Transport{
DialContext: customDialContext,
Proxy: getHTTPProxy,
TLSClientConfig: &tls.Config{
RootCAs: Context.tlsRoots,
CipherSuites: Context.tlsCipherIDs,
MinVersion: tls.VersionTLS12,
},
}
</s> add </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add </s> remove Context.hostsWatcher, err = aghos.NewOSWritesWatcher()
</s> add hostsWatcher, err := aghos.NewOSWritesWatcher() </s> remove log.Error("%s: %s", hostsContainerPref, err)
</s> add log.Error("%s: %s", hostsContainerPrefix, err) </s> remove log.Debug("%s: closing", hostsContainerPref)
</s> add log.Debug("%s: closing", hostsContainerPrefix)
err = hc.watcher.Close()
if err != nil {
err = fmt.Errorf("closing fs watcher: %w", err)
// Go on and close the container either way.
} | Timeout: time.Minute * 5,
Transport: &http.Transport{
DialContext: customDialContext,
Proxy: getHTTPProxy,
TLSClientConfig: &tls.Config{
RootCAs: Context.tlsRoots,
CipherSuites: Context.tlsCipherIDs,
MinVersion: tls.VersionTLS12,
},
}, | MinVersion: tls.VersionTLS12,
},
}
Context.client = &http.Client{
Timeout: time.Minute * 5,
Transport: &http.Transport{
DialContext: customDialContext,
Proxy: getHTTPProxy,
TLSClientConfig: &tls.Config{
RootCAs: Context.tlsRoots,
CipherSuites: Context.tlsCipherIDs,
MinVersion: tls.VersionTLS12,
},
},
Timeout: time.Minute * 5,
Transport: &http.Transport{
DialContext: customDialContext,
Proxy: getHTTPProxy,
TLSClientConfig: &tls.Config{
RootCAs: Context.tlsRoots,
CipherSuites: Context.tlsCipherIDs,
MinVersion: tls.VersionTLS12,
},
},
}
if !Context.firstRun {
// Do the upgrade if necessary.
err := upgradeConfig() | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go |
// setupHostsContainer initializes the structures to keep up-to-date the hosts
// provided by the OS.
func setupHostsContainer() (err error) {
Context.hostsWatcher, err = aghos.NewOSWritesWatcher()
if err != nil {
return fmt.Errorf("initing hosts watcher: %w", err)
}
Context.etcHosts, err = aghnet.NewHostsContainer(
| </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add </s> remove log.Debug("%s: closing", hostsContainerPref)
</s> add log.Debug("%s: closing", hostsContainerPrefix)
err = hc.watcher.Close()
if err != nil {
err = fmt.Errorf("closing fs watcher: %w", err)
// Go on and close the container either way.
} </s> remove log.Debug("%s: refreshing", hostsContainerPref)
</s> add log.Debug("%s: refreshing", hostsContainerPrefix) </s> remove Context.hostsWatcher,
</s> add hostsWatcher, </s> remove const hostsContainerPref = "hosts container"
</s> add const hostsContainerPrefix = "hosts container" | hostsWatcher, err := aghos.NewOSWritesWatcher() |
// setupHostsContainer initializes the structures to keep up-to-date the hosts
// provided by the OS.
func setupHostsContainer() (err error) {
hostsWatcher, err := aghos.NewOSWritesWatcher()
if err != nil {
return fmt.Errorf("initing hosts watcher: %w", err)
}
Context.etcHosts, err = aghnet.NewHostsContainer( | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go |
Context.etcHosts, err = aghnet.NewHostsContainer(
filtering.SysHostsListID,
aghos.RootDirFS(),
Context.hostsWatcher,
aghnet.DefaultHostsPaths()...,
)
if err != nil {
cerr := Context.hostsWatcher.Close()
if errors.Is(err, aghnet.ErrNoHostsPaths) && cerr == nil {
| </s> remove cerr := Context.hostsWatcher.Close()
if errors.Is(err, aghnet.ErrNoHostsPaths) && cerr == nil {
</s> add closeErr := hostsWatcher.Close()
if errors.Is(err, aghnet.ErrNoHostsPaths) && closeErr == nil { </s> remove Context.hostsWatcher, err = aghos.NewOSWritesWatcher()
</s> add hostsWatcher, err := aghos.NewOSWritesWatcher() </s> remove defer func() { err = errors.Annotate(err, "%s: %w", hostsContainerPref) }()
</s> add defer func() { err = errors.Annotate(err, "%s: %w", hostsContainerPrefix) }() </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add </s> remove log.Debug("%s: watcher closed the events channel", hostsContainerPref)
</s> add log.Debug("%s: watcher closed the events channel", hostsContainerPrefix) | hostsWatcher, |
Context.etcHosts, err = aghnet.NewHostsContainer(
filtering.SysHostsListID,
aghos.RootDirFS(),
hostsWatcher,
aghnet.DefaultHostsPaths()...,
)
if err != nil {
cerr := Context.hostsWatcher.Close()
if errors.Is(err, aghnet.ErrNoHostsPaths) && cerr == nil { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go |
Context.hostsWatcher,
aghnet.DefaultHostsPaths()...,
)
if err != nil {
cerr := Context.hostsWatcher.Close()
if errors.Is(err, aghnet.ErrNoHostsPaths) && cerr == nil {
log.Info("warning: initing hosts container: %s", err)
return nil
}
| </s> remove Context.hostsWatcher,
</s> add hostsWatcher, </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add </s> remove log.Error("%s: %s", hostsContainerPref, err)
</s> add log.Error("%s: %s", hostsContainerPrefix, err) </s> remove Context.hostsWatcher, err = aghos.NewOSWritesWatcher()
</s> add hostsWatcher, err := aghos.NewOSWritesWatcher() </s> remove return errors.WithDeferred(fmt.Errorf("initing hosts container: %w", err), cerr)
</s> add return errors.WithDeferred(fmt.Errorf("initing hosts container: %w", err), closeErr) | closeErr := hostsWatcher.Close()
if errors.Is(err, aghnet.ErrNoHostsPaths) && closeErr == nil { | Context.hostsWatcher,
aghnet.DefaultHostsPaths()...,
)
if err != nil {
closeErr := hostsWatcher.Close()
if errors.Is(err, aghnet.ErrNoHostsPaths) && closeErr == nil {
closeErr := hostsWatcher.Close()
if errors.Is(err, aghnet.ErrNoHostsPaths) && closeErr == nil {
log.Info("warning: initing hosts container: %s", err)
return nil
}
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go |
return nil
}
return errors.WithDeferred(fmt.Errorf("initing hosts container: %w", err), cerr)
}
return nil
}
| </s> remove // Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
</s> add </s> remove cerr := Context.hostsWatcher.Close()
if errors.Is(err, aghnet.ErrNoHostsPaths) && cerr == nil {
</s> add closeErr := hostsWatcher.Close()
if errors.Is(err, aghnet.ErrNoHostsPaths) && closeErr == nil { </s> remove Context.hostsWatcher, err = aghos.NewOSWritesWatcher()
</s> add hostsWatcher, err := aghos.NewOSWritesWatcher() </s> remove log.Debug("%s: closing", hostsContainerPref)
</s> add log.Debug("%s: closing", hostsContainerPrefix)
err = hc.watcher.Close()
if err != nil {
err = fmt.Errorf("closing fs watcher: %w", err)
// Go on and close the container either way.
} </s> remove log.Debug("%s: no changes detected", hostsContainerPref)
</s> add log.Debug("%s: no changes detected", hostsContainerPrefix) | return errors.WithDeferred(fmt.Errorf("initing hosts container: %w", err), closeErr) |
return nil
}
return errors.WithDeferred(fmt.Errorf("initing hosts container: %w", err), closeErr)
}
return nil
}
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go |
}
}
if Context.etcHosts != nil {
// Currently Context.hostsWatcher is only used in Context.etcHosts and
// needs closing only in case of the successful initialization of
// Context.etcHosts.
if err = Context.hostsWatcher.Close(); err != nil {
log.Error("closing hosts watcher: %s", err)
}
if err = Context.etcHosts.Close(); err != nil {
log.Error("closing hosts container: %s", err)
}
}
| </s> remove log.Error("%s: %s", hostsContainerPref, err)
</s> add log.Error("%s: %s", hostsContainerPrefix, err) </s> remove log.Debug("%s: closing", hostsContainerPref)
</s> add log.Debug("%s: closing", hostsContainerPrefix)
err = hc.watcher.Close()
if err != nil {
err = fmt.Errorf("closing fs watcher: %w", err)
// Go on and close the container either way.
} </s> remove cerr := Context.hostsWatcher.Close()
if errors.Is(err, aghnet.ErrNoHostsPaths) && cerr == nil {
</s> add closeErr := hostsWatcher.Close()
if errors.Is(err, aghnet.ErrNoHostsPaths) && closeErr == nil { </s> remove Context.hostsWatcher, err = aghos.NewOSWritesWatcher()
</s> add hostsWatcher, err := aghos.NewOSWritesWatcher() </s> remove log.Error("%s: host %q is invalid, ignoring", hostsContainerPref, f)
</s> add log.Error("%s: host %q is invalid, ignoring", hostsContainerPrefix, f) | }
}
if Context.etcHosts != nil {
if err = Context.etcHosts.Close(); err != nil {
log.Error("closing hosts container: %s", err)
}
}
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commit of the following:
commit 402bbba6a68f163cd6a3751a50ecd544eebc875f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:07:11 2023 +0300
aghnet: names
commit 209a2bb7878ee9110595f1fcf09df7f83777b80f
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:03:33 2023 +0300
home: typo
commit 61684815c260d5d7a34be612e06714456399a833
Merge: 7adfcf15 132ec556
Author: Ainar Garipov <[email protected]>
Date: Tue Mar 28 13:02:18 2023 +0300
Merge branch 'master' into rm-context-fields
commit 7adfcf1576b52f80137aa9044355bfbec6243e28
Merge: 0d5b85f5 0df32601
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 14:25:27 2023 +0300
Merge branch 'master' into rm-context-fields
commit 0d5b85f51b3eb72c3e905d5ad82c17cd932b246b
Author: Ainar Garipov <[email protected]>
Date: Sun Mar 26 13:21:26 2023 +0300
all: rm unnecessary home context fields | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go |
|
// maxDomainLabelLen is the maximum allowed length of a domain name label
// according to RFC 1035.
const maxDomainLabelLen = 63
// maxDomainNameLen is the maximum allowed length of a full domain name
// according to RFC 1035.
//
// See https://stackoverflow.com/a/32294443/1892060.
const maxDomainNameLen = 253
| </s> remove const maxDomainNameLen = 253
</s> add const MaxDomainNameLen = 253 </s> remove } else if l > maxDomainNameLen {
return fmt.Errorf("too long, max: %d", maxDomainNameLen)
</s> add } else if l > MaxDomainNameLen {
return fmt.Errorf("too long, max: %d", MaxDomainNameLen) </s> remove func processUpstream(ctx *dnsContext) (rc resultCode) {
s := ctx.srv
</s> add func (s *Server) processUpstream(ctx *dnsContext) (rc resultCode) { | // MaxDomainNameLen is the maximum allowed length of a full domain name | // maxDomainLabelLen is the maximum allowed length of a domain name label
// according to RFC 1035.
const maxDomainLabelLen = 63
// MaxDomainNameLen is the maximum allowed length of a full domain name
// according to RFC 1035.
//
// See https://stackoverflow.com/a/32294443/1892060.
const maxDomainNameLen = 253
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/aghnet/addr.go |
// maxDomainNameLen is the maximum allowed length of a full domain name
// according to RFC 1035.
//
// See https://stackoverflow.com/a/32294443/1892060.
const maxDomainNameLen = 253
// ValidateDomainNameLabel returns an error if label is not a valid label of
// a domain name.
func ValidateDomainNameLabel(label string) (err error) {
defer func() { err = errors.Annotate(err, "validating label %q: %w", label) }()
| </s> remove // maxDomainNameLen is the maximum allowed length of a full domain name
</s> add // MaxDomainNameLen is the maximum allowed length of a full domain name </s> remove s := &Server{}
</s> add s := &Server{
recDetector: newRecursionDetector(0, 1),
} </s> remove } else if l > maxDomainNameLen {
return fmt.Errorf("too long, max: %d", maxDomainNameLen)
</s> add } else if l > MaxDomainNameLen {
return fmt.Errorf("too long, max: %d", MaxDomainNameLen) </s> remove func processUpstream(ctx *dnsContext) (rc resultCode) {
s := ctx.srv
</s> add func (s *Server) processUpstream(ctx *dnsContext) (rc resultCode) { | const MaxDomainNameLen = 253 | // maxDomainNameLen is the maximum allowed length of a full domain name
// according to RFC 1035.
//
// See https://stackoverflow.com/a/32294443/1892060.
const MaxDomainNameLen = 253
// ValidateDomainNameLabel returns an error if label is not a valid label of
// a domain name.
func ValidateDomainNameLabel(label string) (err error) {
defer func() { err = errors.Annotate(err, "validating label %q: %w", label) }() | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/aghnet/addr.go |
l := len(name)
if l == 0 {
return errors.Error("domain name is empty")
} else if l > maxDomainNameLen {
return fmt.Errorf("too long, max: %d", maxDomainNameLen)
}
labels := strings.Split(name, ".")
for i, l := range labels {
err = ValidateDomainNameLabel(l)
| </s> remove resp = ctx.Res
</s> add resp := ctx.Res </s> remove upstreamsConf := s.conf.GetCustomUpstreamByClient(clientIP)
if upstreamsConf != nil {
log.Debug("Using custom upstreams for %s", clientIP)
d.CustomUpstreamConfig = upstreamsConf
</s> add if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf </s> remove opt := d.Req.IsEdns0()
</s> add opt := req.IsEdns0() </s> remove log.Debug("dns: Adding OPT record with DNSSEC flag")
d.Req.SetEdns0(4096, true)
</s> add log.Debug("dns: adding OPT record with DNSSEC flag")
req.SetEdns0(4096, true) | } else if l > MaxDomainNameLen {
return fmt.Errorf("too long, max: %d", MaxDomainNameLen) |
l := len(name)
if l == 0 {
return errors.Error("domain name is empty")
} else if l > MaxDomainNameLen {
return fmt.Errorf("too long, max: %d", MaxDomainNameLen)
} else if l > MaxDomainNameLen {
return fmt.Errorf("too long, max: %d", MaxDomainNameLen)
}
labels := strings.Split(name, ".")
for i, l := range labels {
err = ValidateDomainNameLabel(l) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/aghnet/addr.go |
// out of range checking in any of the following functions, because the
// (*proxy.Proxy).handleDNSRequest method performs it before calling the
// appropriate handler.
mods := []modProcessFunc{
processInitial,
s.processDetermineLocal,
s.processInternalHosts,
s.processRestrictLocal,
s.processInternalIPAddrs,
processClientID,
| </s> remove // maxDomainNameLen is the maximum allowed length of a full domain name
</s> add // MaxDomainNameLen is the maximum allowed length of a full domain name </s> remove processUpstream,
</s> add s.processUpstream, </s> remove const maxDomainNameLen = 253
</s> add const MaxDomainNameLen = 253 | s.processRecursion, | // out of range checking in any of the following functions, because the
// (*proxy.Proxy).handleDNSRequest method performs it before calling the
// appropriate handler.
mods := []modProcessFunc{
s.processRecursion,
processInitial,
s.processDetermineLocal,
s.processInternalHosts,
s.processRestrictLocal,
s.processInternalIPAddrs,
processClientID, | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
s.processInternalIPAddrs,
processClientID,
processFilteringBeforeRequest,
s.processLocalPTR,
processUpstream,
processDNSSECAfterResponse,
processFilteringAfterResponse,
s.ipset.process,
processQueryLogsAndStats,
}
| </s> remove opt := d.Req.IsEdns0()
</s> add opt := req.IsEdns0() </s> remove s := &Server{}
</s> add s := &Server{
recDetector: newRecursionDetector(0, 1),
} | s.processUpstream, | s.processInternalIPAddrs,
processClientID,
processFilteringBeforeRequest,
s.processLocalPTR,
s.processUpstream,
processDNSSECAfterResponse,
processFilteringAfterResponse,
s.ipset.process,
processQueryLogsAndStats,
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
return nil
}
// Perform initial checks; process WHOIS & rDNS
func processInitial(ctx *dnsContext) (rc resultCode) {
s := ctx.srv
d := ctx.proxyCtx
if s.conf.AAAADisabled && d.Req.Question[0].Qtype == dns.TypeAAAA {
_ = proxy.CheckDisabledAAAARequest(d, true)
| </s> remove func processUpstream(ctx *dnsContext) (rc resultCode) {
s := ctx.srv
</s> add func (s *Server) processUpstream(ctx *dnsContext) (rc resultCode) { </s> remove s := &Server{}
</s> add s := &Server{
recDetector: newRecursionDetector(0, 1),
} </s> remove upstreamsConf := s.conf.GetCustomUpstreamByClient(clientIP)
if upstreamsConf != nil {
log.Debug("Using custom upstreams for %s", clientIP)
d.CustomUpstreamConfig = upstreamsConf
</s> add if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf </s> remove log.Debug("dns: Adding OPT record with DNSSEC flag")
d.Req.SetEdns0(4096, true)
</s> add log.Debug("dns: adding OPT record with DNSSEC flag")
req.SetEdns0(4096, true) | // processRecursion checks the incoming request and halts it's handling if s
// have tried to resolve it recently.
func (s *Server) processRecursion(dctx *dnsContext) (rc resultCode) {
pctx := dctx.proxyCtx
if msg := pctx.Req; msg != nil && s.recDetector.check(*msg) {
log.Debug("recursion detected resolving %q", msg.Question[0].Name)
pctx.Res = s.genNXDomain(pctx.Req)
return resultCodeFinish
}
return resultCodeSuccess
}
| return nil
}
// processRecursion checks the incoming request and halts it's handling if s
// have tried to resolve it recently.
func (s *Server) processRecursion(dctx *dnsContext) (rc resultCode) {
pctx := dctx.proxyCtx
if msg := pctx.Req; msg != nil && s.recDetector.check(*msg) {
log.Debug("recursion detected resolving %q", msg.Question[0].Name)
pctx.Res = s.genNXDomain(pctx.Req)
return resultCodeFinish
}
return resultCodeSuccess
}
// Perform initial checks; process WHOIS & rDNS
func processInitial(ctx *dnsContext) (rc resultCode) {
s := ctx.srv
d := ctx.proxyCtx
if s.conf.AAAADisabled && d.Req.Question[0].Qtype == dns.TypeAAAA {
_ = proxy.CheckDisabledAAAARequest(d, true) | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
}
if s.conf.UsePrivateRDNS {
if err := s.localResolvers.Resolve(d); err != nil {
ctx.err = err
return resultCodeError
}
}
| </s> remove err := s.dnsProxy.Resolve(d)
if err != nil {
ctx.err = err
</s> add s.recDetector.add(*req)
if ctx.err = s.dnsProxy.Resolve(d); ctx.err != nil { </s> remove var resp *dns.Msg
err = resolver.Resolve(ctx)
if err != nil {
</s> add s.recDetector.add(*req)
if err = resolver.Resolve(ctx); err != nil { </s> remove resp = ctx.Res
</s> add resp := ctx.Res </s> remove upstreamsConf := s.conf.GetCustomUpstreamByClient(clientIP)
if upstreamsConf != nil {
log.Debug("Using custom upstreams for %s", clientIP)
d.CustomUpstreamConfig = upstreamsConf
</s> add if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf </s> remove } else if l > maxDomainNameLen {
return fmt.Errorf("too long, max: %d", maxDomainNameLen)
</s> add } else if l > MaxDomainNameLen {
return fmt.Errorf("too long, max: %d", MaxDomainNameLen) | s.recDetector.add(*d.Req) | }
if s.conf.UsePrivateRDNS {
s.recDetector.add(*d.Req)
if err := s.localResolvers.Resolve(d); err != nil {
ctx.err = err
return resultCodeError
}
} | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
return resultCodeSuccess
}
// processUpstream passes request to upstream servers and handles the response.
func processUpstream(ctx *dnsContext) (rc resultCode) {
s := ctx.srv
d := ctx.proxyCtx
if d.Res != nil {
return resultCodeSuccess // response is already set - nothing to do
}
| </s> remove err := s.dnsProxy.Resolve(d)
if err != nil {
ctx.err = err
</s> add s.recDetector.add(*req)
if ctx.err = s.dnsProxy.Resolve(d); ctx.err != nil { </s> remove s := &Server{}
</s> add s := &Server{
recDetector: newRecursionDetector(0, 1),
} </s> remove upstreamsConf := s.conf.GetCustomUpstreamByClient(clientIP)
if upstreamsConf != nil {
log.Debug("Using custom upstreams for %s", clientIP)
d.CustomUpstreamConfig = upstreamsConf
</s> add if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf | func (s *Server) processUpstream(ctx *dnsContext) (rc resultCode) { | return resultCodeSuccess
}
// processUpstream passes request to upstream servers and handles the response.
func (s *Server) processUpstream(ctx *dnsContext) (rc resultCode) {
func (s *Server) processUpstream(ctx *dnsContext) (rc resultCode) {
d := ctx.proxyCtx
if d.Res != nil {
return resultCodeSuccess // response is already set - nothing to do
}
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
}
if d.Addr != nil && s.conf.GetCustomUpstreamByClient != nil {
clientIP := IPStringFromAddr(d.Addr)
upstreamsConf := s.conf.GetCustomUpstreamByClient(clientIP)
if upstreamsConf != nil {
log.Debug("Using custom upstreams for %s", clientIP)
d.CustomUpstreamConfig = upstreamsConf
}
}
if s.conf.EnableDNSSEC {
opt := d.Req.IsEdns0()
| </s> remove opt := d.Req.IsEdns0()
</s> add opt := req.IsEdns0() </s> remove log.Debug("dns: Adding OPT record with DNSSEC flag")
d.Req.SetEdns0(4096, true)
</s> add log.Debug("dns: adding OPT record with DNSSEC flag")
req.SetEdns0(4096, true) </s> remove resp = ctx.Res
</s> add resp := ctx.Res | if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf | }
if d.Addr != nil && s.conf.GetCustomUpstreamByClient != nil {
clientIP := IPStringFromAddr(d.Addr)
if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf
if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf
if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf
if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf
}
}
if s.conf.EnableDNSSEC {
opt := d.Req.IsEdns0() | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
}
}
if s.conf.EnableDNSSEC {
opt := req.IsEdns0()
if opt == nil {
log.Debug("dns: adding OPT record with DNSSEC flag")
req.SetEdns0(4096, true)
} else if !opt.Do() {
| </s> remove log.Debug("dns: Adding OPT record with DNSSEC flag")
d.Req.SetEdns0(4096, true)
</s> add log.Debug("dns: adding OPT record with DNSSEC flag")
req.SetEdns0(4096, true) </s> remove opt := d.Req.IsEdns0()
</s> add opt := req.IsEdns0() </s> remove upstreamsConf := s.conf.GetCustomUpstreamByClient(clientIP)
if upstreamsConf != nil {
log.Debug("Using custom upstreams for %s", clientIP)
d.CustomUpstreamConfig = upstreamsConf
</s> add if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf </s> remove } else if l > maxDomainNameLen {
return fmt.Errorf("too long, max: %d", maxDomainNameLen)
</s> add } else if l > MaxDomainNameLen {
return fmt.Errorf("too long, max: %d", MaxDomainNameLen) | req := d.Req | }
}
req := d.Req
if s.conf.EnableDNSSEC {
opt := req.IsEdns0()
if opt == nil {
log.Debug("dns: adding OPT record with DNSSEC flag")
req.SetEdns0(4096, true)
} else if !opt.Do() { | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
}
}
if s.conf.EnableDNSSEC {
opt := d.Req.IsEdns0()
if opt == nil {
log.Debug("dns: Adding OPT record with DNSSEC flag")
d.Req.SetEdns0(4096, true)
} else if !opt.Do() {
opt.SetDo(true)
| </s> remove log.Debug("dns: Adding OPT record with DNSSEC flag")
d.Req.SetEdns0(4096, true)
</s> add log.Debug("dns: adding OPT record with DNSSEC flag")
req.SetEdns0(4096, true) </s> remove upstreamsConf := s.conf.GetCustomUpstreamByClient(clientIP)
if upstreamsConf != nil {
log.Debug("Using custom upstreams for %s", clientIP)
d.CustomUpstreamConfig = upstreamsConf
</s> add if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf </s> remove } else if l > maxDomainNameLen {
return fmt.Errorf("too long, max: %d", maxDomainNameLen)
</s> add } else if l > MaxDomainNameLen {
return fmt.Errorf("too long, max: %d", MaxDomainNameLen) | opt := req.IsEdns0() | }
}
if s.conf.EnableDNSSEC {
opt := req.IsEdns0()
if opt == nil {
log.Debug("dns: Adding OPT record with DNSSEC flag")
d.Req.SetEdns0(4096, true)
} else if !opt.Do() {
opt.SetDo(true) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
if s.conf.EnableDNSSEC {
opt := d.Req.IsEdns0()
if opt == nil {
log.Debug("dns: Adding OPT record with DNSSEC flag")
d.Req.SetEdns0(4096, true)
} else if !opt.Do() {
opt.SetDo(true)
} else {
ctx.origReqDNSSEC = true
}
| </s> remove opt := d.Req.IsEdns0()
</s> add opt := req.IsEdns0() </s> remove upstreamsConf := s.conf.GetCustomUpstreamByClient(clientIP)
if upstreamsConf != nil {
log.Debug("Using custom upstreams for %s", clientIP)
d.CustomUpstreamConfig = upstreamsConf
</s> add if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf </s> remove } else if l > maxDomainNameLen {
return fmt.Errorf("too long, max: %d", maxDomainNameLen)
</s> add } else if l > MaxDomainNameLen {
return fmt.Errorf("too long, max: %d", MaxDomainNameLen) </s> remove err := s.dnsProxy.Resolve(d)
if err != nil {
ctx.err = err
</s> add s.recDetector.add(*req)
if ctx.err = s.dnsProxy.Resolve(d); ctx.err != nil { | log.Debug("dns: adding OPT record with DNSSEC flag")
req.SetEdns0(4096, true) |
if s.conf.EnableDNSSEC {
opt := d.Req.IsEdns0()
if opt == nil {
log.Debug("dns: adding OPT record with DNSSEC flag")
req.SetEdns0(4096, true)
log.Debug("dns: adding OPT record with DNSSEC flag")
req.SetEdns0(4096, true)
} else if !opt.Do() {
opt.SetDo(true)
} else {
ctx.origReqDNSSEC = true
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
}
}
// request was not filtered so let it be processed further
err := s.dnsProxy.Resolve(d)
if err != nil {
ctx.err = err
return resultCodeError
}
ctx.responseFromUpstream = true
return resultCodeSuccess
| </s> remove var resp *dns.Msg
err = resolver.Resolve(ctx)
if err != nil {
</s> add s.recDetector.add(*req)
if err = resolver.Resolve(ctx); err != nil { </s> remove resp = ctx.Res
</s> add resp := ctx.Res </s> remove log.Debug("dns: Adding OPT record with DNSSEC flag")
d.Req.SetEdns0(4096, true)
</s> add log.Debug("dns: adding OPT record with DNSSEC flag")
req.SetEdns0(4096, true) | s.recDetector.add(*req)
if ctx.err = s.dnsProxy.Resolve(d); ctx.err != nil { | }
}
// request was not filtered so let it be processed further
s.recDetector.add(*req)
if ctx.err = s.dnsProxy.Resolve(d); ctx.err != nil {
s.recDetector.add(*req)
if ctx.err = s.dnsProxy.Resolve(d); ctx.err != nil {
s.recDetector.add(*req)
if ctx.err = s.dnsProxy.Resolve(d); ctx.err != nil {
return resultCodeError
}
ctx.responseFromUpstream = true
return resultCodeSuccess | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
ipset ipsetCtx
subnetDetector *aghnet.SubnetDetector
localResolvers *proxy.Proxy
tableHostToIP hostToIPTable
tableHostToIPLock sync.Mutex
tableIPToHost ipToHostTable
tableIPToHostLock sync.Mutex
| </s> remove upstreamsConf := s.conf.GetCustomUpstreamByClient(clientIP)
if upstreamsConf != nil {
log.Debug("Using custom upstreams for %s", clientIP)
d.CustomUpstreamConfig = upstreamsConf
</s> add if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf </s> remove const maxDomainNameLen = 253
</s> add const MaxDomainNameLen = 253 </s> remove } else if l > maxDomainNameLen {
return fmt.Errorf("too long, max: %d", maxDomainNameLen)
</s> add } else if l > MaxDomainNameLen {
return fmt.Errorf("too long, max: %d", MaxDomainNameLen) | recDetector *recursionDetector | ipset ipsetCtx
subnetDetector *aghnet.SubnetDetector
localResolvers *proxy.Proxy
recDetector *recursionDetector
tableHostToIP hostToIPTable
tableHostToIPLock sync.Mutex
tableIPToHost ipToHostTable
tableIPToHostLock sync.Mutex | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dnsforward.go |
return string(b)
}
// NewServer creates a new instance of the dnsforward.Server
// Note: this function must be called only once
func NewServer(p DNSCreateParams) (s *Server, err error) {
var localDomainSuffix string
if p.LocalDomain == "" {
localDomainSuffix = defaultLocalDomainSuffix
| </s> remove s := &Server{}
</s> add s := &Server{
recDetector: newRecursionDetector(0, 1),
} </s> remove const maxDomainNameLen = 253
</s> add const MaxDomainNameLen = 253 </s> remove var resp *dns.Msg
err = resolver.Resolve(ctx)
if err != nil {
</s> add s.recDetector.add(*req)
if err = resolver.Resolve(ctx); err != nil { </s> remove err := s.dnsProxy.Resolve(d)
if err != nil {
ctx.err = err
</s> add s.recDetector.add(*req)
if ctx.err = s.dnsProxy.Resolve(d); ctx.err != nil { | const (
// recursionTTL is the time recursive request is cached for.
recursionTTL = 5 * time.Second
// cachedRecurrentReqNum is the maximum number of cached recurrent
// requests.
cachedRecurrentReqNum = 1000
)
|
return string(b)
}
const (
// recursionTTL is the time recursive request is cached for.
recursionTTL = 5 * time.Second
// cachedRecurrentReqNum is the maximum number of cached recurrent
// requests.
cachedRecurrentReqNum = 1000
)
// NewServer creates a new instance of the dnsforward.Server
// Note: this function must be called only once
func NewServer(p DNSCreateParams) (s *Server, err error) {
var localDomainSuffix string
if p.LocalDomain == "" {
localDomainSuffix = defaultLocalDomainSuffix | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dnsforward.go |
queryLog: p.QueryLog,
subnetDetector: p.SubnetDetector,
localDomainSuffix: localDomainSuffix,
}
if p.DHCPServer != nil {
s.dhcpServer = p.DHCPServer
s.dhcpServer.SetOnLeaseChanged(s.onDHCPLeaseChanged)
s.onDHCPLeaseChanged(dhcpd.LeaseChangedAdded)
| </s> remove upstreamsConf := s.conf.GetCustomUpstreamByClient(clientIP)
if upstreamsConf != nil {
log.Debug("Using custom upstreams for %s", clientIP)
d.CustomUpstreamConfig = upstreamsConf
</s> add if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf </s> remove var resp *dns.Msg
err = resolver.Resolve(ctx)
if err != nil {
</s> add s.recDetector.add(*req)
if err = resolver.Resolve(ctx); err != nil { </s> remove err := s.dnsProxy.Resolve(d)
if err != nil {
ctx.err = err
</s> add s.recDetector.add(*req)
if ctx.err = s.dnsProxy.Resolve(d); ctx.err != nil { </s> remove resp = ctx.Res
</s> add resp := ctx.Res | recDetector: newRecursionDetector(recursionTTL, cachedRecurrentReqNum), | queryLog: p.QueryLog,
subnetDetector: p.SubnetDetector,
localDomainSuffix: localDomainSuffix,
recDetector: newRecursionDetector(recursionTTL, cachedRecurrentReqNum),
}
if p.DHCPServer != nil {
s.dhcpServer = p.DHCPServer
s.dhcpServer.SetOnLeaseChanged(s.onDHCPLeaseChanged)
s.onDHCPLeaseChanged(dhcpd.LeaseChangedAdded) | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dnsforward.go |
}
// NewCustomServer creates a new instance of *Server with custom internal proxy.
func NewCustomServer(internalProxy *proxy.Proxy) *Server {
s := &Server{}
if internalProxy != nil {
s.internalProxy = internalProxy
}
return s
| </s> remove upstreamsConf := s.conf.GetCustomUpstreamByClient(clientIP)
if upstreamsConf != nil {
log.Debug("Using custom upstreams for %s", clientIP)
d.CustomUpstreamConfig = upstreamsConf
</s> add if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf </s> remove func processUpstream(ctx *dnsContext) (rc resultCode) {
s := ctx.srv
</s> add func (s *Server) processUpstream(ctx *dnsContext) (rc resultCode) { </s> remove log.Debug("dns: Adding OPT record with DNSSEC flag")
d.Req.SetEdns0(4096, true)
</s> add log.Debug("dns: adding OPT record with DNSSEC flag")
req.SetEdns0(4096, true) | s := &Server{
recDetector: newRecursionDetector(0, 1),
} | }
// NewCustomServer creates a new instance of *Server with custom internal proxy.
func NewCustomServer(internalProxy *proxy.Proxy) *Server {
s := &Server{
recDetector: newRecursionDetector(0, 1),
}
if internalProxy != nil {
s.internalProxy = internalProxy
}
return s | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dnsforward.go |
Proto: "udp",
Req: req,
StartTime: time.Now(),
}
var resp *dns.Msg
err = resolver.Resolve(ctx)
if err != nil {
return "", err
}
resp = ctx.Res
| </s> remove resp = ctx.Res
</s> add resp := ctx.Res </s> remove err := s.dnsProxy.Resolve(d)
if err != nil {
ctx.err = err
</s> add s.recDetector.add(*req)
if ctx.err = s.dnsProxy.Resolve(d); ctx.err != nil { </s> remove upstreamsConf := s.conf.GetCustomUpstreamByClient(clientIP)
if upstreamsConf != nil {
log.Debug("Using custom upstreams for %s", clientIP)
d.CustomUpstreamConfig = upstreamsConf
</s> add if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf | s.recDetector.add(*req)
if err = resolver.Resolve(ctx); err != nil { | Proto: "udp",
Req: req,
StartTime: time.Now(),
}
s.recDetector.add(*req)
if err = resolver.Resolve(ctx); err != nil {
s.recDetector.add(*req)
if err = resolver.Resolve(ctx); err != nil {
s.recDetector.add(*req)
if err = resolver.Resolve(ctx); err != nil {
return "", err
}
resp = ctx.Res
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dnsforward.go |
if err != nil {
return "", err
}
resp = ctx.Res
if len(resp.Answer) == 0 {
return "", fmt.Errorf("lookup for %q: %w", arpa, rDNSEmptyAnswerErr)
}
ptr, ok := resp.Answer[0].(*dns.PTR)
| </s> remove var resp *dns.Msg
err = resolver.Resolve(ctx)
if err != nil {
</s> add s.recDetector.add(*req)
if err = resolver.Resolve(ctx); err != nil { </s> remove } else if l > maxDomainNameLen {
return fmt.Errorf("too long, max: %d", maxDomainNameLen)
</s> add } else if l > MaxDomainNameLen {
return fmt.Errorf("too long, max: %d", MaxDomainNameLen) </s> remove upstreamsConf := s.conf.GetCustomUpstreamByClient(clientIP)
if upstreamsConf != nil {
log.Debug("Using custom upstreams for %s", clientIP)
d.CustomUpstreamConfig = upstreamsConf
</s> add if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf </s> remove err := s.dnsProxy.Resolve(d)
if err != nil {
ctx.err = err
</s> add s.recDetector.add(*req)
if ctx.err = s.dnsProxy.Resolve(d); ctx.err != nil { | resp := ctx.Res | if err != nil {
return "", err
}
resp := ctx.Res
resp := ctx.Res
if len(resp.Answer) == 0 {
return "", fmt.Errorf("lookup for %q: %w", arpa, rDNSEmptyAnswerErr)
}
ptr, ok := resp.Answer[0].(*dns.PTR) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dnsforward.go |
return fmt.Errorf("setting up resolvers: %w", err)
}
return nil
}
// Stop stops the DNS server.
func (s *Server) Stop() error {
s.serverLock.Lock()
| </s> remove func processUpstream(ctx *dnsContext) (rc resultCode) {
s := ctx.srv
</s> add func (s *Server) processUpstream(ctx *dnsContext) (rc resultCode) { </s> remove const maxDomainNameLen = 253
</s> add const MaxDomainNameLen = 253 </s> remove resp = ctx.Res
</s> add resp := ctx.Res </s> remove s := &Server{}
</s> add s := &Server{
recDetector: newRecursionDetector(0, 1),
} | s.recDetector.clear()
| return fmt.Errorf("setting up resolvers: %w", err)
}
s.recDetector.clear()
return nil
}
// Stop stops the DNS server.
func (s *Server) Stop() error {
s.serverLock.Lock() | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #3185.
Squashed commit of the following:
commit 2fa44223f533c471f2b8c0e17d8550bf4ff73c7b
Merge: 7975957c 7a48e92e
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 19:04:44 2021 +0300
Merge branch 'master' into 3185-recursion
commit 7975957cceb840f76eef0e2e434f4163a122ac34
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:36:22 2021 +0300
dnsforward: imp docs
commit 1af7131a5b7c1fefed2d1eb8ee24ebfd3602dc77
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 17:15:00 2021 +0300
dnsforward: imp code, tests, docs
commit f3f9145fb5e1174fab87ca6890da9df722cfebf0
Author: Eugene Burkov <[email protected]>
Date: Thu May 27 15:45:44 2021 +0300
dnsforward: add recursion detector | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dnsforward.go |
"fmt"
"os/exec"
"syscall"
)
// UnsupportedError is returned by functions and methods when a particular
| </s> remove // ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
//
// TODO(a.garipov): Make a structured error and use it everywhere instead of
// a bunch of fmt.Errorf and all that.
const ErrUnsupported errors.Error = "unsupported"
</s> add // UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
} </s> remove
"github.com/AdguardTeam/golibs/errors"
</s> add </s> remove "fmt"
</s> add </s> remove "github.com/AdguardTeam/golibs/errors"
</s> add "github.com/AdguardTeam/AdGuardHome/internal/aghos" </s> remove ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client
Language string `yaml:"language"` // two-letter ISO 639-1 language code
RlimitNoFile uint64 `yaml:"rlimit_nofile"` // Maximum number of opened fd's per process (0: default)
DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060
</s> add ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client
Language string `yaml:"language"` // two-letter ISO 639-1 language code
DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060 | "runtime" | "fmt"
"os/exec"
"runtime"
"syscall"
)
// UnsupportedError is returned by functions and methods when a particular | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/aghos/os.go |
import (
"fmt"
"os/exec"
"syscall"
"github.com/AdguardTeam/golibs/errors"
)
// ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
//
| </s> remove // ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
//
// TODO(a.garipov): Make a structured error and use it everywhere instead of
// a bunch of fmt.Errorf and all that.
const ErrUnsupported errors.Error = "unsupported"
</s> add // UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
} </s> remove "fmt"
</s> add </s> remove const currentSchemaVersion = 10
</s> add const currentSchemaVersion = 11 </s> remove "github.com/AdguardTeam/golibs/errors"
</s> add "github.com/AdguardTeam/AdGuardHome/internal/aghos" | import (
"fmt"
"os/exec"
"syscall"
)
// ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
// | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/aghos/os.go |
|
"github.com/AdguardTeam/golibs/errors"
)
// ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
//
// TODO(a.garipov): Make a structured error and use it everywhere instead of
// a bunch of fmt.Errorf and all that.
const ErrUnsupported errors.Error = "unsupported"
// CanBindPrivilegedPorts checks if current process can bind to privileged
// ports.
func CanBindPrivilegedPorts() (can bool, err error) {
return canBindPrivilegedPorts()
| </s> remove
"github.com/AdguardTeam/golibs/errors"
</s> add </s> remove const currentSchemaVersion = 10
</s> add const currentSchemaVersion = 11 </s> remove log.Fatal("service actions are not supported on openbsd")
</s> add log.Fatal("service actions are not supported on openbsd, see issue 3226") | // UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
} |
"github.com/AdguardTeam/golibs/errors"
)
// UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
}
// UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
}
// UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
}
// UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
}
// UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
}
// UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
}
// CanBindPrivilegedPorts checks if current process can bind to privileged
// ports.
func CanBindPrivilegedPorts() (can bool, err error) {
return canBindPrivilegedPorts() | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/aghos/os.go |
package aghos
import (
"fmt"
"syscall"
"golang.org/x/sys/windows"
)
| </s> remove
"github.com/AdguardTeam/golibs/errors"
</s> add </s> remove import "fmt"
</s> add import "github.com/AdguardTeam/AdGuardHome/internal/aghos" </s> remove "github.com/AdguardTeam/golibs/errors"
</s> add "github.com/AdguardTeam/AdGuardHome/internal/aghos" </s> remove return false, fmt.Errorf("not supported")
</s> add return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4") |
package aghos
import (
"syscall"
"golang.org/x/sys/windows"
)
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/aghos/os_windows.go |
|
return HaveAdminRights()
}
func setRlimit(val uint64) (err error) {
return ErrUnsupported
}
func haveAdminRights() (bool, error) {
var token windows.Token
h := windows.CurrentProcess()
| </s> remove return false, fmt.Errorf("not supported")
</s> add return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4") </s> remove return false, fmt.Errorf("not supported")
</s> add return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV6") </s> remove import "fmt"
</s> add import "github.com/AdguardTeam/AdGuardHome/internal/aghos" </s> remove // ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
//
// TODO(a.garipov): Make a structured error and use it everywhere instead of
// a bunch of fmt.Errorf and all that.
const ErrUnsupported errors.Error = "unsupported"
</s> add // UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
} </s> remove func newBroadcastPacketConn(bindAddr net.IP, port int, ifname string) (*ipv4.PacketConn, error) {
return nil, errors.Error("newBroadcastPacketConn(): not supported on Windows")
</s> add func newBroadcastPacketConn(_ net.IP, _ int, _ string) (*ipv4.PacketConn, error) {
return nil, aghos.Unsupported("newBroadcastPacketConn") | return Unsupported("setrlimit") | return HaveAdminRights()
}
func setRlimit(val uint64) (err error) {
return Unsupported("setrlimit")
}
func haveAdminRights() (bool, error) {
var token windows.Token
h := windows.CurrentProcess() | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/aghos/os_windows.go |
return true, nil
}
func sendProcessSignal(pid int, sig syscall.Signal) error {
return fmt.Errorf("not supported on Windows")
}
func isOpenWrt() (ok bool) {
return false
}
| </s> remove func newBroadcastPacketConn(bindAddr net.IP, port int, ifname string) (*ipv4.PacketConn, error) {
return nil, errors.Error("newBroadcastPacketConn(): not supported on Windows")
</s> add func newBroadcastPacketConn(_ net.IP, _ int, _ string) (*ipv4.PacketConn, error) {
return nil, aghos.Unsupported("newBroadcastPacketConn") </s> remove return false, fmt.Errorf("not supported")
</s> add return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4") </s> remove return false, fmt.Errorf("not supported")
</s> add return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV6") </s> remove if config.RlimitNoFile != 0 {
err = aghos.SetRlimit(config.RlimitNoFile)
if err != nil && !errors.Is(err, aghos.ErrUnsupported) {
return fmt.Errorf("setting rlimit: %w", err)
}
}
</s> add </s> remove import "fmt"
</s> add import "github.com/AdguardTeam/AdGuardHome/internal/aghos" | return Unsupported("kill") | return true, nil
}
func sendProcessSignal(pid int, sig syscall.Signal) error {
return Unsupported("kill")
}
func isOpenWrt() (ok bool) {
return false
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/aghos/os_windows.go |
"runtime"
"time"
"github.com/AdguardTeam/AdGuardHome/internal/aghnet"
"github.com/AdguardTeam/golibs/errors"
"github.com/AdguardTeam/golibs/log"
"github.com/insomniacslk/dhcp/dhcpv4"
"github.com/insomniacslk/dhcp/dhcpv4/nclient4"
"github.com/insomniacslk/dhcp/dhcpv6"
"github.com/insomniacslk/dhcp/dhcpv6/nclient6"
| </s> remove
"github.com/AdguardTeam/golibs/errors"
</s> add </s> remove "github.com/AdguardTeam/golibs/errors"
</s> add "github.com/AdguardTeam/AdGuardHome/internal/aghos" </s> remove // ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
//
// TODO(a.garipov): Make a structured error and use it everywhere instead of
// a bunch of fmt.Errorf and all that.
const ErrUnsupported errors.Error = "unsupported"
</s> add // UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
} </s> remove return false, fmt.Errorf("not supported")
</s> add return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4") | "github.com/AdguardTeam/AdGuardHome/internal/aghos" | "runtime"
"time"
"github.com/AdguardTeam/AdGuardHome/internal/aghnet"
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
"github.com/AdguardTeam/golibs/errors"
"github.com/AdguardTeam/golibs/log"
"github.com/insomniacslk/dhcp/dhcpv4"
"github.com/insomniacslk/dhcp/dhcpv4/nclient4"
"github.com/insomniacslk/dhcp/dhcpv6"
"github.com/insomniacslk/dhcp/dhcpv6/nclient6" | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/dhcpd/checkother.go |
// TODO(a.garipov): Find out what this is about. Perhaps this
// information is outdated or at least incomplete.
if runtime.GOOS == "darwin" {
return false, fmt.Errorf("can't find DHCP server: not supported on macOS")
}
srcIP := ifaceIPNet[0]
src := aghnet.JoinHostPort(srcIP.String(), 68)
dst := "255.255.255.255:67"
| </s> remove log.Fatal("service actions are not supported on openbsd")
</s> add log.Fatal("service actions are not supported on openbsd, see issue 3226") </s> remove return ErrUnsupported
</s> add return Unsupported("setrlimit") </s> remove // ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
//
// TODO(a.garipov): Make a structured error and use it everywhere instead of
// a bunch of fmt.Errorf and all that.
const ErrUnsupported errors.Error = "unsupported"
</s> add // UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
} </s> remove func newBroadcastPacketConn(bindAddr net.IP, port int, ifname string) (*ipv4.PacketConn, error) {
return nil, errors.Error("newBroadcastPacketConn(): not supported on Windows")
</s> add func newBroadcastPacketConn(_ net.IP, _ int, _ string) (*ipv4.PacketConn, error) {
return nil, aghos.Unsupported("newBroadcastPacketConn") | return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4") |
// TODO(a.garipov): Find out what this is about. Perhaps this
// information is outdated or at least incomplete.
if runtime.GOOS == "darwin" {
return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4")
}
srcIP := ifaceIPNet[0]
src := aghnet.JoinHostPort(srcIP.String(), 68)
dst := "255.255.255.255:67" | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/dhcpd/checkother.go |
package dhcpd
import "fmt"
func CheckIfOtherDHCPServersPresentV4(ifaceName string) (bool, error) {
return false, fmt.Errorf("not supported")
}
| </s> remove return false, fmt.Errorf("not supported")
</s> add return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4") </s> remove return false, fmt.Errorf("not supported")
</s> add return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV6") </s> remove "fmt"
</s> add </s> remove return ErrUnsupported
</s> add return Unsupported("setrlimit") </s> remove return fmt.Errorf("not supported on Windows")
</s> add return Unsupported("kill") | import "github.com/AdguardTeam/AdGuardHome/internal/aghos" | package dhcpd
import "github.com/AdguardTeam/AdGuardHome/internal/aghos"
func CheckIfOtherDHCPServersPresentV4(ifaceName string) (bool, error) {
return false, fmt.Errorf("not supported")
}
| [
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/dhcpd/checkother_windows.go |
import "fmt"
func CheckIfOtherDHCPServersPresentV4(ifaceName string) (bool, error) {
return false, fmt.Errorf("not supported")
}
func CheckIfOtherDHCPServersPresentV6(ifaceName string) (bool, error) {
return false, fmt.Errorf("not supported")
}
| </s> remove return false, fmt.Errorf("not supported")
</s> add return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV6") </s> remove import "fmt"
</s> add import "github.com/AdguardTeam/AdGuardHome/internal/aghos" </s> remove return ErrUnsupported
</s> add return Unsupported("setrlimit") </s> remove return fmt.Errorf("not supported on Windows")
</s> add return Unsupported("kill") </s> remove func newBroadcastPacketConn(bindAddr net.IP, port int, ifname string) (*ipv4.PacketConn, error) {
return nil, errors.Error("newBroadcastPacketConn(): not supported on Windows")
</s> add func newBroadcastPacketConn(_ net.IP, _ int, _ string) (*ipv4.PacketConn, error) {
return nil, aghos.Unsupported("newBroadcastPacketConn") | return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4") |
import "fmt"
func CheckIfOtherDHCPServersPresentV4(ifaceName string) (bool, error) {
return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4")
}
func CheckIfOtherDHCPServersPresentV6(ifaceName string) (bool, error) {
return false, fmt.Errorf("not supported")
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/dhcpd/checkother_windows.go |
return false, fmt.Errorf("not supported")
}
func CheckIfOtherDHCPServersPresentV6(ifaceName string) (bool, error) {
return false, fmt.Errorf("not supported")
}
| </s> remove return false, fmt.Errorf("not supported")
</s> add return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4") </s> remove import "fmt"
</s> add import "github.com/AdguardTeam/AdGuardHome/internal/aghos" </s> remove return fmt.Errorf("not supported on Windows")
</s> add return Unsupported("kill") </s> remove return ErrUnsupported
</s> add return Unsupported("setrlimit") </s> remove return false, fmt.Errorf("can't find DHCP server: not supported on macOS")
</s> add return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4") | return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV6") | return false, fmt.Errorf("not supported")
}
func CheckIfOtherDHCPServersPresentV6(ifaceName string) (bool, error) {
return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV6")
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/dhcpd/checkother_windows.go |
import (
"net"
"github.com/AdguardTeam/golibs/errors"
"golang.org/x/net/ipv4"
)
// Create a socket for receiving broadcast packets
func newBroadcastPacketConn(bindAddr net.IP, port int, ifname string) (*ipv4.PacketConn, error) {
| </s> remove func newBroadcastPacketConn(bindAddr net.IP, port int, ifname string) (*ipv4.PacketConn, error) {
return nil, errors.Error("newBroadcastPacketConn(): not supported on Windows")
</s> add func newBroadcastPacketConn(_ net.IP, _ int, _ string) (*ipv4.PacketConn, error) {
return nil, aghos.Unsupported("newBroadcastPacketConn") </s> remove
"github.com/AdguardTeam/golibs/errors"
</s> add </s> remove // ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
//
// TODO(a.garipov): Make a structured error and use it everywhere instead of
// a bunch of fmt.Errorf and all that.
const ErrUnsupported errors.Error = "unsupported"
</s> add // UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
} </s> remove import "fmt"
</s> add import "github.com/AdguardTeam/AdGuardHome/internal/aghos" </s> remove return false, fmt.Errorf("not supported")
</s> add return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4") | "github.com/AdguardTeam/AdGuardHome/internal/aghos" |
import (
"net"
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
"golang.org/x/net/ipv4"
)
// Create a socket for receiving broadcast packets
func newBroadcastPacketConn(bindAddr net.IP, port int, ifname string) (*ipv4.PacketConn, error) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/dhcpd/os_windows.go |
"golang.org/x/net/ipv4"
)
// Create a socket for receiving broadcast packets
func newBroadcastPacketConn(bindAddr net.IP, port int, ifname string) (*ipv4.PacketConn, error) {
return nil, errors.Error("newBroadcastPacketConn(): not supported on Windows")
}
| </s> remove "github.com/AdguardTeam/golibs/errors"
</s> add "github.com/AdguardTeam/AdGuardHome/internal/aghos" </s> remove return fmt.Errorf("not supported on Windows")
</s> add return Unsupported("kill") </s> remove log.Fatal("service actions are not supported on openbsd")
</s> add log.Fatal("service actions are not supported on openbsd, see issue 3226") </s> remove // ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
//
// TODO(a.garipov): Make a structured error and use it everywhere instead of
// a bunch of fmt.Errorf and all that.
const ErrUnsupported errors.Error = "unsupported"
</s> add // UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
} </s> remove return false, fmt.Errorf("can't find DHCP server: not supported on macOS")
</s> add return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4") | func newBroadcastPacketConn(_ net.IP, _ int, _ string) (*ipv4.PacketConn, error) {
return nil, aghos.Unsupported("newBroadcastPacketConn") | "golang.org/x/net/ipv4"
)
// Create a socket for receiving broadcast packets
func newBroadcastPacketConn(_ net.IP, _ int, _ string) (*ipv4.PacketConn, error) {
return nil, aghos.Unsupported("newBroadcastPacketConn")
func newBroadcastPacketConn(_ net.IP, _ int, _ string) (*ipv4.PacketConn, error) {
return nil, aghos.Unsupported("newBroadcastPacketConn")
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/dhcpd/os_windows.go |
LogFile string `yaml:"log_file"` // Path to the log file. If empty, write to stdout. If "syslog", writes to syslog
Verbose bool `yaml:"verbose"` // If true, verbose logging is enabled
}
// configuration is loaded from YAML
// field ordering is important -- yaml fields will mirror ordering from here
type configuration struct {
// Raw file data to avoid re-reading of configuration file
// It's reset after config is parsed
| </s> remove // ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
//
// TODO(a.garipov): Make a structured error and use it everywhere instead of
// a bunch of fmt.Errorf and all that.
const ErrUnsupported errors.Error = "unsupported"
</s> add // UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
} </s> remove ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client
Language string `yaml:"language"` // two-letter ISO 639-1 language code
RlimitNoFile uint64 `yaml:"rlimit_nofile"` // Maximum number of opened fd's per process (0: default)
DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060
</s> add ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client
Language string `yaml:"language"` // two-letter ISO 639-1 language code
DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060 </s> remove log.Fatal("service actions are not supported on openbsd")
</s> add log.Fatal("service actions are not supported on openbsd, see issue 3226") | // osConfig contains OS-related configuration.
type osConfig struct {
// Group is the name of the group which AdGuard Home must switch to on
// startup. Empty string means no switching.
Group string `yaml:"group"`
// User is the name of the user which AdGuard Home must switch to on
// startup. Empty string means no switching.
User string `yaml:"user"`
// RlimitNoFile is the maximum number of opened fd's per process. Zero
// means use the default value.
RlimitNoFile uint64 `yaml:"rlimit_nofile"`
}
| LogFile string `yaml:"log_file"` // Path to the log file. If empty, write to stdout. If "syslog", writes to syslog
Verbose bool `yaml:"verbose"` // If true, verbose logging is enabled
}
// osConfig contains OS-related configuration.
type osConfig struct {
// Group is the name of the group which AdGuard Home must switch to on
// startup. Empty string means no switching.
Group string `yaml:"group"`
// User is the name of the user which AdGuard Home must switch to on
// startup. Empty string means no switching.
User string `yaml:"user"`
// RlimitNoFile is the maximum number of opened fd's per process. Zero
// means use the default value.
RlimitNoFile uint64 `yaml:"rlimit_nofile"`
}
// configuration is loaded from YAML
// field ordering is important -- yaml fields will mirror ordering from here
type configuration struct {
// Raw file data to avoid re-reading of configuration file
// It's reset after config is parsed | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/config.go |
AuthAttempts uint `yaml:"auth_attempts"`
// AuthBlockMin is the duration, in minutes, of the block of new login
// attempts after AuthAttempts unsuccessful login attempts.
AuthBlockMin uint `yaml:"block_auth_min"`
ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client
Language string `yaml:"language"` // two-letter ISO 639-1 language code
RlimitNoFile uint64 `yaml:"rlimit_nofile"` // Maximum number of opened fd's per process (0: default)
DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060
// TTL for a web session (in hours)
// An active session is automatically refreshed once a day.
WebSessionTTLHours uint32 `yaml:"web_session_ttl"`
| </s> remove // ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
//
// TODO(a.garipov): Make a structured error and use it everywhere instead of
// a bunch of fmt.Errorf and all that.
const ErrUnsupported errors.Error = "unsupported"
</s> add // UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
} </s> remove log.Fatal("service actions are not supported on openbsd")
</s> add log.Fatal("service actions are not supported on openbsd, see issue 3226") </s> remove
"github.com/AdguardTeam/golibs/errors"
</s> add </s> remove "github.com/AdguardTeam/golibs/errors"
</s> add "github.com/AdguardTeam/AdGuardHome/internal/aghos" | ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client
Language string `yaml:"language"` // two-letter ISO 639-1 language code
DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060 | AuthAttempts uint `yaml:"auth_attempts"`
// AuthBlockMin is the duration, in minutes, of the block of new login
// attempts after AuthAttempts unsuccessful login attempts.
AuthBlockMin uint `yaml:"block_auth_min"`
ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client
Language string `yaml:"language"` // two-letter ISO 639-1 language code
DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060
ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client
Language string `yaml:"language"` // two-letter ISO 639-1 language code
DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060
ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client
Language string `yaml:"language"` // two-letter ISO 639-1 language code
DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060
ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client
Language string `yaml:"language"` // two-letter ISO 639-1 language code
DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060
// TTL for a web session (in hours)
// An active session is automatically refreshed once a day.
WebSessionTTLHours uint32 `yaml:"web_session_ttl"`
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/config.go |
logSettings `yaml:",inline"`
sync.RWMutex `yaml:"-"`
SchemaVersion int `yaml:"schema_version"` // keeping last so that users will be less tempted to change it -- used when upgrading between versions
}
| </s> remove // ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
//
// TODO(a.garipov): Make a structured error and use it everywhere instead of
// a bunch of fmt.Errorf and all that.
const ErrUnsupported errors.Error = "unsupported"
</s> add // UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
} </s> remove log.Fatal("service actions are not supported on openbsd")
</s> add log.Fatal("service actions are not supported on openbsd, see issue 3226") </s> remove
"github.com/AdguardTeam/golibs/errors"
</s> add | OSConfig *osConfig `yaml:"os"`
|
logSettings `yaml:",inline"`
OSConfig *osConfig `yaml:"os"`
sync.RWMutex `yaml:"-"`
SchemaVersion int `yaml:"schema_version"` // keeping last so that users will be less tempted to change it -- used when upgrading between versions
} | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/config.go |
LogMaxBackups: 0,
LogMaxSize: 100,
LogMaxAge: 3,
},
SchemaVersion: currentSchemaVersion,
}
// initConfig initializes default configuration for the current OS&ARCH
func initConfig() {
| </s> remove // ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
//
// TODO(a.garipov): Make a structured error and use it everywhere instead of
// a bunch of fmt.Errorf and all that.
const ErrUnsupported errors.Error = "unsupported"
</s> add // UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
} </s> remove const currentSchemaVersion = 10
</s> add const currentSchemaVersion = 11 </s> remove
"github.com/AdguardTeam/golibs/errors"
</s> add </s> remove func newBroadcastPacketConn(bindAddr net.IP, port int, ifname string) (*ipv4.PacketConn, error) {
return nil, errors.Error("newBroadcastPacketConn(): not supported on Windows")
</s> add func newBroadcastPacketConn(_ net.IP, _ int, _ string) (*ipv4.PacketConn, error) {
return nil, aghos.Unsupported("newBroadcastPacketConn") | OSConfig: &osConfig{}, | LogMaxBackups: 0,
LogMaxSize: 100,
LogMaxAge: 3,
},
OSConfig: &osConfig{},
SchemaVersion: currentSchemaVersion,
}
// initConfig initializes default configuration for the current OS&ARCH
func initConfig() { | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/config.go |
// TODO(a.garipov): github.com/kardianos/service doesn't seem to
// support OpenBSD currently. Either patch it to do so or make
// our own implementation of the service.System interface.
if runtime.GOOS == "openbsd" {
log.Fatal("service actions are not supported on openbsd")
}
handleServiceControlAction(args, clientBuildFS)
return
| </s> remove return false, fmt.Errorf("can't find DHCP server: not supported on macOS")
</s> add return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4") </s> remove // ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
//
// TODO(a.garipov): Make a structured error and use it everywhere instead of
// a bunch of fmt.Errorf and all that.
const ErrUnsupported errors.Error = "unsupported"
</s> add // UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
} | log.Fatal("service actions are not supported on openbsd, see issue 3226") | // TODO(a.garipov): github.com/kardianos/service doesn't seem to
// support OpenBSD currently. Either patch it to do so or make
// our own implementation of the service.System interface.
if runtime.GOOS == "openbsd" {
log.Fatal("service actions are not supported on openbsd, see issue 3226")
}
handleServiceControlAction(args, clientBuildFS)
return | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/home.go |
}
Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts)
config.Clients = nil
if config.RlimitNoFile != 0 {
err = aghos.SetRlimit(config.RlimitNoFile)
if err != nil && !errors.Is(err, aghos.ErrUnsupported) {
return fmt.Errorf("setting rlimit: %w", err)
}
}
// override bind host/port from the console
if args.bindHost != nil {
config.BindHost = args.bindHost
}
if args.bindPort != 0 {
| </s> remove return fmt.Errorf("not supported on Windows")
</s> add return Unsupported("kill") </s> remove // ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
//
// TODO(a.garipov): Make a structured error and use it everywhere instead of
// a bunch of fmt.Errorf and all that.
const ErrUnsupported errors.Error = "unsupported"
</s> add // UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
} </s> remove log.Fatal("service actions are not supported on openbsd")
</s> add log.Fatal("service actions are not supported on openbsd, see issue 3226") </s> remove return false, fmt.Errorf("can't find DHCP server: not supported on macOS")
</s> add return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4") | }
Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts)
config.Clients = nil
// override bind host/port from the console
if args.bindHost != nil {
config.BindHost = args.bindHost
}
if args.bindPort != 0 { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/home.go |
|
setupContext(args)
// clients package uses filtering package's static data (filtering.BlockedSvcKnown()),
// so we have to initialize filtering's static data first,
// but also avoid relying on automatic Go init() function
filtering.InitModule()
| </s> remove log.Fatal("service actions are not supported on openbsd")
</s> add log.Fatal("service actions are not supported on openbsd, see issue 3226") </s> remove // ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
//
// TODO(a.garipov): Make a structured error and use it everywhere instead of
// a bunch of fmt.Errorf and all that.
const ErrUnsupported errors.Error = "unsupported"
</s> add // UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
} </s> remove
"github.com/AdguardTeam/golibs/errors"
</s> add | err = configureOS(&config)
fatalOnError(err)
|
setupContext(args)
err = configureOS(&config)
fatalOnError(err)
// clients package uses filtering package's static data (filtering.BlockedSvcKnown()),
// so we have to initialize filtering's static data first,
// but also avoid relying on automatic Go init() function
filtering.InitModule() | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/home.go |
yaml "gopkg.in/yaml.v2"
)
// currentSchemaVersion is the current schema version.
const currentSchemaVersion = 10
// These aliases are provided for convenience.
type (
any = interface{}
yarr = []any
| </s> remove // ErrUnsupported is returned when the functionality is unsupported on the
// current operating system.
//
// TODO(a.garipov): Make a structured error and use it everywhere instead of
// a bunch of fmt.Errorf and all that.
const ErrUnsupported errors.Error = "unsupported"
</s> add // UnsupportedError is returned by functions and methods when a particular
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) {
return &UnsupportedError{
Op: op,
OS: runtime.GOOS,
}
} </s> remove
"github.com/AdguardTeam/golibs/errors"
</s> add </s> remove if config.RlimitNoFile != 0 {
err = aghos.SetRlimit(config.RlimitNoFile)
if err != nil && !errors.Is(err, aghos.ErrUnsupported) {
return fmt.Errorf("setting rlimit: %w", err)
}
}
</s> add | const currentSchemaVersion = 11 | yaml "gopkg.in/yaml.v2"
)
// currentSchemaVersion is the current schema version.
const currentSchemaVersion = 11
// These aliases are provided for convenience.
type (
any = interface{}
yarr = []any | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/upgrade.go |
upgradeSchema7to8,
upgradeSchema8to9,
upgradeSchema9to10,
}
n := 0
for i, u := range upgrades {
| </s> remove return false, fmt.Errorf("can't find DHCP server: not supported on macOS")
</s> add return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4") </s> remove return ErrUnsupported
</s> add return Unsupported("setrlimit") </s> remove if config.RlimitNoFile != 0 {
err = aghos.SetRlimit(config.RlimitNoFile)
if err != nil && !errors.Is(err, aghos.ErrUnsupported) {
return fmt.Errorf("setting rlimit: %w", err)
}
}
</s> add </s> remove func newBroadcastPacketConn(bindAddr net.IP, port int, ifname string) (*ipv4.PacketConn, error) {
return nil, errors.Error("newBroadcastPacketConn(): not supported on Windows")
</s> add func newBroadcastPacketConn(_ net.IP, _ int, _ string) (*ipv4.PacketConn, error) {
return nil, aghos.Unsupported("newBroadcastPacketConn") | upgradeSchema10to11, | upgradeSchema7to8,
upgradeSchema8to9,
upgradeSchema9to10,
upgradeSchema10to11,
}
n := 0
for i, u := range upgrades { | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 16:25:17 2021 +0300
all: move rlimit_nofile, imp docs
commit ba95d4ab7c722bf83300d626a598aface37539ad
Author: Ainar Garipov <[email protected]>
Date: Fri Jun 4 15:12:23 2021 +0300
all: support setgid, setuid on unix | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/upgrade.go |
}
// InSlice checks if string is in the slice of strings.
func InSlice(strs []string, str string) (ok bool) {
for _, s := range strs {
if s == str {
return true
}
| </s> remove cSet := make(map[string]unit)
for _, k := range a {
cSet[k] = unit{}
</s> add // sliceToSet converts a slice of strings into a string set.
func sliceToSet(strs []string) (set map[string]unit) {
set = make(map[string]unit, len(strs))
for _, s := range strs {
set[s] = unit{} </s> remove
// Is not comment
func isUpstream(line string) bool {
return !strings.HasPrefix(line, "#")
}
func filterOutComments(lines []string) []string {
var filtered []string
for _, l := range lines {
if isUpstream(l) {
filtered = append(filtered, l)
}
}
return filtered
}
</s> add </s> remove if len(c.Upstreams) == 0 {
</s> add upstreams := aghstrings.FilterOut(c.Upstreams, aghstrings.IsCommentOrEmpty)
if len(upstreams) == 0 { </s> remove for _, k := range b {
delete(cSet, k)
}
c = make([]string, len(cSet))
i := 0
for k := range cSet {
c[i] = k
i++
}
return c
</s> add return set | // FilterOut returns a copy of strs with all strings for which f returned true
// removed.
func FilterOut(strs []string, f func(s string) (ok bool)) (filtered []string) {
for _, s := range strs {
if !f(s) {
filtered = append(filtered, s)
}
}
return filtered
}
| }
// FilterOut returns a copy of strs with all strings for which f returned true
// removed.
func FilterOut(strs []string, f func(s string) (ok bool)) (filtered []string) {
for _, s := range strs {
if !f(s) {
filtered = append(filtered, s)
}
}
return filtered
}
// InSlice checks if string is in the slice of strings.
func InSlice(strs []string, str string) (ok bool) {
for _, s := range strs {
if s == str {
return true
} | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: fix client custom upstream comments
Updates #2947.
Squashed commit of the following:
commit 498a05459b1aa00bcffee490acfeecb567025971
Merge: 6a7a2f87 21e2c419
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:40:29 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 6a7a2f87cfd2bdd829b82889890511fef8d84b9b
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:34:28 2021 +0300
all: imp code, tests
commit abc0be239f69cfc3e7d0cde2fc952d9157b2cd5d
Merge: 82fb3fcb 6410feeb
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:17:09 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 82fb3fcb49cbc8d439cb5959c1cb84ae49b2257e
Author: Ainar Garipov <[email protected]>
Date: Mon Apr 12 22:13:41 2021 +0300
all: fix client custom upstream comments | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/aghstrings/strings.go |
return false
}
// SplitNext splits string by a byte and returns the first chunk skipping empty
// ones. Whitespaces are trimmed.
func SplitNext(s *string, sep rune) (chunk string) {
if s == nil {
| </s> remove if len(c.Upstreams) == 0 {
</s> add upstreams := aghstrings.FilterOut(c.Upstreams, aghstrings.IsCommentOrEmpty)
if len(upstreams) == 0 { </s> remove
// Is not comment
func isUpstream(line string) bool {
return !strings.HasPrefix(line, "#")
}
func filterOutComments(lines []string) []string {
var filtered []string
for _, l := range lines {
if isUpstream(l) {
filtered = append(filtered, l)
}
}
return filtered
}
</s> add </s> remove if !isUpstream(input) {
</s> add if aghstrings.IsCommentOrEmpty(input) { </s> remove upstreams = filterOutComments(upstreams)
</s> add upstreams = aghstrings.FilterOut(upstreams, aghstrings.IsCommentOrEmpty) | // IsCommentOrEmpty returns true of the string starts with a "#" character or is
// an empty string.
func IsCommentOrEmpty(s string) (ok bool) {
return len(s) == 0 || s[0] == '#'
}
|
return false
}
// IsCommentOrEmpty returns true of the string starts with a "#" character or is
// an empty string.
func IsCommentOrEmpty(s string) (ok bool) {
return len(s) == 0 || s[0] == '#'
}
// SplitNext splits string by a byte and returns the first chunk skipping empty
// ones. Whitespaces are trimmed.
func SplitNext(s *string, sep rune) (chunk string) {
if s == nil { | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: fix client custom upstream comments
Updates #2947.
Squashed commit of the following:
commit 498a05459b1aa00bcffee490acfeecb567025971
Merge: 6a7a2f87 21e2c419
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:40:29 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 6a7a2f87cfd2bdd829b82889890511fef8d84b9b
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:34:28 2021 +0300
all: imp code, tests
commit abc0be239f69cfc3e7d0cde2fc952d9157b2cd5d
Merge: 82fb3fcb 6410feeb
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:17:09 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 82fb3fcb49cbc8d439cb5959c1cb84ae49b2257e
Author: Ainar Garipov <[email protected]>
Date: Mon Apr 12 22:13:41 2021 +0300
all: fix client custom upstream comments | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/aghstrings/strings.go |
assert.Equal(t, CloneSlice(a), CloneSliceOrEmpty(a))
})
}
func TestInSlice(t *testing.T) {
simpleStrs := []string{"1", "2", "3"}
testCases := []struct {
name string
| </s> remove cSet := make(map[string]unit)
for _, k := range a {
cSet[k] = unit{}
</s> add // sliceToSet converts a slice of strings into a string set.
func sliceToSet(strs []string) (set map[string]unit) {
set = make(map[string]unit, len(strs))
for _, s := range strs {
set[s] = unit{} </s> remove
// Is not comment
func isUpstream(line string) bool {
return !strings.HasPrefix(line, "#")
}
func filterOutComments(lines []string) []string {
var filtered []string
for _, l := range lines {
if isUpstream(l) {
filtered = append(filtered, l)
}
}
return filtered
}
</s> add </s> remove for _, k := range b {
delete(cSet, k)
}
c = make([]string, len(cSet))
i := 0
for k := range cSet {
c[i] = k
i++
}
return c
</s> add return set | func TestFilterOut(t *testing.T) {
strs := []string{
"1.2.3.4",
"",
"# 5.6.7.8",
}
want := []string{
"1.2.3.4",
}
got := FilterOut(strs, IsCommentOrEmpty)
assert.Equal(t, want, got)
}
| assert.Equal(t, CloneSlice(a), CloneSliceOrEmpty(a))
})
}
func TestFilterOut(t *testing.T) {
strs := []string{
"1.2.3.4",
"",
"# 5.6.7.8",
}
want := []string{
"1.2.3.4",
}
got := FilterOut(strs, IsCommentOrEmpty)
assert.Equal(t, want, got)
}
func TestInSlice(t *testing.T) {
simpleStrs := []string{"1", "2", "3"}
testCases := []struct {
name string | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: fix client custom upstream comments
Updates #2947.
Squashed commit of the following:
commit 498a05459b1aa00bcffee490acfeecb567025971
Merge: 6a7a2f87 21e2c419
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:40:29 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 6a7a2f87cfd2bdd829b82889890511fef8d84b9b
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:34:28 2021 +0300
all: imp code, tests
commit abc0be239f69cfc3e7d0cde2fc952d9157b2cd5d
Merge: 82fb3fcb 6410feeb
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:17:09 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 82fb3fcb49cbc8d439cb5959c1cb84ae49b2257e
Author: Ainar Garipov <[email protected]>
Date: Mon Apr 12 22:13:41 2021 +0300
all: fix client custom upstream comments | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/aghstrings/strings_test.go |
} else {
upstreams = s.conf.UpstreamDNS
}
upstreams = filterOutComments(upstreams)
upstreamConfig, err := proxy.ParseUpstreamsConfig(
upstreams,
upstream.Options{
Bootstrap: s.conf.BootstrapDNS,
Timeout: DefaultTimeout,
| </s> remove c.Upstreams,
</s> add upstreams, </s> remove if len(c.Upstreams) == 0 {
</s> add upstreams := aghstrings.FilterOut(c.Upstreams, aghstrings.IsCommentOrEmpty)
if len(upstreams) == 0 { </s> remove upstreams = filterOutComments(upstreams)
</s> add upstreams = aghstrings.FilterOut(upstreams, aghstrings.IsCommentOrEmpty) </s> remove localAddrs = stringSetSubtract(localAddrs, ourAddrs)
</s> add localAddrs = aghstrings.FilterOut(localAddrs, func(s string) (ok bool) {
_, ok = ourAddrsSet[s]
return ok
}) </s> remove name: "upstream_dns_bad",
wantSet: "wrong upstreams specification: missing port in address\n",
</s> add name: "upstream_dns_bad",
wantSet: `wrong upstreams specification: address !!!: ` +
`missing port in address`, | upstreams = aghstrings.FilterOut(upstreams, aghstrings.IsCommentOrEmpty) | } else {
upstreams = s.conf.UpstreamDNS
}
upstreams = aghstrings.FilterOut(upstreams, aghstrings.IsCommentOrEmpty)
upstreamConfig, err := proxy.ParseUpstreamsConfig(
upstreams,
upstream.Options{
Bootstrap: s.conf.BootstrapDNS,
Timeout: DefaultTimeout, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: fix client custom upstream comments
Updates #2947.
Squashed commit of the following:
commit 498a05459b1aa00bcffee490acfeecb567025971
Merge: 6a7a2f87 21e2c419
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:40:29 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 6a7a2f87cfd2bdd829b82889890511fef8d84b9b
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:34:28 2021 +0300
all: imp code, tests
commit abc0be239f69cfc3e7d0cde2fc952d9157b2cd5d
Merge: 82fb3fcb 6410feeb
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:17:09 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 82fb3fcb49cbc8d439cb5959c1cb84ae49b2257e
Author: Ainar Garipov <[email protected]>
Date: Mon Apr 12 22:13:41 2021 +0300
all: fix client custom upstream comments | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/dnsforward/config.go |
// locally-served networks. It is assumed that local resolvers should work much
// faster than ordinary upstreams.
const defaultLocalTimeout = 1 * time.Second
// collectDNSIPAddrs returns the slice of IP addresses without port number which
// we are listening on. For internal use only.
func (s *Server) collectDNSIPAddrs() (addrs []string, err error) {
addrs = make([]string, len(s.conf.TCPListenAddrs)+len(s.conf.UDPListenAddrs))
var i int
var ip net.IP
for _, addr := range s.conf.TCPListenAddrs {
| </s> remove for _, k := range b {
delete(cSet, k)
}
c = make([]string, len(cSet))
i := 0
for k := range cSet {
c[i] = k
i++
}
return c
</s> add return set </s> remove localAddrs = stringSetSubtract(localAddrs, ourAddrs)
</s> add localAddrs = aghstrings.FilterOut(localAddrs, func(s string) (ok bool) {
_, ok = ourAddrsSet[s]
return ok
}) </s> remove if !isUpstream(input) {
</s> add if aghstrings.IsCommentOrEmpty(input) { | // collectDNSIPAddrs returns IP addresses the server is listening on without
// port numbers as a map. For internal use only. | // locally-served networks. It is assumed that local resolvers should work much
// faster than ordinary upstreams.
const defaultLocalTimeout = 1 * time.Second
// collectDNSIPAddrs returns IP addresses the server is listening on without
// port numbers as a map. For internal use only.
// collectDNSIPAddrs returns IP addresses the server is listening on without
// port numbers as a map. For internal use only.
func (s *Server) collectDNSIPAddrs() (addrs []string, err error) {
addrs = make([]string, len(s.conf.TCPListenAddrs)+len(s.conf.UDPListenAddrs))
var i int
var ip net.IP
for _, addr := range s.conf.TCPListenAddrs { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: fix client custom upstream comments
Updates #2947.
Squashed commit of the following:
commit 498a05459b1aa00bcffee490acfeecb567025971
Merge: 6a7a2f87 21e2c419
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:40:29 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 6a7a2f87cfd2bdd829b82889890511fef8d84b9b
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:34:28 2021 +0300
all: imp code, tests
commit abc0be239f69cfc3e7d0cde2fc952d9157b2cd5d
Merge: 82fb3fcb 6410feeb
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:17:09 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 82fb3fcb49cbc8d439cb5959c1cb84ae49b2257e
Author: Ainar Garipov <[email protected]>
Date: Mon Apr 12 22:13:41 2021 +0300
all: fix client custom upstream comments | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/dnsforward/dnsforward.go |
return addrs[:i], nil
}
// stringSetSubtract subtracts b from a interpreted as sets.
func stringSetSubtract(a, b []string) (c []string) {
// unit is an object to be used as value in set.
type unit = struct{}
cSet := make(map[string]unit)
for _, k := range a {
cSet[k] = unit{}
}
| </s> remove cSet := make(map[string]unit)
for _, k := range a {
cSet[k] = unit{}
</s> add // sliceToSet converts a slice of strings into a string set.
func sliceToSet(strs []string) (set map[string]unit) {
set = make(map[string]unit, len(strs))
for _, s := range strs {
set[s] = unit{} </s> remove for _, k := range b {
delete(cSet, k)
}
c = make([]string, len(cSet))
i := 0
for k := range cSet {
c[i] = k
i++
}
return c
</s> add return set </s> remove
// Is not comment
func isUpstream(line string) bool {
return !strings.HasPrefix(line, "#")
}
func filterOutComments(lines []string) []string {
var filtered []string
for _, l := range lines {
if isUpstream(l) {
filtered = append(filtered, l)
}
}
return filtered
}
</s> add </s> remove upstreams = filterOutComments(upstreams)
</s> add upstreams = aghstrings.FilterOut(upstreams, aghstrings.IsCommentOrEmpty) | // unit is used to show the presence of a value in a set.
type unit = struct{} |
return addrs[:i], nil
}
// unit is used to show the presence of a value in a set.
type unit = struct{}
// unit is used to show the presence of a value in a set.
type unit = struct{}
// unit is used to show the presence of a value in a set.
type unit = struct{}
// unit is used to show the presence of a value in a set.
type unit = struct{}
cSet := make(map[string]unit)
for _, k := range a {
cSet[k] = unit{}
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: fix client custom upstream comments
Updates #2947.
Squashed commit of the following:
commit 498a05459b1aa00bcffee490acfeecb567025971
Merge: 6a7a2f87 21e2c419
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:40:29 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 6a7a2f87cfd2bdd829b82889890511fef8d84b9b
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:34:28 2021 +0300
all: imp code, tests
commit abc0be239f69cfc3e7d0cde2fc952d9157b2cd5d
Merge: 82fb3fcb 6410feeb
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:17:09 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 82fb3fcb49cbc8d439cb5959c1cb84ae49b2257e
Author: Ainar Garipov <[email protected]>
Date: Mon Apr 12 22:13:41 2021 +0300
all: fix client custom upstream comments | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/dnsforward/dnsforward.go |
func stringSetSubtract(a, b []string) (c []string) {
// unit is an object to be used as value in set.
type unit = struct{}
cSet := make(map[string]unit)
for _, k := range a {
cSet[k] = unit{}
}
for _, k := range b {
delete(cSet, k)
}
| </s> remove // stringSetSubtract subtracts b from a interpreted as sets.
func stringSetSubtract(a, b []string) (c []string) {
// unit is an object to be used as value in set.
type unit = struct{}
</s> add // unit is used to show the presence of a value in a set.
type unit = struct{} </s> remove for _, k := range b {
delete(cSet, k)
}
c = make([]string, len(cSet))
i := 0
for k := range cSet {
c[i] = k
i++
}
return c
</s> add return set </s> remove
// Is not comment
func isUpstream(line string) bool {
return !strings.HasPrefix(line, "#")
}
func filterOutComments(lines []string) []string {
var filtered []string
for _, l := range lines {
if isUpstream(l) {
filtered = append(filtered, l)
}
}
return filtered
}
</s> add </s> remove upstreams = filterOutComments(upstreams)
</s> add upstreams = aghstrings.FilterOut(upstreams, aghstrings.IsCommentOrEmpty) | // sliceToSet converts a slice of strings into a string set.
func sliceToSet(strs []string) (set map[string]unit) {
set = make(map[string]unit, len(strs))
for _, s := range strs {
set[s] = unit{} | func stringSetSubtract(a, b []string) (c []string) {
// unit is an object to be used as value in set.
type unit = struct{}
// sliceToSet converts a slice of strings into a string set.
func sliceToSet(strs []string) (set map[string]unit) {
set = make(map[string]unit, len(strs))
for _, s := range strs {
set[s] = unit{}
// sliceToSet converts a slice of strings into a string set.
func sliceToSet(strs []string) (set map[string]unit) {
set = make(map[string]unit, len(strs))
for _, s := range strs {
set[s] = unit{}
// sliceToSet converts a slice of strings into a string set.
func sliceToSet(strs []string) (set map[string]unit) {
set = make(map[string]unit, len(strs))
for _, s := range strs {
set[s] = unit{}
}
for _, k := range b {
delete(cSet, k)
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: fix client custom upstream comments
Updates #2947.
Squashed commit of the following:
commit 498a05459b1aa00bcffee490acfeecb567025971
Merge: 6a7a2f87 21e2c419
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:40:29 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 6a7a2f87cfd2bdd829b82889890511fef8d84b9b
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:34:28 2021 +0300
all: imp code, tests
commit abc0be239f69cfc3e7d0cde2fc952d9157b2cd5d
Merge: 82fb3fcb 6410feeb
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:17:09 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 82fb3fcb49cbc8d439cb5959c1cb84ae49b2257e
Author: Ainar Garipov <[email protected]>
Date: Mon Apr 12 22:13:41 2021 +0300
all: fix client custom upstream comments | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/dnsforward/dnsforward.go |
for _, k := range a {
cSet[k] = unit{}
}
for _, k := range b {
delete(cSet, k)
}
c = make([]string, len(cSet))
i := 0
for k := range cSet {
c[i] = k
i++
}
return c
}
// setupResolvers initializes the resolvers for local addresses. For internal
// use only.
func (s *Server) setupResolvers(localAddrs []string) (err error) {
| </s> remove cSet := make(map[string]unit)
for _, k := range a {
cSet[k] = unit{}
</s> add // sliceToSet converts a slice of strings into a string set.
func sliceToSet(strs []string) (set map[string]unit) {
set = make(map[string]unit, len(strs))
for _, s := range strs {
set[s] = unit{} </s> remove // stringSetSubtract subtracts b from a interpreted as sets.
func stringSetSubtract(a, b []string) (c []string) {
// unit is an object to be used as value in set.
type unit = struct{}
</s> add // unit is used to show the presence of a value in a set.
type unit = struct{} </s> remove // collectDNSIPAddrs returns the slice of IP addresses without port number which
// we are listening on. For internal use only.
</s> add // collectDNSIPAddrs returns IP addresses the server is listening on without
// port numbers as a map. For internal use only. </s> remove
// Is not comment
func isUpstream(line string) bool {
return !strings.HasPrefix(line, "#")
}
func filterOutComments(lines []string) []string {
var filtered []string
for _, l := range lines {
if isUpstream(l) {
filtered = append(filtered, l)
}
}
return filtered
}
</s> add | return set | for _, k := range a {
cSet[k] = unit{}
}
return set
return set
return set
return set
return set
return set
return set
return set
return set
return set
return set
return set
}
// setupResolvers initializes the resolvers for local addresses. For internal
// use only.
func (s *Server) setupResolvers(localAddrs []string) (err error) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: fix client custom upstream comments
Updates #2947.
Squashed commit of the following:
commit 498a05459b1aa00bcffee490acfeecb567025971
Merge: 6a7a2f87 21e2c419
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:40:29 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 6a7a2f87cfd2bdd829b82889890511fef8d84b9b
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:34:28 2021 +0300
all: imp code, tests
commit abc0be239f69cfc3e7d0cde2fc952d9157b2cd5d
Merge: 82fb3fcb 6410feeb
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:17:09 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 82fb3fcb49cbc8d439cb5959c1cb84ae49b2257e
Author: Ainar Garipov <[email protected]>
Date: Mon Apr 12 22:13:41 2021 +0300
all: fix client custom upstream comments | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/dnsforward/dnsforward.go |
}
// TODO(e.burkov): The approach of subtracting sets of strings is not
// really applicable here since in case of listening on all network
// interfaces we should check the whole interface's network to cut off
// all the loopback addresses as well.
localAddrs = aghstrings.FilterOut(localAddrs, func(s string) (ok bool) {
_, ok = ourAddrsSet[s]
| </s> remove localAddrs = stringSetSubtract(localAddrs, ourAddrs)
</s> add localAddrs = aghstrings.FilterOut(localAddrs, func(s string) (ok bool) {
_, ok = ourAddrsSet[s]
return ok
}) </s> remove // collectDNSIPAddrs returns the slice of IP addresses without port number which
// we are listening on. For internal use only.
</s> add // collectDNSIPAddrs returns IP addresses the server is listening on without
// port numbers as a map. For internal use only. </s> remove // stringSetSubtract subtracts b from a interpreted as sets.
func stringSetSubtract(a, b []string) (c []string) {
// unit is an object to be used as value in set.
type unit = struct{}
</s> add // unit is used to show the presence of a value in a set.
type unit = struct{} | ourAddrsSet := sliceToSet(ourAddrs)
| }
ourAddrsSet := sliceToSet(ourAddrs)
// TODO(e.burkov): The approach of subtracting sets of strings is not
// really applicable here since in case of listening on all network
// interfaces we should check the whole interface's network to cut off
// all the loopback addresses as well.
localAddrs = aghstrings.FilterOut(localAddrs, func(s string) (ok bool) {
_, ok = ourAddrsSet[s] | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: fix client custom upstream comments
Updates #2947.
Squashed commit of the following:
commit 498a05459b1aa00bcffee490acfeecb567025971
Merge: 6a7a2f87 21e2c419
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:40:29 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 6a7a2f87cfd2bdd829b82889890511fef8d84b9b
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:34:28 2021 +0300
all: imp code, tests
commit abc0be239f69cfc3e7d0cde2fc952d9157b2cd5d
Merge: 82fb3fcb 6410feeb
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:17:09 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 82fb3fcb49cbc8d439cb5959c1cb84ae49b2257e
Author: Ainar Garipov <[email protected]>
Date: Mon Apr 12 22:13:41 2021 +0300
all: fix client custom upstream comments | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/dnsforward/dnsforward.go |
// TODO(e.burkov): The approach of subtracting sets of strings is not
// really applicable here since in case of listening on all network
// interfaces we should check the whole interface's network to cut off
// all the loopback addresses as well.
localAddrs = stringSetSubtract(localAddrs, ourAddrs)
var upsConfig proxy.UpstreamConfig
upsConfig, err = proxy.ParseUpstreamsConfig(localAddrs, upstream.Options{
Bootstrap: bootstraps,
Timeout: defaultLocalTimeout,
| </s> remove // collectDNSIPAddrs returns the slice of IP addresses without port number which
// we are listening on. For internal use only.
</s> add // collectDNSIPAddrs returns IP addresses the server is listening on without
// port numbers as a map. For internal use only. </s> remove upstreams = filterOutComments(upstreams)
</s> add upstreams = aghstrings.FilterOut(upstreams, aghstrings.IsCommentOrEmpty) </s> remove // stringSetSubtract subtracts b from a interpreted as sets.
func stringSetSubtract(a, b []string) (c []string) {
// unit is an object to be used as value in set.
type unit = struct{}
</s> add // unit is used to show the presence of a value in a set.
type unit = struct{} | localAddrs = aghstrings.FilterOut(localAddrs, func(s string) (ok bool) {
_, ok = ourAddrsSet[s]
return ok
}) | // TODO(e.burkov): The approach of subtracting sets of strings is not
// really applicable here since in case of listening on all network
// interfaces we should check the whole interface's network to cut off
// all the loopback addresses as well.
localAddrs = aghstrings.FilterOut(localAddrs, func(s string) (ok bool) {
_, ok = ourAddrsSet[s]
return ok
})
var upsConfig proxy.UpstreamConfig
upsConfig, err = proxy.ParseUpstreamsConfig(localAddrs, upstream.Options{
Bootstrap: bootstraps,
Timeout: defaultLocalTimeout, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: fix client custom upstream comments
Updates #2947.
Squashed commit of the following:
commit 498a05459b1aa00bcffee490acfeecb567025971
Merge: 6a7a2f87 21e2c419
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:40:29 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 6a7a2f87cfd2bdd829b82889890511fef8d84b9b
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:34:28 2021 +0300
all: imp code, tests
commit abc0be239f69cfc3e7d0cde2fc952d9157b2cd5d
Merge: 82fb3fcb 6410feeb
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:17:09 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 82fb3fcb49cbc8d439cb5959c1cb84ae49b2257e
Author: Ainar Garipov <[email protected]>
Date: Mon Apr 12 22:13:41 2021 +0300
all: fix client custom upstream comments | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/dnsforward/dnsforward.go |
//
// TODO(e.burkov): Move into aghnet or even into dnsproxy.
func ValidateUpstreams(upstreams []string) (err error) {
// No need to validate comments
upstreams = filterOutComments(upstreams)
// Consider this case valid because defaultDNS will be used
if len(upstreams) == 0 {
return nil
}
| </s> remove if len(c.Upstreams) == 0 {
</s> add upstreams := aghstrings.FilterOut(c.Upstreams, aghstrings.IsCommentOrEmpty)
if len(upstreams) == 0 { </s> remove if !isUpstream(input) {
</s> add if aghstrings.IsCommentOrEmpty(input) { </s> remove cSet := make(map[string]unit)
for _, k := range a {
cSet[k] = unit{}
</s> add // sliceToSet converts a slice of strings into a string set.
func sliceToSet(strs []string) (set map[string]unit) {
set = make(map[string]unit, len(strs))
for _, s := range strs {
set[s] = unit{} </s> remove for _, k := range b {
delete(cSet, k)
}
c = make([]string, len(cSet))
i := 0
for k := range cSet {
c[i] = k
i++
}
return c
</s> add return set | upstreams = aghstrings.FilterOut(upstreams, aghstrings.IsCommentOrEmpty) | //
// TODO(e.burkov): Move into aghnet or even into dnsproxy.
func ValidateUpstreams(upstreams []string) (err error) {
// No need to validate comments
upstreams = aghstrings.FilterOut(upstreams, aghstrings.IsCommentOrEmpty)
// Consider this case valid because defaultDNS will be used
if len(upstreams) == 0 {
return nil
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: fix client custom upstream comments
Updates #2947.
Squashed commit of the following:
commit 498a05459b1aa00bcffee490acfeecb567025971
Merge: 6a7a2f87 21e2c419
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:40:29 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 6a7a2f87cfd2bdd829b82889890511fef8d84b9b
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:34:28 2021 +0300
all: imp code, tests
commit abc0be239f69cfc3e7d0cde2fc952d9157b2cd5d
Merge: 82fb3fcb 6410feeb
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:17:09 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 82fb3fcb49cbc8d439cb5959c1cb84ae49b2257e
Author: Ainar Garipov <[email protected]>
Date: Mon Apr 12 22:13:41 2021 +0300
all: fix client custom upstream comments | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/dnsforward/http.go |
return nil
}
func checkDNS(input string, bootstrap []string, ef excFunc) (err error) {
if !isUpstream(input) {
return nil
}
// Separate upstream from domains list.
var useDefault bool
| </s> remove
// Is not comment
func isUpstream(line string) bool {
return !strings.HasPrefix(line, "#")
}
func filterOutComments(lines []string) []string {
var filtered []string
for _, l := range lines {
if isUpstream(l) {
filtered = append(filtered, l)
}
}
return filtered
}
</s> add </s> remove if len(c.Upstreams) == 0 {
</s> add upstreams := aghstrings.FilterOut(c.Upstreams, aghstrings.IsCommentOrEmpty)
if len(upstreams) == 0 { </s> remove upstreams = filterOutComments(upstreams)
</s> add upstreams = aghstrings.FilterOut(upstreams, aghstrings.IsCommentOrEmpty) </s> remove for _, k := range b {
delete(cSet, k)
}
c = make([]string, len(cSet))
i := 0
for k := range cSet {
c[i] = k
i++
}
return c
</s> add return set | if aghstrings.IsCommentOrEmpty(input) { | return nil
}
func checkDNS(input string, bootstrap []string, ef excFunc) (err error) {
if aghstrings.IsCommentOrEmpty(input) {
return nil
}
// Separate upstream from domains list.
var useDefault bool | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: all: fix client custom upstream comments
Updates #2947.
Squashed commit of the following:
commit 498a05459b1aa00bcffee490acfeecb567025971
Merge: 6a7a2f87 21e2c419
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:40:29 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 6a7a2f87cfd2bdd829b82889890511fef8d84b9b
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:34:28 2021 +0300
all: imp code, tests
commit abc0be239f69cfc3e7d0cde2fc952d9157b2cd5d
Merge: 82fb3fcb 6410feeb
Author: Ainar Garipov <[email protected]>
Date: Tue Apr 13 13:17:09 2021 +0300
Merge branch 'master' into 2947-cli-ups-comment
commit 82fb3fcb49cbc8d439cb5959c1cb84ae49b2257e
Author: Ainar Garipov <[email protected]>
Date: Mon Apr 12 22:13:41 2021 +0300
all: fix client custom upstream comments | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/dnsforward/http.go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.