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
<mask> <mask> import ( <mask> "bufio" <mask> "io" <mask> "io/fs" <mask> "path" <mask> "testing" <mask> "testing/fstest" <mask> <mask> "github.com/AdguardTeam/golibs/errors" </s> Pull request #1558: add-dnssvc Merge in DNS/adguard-home from add-dnssvc to master Squashed commit of the following: co...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghos/filewalker_test.go
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
<mask> "testing" <mask> "testing/fstest" <mask> <mask> "github.com/AdguardTeam/golibs/errors" <mask> "github.com/stretchr/testify/assert" <mask> "github.com/stretchr/testify/require" <mask> ) <mask> </s> Pull request #1558: add-dnssvc Merge in DNS/adguard-home from add-dnssvc to master Squashed commit...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghos/filewalker_test.go
makeFileWalker := func(_ string) (fw aghos.FileWalker) {
<mask> <mask> func TestFileWalker_Walk(t *testing.T) { <mask> const attribute = `000` <mask> <mask> makeFileWalker := func(_ string) (fw FileWalker) { <mask> return func(r io.Reader) (patterns []string, cont bool, err error) { <mask> s := bufio.NewScanner(r) <mask> for s.Scan() { <mask> line :=...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghos/filewalker_test.go
ok, err := aghos.FileWalker(func(r io.Reader) (patterns []string, cont bool, err error) {
<mask> <mask> f := fstest.MapFS{ <mask> filename: &fstest.MapFile{Data: []byte("[]")}, <mask> } <mask> ok, err := FileWalker(func(r io.Reader) (patterns []string, cont bool, err error) { <mask> s := bufio.NewScanner(r) <mask> for s.Scan() { <mask> patterns = append(patterns, s.Text()) <mask...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghos/filewalker_test.go
ok, err := aghos.FileWalker(func(r io.Reader) (patterns []string, ok bool, err error) {
<mask> f := fstest.MapFS{ <mask> "mockfile.txt": &fstest.MapFile{Data: []byte(`mockdata`)}, <mask> } <mask> <mask> ok, err := FileWalker(func(r io.Reader) (patterns []string, ok bool, err error) { <mask> return nil, true, rerr <mask> }).Walk(f, "*") <mask> require.ErrorIs(t, err, rerr) <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghos/filewalker_test.go
<mask> <mask> assert.False(t, ok) <mask> }) <mask> } <mask> <mask> type errFS struct { <mask> fs.GlobFS <mask> } <mask> <mask> const errErrFSOpen errors.Error = "this error is always returned" <mask> <mask> func (efs *errFS) Open(name string) (fs.File, error) { <mask> return nil, errErrFSOpen <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "re...
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghos/filewalker_test.go
"testing"
<mask> "encoding/hex" <mask> "fmt" <mask> "net" <mask> "strings" <mask> "sync" <mask> <mask> "github.com/miekg/dns" <mask> ) <mask> <mask> // Upstream is a mock implementation of upstream.Upstream. </s> Pull request #1558: add-dnssvc Merge in DNS/adguard-home from add-dnssvc to master Squashed comm...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghtest/upstream.go
"github.com/AdguardTeam/golibs/errors"
<mask> "net" <mask> "strings" <mask> "testing" <mask> <mask> "github.com/miekg/dns" <mask> "github.com/stretchr/testify/require" <mask> ) <mask> <mask> // Additional Upstream Testing Utilities </s> Pull request #1558: add-dnssvc Merge in DNS/adguard-home from add-dnssvc to master Squashed commit of t...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghtest/upstream.go
"github.com/stretchr/testify/require"
<mask> "github.com/AdguardTeam/golibs/errors" <mask> "github.com/miekg/dns" <mask> ) <mask> <mask> // Additional Upstream Testing Utilities <mask> </s> Pull request #1558: add-dnssvc Merge in DNS/adguard-home from add-dnssvc to master Squashed commit of the following: commit 55f4f114bab65a03c0d65383e89020...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghtest/upstream.go
// Additional Upstream Testing Utilities
<mask> "github.com/miekg/dns" <mask> "github.com/stretchr/testify/require" <mask> ) <mask> <mask> // Upstream is a mock implementation of upstream.Upstream. <mask> // <mask> // TODO(a.garipov): Replace with UpstreamMock and rename it to just Upstream. <mask> type Upstream struct { </s> Pull request #1558: a...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghtest/upstream.go
// // TODO(a.garipov): Replace with UpstreamMock and rename it to just Upstream.
<mask> <mask> // Upstream is a mock implementation of upstream.Upstream. <mask> type Upstream struct { <mask> // CName is a map of hostname to canonical name. <mask> CName map[string][]string <mask> // IPv4 is a map of hostname to IPv4. </s> Pull request #1558: add-dnssvc Merge in DNS/adguard-home from add-...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghtest/upstream.go
// NewBlockUpstream returns an [*UpstreamMock] that works like an upstream that // supports hash-based safe-browsing/adult-blocking feature. If shouldBlock is // true, hostname's actual hash is returned, blocking it. Otherwise, it returns // a different hash. func NewBlockUpstream(hostname string, shouldBlock bool) (...
<mask> func (u *Upstream) Address() string { <mask> return u.Addr <mask> } <mask> <mask> // TestBlockUpstream implements upstream.Upstream interface for replacing real <mask> // upstream in tests. <mask> type TestBlockUpstream struct { <mask> Hostname string <mask> <mask> // lock protects reqNum. <mask>...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "re...
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghtest/upstream.go
ans := &dns.TXT{ Hdr: dns.RR_Header{ Name: "", Rrtype: dns.TypeTXT, Class: dns.ClassINET, Ttl: 60,
<mask> if !u.Block { <mask> hashToReturn = hex.EncodeToString(hash[:])[:2] + strings.Repeat("ab", 28) <mask> } <mask> <mask> m := &dns.Msg{} <mask> m.SetReply(r) <mask> m.Answer = []dns.RR{ <mask> &dns.TXT{ <mask> Hdr: dns.RR_Header{ <mask> Name: r.Question[0].Name, <mask> }, <mask> T...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghtest/upstream.go
Txt: []string{hashStr}, } respTmpl := &dns.Msg{ Answer: []dns.RR{ans},
<mask> Rrtype: dns.TypeTXT, <mask> Class: dns.ClassINET, <mask> Ttl: 60, <mask> }, <mask> } <mask> <mask> return &UpstreamMock{ <mask> OnAddress: func() (addr string) { </s> Pull request #1558: add-dnssvc Merge in DNS/adguard-home from add-dnssvc to master Squashed commit of the following...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghtest/upstream.go
return &UpstreamMock{ OnAddress: func() (addr string) { return "sbpc.upstream.example" }, OnExchange: func(req *dns.Msg) (resp *dns.Msg, err error) { resp = respTmpl.Copy() resp.SetReply(req) resp.Answer[0].(*dns.TXT).Hdr.Name = req.Question[0].Name
<mask> }, <mask> }, <mask> } <mask> <mask> return m, nil <mask> } <mask> <mask> // Address always returns an empty string. <mask> func (u *TestBlockUpstream) Address() string { <mask> return "" <mask> } <mask> <mask> // RequestsCount returns the number of handled requests. It's safe for <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghtest/upstream.go
return resp, nil }, }
<mask> <mask> return u.reqNum <mask> } <mask> <mask> // TestErrUpstream implements upstream.Upstream interface for replacing real <mask> // upstream in tests. <mask> type TestErrUpstream struct { <mask> // The error returned by Exchange may be unwrapped to the Err. <mask> Err error <mask> } <mask> <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghtest/upstream.go
// ErrUpstream is the error returned from the [*UpstreamMock] created by // [NewErrorUpstream]. const ErrUpstream errors.Error = "test upstream error"
<mask> // The error returned by Exchange may be unwrapped to the Err. <mask> Err error <mask> } <mask> <mask> // Exchange always returns nil Msg and non-nil error. <mask> func (u *TestErrUpstream) Exchange(*dns.Msg) (*dns.Msg, error) { <mask> return nil, fmt.Errorf("errupstream: %w", u.Err) <mask> } <mask>...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghtest/upstream.go
// NewErrorUpstream returns an [*UpstreamMock] that returns [ErrUpstream] from // its Exchange method. func NewErrorUpstream() (u *UpstreamMock) { return &UpstreamMock{ OnAddress: func() (addr string) { return "error.upstream.example" }, OnExchange: func(_ *dns.Msg) (resp *dns.Msg, err error) { return nil,...
<mask> func (u *TestErrUpstream) Exchange(*dns.Msg) (*dns.Msg, error) { <mask> return nil, fmt.Errorf("errupstream: %w", u.Err) <mask> } <mask> <mask> // Address always returns an empty string. <mask> func (u *TestErrUpstream) Address() string { <mask> return "" <mask> } </s> Pull request #1558: add-dnssvc ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/aghtest/upstream.go
"github.com/AdguardTeam/AdGuardHome/internal/aghalg"
<mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghnet" <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghtest" <mask> "github.com/AdguardTeam/AdGuardHome/internal/dhcpd" <mask> "github.com/AdguardTeam/AdGuardHome/internal/filtering" <mask> "github.com/AdguardTeam/dnsproxy/pr...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/dnsforward/dnsforward_test.go
<mask> "github.com/AdguardTeam/AdGuardHome/internal/dhcpd" <mask> "github.com/AdguardTeam/AdGuardHome/internal/filtering" <mask> "github.com/AdguardTeam/dnsproxy/proxy" <mask> "github.com/AdguardTeam/dnsproxy/upstream" <mask> "github.com/AdguardTeam/golibs/errors" <mask> "github.com/AdguardTeam/golibs/netut...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/dnsforward/dnsforward_test.go
sbUps := aghtest.NewBlockUpstream(hostname, true)
<mask> <mask> func TestBlockedBySafeBrowsing(t *testing.T) { <mask> const hostname = "wmconvirus.narod.ru" <mask> <mask> sbUps := &aghtest.TestBlockUpstream{ <mask> Hostname: hostname, <mask> Block: true, <mask> } <mask> ans4, _ := (&aghtest.TestResolver{}).HostToIPs(hostname) <mask> <mask> fi...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/dnsforward/dnsforward_test.go
s.conf.ProtectionEnabled = true
<mask> <mask> s.conf.UDPListenAddrs = []*net.UDPAddr{{}} <mask> s.conf.TCPListenAddrs = []*net.TCPAddr{{}} <mask> s.conf.UpstreamDNS = []string{"127.0.0.1:53"} <mask> s.conf.FilteringConfig.ProtectionEnabled = true <mask> <mask> err = s.Prepare(nil) <mask> require.NoError(t, err) <mask> <mask> err =...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/dnsforward/dnsforward_test.go
const ( onesHost = "one.one.one.one" localDomainHost = "local.domain" ) var ( onesIP = net.IP{1, 1, 1, 1} localIP = net.IP{192, 168, 1, 1} ) revExtIPv4, err := netutil.IPToReversedAddr(onesIP) require.NoError(t, err) extUpstream := &aghtest.UpstreamMock{ OnAddress: func() (addr string) { ret...
<mask> } <mask> } <mask> <mask> func TestServer_Exchange(t *testing.T) { <mask> extUpstream := &aghtest.Upstream{ <mask> Reverse: map[string][]string{ <mask> "1.1.1.1.in-addr.arpa.": {"one.one.one.one"}, <mask> }, <mask> } <mask> locUpstream := &aghtest.Upstream{ <mask> Reverse: map[string][]st...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/dnsforward/dnsforward_test.go
revLocIPv4, err := netutil.IPToReversedAddr(localIP) require.NoError(t, err) locUpstream := &aghtest.UpstreamMock{ OnAddress: func() (addr string) { return "local.upstream.example" }, OnExchange: func(req *dns.Msg) (resp *dns.Msg, err error) { resp = aghalg.Coalesce( aghtest.RespondTo(t, req, dns.ClassIN...
<mask> Reverse: map[string][]string{ <mask> "1.1.1.1.in-addr.arpa.": {"one.one.one.one"}, <mask> }, <mask> } <mask> locUpstream := &aghtest.Upstream{ <mask> Reverse: map[string][]string{ <mask> "1.1.168.192.in-addr.arpa.": {"local.domain"}, <mask> "2.1.168.192.in-addr.arpa.": {}, <mask> }, ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/dnsforward/dnsforward_test.go
errUpstream := aghtest.NewErrorUpstream() nonPtrUpstream := aghtest.NewBlockUpstream("some-host", true)
<mask> "1.1.168.192.in-addr.arpa.": {"local.domain"}, <mask> "2.1.168.192.in-addr.arpa.": {}, <mask> }, <mask> } <mask> upstreamErr := errors.Error("upstream error") <mask> errUpstream := &aghtest.TestErrUpstream{ <mask> Err: upstreamErr, <mask> } <mask> nonPtrUpstream := &aghtest.TestBlockUpstr...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/dnsforward/dnsforward_test.go
<mask> srv.conf.UsePrivateRDNS = true <mask> <mask> srv.privateNets = netutil.SubnetSetFunc(netutil.IsLocallyServed) <mask> <mask> localIP := net.IP{192, 168, 1, 1} <mask> testCases := []struct { <mask> name string <mask> want string <mask> wantErr error <mask> locUpstream upst...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/dnsforward/dnsforward_test.go
want: onesHost,
<mask> locUpstream upstream.Upstream <mask> req net.IP <mask> }{{ <mask> name: "external_good", <mask> want: "one.one.one.one", <mask> wantErr: nil, <mask> locUpstream: nil, <mask> req: net.IP{1, 1, 1, 1}, <mask> }, { <mask> name: "local_good", </s> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/dnsforward/dnsforward_test.go
req: onesIP,
<mask> name: "external_good", <mask> want: "one.one.one.one", <mask> wantErr: nil, <mask> locUpstream: nil, <mask> req: net.IP{1, 1, 1, 1}, <mask> }, { <mask> name: "local_good", <mask> want: "local.domain", <mask> wantErr: nil, <mask> locUpstream...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/dnsforward/dnsforward_test.go
want: localDomainHost,
<mask> locUpstream: nil, <mask> req: net.IP{1, 1, 1, 1}, <mask> }, { <mask> name: "local_good", <mask> want: "local.domain", <mask> wantErr: nil, <mask> locUpstream: locUpstream, <mask> req: localIP, <mask> }, { <mask> name: "upstream_error", </s> Pu...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/dnsforward/dnsforward_test.go
wantErr: aghtest.ErrUpstream,
<mask> req: localIP, <mask> }, { <mask> name: "upstream_error", <mask> want: "", <mask> wantErr: upstreamErr, <mask> locUpstream: errUpstream, <mask> req: localIP, <mask> }, { <mask> name: "empty_answer_error", <mask> want: "", </s> Pull reque...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/dnsforward/dnsforward_test.go
const ( sbBlocked = "wmconvirus.narod.ru" pcBlocked = "pornhub.com" )
<mask> func TestMain(m *testing.M) { <mask> aghtest.DiscardLogOutput(m) <mask> } <mask> <mask> var setts = Settings{ <mask> ProtectionEnabled: true, <mask> } <mask> <mask> // Helpers. </s> Pull request #1558: add-dnssvc Merge in DNS/adguard-home from add-dnssvc to master Squashed commit of the following...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
<mask> aghtest.ReplaceLogLevel(t, log.DEBUG) <mask> <mask> d := newForTest(t, &Config{SafeBrowsingEnabled: true}, nil) <mask> t.Cleanup(d.Close) <mask> const matching = "wmconvirus.narod.ru" <mask> d.SetSafeBrowsingUpstream(&aghtest.TestBlockUpstream{ <mask> Hostname: matching, <mask> Block: true, ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
d.SetSafeBrowsingUpstream(aghtest.NewBlockUpstream(sbBlocked, true)) d.checkMatch(t, sbBlocked) require.Contains(t, logOutput.String(), fmt.Sprintf("safebrowsing lookup for %q", sbBlocked))
<mask> Block: true, <mask> }) <mask> d.checkMatch(t, matching) <mask> <mask> require.Contains(t, logOutput.String(), "SafeBrowsing lookup for "+matching) <mask> <mask> d.checkMatch(t, "test."+matching) <mask> d.checkMatchEmpty(t, "yandex.ru") <mask> d.checkMatchEmpty(t, "pornhub.com") <mask> </...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
d.checkMatch(t, "test."+sbBlocked)
<mask> d.checkMatch(t, matching) <mask> <mask> require.Contains(t, logOutput.String(), "SafeBrowsing lookup for "+matching) <mask> <mask> d.checkMatch(t, "test."+matching) <mask> d.checkMatchEmpty(t, "yandex.ru") <mask> d.checkMatchEmpty(t, "pornhub.com") <mask> <mask> // Cached result. <mask> d.saf...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
d.checkMatchEmpty(t, pcBlocked)
<mask> require.Contains(t, logOutput.String(), "SafeBrowsing lookup for "+matching) <mask> <mask> d.checkMatch(t, "test."+matching) <mask> d.checkMatchEmpty(t, "yandex.ru") <mask> d.checkMatchEmpty(t, "pornhub.com") <mask> <mask> // Cached result. <mask> d.safeBrowsingServer = "127.0.0.1" <mask> d.che...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
d.checkMatch(t, sbBlocked) d.checkMatchEmpty(t, pcBlocked)
<mask> d.checkMatchEmpty(t, "pornhub.com") <mask> <mask> // Cached result. <mask> d.safeBrowsingServer = "127.0.0.1" <mask> d.checkMatch(t, matching) <mask> d.checkMatchEmpty(t, "pornhub.com") <mask> d.safeBrowsingServer = defaultSafebrowsingServer <mask> } <mask> <mask> func TestParallelSB(t *testing...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
d.SetSafeBrowsingUpstream(aghtest.NewBlockUpstream(sbBlocked, true))
<mask> <mask> func TestParallelSB(t *testing.T) { <mask> d := newForTest(t, &Config{SafeBrowsingEnabled: true}, nil) <mask> t.Cleanup(d.Close) <mask> const matching = "wmconvirus.narod.ru" <mask> d.SetSafeBrowsingUpstream(&aghtest.TestBlockUpstream{ <mask> Hostname: matching, <mask> Block: true, <m...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
d.checkMatch(t, sbBlocked) d.checkMatch(t, "test."+sbBlocked)
<mask> t.Run("group", func(t *testing.T) { <mask> for i := 0; i < 100; i++ { <mask> t.Run(fmt.Sprintf("aaa%d", i), func(t *testing.T) { <mask> t.Parallel() <mask> d.checkMatch(t, matching) <mask> d.checkMatch(t, "test."+matching) <mask> d.checkMatchEmpty(t, "yandex.ru") <mask> d.checkM...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
d.checkMatchEmpty(t, pcBlocked)
<mask> t.Parallel() <mask> d.checkMatch(t, matching) <mask> d.checkMatch(t, "test."+matching) <mask> d.checkMatchEmpty(t, "yandex.ru") <mask> d.checkMatchEmpty(t, "pornhub.com") <mask> }) <mask> } <mask> }) <mask> } <mask> </s> Pull request #1558: add-dnssvc Merge in DNS/adguard-h...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
<mask> aghtest.ReplaceLogLevel(t, log.DEBUG) <mask> <mask> d := newForTest(t, &Config{ParentalEnabled: true}, nil) <mask> t.Cleanup(d.Close) <mask> const matching = "pornhub.com" <mask> d.SetParentalUpstream(&aghtest.TestBlockUpstream{ <mask> Hostname: matching, <mask> Block: true, <mask> }) <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
d.SetParentalUpstream(aghtest.NewBlockUpstream(pcBlocked, true)) d.checkMatch(t, pcBlocked) require.Contains(t, logOutput.String(), fmt.Sprintf("parental lookup for %q", pcBlocked))
<mask> Hostname: matching, <mask> Block: true, <mask> }) <mask> <mask> d.checkMatch(t, matching) <mask> require.Contains(t, logOutput.String(), "Parental lookup for "+matching) <mask> <mask> d.checkMatch(t, "www."+matching) <mask> d.checkMatchEmpty(t, "www.yandex.ru") <mask> d.checkMatchEmpty(t...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
d.checkMatch(t, "www."+pcBlocked)
<mask> <mask> d.checkMatch(t, matching) <mask> require.Contains(t, logOutput.String(), "Parental lookup for "+matching) <mask> <mask> d.checkMatch(t, "www."+matching) <mask> d.checkMatchEmpty(t, "www.yandex.ru") <mask> d.checkMatchEmpty(t, "yandex.ru") <mask> d.checkMatchEmpty(t, "api.jquery.com") <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
d.checkMatch(t, pcBlocked)
<mask> d.checkMatchEmpty(t, "api.jquery.com") <mask> <mask> // Test cached result. <mask> d.parentalServer = "127.0.0.1" <mask> d.checkMatch(t, matching) <mask> d.checkMatchEmpty(t, "yandex.ru") <mask> } <mask> <mask> // Filtering. <mask> </s> Pull request #1558: add-dnssvc Merge in DNS/adguard-home...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
host: sbBlocked,
<mask> wantDNSType: dns.TypeA, <mask> }, { <mask> name: "sanity", <mask> rules: "||doubleclick.net^", <mask> host: "wmconvirus.narod.ru", <mask> wantIsFiltered: false, <mask> wantReason: NotFilteredNotFound, <mask> wantDNSType: dns.TypeA, <mask> }, { <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
d.SetParentalUpstream(aghtest.NewBlockUpstream(pcBlocked, true)) d.SetSafeBrowsingUpstream(aghtest.NewBlockUpstream(sbBlocked, true))
<mask> ID: 0, Data: []byte("||example.org^\n"), <mask> }}, <mask> ) <mask> t.Cleanup(d.Close) <mask> d.SetParentalUpstream(&aghtest.TestBlockUpstream{ <mask> Hostname: "pornhub.com", <mask> Block: true, <mask> }) <mask> d.SetSafeBrowsingUpstream(&aghtest.TestBlockUpstream{ <mask> Hostname: ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
host: pcBlocked,
<mask> before: true, <mask> wantReason: FilteredBlockList, <mask> }, { <mask> name: "parental", <mask> host: "pornhub.com", <mask> before: true, <mask> wantReason: FilteredParental, <mask> }, { <mask> name: "safebrowsing", <mask> host: "wmconvirus.narod.ru", ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
host: sbBlocked,
<mask> before: true, <mask> wantReason: FilteredParental, <mask> }, { <mask> name: "safebrowsing", <mask> host: "wmconvirus.narod.ru", <mask> before: false, <mask> wantReason: FilteredSafeBrowsing, <mask> }, { <mask> name: "additional_rules", <mask> host: "fac...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
d.SetSafeBrowsingUpstream(aghtest.NewBlockUpstream(sbBlocked, true))
<mask> <mask> func BenchmarkSafeBrowsing(b *testing.B) { <mask> d := newForTest(b, &Config{SafeBrowsingEnabled: true}, nil) <mask> b.Cleanup(d.Close) <mask> blocked := "wmconvirus.narod.ru" <mask> d.SetSafeBrowsingUpstream(&aghtest.TestBlockUpstream{ <mask> Hostname: blocked, <mask> Block: true, <m...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
res, err := d.CheckHost(sbBlocked, dns.TypeA, &setts)
<mask> Hostname: blocked, <mask> Block: true, <mask> }) <mask> for n := 0; n < b.N; n++ { <mask> res, err := d.CheckHost(blocked, dns.TypeA, &setts) <mask> require.NoError(b, err) <mask> <mask> assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) <mask> } <mask> } </s> Pu...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
assert.Truef(b, res.IsFiltered, "expected hostname %q to match", sbBlocked)
<mask> for n := 0; n < b.N; n++ { <mask> res, err := d.CheckHost(blocked, dns.TypeA, &setts) <mask> require.NoError(b, err) <mask> <mask> assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) <mask> } <mask> } <mask> <mask> func BenchmarkSafeBrowsingParallel(b *testing.B) { <mask>...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
d.SetSafeBrowsingUpstream(aghtest.NewBlockUpstream(sbBlocked, true))
<mask> <mask> func BenchmarkSafeBrowsingParallel(b *testing.B) { <mask> d := newForTest(b, &Config{SafeBrowsingEnabled: true}, nil) <mask> b.Cleanup(d.Close) <mask> blocked := "wmconvirus.narod.ru" <mask> d.SetSafeBrowsingUpstream(&aghtest.TestBlockUpstream{ <mask> Hostname: blocked, <mask> Block: t...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
res, err := d.CheckHost(sbBlocked, dns.TypeA, &setts)
<mask> Block: true, <mask> }) <mask> b.RunParallel(func(pb *testing.PB) { <mask> for pb.Next() { <mask> res, err := d.CheckHost(blocked, dns.TypeA, &setts) <mask> require.NoError(b, err) <mask> <mask> assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) <mask> } <mask>...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
assert.Truef(b, res.IsFiltered, "expected hostname %q to match", sbBlocked)
<mask> for pb.Next() { <mask> res, err := d.CheckHost(blocked, dns.TypeA, &setts) <mask> require.NoError(b, err) <mask> <mask> assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) <mask> } <mask> }) <mask> } <mask> <mask> func BenchmarkSafeSearch(b *testing.B) { </s> Pull ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/filtering_test.go
defer timer.LogElapsed("safebrowsing lookup for %q", host)
<mask> } <mask> <mask> if log.GetLevel() >= log.DEBUG { <mask> timer := log.StartTimer() <mask> defer timer.LogElapsed("SafeBrowsing lookup for %s", host) <mask> } <mask> <mask> sctx := &sbCtx{ <mask> host: host, <mask> svc: "SafeBrowsing", </s> Pull request #1558: add-dnssvc Merge ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/safebrowsing.go
defer timer.LogElapsed("parental lookup for %q", host)
<mask> } <mask> <mask> if log.GetLevel() >= log.DEBUG { <mask> timer := log.StartTimer() <mask> defer timer.LogElapsed("Parental lookup for %s", host) <mask> } <mask> <mask> sctx := &sbCtx{ <mask> host: host, <mask> svc: "Parental", </s> Pull request #1558: add-dnssvc Merge in DNS/a...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/safebrowsing.go
// Match "sub.host.com" from cache. Another hash for "host.example" is not // in the cache, so get data for it from the server.
<mask> hash = sha256.Sum256([]byte("sub.host.com")) <mask> c.hashToHost[hash] = "sub.host.com" <mask> assert.Equal(t, -1, c.getCached()) <mask> <mask> // match "sub.host.com" from cache, <mask> // but another hash for "nonexisting.com" is not in cache <mask> // which means that we must get data from ser...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/safebrowsing_test.go
hash = sha256.Sum256([]byte("host.example")) c.hashToHost[hash] = "host.example"
<mask> // which means that we must get data from server for it <mask> c.hashToHost = make(map[[32]byte]string) <mask> hash = sha256.Sum256([]byte("sub.host.com")) <mask> c.hashToHost[hash] = "sub.host.com" <mask> hash = sha256.Sum256([]byte("nonexisting.com")) <mask> c.hashToHost[hash] = "nonexisting.com" ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/safebrowsing_test.go
hash = sha256.Sum256([]byte("host.example"))
<mask> hash = sha256.Sum256([]byte("sub.host.com")) <mask> _, ok := c.hashToHost[hash] <mask> assert.False(t, ok) <mask> <mask> hash = sha256.Sum256([]byte("nonexisting.com")) <mask> _, ok = c.hashToHost[hash] <mask> assert.True(t, ok) <mask> <mask> c = &sbCtx{ <mask> svc: "SafeBrowsing", </...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/safebrowsing_test.go
ups := aghtest.NewErrorUpstream()
<mask> func TestSBPC_checkErrorUpstream(t *testing.T) { <mask> d := newForTest(t, &Config{SafeBrowsingEnabled: true}, nil) <mask> t.Cleanup(d.Close) <mask> <mask> ups := &aghtest.TestErrUpstream{} <mask> <mask> d.SetSafeBrowsingUpstream(ups) <mask> d.SetParentalUpstream(ups) <mask> <mask> setts := &S...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/safebrowsing_test.go
ups := aghtest.NewBlockUpstream(hostname, tc.block) var numReq int onExchange := ups.OnExchange ups.OnExchange = func(req *dns.Msg) (resp *dns.Msg, err error) { numReq++ return onExchange(req)
<mask> }} <mask> <mask> for _, tc := range testCases { <mask> // Prepare the upstream. <mask> ups := &aghtest.TestBlockUpstream{ <mask> Hostname: hostname, <mask> Block: tc.block, <mask> } <mask> d.SetSafeBrowsingUpstream(ups) <mask> d.SetParentalUpstream(ups) <mask> <mask> t.Run(tc...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/safebrowsing_test.go
assert.Equal(t, 1, numReq)
<mask> assert.Equal(t, 1, tc.testCache.Stats().Count) <mask> assert.Equal(t, hits, tc.testCache.Stats().Hit) <mask> <mask> // There was one request to an upstream. <mask> assert.Equal(t, 1, ups.RequestsCount()) <mask> <mask> // Now make the same request to check the cache was used. <mask> re...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/safebrowsing_test.go
assert.Equal(t, 1, numReq)
<mask> assert.Equal(t, 1, tc.testCache.Stats().Count) <mask> assert.Equal(t, hits+1, tc.testCache.Stats().Hit) <mask> <mask> // Check that there were no additional requests. <mask> assert.Equal(t, 1, ups.RequestsCount()) <mask> }) <mask> <mask> purgeCaches(d) <mask> } <mask> } </s> Pull re...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/filtering/safebrowsing_test.go
"fmt"
<mask> "bytes" <mask> "encoding/binary" <mask> "net" <mask> "sync" <mask> "testing" <mask> "time" </s> Pull request #1558: add-dnssvc Merge in DNS/adguard-home from add-dnssvc to master Squashed commit of the following: commit 55f4f114bab65a03c0d65383e89020a7356cff32 Merge: 95dc28d9 6e63757f Author: Ain...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/home/rdns_test.go
"github.com/AdguardTeam/AdGuardHome/internal/aghalg"
<mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghtest" <mask> "github.com/AdguardTeam/dnsproxy/upstream" <mask> "github.com/AdguardTeam/golibs/cache" <mask> "github.com/AdguardTeam/golibs/log" </s> Pull request #1558: add-dnssvc Merge in DNS/adguard-home from add-dnssvc to maste...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/home/rdns_test.go
<mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghtest" <mask> "github.com/AdguardTeam/dnsproxy/upstream" <mask> "github.com/AdguardTeam/golibs/cache" <mask> "github.com/AdguardTeam/golibs/errors" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/AdguardTeam/golibs/netutil" <mask>...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/home/rdns_test.go
ipCache: ipCache, exchanger: &rDNSExchanger{ ex: aghtest.NewErrorUpstream(), },
<mask> ttl := make([]byte, binary.Size(uint64(0))) <mask> binary.BigEndian.PutUint64(ttl, uint64(time.Now().Add(100*time.Hour).Unix())) <mask> <mask> rdns := &RDNS{ <mask> ipCache: ipCache, <mask> exchanger: &rDNSExchanger{}, <mask> clients: &clientsContainer{ <mask> list: map[string]*C...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/home/rdns_test.go
ex upstream.Upstream
<mask> } <mask> <mask> // rDNSExchanger is a mock dnsforward.RDNSExchanger implementation for tests. <mask> type rDNSExchanger struct { <mask> ex aghtest.Exchanger <mask> usePrivate bool <mask> } <mask> <mask> // Exchange implements dnsforward.RDNSExchanger interface for *RDNSExchanger. <mask> fun...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/home/rdns_test.go
rev, err := netutil.IPToReversedAddr(ip) if err != nil { return "", fmt.Errorf("reversing ip: %w", err) }
<mask> <mask> // Exchange implements dnsforward.RDNSExchanger interface for *RDNSExchanger. <mask> func (e *rDNSExchanger) Exchange(ip net.IP) (host string, err error) { <mask> req := &dns.Msg{ <mask> Question: []dns.Question{{ <mask> Name: dns.Fqdn(rev), <mask> Qclass: dns.ClassINET, <mask> Qtyp...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/home/rdns_test.go
Name: dns.Fqdn(rev), Qclass: dns.ClassINET, Qtype: dns.TypePTR,
<mask> // Exchange implements dnsforward.RDNSExchanger interface for *RDNSExchanger. <mask> func (e *rDNSExchanger) Exchange(ip net.IP) (host string, err error) { <mask> req := &dns.Msg{ <mask> Question: []dns.Question{{ <mask> Name: ip.String(), <mask> Qtype: dns.TypePTR, <mask> }}, <mask> } <mas...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/home/rdns_test.go
ex := &rDNSExchanger{ ex: aghtest.NewErrorUpstream(), }
<mask> EnableLRU: true, <mask> MaxCount: defaultRDNSCacheSize, <mask> }) <mask> <mask> ex := &rDNSExchanger{} <mask> <mask> rdns := &RDNS{ <mask> ipCache: ipCache, <mask> exchanger: ex, <mask> } </s> Pull request #1558: add-dnssvc Merge in DNS/adguard-home from add-dnssvc to master Squashe...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/home/rdns_test.go
localIP := net.IP{192, 168, 1, 1} revIPv4, err := netutil.IPToReversedAddr(localIP) require.NoError(t, err) revIPv6, err := netutil.IPToReversedAddr(net.ParseIP("2a00:1450:400c:c06::93")) require.NoError(t, err) locUpstream := &aghtest.UpstreamMock{ OnAddress: func() (addr string) { return "local.upstream.exa...
<mask> aghtest.ReplaceLogLevel(t, log.DEBUG) <mask> w := &bytes.Buffer{} <mask> aghtest.ReplaceLogWriter(t, w) <mask> <mask> locUpstream := &aghtest.Upstream{ <mask> Reverse: map[string][]string{ <mask> "192.168.1.1": {"local.domain"}, <mask> "2a00:1450:400c:c06::93": {"ipv6.domain"}, <...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/home/rdns_test.go
errUpstream := aghtest.NewErrorUpstream()
<mask> "192.168.1.1": {"local.domain"}, <mask> "2a00:1450:400c:c06::93": {"ipv6.domain"}, <mask> }, <mask> } <mask> errUpstream := &aghtest.TestErrUpstream{ <mask> Err: errors.Error("1234"), <mask> } <mask> <mask> testCases := []struct { <mask> ups upstream.Upstream <mask> w...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/home/rdns_test.go
cliIP: localIP,
<mask> }{{ <mask> ups: locUpstream, <mask> wantLog: "", <mask> name: "all_good", <mask> cliIP: net.IP{192, 168, 1, 1}, <mask> }, { <mask> ups: errUpstream, <mask> wantLog: `rdns: resolving "192.168.1.2": errupstream: 1234`, <mask> name: "resolve_error", <mask> cliIP: net.IP...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/home/rdns_test.go
wantLog: `rdns: resolving "192.168.1.2": test upstream error`,
<mask> name: "all_good", <mask> cliIP: net.IP{192, 168, 1, 1}, <mask> }, { <mask> ups: errUpstream, <mask> wantLog: `rdns: resolving "192.168.1.2": errupstream: 1234`, <mask> name: "resolve_error", <mask> cliIP: net.IP{192, 168, 1, 2}, <mask> }, { <mask> ups: locUpstream, <ma...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/home/rdns_test.go
ex: tc.ups,
<mask> } <mask> ch := make(chan net.IP) <mask> rdns := &RDNS{ <mask> exchanger: &rDNSExchanger{ <mask> ex: aghtest.Exchanger{ <mask> Ups: tc.ups, <mask> }, <mask> }, <mask> clients: cc, <mask> ipCh: ch, <mask> } <mask> </s> Pull request #1558: add-dnssvc Merge in DNS/a...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/home/rdns_test.go
// Service is the AdGuard Home web service. A nil *Service is a valid // [agh.Service] that does nothing.
<mask> // Timeout is the timeout for all server operations. <mask> Timeout time.Duration <mask> } <mask> <mask> // Service is the AdGuard Home web service. A nil *Service is a valid service <mask> // that does nothing. <mask> type Service struct { <mask> tls *tls.Config <mask> servers []*http.Server ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/v1/websvc/websvc.go
// Start implements the [agh.Service] interface for *Service. svc may be nil.
<mask> <mask> // type check <mask> var _ agh.Service = (*Service)(nil) <mask> <mask> // Start implements the agh.Service interface for *Service. svc may be nil. <mask> // After Start exits, all HTTP servers have tried to start, possibly failing and <mask> // writing error messages to the log. <mask> func (sv...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/v1/websvc/websvc.go
// Shutdown implements the [agh.Service] interface for *Service. svc may be // nil.
<mask> srv.ErrorLog.Printf("starting srv %s: %s", addr, err) <mask> } <mask> } <mask> <mask> // Shutdown implements the agh.Service interface for *Service. svc may be nil. <mask> func (svc *Service) Shutdown(ctx context.Context) (err error) { <mask> if svc == nil { <mask> return nil <mask> } <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d4c3a43bcb1ac006fe92a5b5478f61dc60d0bd3f
internal/v1/websvc/websvc.go
// Init initializes clients container // Note: this function must be called only once func (clients *clientsContainer) Init() {
<mask> ipHost map[string]ClientHost // IP -> Hostname <mask> lock sync.Mutex <mask> } <mask> <mask> var clients clientsContainer <mask> <mask> // Initialize clients container <mask> func clientsInit() { <mask> if clients.list != nil { <mask> log.Fatal("clients.list != nil") <mask> } <mask> clie...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
go clients.periodicUpdate()
<mask> clients.list = make(map[string]*Client) <mask> clients.ipIndex = make(map[string]*Client) <mask> clients.ipHost = make(map[string]ClientHost) <mask> <mask> go periodicClientsUpdate() <mask> } <mask> <mask> func periodicClientsUpdate() { <mask> for { <mask> clientsAddFromHostsFile() </s> * cli...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
func (clients *clientsContainer) periodicUpdate() {
<mask> <mask> go periodicClientsUpdate() <mask> } <mask> <mask> func periodicClientsUpdate() { <mask> for { <mask> clientsAddFromHostsFile() <mask> clientsAddFromSystemARP() <mask> time.Sleep(clientsUpdatePeriod) <mask> } </s> * clients: move container object to "config" Now the functions use par...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
clients.addFromHostsFile() clients.addFromSystemARP()
<mask> } <mask> <mask> func periodicClientsUpdate() { <mask> for { <mask> clientsAddFromHostsFile() <mask> clientsAddFromSystemARP() <mask> time.Sleep(clientsUpdatePeriod) <mask> } <mask> } <mask> <mask> func clientsGetList() map[string]*Client { </s> * clients: move container object to "config" ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
// GetList returns the pointer to clients list func (clients *clientsContainer) GetList() map[string]*Client {
<mask> time.Sleep(clientsUpdatePeriod) <mask> } <mask> } <mask> <mask> func clientsGetList() map[string]*Client { <mask> return clients.list <mask> } <mask> <mask> func clientExists(ip string) bool { <mask> clients.lock.Lock() </s> * clients: move container object to "config" Now the functions use pa...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
// Exists checks if client with this IP already exists func (clients *clientsContainer) Exists(ip string) bool {
<mask> func clientsGetList() map[string]*Client { <mask> return clients.list <mask> } <mask> <mask> func clientExists(ip string) bool { <mask> clients.lock.Lock() <mask> defer clients.lock.Unlock() <mask> <mask> _, ok := clients.ipIndex[ip] <mask> if ok { </s> * clients: move container object to "conf...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
// Find searches for a client by IP func (clients *clientsContainer) Find(ip string) (Client, bool) {
<mask> _, ok = clients.ipHost[ip] <mask> return ok <mask> } <mask> <mask> // Search for a client by IP <mask> func clientFind(ip string) (Client, bool) { <mask> clients.lock.Lock() <mask> defer clients.lock.Unlock() <mask> <mask> c, ok := clients.ipIndex[ip] <mask> if ok { </s> * clients: move conta...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
func (c *Client) check() error {
<mask> return Client{}, false <mask> } <mask> <mask> // Check if Client object's fields are correct <mask> func clientCheck(c *Client) error { <mask> if len(c.Name) == 0 { <mask> return fmt.Errorf("Invalid Name") <mask> } <mask> <mask> if (len(c.IP) == 0 && len(c.MAC) == 0) || </s> * clients: move co...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
func (clients *clientsContainer) Add(c Client) (bool, error) { e := c.check()
<mask> } <mask> <mask> // Add a new client object <mask> // Return true: success; false: client exists. <mask> func clientAdd(c Client) (bool, error) { <mask> e := clientCheck(&c) <mask> if e != nil { <mask> return false, e <mask> } <mask> <mask> clients.lock.Lock() </s> * clients: move container o...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
// Del removes a client func (clients *clientsContainer) Del(name string) bool {
<mask> log.Tracef("'%s': '%s' | '%s' -> [%d]", c.Name, c.IP, c.MAC, len(clients.list)) <mask> return true, nil <mask> } <mask> <mask> // Remove a client <mask> func clientDel(name string) bool { <mask> clients.lock.Lock() <mask> defer clients.lock.Unlock() <mask> <mask> c, ok := clients.list[name] <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
func (clients *clientsContainer) Update(name string, c Client) error { err := c.check()
<mask> return true <mask> } <mask> <mask> // Update a client <mask> func clientUpdate(name string, c Client) error { <mask> err := clientCheck(&c) <mask> if err != nil { <mask> return err <mask> } <mask> <mask> clients.lock.Lock() </s> * clients: move container object to "config" Now the functions...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
// AddHost adds new IP -> Host pair
<mask> <mask> return nil <mask> } <mask> <mask> // Add new IP -> Host pair <mask> // Use priority of the source (etc/hosts > ARP > rDNS) <mask> // so we overwrite existing entries with an equal or higher priority <mask> func clientAddHost(ip, host string, source clientSource) (bool, error) { <mask> client...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
func (clients *clientsContainer) AddHost(ip, host string, source clientSource) (bool, error) {
<mask> <mask> // Add new IP -> Host pair <mask> // Use priority of the source (etc/hosts > ARP > rDNS) <mask> // so we overwrite existing entries with an equal or higher priority <mask> func clientAddHost(ip, host string, source clientSource) (bool, error) { <mask> clients.lock.Lock() <mask> defer clients.lo...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
func (clients *clientsContainer) addFromHostsFile() {
<mask> return true, nil <mask> } <mask> <mask> // Parse system 'hosts' file and fill clients array <mask> func clientsAddFromHostsFile() { <mask> hostsFn := "/etc/hosts" <mask> if runtime.GOOS == "windows" { <mask> hostsFn = os.ExpandEnv("$SystemRoot\\system32\\drivers\\etc\\hosts") <mask> } <mask> <...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
ok, e := clients.AddHost(fields[0], fields[1], ClientSourceHostsFile)
<mask> if len(fields) < 2 { <mask> continue <mask> } <mask> <mask> ok, e := clientAddHost(fields[0], fields[1], ClientSourceHostsFile) <mask> if e != nil { <mask> log.Tracef("%s", e) <mask> } <mask> if ok { <mask> n++ </s> * clients: move container object to "config" Now the functions ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
func (clients *clientsContainer) addFromSystemARP() {
<mask> <mask> // Add IP -> Host pairs from the system's `arp -a` command output <mask> // The command's output is: <mask> // HOST (IP) at MAC on IFACE <mask> func clientsAddFromSystemARP() { <mask> <mask> if runtime.GOOS == "windows" { <mask> return <mask> } <mask> </s> * clients: move container objec...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
ok, e := clients.AddHost(ip, host, ClientSourceARP)
<mask> if utils.IsValidHostname(host) != nil || net.ParseIP(ip) == nil { <mask> continue <mask> } <mask> <mask> ok, e := clientAddHost(ip, host, ClientSourceARP) <mask> if e != nil { <mask> log.Tracef("%s", e) <mask> } <mask> if ok { <mask> n++ </s> * clients: move container object to "...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
config.clients.lock.Lock() for _, c := range config.clients.list {
<mask> log.Tracef("%s %v", r.Method, r.URL) <mask> <mask> data := clientListJSON{} <mask> <mask> clients.lock.Lock() <mask> for _, c := range clients.list { <mask> cj := clientJSON{ <mask> IP: c.IP, <mask> MAC: c.MAC, <mask> Name: c.Name, <mask...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
for ip, ch := range config.clients.ipHost {
<mask> } <mask> <mask> data.Clients = append(data.Clients, cj) <mask> } <mask> for ip, ch := range clients.ipHost { <mask> cj := clientHostJSON{ <mask> IP: ip, <mask> Name: ch.Host, <mask> } <mask> cj.Source = "etc/hosts" </s> * clients: move container object to "config" Now the functio...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
config.clients.lock.Unlock()
<mask> cj.Source = "ARP" <mask> } <mask> data.AutoClients = append(data.AutoClients, cj) <mask> } <mask> clients.lock.Unlock() <mask> <mask> w.Header().Set("Content-Type", "application/json") <mask> e := json.NewEncoder(w).Encode(data) <mask> if e != nil { <mask> httpError(w, http.StatusInterna...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
ok, err := config.clients.Add(*c)
<mask> if err != nil { <mask> httpError(w, http.StatusBadRequest, "%s", err) <mask> return <mask> } <mask> ok, err := clientAdd(*c) <mask> if err != nil { <mask> httpError(w, http.StatusBadRequest, "%s", err) <mask> return <mask> } <mask> if !ok { </s> * clients: move container object to "confi...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go
if !config.clients.Del(cj.Name) {
<mask> httpError(w, http.StatusBadRequest, "JSON parse: %s", err) <mask> return <mask> } <mask> <mask> if !clientDel(cj.Name) { <mask> httpError(w, http.StatusBadRequest, "Client not found") <mask> return <mask> } <mask> <mask> _ = writeAllConfigsAndReloadDNS() </s> * clients: move container ob...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/d51f43e27a5b664be5da299ea6f8c73872ef1a9e
home/clients.go