docstring_tokens stringlengths 0 76.5k | code_tokens stringlengths 75 1.81M | label_window listlengths 4 2.12k | html_url stringlengths 74 116 | file_name stringlengths 3 311 |
|---|---|---|---|---|
if !privateNets.Contains(subnet.Addr().AsSlice()) { | <mask>
<mask> continue
<mask> }
<mask>
<mask> if !privateNets.Contains(subnet.IP) {
<mask> errs = append(
<mask> errs,
<mask> fmt.Errorf("arpa domain %q should point to a locally-served network", domain),
<mask> )
<mask> }
</s> Pull request #1770: 5567-extract-subnet-arpa
Merge in D... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48431f8b86a1e4dde8aebb7539682eb8d043c556 | internal/dnsforward/http.go |
`bad arpa domain name "non.arpa.": not a reversed ip network`, | <mask> wantSet: "",
<mask> }, {
<mask> name: "local_ptr_upstreams_bad",
<mask> wantSet: `validating private upstream servers: checking domain-specific upstreams: ` +
<mask> `bad arpa domain name "non.arpa": not a reversed ip network`,
<mask> }, {
<mask> name: "local_ptr_upstreams_null",
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48431f8b86a1e4dde8aebb7539682eb8d043c556 | internal/dnsforward/http_test.go |
`bad arpa domain name "hello.world.": not a reversed ip network`, | <mask> u: "[/127.in-addr.arpa/]#",
<mask> }, {
<mask> name: "not_arpa_subnet",
<mask> wantErr: `checking domain-specific upstreams: ` +
<mask> `bad arpa domain name "hello.world": not a reversed ip network`,
<mask> u: "[/hello.world/]#",
<mask> }, {
<mask> name: "non-private_arpa_address",
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48431f8b86a1e4dde8aebb7539682eb8d043c556 | internal/dnsforward/http_test.go |
`"bad arpa domain name \"non.arpa.\": not a reversed ip network"`, | <mask> }, {
<mask> name: "several_bad",
<mask> wantErr: `checking domain-specific upstreams: 2 errors: ` +
<mask> `"arpa domain \"1.2.3.4.in-addr.arpa.\" should point to a locally-served network", ` +
<mask> `"bad arpa domain name \"non.arpa\": not a reversed ip network"`,
<mask> u: "[/non.arpa/1.2.3... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48431f8b86a1e4dde8aebb7539682eb8d043c556 | internal/dnsforward/http_test.go |
}, {
name: "partial_good",
wantErr: "",
u: "[/a.1.2.3.10.in-addr.arpa/a.10.in-addr.arpa/]#", | <mask> wantErr: `checking domain-specific upstreams: 2 errors: ` +
<mask> `"arpa domain \"1.2.3.4.in-addr.arpa.\" should point to a locally-served network", ` +
<mask> `"bad arpa domain name \"non.arpa.\": not a reversed ip network"`,
<mask> u: "[/non.arpa/1.2.3.4.in-addr.arpa/127.in-addr.arpa/]#",
<mask... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48431f8b86a1e4dde8aebb7539682eb8d043c556 | internal/dnsforward/http_test.go |
sharp := strings.IndexByte(host, '#')
if sharp == 0 {
break // skip the rest of the line after #
} else if sharp > 0 {
host = host[:sharp]
}
| <mask> host := fields[i]
<mask> if len(host) == 0 {
<mask> break
<mask> }
<mask> a.updateTable(table, host, ipAddr)
<mask> a.updateTableRev(tableRev, host, ipAddr)
<mask> if sharp >= 0 {
<mask> break // skip the rest of the line after #
<mask> }
<mask> }
</s> * auto-hosts: supp... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/4870da7f94e040fea63f2ff99bf1b79ee5da457e | util/auto_hosts.go |
if sharp >= 0 {
break // skip the rest of the line after #
} | <mask> a.updateTable(table, host, ipAddr)
<mask> a.updateTableRev(tableRev, host, ipAddr)
<mask> }
<mask> }
<mask> }
<mask>
<mask> // Receive notifications from fsnotify package
</s> * auto-hosts: support '#' comments after ip and hosts
Close #1807
Squashed commit of the following:
commit 9d3e2809df... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/4870da7f94e040fea63f2ff99bf1b79ee5da457e | util/auto_hosts.go |
_, _ = f.WriteString(" 127.0.0.1 host localhost # comment \n")
_, _ = f.WriteString(" ::1 localhost#comment \n") | <mask> f, _ := ioutil.TempFile(dir, "")
<mask> defer func() { _ = os.Remove(f.Name()) }()
<mask> defer f.Close()
<mask>
<mask> _, _ = f.WriteString(" 127.0.0.1 host localhost \n")
<mask> _, _ = f.WriteString(" ::1 localhost \n")
<mask>
<mask> ah.Init(f.Name())
<mask>
<mask> // Update from t... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/4870da7f94e040fea63f2ff99bf1b79ee5da457e | util/auto_hosts_test.go |
// Unknown host (comment)
ips = ah.Process("comment", dns.TypeA)
assert.Nil(t, ips)
| <mask> ips = ah.Process("newhost", dns.TypeA)
<mask> assert.Nil(t, ips)
<mask>
<mask> // Test hosts file
<mask> table := ah.List()
<mask> name, ok := table["127.0.0.1"]
<mask> assert.True(t, ok)
</s> * auto-hosts: support '#' comments after ip and hosts
Close #1807
Squashed commit of the following:
com... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/4870da7f94e040fea63f2ff99bf1b79ee5da457e | util/auto_hosts_test.go |
log.Debug("%s: handling the request for %s", hostsContainerPrefix, req.Hostname) | <mask> req *urlfilter.DNSRequest,
<mask> ) (res *urlfilter.DNSResult, ok bool) {
<mask> switch req.DNSType {
<mask> case dns.TypeA, dns.TypeAAAA, dns.TypePTR:
<mask> log.Debug("%s: handling the request for %s", hostsContainerPref, req.Hostname)
<mask> default:
<mask> return nil, false
<mask> }
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
// hostsContainerPrefix is a prefix for logging and wrapping errors in | <mask>
<mask> rm.translator = tr
<mask> }
<mask>
<mask> // hostsContainerPref is a prefix for logging and wrapping errors in
<mask> // HostsContainer's methods.
<mask> const hostsContainerPref = "hosts container"
<mask>
<mask> // HostsContainer stores the relevant hosts database provided by the OS and
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
const hostsContainerPrefix = "hosts container" | <mask> }
<mask>
<mask> // hostsContainerPref is a prefix for logging and wrapping errors in
<mask> // HostsContainer's methods.
<mask> const hostsContainerPref = "hosts container"
<mask>
<mask> // HostsContainer stores the relevant hosts database provided by the OS and
<mask> // processes both A/AAAA and PTR ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
// watcher tracks the changes in specified files and directories.
watcher aghos.FSWatcher | <mask>
<mask> // fsys is the working file system to read hosts files from.
<mask> fsys fs.FS
<mask>
<mask> // w tracks the changes in specified files and directories.
<mask> w aghos.FSWatcher
<mask>
<mask> // patterns stores specified paths in the fs.Glob-compatible form.
<mask> patterns []string
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
defer func() { err = errors.Annotate(err, "%s: %w", hostsContainerPrefix) }() | <mask> fsys fs.FS,
<mask> w aghos.FSWatcher,
<mask> paths ...string,
<mask> ) (hc *HostsContainer, err error) {
<mask> defer func() { err = errors.Annotate(err, "%s: %w", hostsContainerPref) }()
<mask>
<mask> if len(paths) == 0 {
<mask> return nil, ErrNoHostsPaths
<mask> }
<mask>
</s> Pull request ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
watcher: w, | <mask> listID: listID,
<mask> done: make(chan struct{}, 1),
<mask> updates: make(chan HostsRecords, 1),
<mask> fsys: fsys,
<mask> w: w,
<mask> patterns: patterns,
<mask> }
<mask>
<mask> log.Debug("%s: starting", hostsContainerPref)
<mask>
</s> Pull request 1786: rm-context-f... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
log.Debug("%s: starting", hostsContainerPrefix) | <mask> w: w,
<mask> patterns: patterns,
<mask> }
<mask>
<mask> log.Debug("%s: starting", hostsContainerPref)
<mask>
<mask> // Load initially.
<mask> if err = hc.refresh(); err != nil {
<mask> return nil, err
<mask> }
</s> Pull request 1786: rm-context-fields
Merge in DNS/adguard-home fro... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
log.Debug("%s: %s is expected to exist but doesn't", hostsContainerPrefix, p) | <mask> if !errors.Is(err, fs.ErrNotExist) {
<mask> return nil, fmt.Errorf("adding path: %w", err)
<mask> }
<mask>
<mask> log.Debug("%s: %s is expected to exist but doesn't", hostsContainerPref, p)
<mask> }
<mask> }
<mask>
<mask> go hc.handleEvents()
<mask>
</s> Pull request 1786: rm-conte... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
// Close implements the [io.Closer] interface for *HostsContainer. It closes
// both itself and its [aghos.FSWatcher]. Close must only be called once. | <mask>
<mask> return hc, nil
<mask> }
<mask>
<mask> // Close implements the io.Closer interface for *HostsContainer. Close must
<mask> // only be called once. The returned err is always nil.
<mask> func (hc *HostsContainer) Close() (err error) {
<mask> log.Debug("%s: closing", hostsContainerPref)
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
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.
} | <mask>
<mask> // Close implements the io.Closer interface for *HostsContainer. Close must
<mask> // only be called once. The returned err is always nil.
<mask> func (hc *HostsContainer) Close() (err error) {
<mask> log.Debug("%s: closing", hostsContainerPref)
<mask>
<mask> close(hc.done)
<mask>
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
return err | <mask> log.Debug("%s: closing", hostsContainerPref)
<mask>
<mask> close(hc.done)
<mask>
<mask> return nil
<mask> }
<mask>
<mask> // Upd returns the channel into which the updates are sent.
<mask> func (hc *HostsContainer) Upd() (updates <-chan HostsRecords) {
<mask> return hc.updates
</s> Pull request... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPrefix)) | <mask> // handleEvents concurrently handles the file system events. It closes the
<mask> // update channel of HostsContainer when finishes. It's used to be called
<mask> // within a separate goroutine.
<mask> func (hc *HostsContainer) handleEvents() {
<mask> defer log.OnPanic(fmt.Sprintf("%s: handling events", ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
ok, eventsCh := true, hc.watcher.Events() | <mask> defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPref))
<mask>
<mask> defer close(hc.updates)
<mask>
<mask> ok, eventsCh := true, hc.w.Events()
<mask> for ok {
<mask> select {
<mask> case _, ok = <-eventsCh:
<mask> if !ok {
<mask> log.Debug("%s: watcher closed the eve... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
log.Debug("%s: watcher closed the events channel", hostsContainerPrefix) | <mask> for ok {
<mask> select {
<mask> case _, ok = <-eventsCh:
<mask> if !ok {
<mask> log.Debug("%s: watcher closed the events channel", hostsContainerPref)
<mask>
<mask> continue
<mask> }
<mask>
<mask> if err := hc.refresh(); err != nil {
</s> Pull request 1786: rm-context-fields
M... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
log.Error("%s: %s", hostsContainerPrefix, err) | <mask> continue
<mask> }
<mask>
<mask> if err := hc.refresh(); err != nil {
<mask> log.Error("%s: %s", hostsContainerPref, err)
<mask> }
<mask> case _, ok = <-hc.done:
<mask> // Go on.
<mask> }
<mask> }
</s> Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-con... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
log.Error("%s: host %q is invalid, ignoring", hostsContainerPrefix, f) | <mask> //
<mask> // TODO(e.burkov): Investigate if hosts may contain DNS-SD domains.
<mask> err = netutil.ValidateHostname(f)
<mask> if err != nil {
<mask> log.Error("%s: host %q is invalid, ignoring", hostsContainerPref, f)
<mask>
<mask> continue
<mask> }
<mask>
<mask> hosts = append(hos... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
log.Debug("%s: added ip-host pair %q-%q", hostsContainerPrefix, ip, host) | <mask> func (hp *hostsParser) addRules(ip netip.Addr, host, line string) {
<mask> rule, rulePtr := hp.writeRules(host, ip)
<mask> hp.translations[rule], hp.translations[rulePtr] = line, line
<mask>
<mask> log.Debug("%s: added ip-host pair %q-%q", hostsContainerPref, ip, host)
<mask> }
<mask>
<mask> // writ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
log.Debug("%s: sending upd", hostsContainerPrefix) | <mask> }
<mask>
<mask> // sendUpd tries to send the parsed data to the ch.
<mask> func (hp *hostsParser) sendUpd(ch chan HostsRecords) {
<mask> log.Debug("%s: sending upd", hostsContainerPref)
<mask>
<mask> upd := hp.table
<mask> select {
<mask> case ch <- upd:
<mask> // Updates are delivered. Go on.... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
log.Debug("%s: replaced the last update", hostsContainerPrefix) | <mask> case ch <- upd:
<mask> // Updates are delivered. Go on.
<mask> case <-ch:
<mask> ch <- upd
<mask> log.Debug("%s: replaced the last update", hostsContainerPref)
<mask> case ch <- upd:
<mask> // The previous update was just read and the next one pushed. Go on.
<mask> default:
<mask> log.Er... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
log.Error("%s: the updates channel is broken", hostsContainerPrefix) | <mask> log.Debug("%s: replaced the last update", hostsContainerPref)
<mask> case ch <- upd:
<mask> // The previous update was just read and the next one pushed. Go on.
<mask> default:
<mask> log.Error("%s: the updates channel is broken", hostsContainerPref)
<mask> }
<mask> }
<mask>
<mask> // newStrg... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
log.Debug("%s: refreshing", hostsContainerPrefix) | <mask> // needed.
<mask> //
<mask> // TODO(e.burkov): Accept a parameter to specify the files to refresh.
<mask> func (hc *HostsContainer) refresh() (err error) {
<mask> log.Debug("%s: refreshing", hostsContainerPref)
<mask>
<mask> hp := hc.newHostsParser()
<mask> if _, err = aghos.FileWalker(hp.parseFile)... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
log.Debug("%s: no changes detected", hostsContainerPrefix) | <mask> }
<mask>
<mask> // hc.last is nil on the first refresh, so let that one through.
<mask> if hc.last != nil && maps.EqualFunc(hp.table, hc.last, (*HostsRecord).equal) {
<mask> log.Debug("%s: no changes detected", hostsContainerPref)
<mask>
<mask> return nil
<mask> }
<mask> defer hp.sendUpd(hc.u... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer.go |
OnClose: func() (err error) { return nil }, | <mask>
<mask> hc, err := NewHostsContainer(0, testFS, &aghtest.FSWatcher{
<mask> OnEvents: onEvents,
<mask> OnAdd: onAdd,
<mask> OnClose: func() (err error) { panic("not implemented") },
<mask> }, tc.paths...)
<mask> if tc.wantErr != nil {
<mask> require.ErrorIs(t, err, tc.wantErr)... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer_test.go |
OnClose: func() (err error) { return nil }, | <mask>
<mask> errWatcher := &aghtest.FSWatcher{
<mask> OnEvents: func() (e <-chan struct{}) { panic("not implemented") },
<mask> OnAdd: func(name string) (err error) { return errOnAdd },
<mask> OnClose: func() (err error) { panic("not implemented") },
<mask> }
<mask>
<mask> hc, err := NewHo... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer_test.go |
OnClose: func() (err error) { return nil }, | <mask> assert.Equal(t, "dir", name)
<mask>
<mask> return nil
<mask> },
<mask> OnClose: func() (err error) { panic("not implemented") },
<mask> }
<mask>
<mask> hc, err := NewHostsContainer(0, testFS, w, "dir")
<mask> require.NoError(t, err)
<mask> testutil.CleanupAndRequireSuccess(t, hc.Close)
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer_test.go |
OnClose: func() (err error) { return nil }, | <mask> func TestHostsContainer_Translate(t *testing.T) {
<mask> stubWatcher := aghtest.FSWatcher{
<mask> OnEvents: func() (e <-chan struct{}) { return nil },
<mask> OnAdd: func(name string) (err error) { return nil },
<mask> OnClose: func() (err error) { panic("not implemented") },
<mask> }
<mask>
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer_test.go |
OnClose: func() (err error) { return nil }, | <mask>
<mask> stubWatcher := aghtest.FSWatcher{
<mask> OnEvents: func() (e <-chan struct{}) { return nil },
<mask> OnAdd: func(name string) (err error) { return nil },
<mask> OnClose: func() (err error) { panic("not implemented") },
<mask> }
<mask>
<mask> hc, err := NewHostsContainer(listID, test... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/aghnet/hostscontainer_test.go |
// etcHosts contains IP-hostname mappings taken from the OS-specific hosts
// configuration files, for example /etc/hosts. | <mask> auth *Auth // HTTP authentication module
<mask> filters *filtering.DNSFilter // DNS filtering module
<mask> web *Web // Web (HTTP, HTTPS) module
<mask> tls *tlsManager // TLS module
<mask> // etcHosts is an IP-hostname pairs set taken from ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go |
<mask> tls *tlsManager // TLS module
<mask> // etcHosts is an IP-hostname pairs set taken from system configuration
<mask> // (e.g. /etc/hosts) files.
<mask> etcHosts *aghnet.HostsContainer
<mask> // hostsWatcher is the watcher to detect changes in the hosts files.
<mask> hostsWatcher aghos.... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go | |
<mask> workDir string // Location of our directory, used to protect against CWD being somewhere else
<mask> pidFileName string // PID file name. Empty if no PID file was created.
<mask> controlLock sync.Mutex
<mask> tlsRoots *x509.CertPool // list of root CAs for TLSv1.2
<mask> tra... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go | |
<mask> func setupContext(opts options) {
<mask> setupContextFlags(opts)
<mask>
<mask> Context.tlsRoots = aghtls.SystemRootCAs()
<mask> Context.transport = &http.Transport{
<mask> DialContext: customDialContext,
<mask> Proxy: getHTTPProxy,
<mask> TLSClientConfig: &tls.Config{
<mask> RootCAs: ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go | |
Timeout: time.Minute * 5,
Transport: &http.Transport{
DialContext: customDialContext,
Proxy: getHTTPProxy,
TLSClientConfig: &tls.Config{
RootCAs: Context.tlsRoots,
CipherSuites: Context.tlsCipherIDs,
MinVersion: tls.VersionTLS12,
},
}, | <mask> MinVersion: tls.VersionTLS12,
<mask> },
<mask> }
<mask> Context.client = &http.Client{
<mask> Timeout: time.Minute * 5,
<mask> Transport: Context.transport,
<mask> }
<mask>
<mask> if !Context.firstRun {
<mask> // Do the upgrade if necessary.
<mask> err := upgradeConfig()
</s> Pu... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go |
hostsWatcher, err := aghos.NewOSWritesWatcher() | <mask>
<mask> // setupHostsContainer initializes the structures to keep up-to-date the hosts
<mask> // provided by the OS.
<mask> func setupHostsContainer() (err error) {
<mask> Context.hostsWatcher, err = aghos.NewOSWritesWatcher()
<mask> if err != nil {
<mask> return fmt.Errorf("initing hosts watcher: %w"... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go |
hostsWatcher, | <mask>
<mask> Context.etcHosts, err = aghnet.NewHostsContainer(
<mask> filtering.SysHostsListID,
<mask> aghos.RootDirFS(),
<mask> Context.hostsWatcher,
<mask> aghnet.DefaultHostsPaths()...,
<mask> )
<mask> if err != nil {
<mask> cerr := Context.hostsWatcher.Close()
<mask> if errors.Is(err, agh... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go |
closeErr := hostsWatcher.Close()
if errors.Is(err, aghnet.ErrNoHostsPaths) && closeErr == nil { | <mask> Context.hostsWatcher,
<mask> aghnet.DefaultHostsPaths()...,
<mask> )
<mask> if err != nil {
<mask> cerr := Context.hostsWatcher.Close()
<mask> if errors.Is(err, aghnet.ErrNoHostsPaths) && cerr == nil {
<mask> log.Info("warning: initing hosts container: %s", err)
<mask>
<mask> return nil... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go |
return errors.WithDeferred(fmt.Errorf("initing hosts container: %w", err), closeErr) | <mask>
<mask> return nil
<mask> }
<mask>
<mask> return errors.WithDeferred(fmt.Errorf("initing hosts container: %w", err), cerr)
<mask> }
<mask>
<mask> return nil
<mask> }
<mask>
</s> Pull request 1786: rm-context-fields
Merge in DNS/adguard-home from rm-context-fields to master
Squashed commi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go |
<mask> }
<mask> }
<mask>
<mask> if Context.etcHosts != nil {
<mask> // Currently Context.hostsWatcher is only used in Context.etcHosts and
<mask> // needs closing only in case of the successful initialization of
<mask> // Context.etcHosts.
<mask> if err = Context.hostsWatcher.Close(); err != nil {
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/487675b9adc1be7f725f763060e90720da32b852 | internal/home/home.go | |
// MaxDomainNameLen is the maximum allowed length of a full domain name | <mask> // maxDomainLabelLen is the maximum allowed length of a domain name label
<mask> // according to RFC 1035.
<mask> const maxDomainLabelLen = 63
<mask>
<mask> // maxDomainNameLen is the maximum allowed length of a full domain name
<mask> // according to RFC 1035.
<mask> //
<mask> // See https://stackoverf... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/aghnet/addr.go |
const MaxDomainNameLen = 253 | <mask> // maxDomainNameLen is the maximum allowed length of a full domain name
<mask> // according to RFC 1035.
<mask> //
<mask> // See https://stackoverflow.com/a/32294443/1892060.
<mask> const maxDomainNameLen = 253
<mask>
<mask> // ValidateDomainNameLabel returns an error if label is not a valid label of
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/aghnet/addr.go |
} else if l > MaxDomainNameLen {
return fmt.Errorf("too long, max: %d", MaxDomainNameLen) | <mask>
<mask> l := len(name)
<mask> if l == 0 {
<mask> return errors.Error("domain name is empty")
<mask> } else if l > maxDomainNameLen {
<mask> return fmt.Errorf("too long, max: %d", maxDomainNameLen)
<mask> }
<mask>
<mask> labels := strings.Split(name, ".")
<mask> for i, l := range labels {
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/aghnet/addr.go |
s.processRecursion, | <mask> // out of range checking in any of the following functions, because the
<mask> // (*proxy.Proxy).handleDNSRequest method performs it before calling the
<mask> // appropriate handler.
<mask> mods := []modProcessFunc{
<mask> processInitial,
<mask> s.processDetermineLocal,
<mask> s.processInternalH... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
s.processUpstream, | <mask> s.processInternalIPAddrs,
<mask> processClientID,
<mask> processFilteringBeforeRequest,
<mask> s.processLocalPTR,
<mask> processUpstream,
<mask> processDNSSECAfterResponse,
<mask> processFilteringAfterResponse,
<mask> s.ipset.process,
<mask> processQueryLogsAndStats,
<mask> }
</s> P... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
// 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", m... | <mask> return nil
<mask> }
<mask>
<mask> // Perform initial checks; process WHOIS & rDNS
<mask> func processInitial(ctx *dnsContext) (rc resultCode) {
<mask> s := ctx.srv
<mask> d := ctx.proxyCtx
<mask> if s.conf.AAAADisabled && d.Req.Question[0].Qtype == dns.TypeAAAA {
<mask> _ = proxy.CheckDisabledAA... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
s.recDetector.add(*d.Req) | <mask> }
<mask>
<mask> if s.conf.UsePrivateRDNS {
<mask> if err := s.localResolvers.Resolve(d); err != nil {
<mask> ctx.err = err
<mask>
<mask> return resultCodeError
<mask> }
<mask> }
</s> Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion to master
Closes #... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
func (s *Server) processUpstream(ctx *dnsContext) (rc resultCode) { | <mask> return resultCodeSuccess
<mask> }
<mask>
<mask> // processUpstream passes request to upstream servers and handles the response.
<mask> func processUpstream(ctx *dnsContext) (rc resultCode) {
<mask> s := ctx.srv
<mask> d := ctx.proxyCtx
<mask> if d.Res != nil {
<mask> return resultCodeSuccess // r... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
if upsConf := s.conf.GetCustomUpstreamByClient(clientIP); upsConf != nil {
log.Debug("dns: using custom upstreams for client %s", clientIP)
d.CustomUpstreamConfig = upsConf | <mask> }
<mask>
<mask> if d.Addr != nil && s.conf.GetCustomUpstreamByClient != nil {
<mask> clientIP := IPStringFromAddr(d.Addr)
<mask> upstreamsConf := s.conf.GetCustomUpstreamByClient(clientIP)
<mask> if upstreamsConf != nil {
<mask> log.Debug("Using custom upstreams for %s", clientIP)
<mask> d... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
req := d.Req | <mask> }
<mask> }
<mask>
<mask> if s.conf.EnableDNSSEC {
<mask> opt := req.IsEdns0()
<mask> if opt == nil {
<mask> log.Debug("dns: adding OPT record with DNSSEC flag")
<mask> req.SetEdns0(4096, true)
<mask> } else if !opt.Do() {
</s> Pull request: 3185 detecting recursion
Merge in DNS/adguar... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
opt := req.IsEdns0() | <mask> }
<mask> }
<mask>
<mask> if s.conf.EnableDNSSEC {
<mask> opt := d.Req.IsEdns0()
<mask> if opt == nil {
<mask> log.Debug("dns: Adding OPT record with DNSSEC flag")
<mask> d.Req.SetEdns0(4096, true)
<mask> } else if !opt.Do() {
<mask> opt.SetDo(true)
</s> Pull request: 3185 detecting... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
log.Debug("dns: adding OPT record with DNSSEC flag")
req.SetEdns0(4096, true) | <mask>
<mask> if s.conf.EnableDNSSEC {
<mask> opt := d.Req.IsEdns0()
<mask> if opt == nil {
<mask> log.Debug("dns: Adding OPT record with DNSSEC flag")
<mask> d.Req.SetEdns0(4096, true)
<mask> } else if !opt.Do() {
<mask> opt.SetDo(true)
<mask> } else {
<mask> ctx.origReqDNSSEC = true
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
s.recDetector.add(*req)
if ctx.err = s.dnsProxy.Resolve(d); ctx.err != nil { | <mask> }
<mask> }
<mask>
<mask> // request was not filtered so let it be processed further
<mask> err := s.dnsProxy.Resolve(d)
<mask> if err != nil {
<mask> ctx.err = err
<mask> return resultCodeError
<mask> }
<mask>
<mask> ctx.responseFromUpstream = true
<mask> return resultCodeSuccess
</s>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dns.go |
recDetector *recursionDetector | <mask> ipset ipsetCtx
<mask> subnetDetector *aghnet.SubnetDetector
<mask> localResolvers *proxy.Proxy
<mask>
<mask> tableHostToIP hostToIPTable
<mask> tableHostToIPLock sync.Mutex
<mask>
<mask> tableIPToHost ipToHostTable
<mask> tableIPToHostLock sync.Mutex
</s> Pull request: 3185 de... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dnsforward.go |
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
)
| <mask>
<mask> return string(b)
<mask> }
<mask>
<mask> // NewServer creates a new instance of the dnsforward.Server
<mask> // Note: this function must be called only once
<mask> func NewServer(p DNSCreateParams) (s *Server, err error) {
<mask> var localDomainSuffix string
<mask> if p.LocalDomain == "" {
<... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dnsforward.go |
recDetector: newRecursionDetector(recursionTTL, cachedRecurrentReqNum), | <mask> queryLog: p.QueryLog,
<mask> subnetDetector: p.SubnetDetector,
<mask> localDomainSuffix: localDomainSuffix,
<mask> }
<mask>
<mask> if p.DHCPServer != nil {
<mask> s.dhcpServer = p.DHCPServer
<mask> s.dhcpServer.SetOnLeaseChanged(s.onDHCPLeaseChanged)
<mask> s.onDHCPLeaseChange... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dnsforward.go |
s := &Server{
recDetector: newRecursionDetector(0, 1),
} | <mask> }
<mask>
<mask> // NewCustomServer creates a new instance of *Server with custom internal proxy.
<mask> func NewCustomServer(internalProxy *proxy.Proxy) *Server {
<mask> s := &Server{}
<mask> if internalProxy != nil {
<mask> s.internalProxy = internalProxy
<mask> }
<mask>
<mask> return s
</s> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dnsforward.go |
s.recDetector.add(*req)
if err = resolver.Resolve(ctx); err != nil { | <mask> Proto: "udp",
<mask> Req: req,
<mask> StartTime: time.Now(),
<mask> }
<mask> var resp *dns.Msg
<mask> err = resolver.Resolve(ctx)
<mask> if err != nil {
<mask> return "", err
<mask> }
<mask>
<mask> resp = ctx.Res
<mask>
</s> Pull request: 3185 detecting recursion
Merge in ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dnsforward.go |
resp := ctx.Res | <mask> if err != nil {
<mask> return "", err
<mask> }
<mask>
<mask> resp = ctx.Res
<mask>
<mask> if len(resp.Answer) == 0 {
<mask> return "", fmt.Errorf("lookup for %q: %w", arpa, rDNSEmptyAnswerErr)
<mask> }
<mask>
<mask> ptr, ok := resp.Answer[0].(*dns.PTR)
</s> Pull request: 3185 detecting r... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dnsforward.go |
s.recDetector.clear()
| <mask> return fmt.Errorf("setting up resolvers: %w", err)
<mask> }
<mask>
<mask> return nil
<mask> }
<mask>
<mask> // Stop stops the DNS server.
<mask> func (s *Server) Stop() error {
<mask> s.serverLock.Lock()
</s> Pull request: 3185 detecting recursion
Merge in DNS/adguard-home from 3185-recursion t... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48b8579703344236296437410697bc99ff18adc4 | internal/dnsforward/dnsforward.go |
"runtime" | <mask> "fmt"
<mask> "os/exec"
<mask> "syscall"
<mask> )
<mask>
<mask> // UnsupportedError is returned by functions and methods when a particular
</s> Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: A... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/aghos/os.go |
<mask> import (
<mask> "fmt"
<mask> "os/exec"
<mask> "syscall"
<mask>
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> )
<mask>
<mask> // ErrUnsupported is returned when the functionality is unsupported on the
<mask> // current operating system.
<mask> //
</s> Pull request: all: support setgid, se... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/aghos/os.go | |
// 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... | <mask>
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> )
<mask>
<mask> // ErrUnsupported is returned when the functionality is unsupported on the
<mask> // current operating system.
<mask> //
<mask> // TODO(a.garipov): Make a structured error and use it everywhere instead of
<mask> // a bunch of fmt.Er... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/aghos/os.go |
<mask>
<mask> package aghos
<mask>
<mask> import (
<mask> "fmt"
<mask> "syscall"
<mask>
<mask> "golang.org/x/sys/windows"
<mask> )
<mask>
</s> Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Author: A... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/aghos/os_windows.go | |
return Unsupported("setrlimit") | <mask> return HaveAdminRights()
<mask> }
<mask>
<mask> func setRlimit(val uint64) (err error) {
<mask> return ErrUnsupported
<mask> }
<mask>
<mask> func haveAdminRights() (bool, error) {
<mask> var token windows.Token
<mask> h := windows.CurrentProcess()
</s> Pull request: all: support setgid, setuid o... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/aghos/os_windows.go |
return Unsupported("kill") | <mask> return true, nil
<mask> }
<mask>
<mask> func sendProcessSignal(pid int, sig syscall.Signal) error {
<mask> return fmt.Errorf("not supported on Windows")
<mask> }
<mask>
<mask> func isOpenWrt() (ok bool) {
<mask> return false
<mask> }
</s> Pull request: all: support setgid, setuid on unix
Updates... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/aghos/os_windows.go |
"github.com/AdguardTeam/AdGuardHome/internal/aghos" | <mask> "runtime"
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghnet"
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/insomniacslk/dhcp/dhcpv4"
<mask> "github.com/insomniacslk/dhcp/dhcpv4/nclient4"
<mask> "github.c... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/dhcpd/checkother.go |
return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4") | <mask>
<mask> // TODO(a.garipov): Find out what this is about. Perhaps this
<mask> // information is outdated or at least incomplete.
<mask> if runtime.GOOS == "darwin" {
<mask> return false, fmt.Errorf("can't find DHCP server: not supported on macOS")
<mask> }
<mask>
<mask> srcIP := ifaceIPNet[0]
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/dhcpd/checkother.go |
import "github.com/AdguardTeam/AdGuardHome/internal/aghos" | <mask> package dhcpd
<mask>
<mask> import "fmt"
<mask>
<mask> func CheckIfOtherDHCPServersPresentV4(ifaceName string) (bool, error) {
<mask> return false, fmt.Errorf("not supported")
<mask> }
<mask>
</s> Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
c... | [
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/dhcpd/checkother_windows.go |
return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV4") | <mask>
<mask> import "fmt"
<mask>
<mask> func CheckIfOtherDHCPServersPresentV4(ifaceName string) (bool, error) {
<mask> return false, fmt.Errorf("not supported")
<mask> }
<mask>
<mask> func CheckIfOtherDHCPServersPresentV6(ifaceName string) (bool, error) {
<mask> return false, fmt.Errorf("not supported")
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/dhcpd/checkother_windows.go |
return false, aghos.Unsupported("CheckIfOtherDHCPServersPresentV6") | <mask> return false, fmt.Errorf("not supported")
<mask> }
<mask>
<mask> func CheckIfOtherDHCPServersPresentV6(ifaceName string) (bool, error) {
<mask> return false, fmt.Errorf("not supported")
<mask> }
</s> Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
c... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/dhcpd/checkother_windows.go |
"github.com/AdguardTeam/AdGuardHome/internal/aghos" | <mask>
<mask> import (
<mask> "net"
<mask>
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "golang.org/x/net/ipv4"
<mask> )
<mask>
<mask> // Create a socket for receiving broadcast packets
<mask> func newBroadcastPacketConn(bindAddr net.IP, port int, ifname string) (*ipv4.PacketConn, error) {
</s>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/dhcpd/os_windows.go |
func newBroadcastPacketConn(_ net.IP, _ int, _ string) (*ipv4.PacketConn, error) {
return nil, aghos.Unsupported("newBroadcastPacketConn") | <mask> "golang.org/x/net/ipv4"
<mask> )
<mask>
<mask> // Create a socket for receiving broadcast packets
<mask> func newBroadcastPacketConn(bindAddr net.IP, port int, ifname string) (*ipv4.PacketConn, error) {
<mask> return nil, errors.Error("newBroadcastPacketConn(): not supported on Windows")
<mask> }
</s>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/dhcpd/os_windows.go |
// 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... | <mask> LogFile string `yaml:"log_file"` // Path to the log file. If empty, write to stdout. If "syslog", writes to syslog
<mask> Verbose bool `yaml:"verbose"` // If true, verbose logging is enabled
<mask> }
<mask>
<mask> // configuration is loaded from YAML
<mask> // field ordering... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/config.go |
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 | <mask> AuthAttempts uint `yaml:"auth_attempts"`
<mask> // AuthBlockMin is the duration, in minutes, of the block of new login
<mask> // attempts after AuthAttempts unsuccessful login attempts.
<mask> AuthBlockMin uint `yaml:"block_auth_min"`
<mask> ProxyURL string `yaml:"http_proxy"` // Proxy address... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/config.go |
OSConfig *osConfig `yaml:"os"`
| <mask>
<mask> logSettings `yaml:",inline"`
<mask>
<mask> sync.RWMutex `yaml:"-"`
<mask>
<mask> SchemaVersion int `yaml:"schema_version"` // keeping last so that users will be less tempted to change it -- used when upgrading between versions
<mask> }
</s> Pull request: all: support setgid, setuid on unix
... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/config.go |
OSConfig: &osConfig{}, | <mask> LogMaxBackups: 0,
<mask> LogMaxSize: 100,
<mask> LogMaxAge: 3,
<mask> },
<mask> SchemaVersion: currentSchemaVersion,
<mask> }
<mask>
<mask> // initConfig initializes default configuration for the current OS&ARCH
<mask> func initConfig() {
</s> Pull request: all: support setgid, setuid o... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/config.go |
log.Fatal("service actions are not supported on openbsd, see issue 3226") | <mask> // TODO(a.garipov): github.com/kardianos/service doesn't seem to
<mask> // support OpenBSD currently. Either patch it to do so or make
<mask> // our own implementation of the service.System interface.
<mask> if runtime.GOOS == "openbsd" {
<mask> log.Fatal("service actions are not supported on op... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/home.go |
<mask> }
<mask> Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts)
<mask> config.Clients = nil
<mask>
<mask> if config.RlimitNoFile != 0 {
<mask> err = aghos.SetRlimit(config.RlimitNoFile)
<mask> if err != nil && !errors.Is(err, aghos.ErrUnsupported) {
<mask> return fmt.Error... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/home.go | |
err = configureOS(&config)
fatalOnError(err)
| <mask>
<mask> setupContext(args)
<mask>
<mask> // clients package uses filtering package's static data (filtering.BlockedSvcKnown()),
<mask> // so we have to initialize filtering's static data first,
<mask> // but also avoid relying on automatic Go init() function
<mask> filtering.InitModule()
</s> Pul... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/home.go |
const currentSchemaVersion = 11 | <mask> yaml "gopkg.in/yaml.v2"
<mask> )
<mask>
<mask> // currentSchemaVersion is the current schema version.
<mask> const currentSchemaVersion = 10
<mask>
<mask> // These aliases are provided for convenience.
<mask> type (
<mask> any = interface{}
<mask> yarr = []any
</s> Pull request: all: support set... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/upgrade.go |
upgradeSchema10to11, | <mask> upgradeSchema7to8,
<mask> upgradeSchema8to9,
<mask> upgradeSchema9to10,
<mask> }
<mask>
<mask> n := 0
<mask> for i, u := range upgrades {
</s> Pull request: all: support setgid, setuid on unix
Updates #2763.
Squashed commit of the following:
commit bd2077c6569b53ae341a58aa73de6063d7037e8e
Au... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48c44c29aba472839b25fe1132c6ee8b91a27bba | internal/home/upgrade.go |
// 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
}
| <mask> }
<mask>
<mask> // InSlice checks if string is in the slice of strings.
<mask> func InSlice(strs []string, str string) (ok bool) {
<mask> for _, s := range strs {
<mask> if s == str {
<mask> return true
<mask> }
</s> Pull request: all: fix client custom upstream comments
Updates #2947.
Squash... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/aghstrings/strings.go |
// 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] == '#'
}
| <mask>
<mask> return false
<mask> }
<mask>
<mask> // SplitNext splits string by a byte and returns the first chunk skipping empty
<mask> // ones. Whitespaces are trimmed.
<mask> func SplitNext(s *string, sep rune) (chunk string) {
<mask> if s == nil {
</s> Pull request: all: fix client custom upstream com... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/aghstrings/strings.go |
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)
}
| <mask> assert.Equal(t, CloneSlice(a), CloneSliceOrEmpty(a))
<mask> })
<mask> }
<mask>
<mask> func TestInSlice(t *testing.T) {
<mask> simpleStrs := []string{"1", "2", "3"}
<mask>
<mask> testCases := []struct {
<mask> name string
</s> Pull request: all: fix client custom upstream comments
Updates #294... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/aghstrings/strings_test.go |
upstreams = aghstrings.FilterOut(upstreams, aghstrings.IsCommentOrEmpty) | <mask> } else {
<mask> upstreams = s.conf.UpstreamDNS
<mask> }
<mask>
<mask> upstreams = filterOutComments(upstreams)
<mask> upstreamConfig, err := proxy.ParseUpstreamsConfig(
<mask> upstreams,
<mask> upstream.Options{
<mask> Bootstrap: s.conf.BootstrapDNS,
<mask> Timeout: DefaultTimeout,
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/dnsforward/config.go |
// collectDNSIPAddrs returns IP addresses the server is listening on without
// port numbers as a map. For internal use only. | <mask> // locally-served networks. It is assumed that local resolvers should work much
<mask> // faster than ordinary upstreams.
<mask> const defaultLocalTimeout = 1 * time.Second
<mask>
<mask> // collectDNSIPAddrs returns the slice of IP addresses without port number which
<mask> // we are listening on. For i... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/dnsforward/dnsforward.go |
// unit is used to show the presence of a value in a set.
type unit = struct{} | <mask>
<mask> return addrs[:i], nil
<mask> }
<mask>
<mask> // stringSetSubtract subtracts b from a interpreted as sets.
<mask> func stringSetSubtract(a, b []string) (c []string) {
<mask> // unit is an object to be used as value in set.
<mask> type unit = struct{}
<mask>
<mask> cSet := make(map[string]u... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/dnsforward/dnsforward.go |
// 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{} | <mask> func stringSetSubtract(a, b []string) (c []string) {
<mask> // unit is an object to be used as value in set.
<mask> type unit = struct{}
<mask>
<mask> cSet := make(map[string]unit)
<mask> for _, k := range a {
<mask> cSet[k] = unit{}
<mask> }
<mask>
<mask> for _, k := range b {
<mask> dele... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/dnsforward/dnsforward.go |
return set | <mask> for _, k := range a {
<mask> cSet[k] = unit{}
<mask> }
<mask>
<mask> for _, k := range b {
<mask> delete(cSet, k)
<mask> }
<mask>
<mask> c = make([]string, len(cSet))
<mask> i := 0
<mask> for k := range cSet {
<mask> c[i] = k
<mask> i++
<mask> }
<mask>
<mask> return c
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/dnsforward/dnsforward.go |
ourAddrsSet := sliceToSet(ourAddrs)
| <mask> }
<mask>
<mask> // TODO(e.burkov): The approach of subtracting sets of strings is not
<mask> // really applicable here since in case of listening on all network
<mask> // interfaces we should check the whole interface's network to cut off
<mask> // all the loopback addresses as well.
<mask> localAd... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/dnsforward/dnsforward.go |
localAddrs = aghstrings.FilterOut(localAddrs, func(s string) (ok bool) {
_, ok = ourAddrsSet[s]
return ok
}) | <mask> // TODO(e.burkov): The approach of subtracting sets of strings is not
<mask> // really applicable here since in case of listening on all network
<mask> // interfaces we should check the whole interface's network to cut off
<mask> // all the loopback addresses as well.
<mask> localAddrs = stringSetSubtr... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/dnsforward/dnsforward.go |
upstreams = aghstrings.FilterOut(upstreams, aghstrings.IsCommentOrEmpty) | <mask> //
<mask> // TODO(e.burkov): Move into aghnet or even into dnsproxy.
<mask> func ValidateUpstreams(upstreams []string) (err error) {
<mask> // No need to validate comments
<mask> upstreams = filterOutComments(upstreams)
<mask>
<mask> // Consider this case valid because defaultDNS will be used
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/48d702f76ac2e651ce788abf006799efcd482152 | internal/dnsforward/http.go |
if aghstrings.IsCommentOrEmpty(input) { | <mask> return nil
<mask> }
<mask>
<mask> func checkDNS(input string, bootstrap []string, ef excFunc) (err error) {
<mask> if !isUpstream(input) {
<mask> return nil
<mask> }
<mask>
<mask> // Separate upstream from domains list.
<mask> var useDefault bool
</s> Pull request: all: fix client custom upst... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | 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.