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
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
<mask> golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= <mask> golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= <mask> golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/137d280032c8f2f0331f16b00cba83682369a43f
internal/tools/go.sum
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
<mask> golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= <mask> golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= <mask> golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= <mask> golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71r...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/137d280032c8f2f0331f16b00cba83682369a43f
internal/tools/go.sum
golang.org/x/vuln v0.0.0-20230201222900-4c848edceff1 h1:HRexnHfiDA2hkPNMDgf3vxabRMeC+XeS8tCKP9olVbs= golang.org/x/vuln v0.0.0-20230201222900-4c848edceff1/go.mod h1:cBP4HMKv0X+x96j8IJWCKk0eqpakBmmHjKGSSC0NaYE=
<mask> golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= <mask> golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= <mask> golang.org/x/tools v0.5.1-0.20230117180257-8aba49bb5ea2 h1:v0FhRDmSCNH/0EurAT6T8KRY4aNuUhz6/WwBMxG+gvQ= <mask> golang.org/x/tools v0...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/137d280032c8f2f0331f16b00cba83682369a43f
internal/tools/go.sum
<mask> golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= <mask> golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= <mask> gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/137d280032c8f2f0331f16b00cba83682369a43f
internal/tools/go.sum
honnef.co/go/tools v0.4.0 h1:lyXVV1c8wUBJRKqI8JgIpT8TW1VDagfYYaxbKa/HoL8= honnef.co/go/tools v0.4.0/go.mod h1:36ZgoUOrqOk1GxwHhyryEkq8FQWkUO2xGuSMhUCcdvA=
<mask> gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= <mask> gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= <mask> gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= <mask> gopkg.in/yaml.v3 v3.0.1/go.mod...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/137d280032c8f2f0331f16b00cba83682369a43f
internal/tools/go.sum
just added and you don't want to wait for automatic refresh to kick in.
<mask> - 'filtering' <mask> 'operationId': 'filteringRefresh' <mask> 'summary': > <mask> Reload filtering rules from URLs. This might be needed if new URL was <mask> just added and you dont want to wait for automatic refresh to kick in. <mask> This API request is ratelim...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/138718e6eca965a98002a6afd5194de813db76c0
openapi/openapi.yaml
# Add the "network-bind" plug to bind to interfaces.
<mask> 'apps': <mask> 'adguard-home': <mask> 'command': 'AdGuardHome --no-check-update -w $SNAP_DATA' <mask> 'plugs': <mask> # Add the "netrwork-bind" plug to bind to interfaces. <mask> - 'network-bind' <mask> # Add the "netrwork-observe" plug to be able to bind to ports below 1024 <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/138718e6eca965a98002a6afd5194de813db76c0
scripts/snap/snap.tmpl.yaml
# Add the "network-observe" plug to be able to bind to ports below 1024
<mask> 'command': 'AdGuardHome --no-check-update -w $SNAP_DATA' <mask> 'plugs': <mask> # Add the "netrwork-bind" plug to bind to interfaces. <mask> - 'network-bind' <mask> # Add the "netrwork-observe" plug to be able to bind to ports below 1024 <mask> # (cap_net_bind_service) and also to b...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/138718e6eca965a98002a6afd5194de813db76c0
scripts/snap/snap.tmpl.yaml
// Error is the constant error type. type Error string // Error implements the error interface for Error. func (err Error) Error() (msg string) { return string(err) }
<mask> "strings" <mask> ) <mask> <mask> // manyError is an error containing several wrapped errors. It is created to be <mask> // a simpler version of the API provided by github.com/joomcode/errorx. <mask> type manyError struct { <mask> message string <mask> underlying []error <mask> } </s> Pull reque...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86
internal/agherr/agherr.go
<mask> package querylog <mask> <mask> import ( <mask> "errors" <mask> "io" <mask> "os" <mask> "sync" <mask> "time" <mask> </s> Pull request: * querylog: fix end of log handling Merge in DNS/adguard-home from 2229-query-log to master Closes #2229. Squashed commit of the following: commit 32508a3f3b1...
[ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86
internal/querylog/qlog_file.go
"github.com/AdguardTeam/AdGuardHome/internal/agherr"
<mask> "sync" <mask> "time" <mask> <mask> "github.com/AdguardTeam/golibs/log" <mask> ) <mask> <mask> // ErrSeekNotFound is returned from Seek if when it fails to find the requested <mask> // record. </s> Pull request: * querylog: fix end of log handling Merge in DNS/adguard-home from 2229-query-log to ma...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86
internal/querylog/qlog_file.go
// ErrSeekNotFound is returned from Seek if when it fails to find the requested // record. const ErrSeekNotFound agherr.Error = "seek: record not found" // ErrEndOfLog is returned from Seek when the end of the current log is reached. const ErrEndOfLog agherr.Error = "seek: end of log"
<mask> <mask> "github.com/AdguardTeam/golibs/log" <mask> ) <mask> <mask> // ErrSeekNotFound is returned from the Seek method <mask> // if we failed to find the desired record <mask> var ErrSeekNotFound = errors.New("Seek not found the record") <mask> <mask> // TODO: Find a way to grow buffer instead of rel...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86
internal/querylog/qlog_file.go
f, err := os.OpenFile(path, os.O_RDONLY, 0o644)
<mask> } <mask> <mask> // NewQLogFile initializes a new instance of the QLogFile <mask> func NewQLogFile(path string) (*QLogFile, error) { <mask> f, err := os.OpenFile(path, os.O_RDONLY, 0644) <mask> <mask> if err != nil { <mask> return nil, err <mask> } <mask> <mask> return &QLogFile{ </s> Pull re...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86
internal/querylog/qlog_file.go
} else if lineIdx == end && lineEndIdx == end { return 0, depth, ErrEndOfLog
<mask> // the scope is too narrow and we won't find anything anymore <mask> log.Error("querylog: didn't find timestamp:%v", timestamp) <mask> return 0, depth, ErrSeekNotFound <mask> } <mask> <mask> // Save the last found idx <mask> lastProbeLineIdx = lineIdx <mask> </s> Pull request: * querylo...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86
internal/querylog/qlog_file.go
startLine := int64(0)
<mask> } <mask> <mask> // Look for the end of the prev line <mask> // This is where we'll read from <mask> var startLine = int64(0) <mask> for i := relativePos - 1; i >= 0; i-- { <mask> if q.buffer[i] == '\n' { <mask> startLine = i + 1 <mask> break <mask> } </s> Pull request: * querylog: fix ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86
internal/querylog/qlog_file.go
startLine := int64(0)
<mask> } <mask> <mask> // Now start looking for the new line character starting <mask> // from the relativePos and going left <mask> var startLine = int64(0) <mask> for i := relativePos - 1; i >= 0; i-- { <mask> if buffer[i] == '\n' { <mask> startLine = i + 1 <mask> break <mask> } </s> Pull r...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86
internal/querylog/qlog_file.go
endLine := int64(bufferLen)
<mask> break <mask> } <mask> } <mask> // Looking for the end of line now <mask> var endLine = int64(bufferLen) <mask> lineEndIdx := endLine + seekPosition <mask> for i := relativePos; i < int64(bufferLen); i++ { <mask> if buffer[i] == '\n' { <mask> endLine = i <mask> lineEndIdx = endLine + s...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86
internal/querylog/qlog_file.go
"errors"
<mask> package querylog <mask> <mask> import ( <mask> "io" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/agherr" <mask> ) <mask> <mask> // QLogReader allows reading from multiple query log files in the reverse order. </s> Pull request: * querylog: fix end of log handling Merge in DNS/adguar...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86
internal/querylog/qlog_reader.go
if err == nil || errors.Is(err, ErrEndOfLog) { // Our search is finished, and we either found the // element we were looking for or reached the end of the // log. Update currentFile only, position is already // set properly in QLogFile.
<mask> func (r *QLogReader) Seek(timestamp int64) error { <mask> for i := len(r.qFiles) - 1; i >= 0; i-- { <mask> q := r.qFiles[i] <mask> _, _, err := q.Seek(timestamp) <mask> if err == nil { <mask> // Our search is finished, we found the element we were looking for <mask> // Update currentFile only...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86
internal/querylog/qlog_reader.go
return err
<mask> if err == nil { <mask> // Our search is finished, we found the element we were looking for <mask> // Update currentFile only, position is already set properly in the QLogFile <mask> r.currentFile = i <mask> return nil <mask> } <mask> } <mask> <mask> return ErrSeekNotFound <mask> } <...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86
internal/querylog/qlog_reader.go
"errors"
<mask> <mask> import ( <mask> "io" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/util" <mask> "github.com/AdguardTeam/golibs/log" <mask> ) </s> Pull request: * querylog: fix end of log handling Merge in DNS/adguard-home from 2229-query-log to master Closes #2229. Squashed co...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86
internal/querylog/querylog_search.go
if len(entries) > 0 && len(entries) <= totalLimit { // Update oldest after merging in the memory buffer.
<mask> entries = make([]*logEntry, 0) <mask> oldest = time.Time{} <mask> } <mask> } <mask> if len(entries) == totalLimit { <mask> // change the "oldest" value here. <mask> // we cannot use the "oldest" we got from "searchFiles" anymore <mask> // because after adding in-memory records and removin...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86
internal/querylog/querylog_search.go
} else if errors.Is(err, ErrEndOfLog) { // We've reached the end of the log. return entries, time.Time{}, 0
<mask> // The one that was specified in the "oldest" param is not needed, <mask> // we need only the one next to it <mask> _, err = r.ReadNext() <mask> } <mask> } <mask> <mask> if err != nil { </s> Pull request: * querylog: fix end of log handling Merge in DNS/adguard-home from 2229-query-log to ...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86
internal/querylog/querylog_search.go
// rule or an empty string if the last doesn't exist. The returned rules are in // a processed format like: // // ip host1 host2 ... //
<mask> return rm.engine.MatchRequest(req) <mask> } <mask> <mask> // Translate returns the source hosts-syntax rule for the generated dnsrewrite <mask> // rule or an empty string if the last doesn't exist. <mask> func (rm *requestMatcher) Translate(rule string) (hostRule string) { <mask> rm.stateLock.RLock() ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
log.Debug("%s: %s is expected to exist but doesn't", hostsContainerPref, p)
<mask> if !errors.Is(err, fs.ErrNotExist) { <mask> return nil, fmt.Errorf("adding path: %w", err) <mask> } <mask> <mask> log.Debug("%s: file %q expected to exist but doesn't", hostsContainerPref, p) <mask> } <mask> } <mask> <mask> go hc.handleEvents() <mask> </s> Pull request: 4079 fix ho...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
// map's values are guaranteed to be of type of *aghnet.Hosts.
<mask> return nil <mask> } <mask> <mask> // Upd returns the channel into which the updates are sent. The receivable <mask> // map's values are guaranteed to be of type of *stringutil.Set. <mask> func (hc *HostsContainer) Upd() (updates <-chan *netutil.IPMap) { <mask> return hc.updates <mask> } <mask> <ma...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
// handleEvents concurrently handles the file system events. It closes the // update channel of HostsContainer when finishes. It's used to be called // within a separate goroutine.
<mask> <mask> return patterns, nil <mask> } <mask> <mask> // handleEvents concurrently handles the events. It closes the update channel <mask> // of HostsContainer when finishes. Used to be called within a goroutine. <mask> func (hc *HostsContainer) handleEvents() { <mask> defer log.OnPanic(fmt.Sprintf("%...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
// ipRules is the pair of generated A/AAAA and PTR rules with related IP. type ipRules struct { // rule is the A/AAAA $dnsrewrite rule. rule string // rulePtr is the PTR $dnsrewrite rule. rulePtr string // ip is the IP address related to the rules. ip net.IP }
<mask> } <mask> <mask> // hostsParser is a helper type to parse rules from the operating system's hosts <mask> // file. It exists for only a single refreshing session. <mask> type hostsParser struct { <mask> // rulesBuilder builds the resulting rules list content. <mask> rulesBuilder *strings.Builder </s> P...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
// rulesBuilder builds the resulting rules list content.
<mask> <mask> // hostsParser is a helper type to parse rules from the operating system's hosts <mask> // file. It exists for only a single refreshing session. <mask> type hostsParser struct { <mask> // rulesBuilder builds the resulting rulesBuilder list content. <mask> rulesBuilder *strings.Builder <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
// rules stores the rules for main hosts to generate translations. rules []ipRules
<mask> type hostsParser struct { <mask> // rulesBuilder builds the resulting rulesBuilder list content. <mask> rulesBuilder *strings.Builder <mask> <mask> // translations maps generated $dnsrewrite rules to the hosts-translations <mask> // rules. <mask> translations map[string]string <mask> <mask> // c...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
// cnameSet prevents duplicating cname rules, e.g. same hostname for // different IP versions.
<mask> // translations maps generated $dnsrewrite rules to the hosts-translations <mask> // rules. <mask> translations map[string]string <mask> <mask> // cnameSet prevents duplicating cname rules. <mask> cnameSet *stringutil.Set <mask> <mask> // table stores only the unique IP-hostname pairs. It's also...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
// newHostsParser creates a new *hostsParser with buffers of size taken from the // previous parse.
<mask> // updates channel afterwards. <mask> table *netutil.IPMap <mask> } <mask> <mask> func (hc *HostsContainer) newHostsParser() (hp *hostsParser) { <mask> lastLen := hc.last.Len() <mask> <mask> return &hostsParser{ <mask> rulesBuilder: &strings.Builder{}, </s> Pull request: 4079 fix hosts containe...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
lastLen := hc.last.Len()
<mask> // previous parse. <mask> func (hc *HostsContainer) newHostsParser() (hp *hostsParser) { <mask> return &hostsParser{ <mask> rulesBuilder: &strings.Builder{}, <mask> rules: make([]ipRules, 0, lastLen), <mask> cnameSet: stringutil.NewSet(), <mask> table: netutil.NewIPMap(lastLen),...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
rules: make([]ipRules, 0, lastLen),
<mask> <mask> func (hc *HostsContainer) newHostsParser() (hp *hostsParser) { <mask> return &hostsParser{ <mask> rulesBuilder: &strings.Builder{}, <mask> // For A/AAAA and PTRs. <mask> translations: make(map[string]string, hc.last.Len()*2), <mask> cnameSet: stringutil.NewSet(), <mask> table: ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
table: netutil.NewIPMap(lastLen),
<mask> rulesBuilder: &strings.Builder{}, <mask> // For A/AAAA and PTRs. <mask> translations: make(map[string]string, hc.last.Len()*2), <mask> cnameSet: stringutil.NewSet(), <mask> table: netutil.NewIPMap(hc.last.Len()), <mask> } <mask> } <mask> <mask> // parseFile is a aghos.FileWalker f...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
func (hp *hostsParser) parseFile(r io.Reader) (patterns []string, cont bool, err error) {
<mask> // parseFile is a aghos.FileWalker for parsing the files with hosts syntax. It <mask> // never signs to stop walking and never returns any additional patterns. <mask> // <mask> // See man hosts(5). <mask> func (hp *hostsParser) parseFile( <mask> r io.Reader, <mask> ) (patterns []string, cont bool, err e...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
// Hosts is used to contain the main host and all it's aliases. type Hosts struct { // Aliases contains all the aliases for Main. Aliases *stringutil.Set // Main is the host itself. Main string } // Equal returns true if h equals hh. func (h *Hosts) Equal(hh *Hosts) (ok bool) { if h == nil || hh == nil { return...
<mask> <mask> return ip, hosts <mask> } <mask> <mask> // Simple types of hosts in hosts database. Zero value isn't used to be able <mask> // quizzaciously emulate nil with 0. <mask> const ( <mask> _ = iota <mask> hostAlias <mask> hostMain <mask> ) <mask> <mask> // add tries to add the ip-host pair....
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
// main host if the host is not the first one added for the ip. // host itself if the host is the first one added for the ip. // "" if the ip-host pair has already been added.
<mask> ) <mask> <mask> // add tries to add the ip-host pair. It returns: <mask> // <mask> // hostAlias if the host is not the first one added for the ip. <mask> // hostMain if the host is the first one added for the ip. <mask> // 0 if the ip-host pair has already been added. <mask> // <mask> f...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
func (hp *hostsParser) add(ip net.IP, host string) (mainHost string) {
<mask> // hostAlias if the host is not the first one added for the ip. <mask> // hostMain if the host is the first one added for the ip. <mask> // 0 if the ip-host pair has already been added. <mask> // <mask> func (hp *hostsParser) add(ip net.IP, host string) (hostType int) { <mask> v, ok := hp.t...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
switch h, _ := v.(*Hosts); { case !ok: // This is the first host for the ip. hp.table.Set(ip, &Hosts{Main: host}) return host case h.Main == host: // This is a duplicate. Go on. case h.Aliases == nil: // This is the first alias. h.Aliases = stringutil.NewSet(host) return h.Main case !h.Aliases.Has...
<mask> // 0 if the ip-host pair has already been added. <mask> // <mask> func (hp *hostsParser) add(ip net.IP, host string) (hostType int) { <mask> v, ok := hp.table.Get(ip) <mask> switch hosts, _ := v.(*stringutil.Set); { <mask> case ok && hosts.Has(host): <mask> return 0 <mask> case hosts == n...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
// This is a duplicate. Go on.
<mask> hp.table.Set(ip, hosts) <mask> <mask> return hostMain <mask> default: <mask> hosts.Add(host) <mask> <mask> return hostAlias <mask> } <mask> } <mask> <mask> // addPair puts the pair of ip and host to the rules builder if needed. For <mask> // each ip the first member of hosts will become...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
return ""
<mask> default: <mask> // This is a duplicate. Go on. <mask> } <mask> } <mask> <mask> // addPair puts the pair of ip and host to the rules builder if needed. For <mask> // each ip the first member of hosts will become the main one. <mask> func (hp *hostsParser) addPairs(ip net.IP, hosts []string) { <mas...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
<mask> <mask> // addPair puts the pair of ip and host to the rules builder if needed. For <mask> // each ip the first member of hosts will become the main one. <mask> func (hp *hostsParser) addPairs(ip net.IP, hosts []string) { <mask> // Put the rule in a processed format like: <mask> // <mask> // ip host...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
switch mainHost := hp.add(ip, host); mainHost { case "": // This host is a duplicate.
<mask> // <mask> hostsLine := strings.Join(append([]string{ip.String()}, hosts...), " ") <mask> var mainHost string <mask> for _, host := range hosts { <mask> switch hp.add(ip, host) { <mask> case 0: <mask> continue <mask> case hostMain: <mask> mainHost = host <mask> added, addedPtr := hp.w...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
case host: // This host is main. added, addedPtr := hp.writeMainRule(host, ip) hp.rules = append(hp.rules, ipRules{ rule: added, rulePtr: addedPtr, ip: ip, }) default: // This host is an alias.
<mask> for _, host := range hosts { <mask> switch hp.add(ip, host) { <mask> case 0: <mask> continue <mask> case hostMain: <mask> mainHost = host <mask> added, addedPtr := hp.writeMainHostRule(host, ip) <mask> hp.translations[added], hp.translations[addedPtr] = hostsLine, hostsLine <mask> c...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
hp.writeAliasRule(host, mainHost)
<mask> pair := fmt.Sprint(host, " ", mainHost) <mask> if hp.cnameSet.Has(pair) { <mask> continue <mask> } <mask> // Since the hostAlias couldn't be returned from add before the <mask> // hostMain the mainHost shouldn't appear empty. <mask> hp.writeAliasHostRule(host, mainHost) <mask> hp...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
// writeAliasRule writes the CNAME rule for the alias-host pair into internal // builders. func (hp *hostsParser) writeAliasRule(alias, host string) {
<mask> log.Debug("%s: added ip-host pair %q-%q", hostsContainerPref, ip, host) <mask> } <mask> } <mask> <mask> // writeAliasHostRule writes the CNAME rule for the alias-host pair into <mask> // internal builders. <mask> func (hp *hostsParser) writeAliasHostRule(alias, host string) { <mask> const ( <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
// writeMainRule writes the actual rule for the qtype and the PTR for the
<mask> hp.rulesBuilder.Grow(constLen + len(host) + len(alias)) <mask> stringutil.WriteToBuilder(hp.rulesBuilder, rules.MaskPipe, alias, rwSuccess, host, nl) <mask> } <mask> <mask> // writeMainHostRule writes the actual rule for the qtype and the PTR for the <mask> // host-ip pair into internal builders. <mask...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
func (hp *hostsParser) writeMainRule(host string, ip net.IP) (added, addedPtr string) {
<mask> } <mask> <mask> // writeMainHostRule writes the actual rule for the qtype and the PTR for the <mask> // host-ip pair into internal builders. <mask> func (hp *hostsParser) writeMainHostRule(host string, ip net.IP) (added, addedPtr string) { <mask> arpa, err := netutil.IPToReversedAddr(ip) <mask> if err ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
hp.table.Range(func(ip net.IP, b interface{}) (cont bool) {
<mask> if hp.table.Len() != target.Len() { <mask> return false <mask> } <mask> <mask> hp.table.Range(func(ip net.IP, val interface{}) (cont bool) { <mask> v, hasIP := target.Get(ip) <mask> // ok is set to true if the target doesn't contain ip or if the <mask> // appropriate hosts set isn't equal to ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
// appropriate hosts set isn't equal to the checked one, i.e. the main // hosts differ or the maps have at least one discrepancy. if a, hasIP := target.Get(ip); !hasIP { ok = true } else if hosts, aok := a.(*Hosts); aok { ok = !hosts.Equal(b.(*Hosts)) }
<mask> <mask> hp.table.Range(func(ip net.IP, val interface{}) (cont bool) { <mask> v, hasIP := target.Get(ip) <mask> // ok is set to true if the target doesn't contain ip or if the <mask> // appropriate hosts set isn't equal to the checked one, i.e. the maps <mask> // have at least one discrepancy. <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
log.Debug("%s: no changes detected", hostsContainerPref)
<mask> return fmt.Errorf("refreshing : %w", err) <mask> } <mask> <mask> if hp.equalSet(hc.last) { <mask> log.Debug("%s: no updates detected", hostsContainerPref) <mask> <mask> return nil <mask> } <mask> defer hp.sendUpd(hc.updates) <mask> </s> Pull request: 4079 fix hosts container aliases Merg...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
hc.resetEng(rulesStrg, hp.translations())
<mask> if rulesStrg, err = hp.newStrg(hc.listID); err != nil { <mask> return fmt.Errorf("initializing rules storage: %w", err) <mask> } <mask> <mask> hc.resetEng(rulesStrg, hp.translations) <mask> <mask> return nil <mask> } </s> Pull request: 4079 fix hosts container aliases Merge in DNS/adguard-home ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer.go
"time"
<mask> "strings" <mask> "sync/atomic" <mask> "testing" <mask> "testing/fstest" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghtest" <mask> "github.com/AdguardTeam/golibs/errors" <mask> "github.com/AdguardTeam/golibs/stringutil" <mask> "github.com/AdguardTeam/urlfilter" <mask> "github....
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
func TestHostsContainer_refresh(t *testing.T) { // TODO(e.burkov): Test the case with no actual updates.
<mask> assert.Nil(t, hc) <mask> }) <mask> } <mask> <mask> func TestHostsContainer_Refresh(t *testing.T) { <mask> knownIP := net.IP{127, 0, 0, 1} <mask> <mask> const knownHost = "localhost" <mask> const knownAlias = "hocallost" <mask> <mask> const dirname = "dir" </s> Pull request: 4079 fix hosts c...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
ip := net.IP{127, 0, 0, 1} ipStr := ip.String()
<mask> <mask> func TestHostsContainer_Refresh(t *testing.T) { <mask> knownIP := net.IP{127, 0, 0, 1} <mask> <mask> const knownHost = "localhost" <mask> const knownAlias = "hocallost" <mask> <mask> const dirname = "dir" <mask> const filename1 = "file1" <mask> const filename2 = "file2" <mask> </s> P...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
testFS := fstest.MapFS{"dir/file1": &fstest.MapFile{Data: []byte(ipStr + ` hostname` + nl)}}
<mask> <mask> const knownHost = "localhost" <mask> const knownAlias = "hocallost" <mask> <mask> const dirname = "dir" <mask> const filename1 = "file1" <mask> const filename2 = "file2" <mask> <mask> p1 := path.Join(dirname, filename1) <mask> p2 := path.Join(dirname, filename2) <mask> <mask> testF...
[ "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/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
assert.Equal(t, "dir", name)
<mask> <mask> w := &aghtest.FSWatcher{ <mask> OnEvents: func() (e <-chan event) { return eventsCh }, <mask> OnAdd: func(name string) (err error) { <mask> assert.Equal(t, dirname, name) <mask> <mask> return nil <mask> }, <mask> OnClose: func() (err error) { panic("not implemented") }, <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
hc, err := NewHostsContainer(0, testFS, w, "dir")
<mask> }, <mask> OnClose: func() (err error) { panic("not implemented") }, <mask> } <mask> <mask> hc, err := NewHostsContainer(0, testFS, w, dirname) <mask> require.NoError(t, err) <mask> <mask> checkRefresh := func(t *testing.T, wantHosts *stringutil.Set) { <mask> upd, ok := <-hc.Upd() <mask> r...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
checkRefresh := func(t *testing.T, wantHosts Hosts) {
<mask> <mask> hc, err := NewHostsContainer(0, testFS, w, dirname) <mask> require.NoError(t, err) <mask> <mask> checkRefresh := func(t *testing.T, wantHosts *stringutil.Set) { <mask> upd, ok := <-hc.Upd() <mask> require.True(t, ok) <mask> require.NotNil(t, upd) <mask> <mask> assert.Equal(t, 1, up...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
v, ok := upd.Get(ip)
<mask> require.NotNil(t, upd) <mask> <mask> assert.Equal(t, 1, upd.Len()) <mask> <mask> v, ok := upd.Get(knownIP) <mask> require.True(t, ok) <mask> <mask> var hosts *stringutil.Set <mask> hosts, ok = v.(*stringutil.Set) <mask> require.True(t, ok) </s> Pull request: 4079 fix hosts container a...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
var hosts *Hosts hosts, ok = v.(*Hosts)
<mask> <mask> v, ok := upd.Get(knownIP) <mask> require.True(t, ok) <mask> <mask> var hosts *stringutil.Set <mask> hosts, ok = v.(*stringutil.Set) <mask> require.True(t, ok) <mask> <mask> assert.True(t, hosts.Equal(wantHosts)) <mask> } <mask> </s> Pull request: 4079 fix hosts container alias...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
assert.Equal(t, wantHosts.Main, hosts.Main) assert.True(t, hosts.Aliases.Equal(wantHosts.Aliases))
<mask> var hosts *stringutil.Set <mask> hosts, ok = v.(*stringutil.Set) <mask> require.True(t, ok) <mask> <mask> assert.True(t, hosts.Equal(wantHosts)) <mask> } <mask> <mask> t.Run("initial_refresh", func(t *testing.T) { <mask> checkRefresh(t, stringutil.NewSet(knownHost)) <mask> }) </s> Pull ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
checkRefresh(t, Hosts{Main: "hostname"})
<mask> assert.True(t, hosts.Equal(wantHosts)) <mask> } <mask> <mask> t.Run("initial_refresh", func(t *testing.T) { <mask> checkRefresh(t, stringutil.NewSet(knownHost)) <mask> }) <mask> <mask> testFS[p2] = &fstest.MapFile{ <mask> Data: []byte(strings.Join([]string{knownIP.String(), knownAlias}, sp) ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
<mask> t.Run("initial_refresh", func(t *testing.T) { <mask> checkRefresh(t, stringutil.NewSet(knownHost)) <mask> }) <mask> <mask> testFS[p2] = &fstest.MapFile{ <mask> Data: []byte(strings.Join([]string{knownIP.String(), knownAlias}, sp) + nl), <mask> } <mask> eventsCh <- event{} <mask> <mask> t.Ru...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
testFS["dir/file2"] = &fstest.MapFile{Data: []byte(ipStr + ` alias` + nl)} eventsCh <- event{} checkRefresh(t, Hosts{Main: "hostname", Aliases: stringutil.NewSet("alias")})
<mask> } <mask> eventsCh <- event{} <mask> <mask> t.Run("second_refresh", func(t *testing.T) { <mask> checkRefresh(t, stringutil.NewSet(knownHost, knownAlias)) <mask> }) <mask> <mask> eventsCh <- event{} <mask> <mask> t.Run("no_changes_refresh", func(t *testing.T) { </s> Pull request: 4079 fix hos...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
t.Run("double_refresh", func(t *testing.T) { // Make a change once. testFS["dir/file1"] = &fstest.MapFile{Data: []byte(ipStr + ` alias` + nl)} eventsCh <- event{} // Require the changes are written. require.Eventually(t, func() bool { res, ok := hc.MatchRequest(urlfilter.DNSRequest{ Hostname: "hostna...
<mask> t.Run("second_refresh", func(t *testing.T) { <mask> checkRefresh(t, stringutil.NewSet(knownHost, knownAlias)) <mask> }) <mask> <mask> eventsCh <- event{} <mask> <mask> t.Run("no_changes_refresh", func(t *testing.T) { <mask> assert.Empty(t, hc.Upd()) <mask> }) <mask> } </s> Pull request: 407...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
return !ok && res.DNSRewrites() == nil }, 5*time.Second, time.Second/2) // Make a change again. testFS["dir/file2"] = &fstest.MapFile{Data: []byte(ipStr + ` hostname` + nl)} eventsCh <- event{} // Require the changes are written. require.Eventually(t, func() bool { res, ok := hc.MatchRequest(urlfilt...
<mask> }) <mask> <mask> eventsCh <- event{} <mask> <mask> t.Run("no_changes_refresh", func(t *testing.T) { <mask> assert.Empty(t, hc.Upd()) <mask> }) <mask> } <mask> <mask> func TestHostsContainer_PathsToPatterns(t *testing.T) { <mask> const ( </s> Pull request: 4079 fix hosts container aliases M...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
<mask> }) <mask> } <mask> <mask> func TestHostsContainer_PathsToPatterns(t *testing.T) { <mask> const ( <mask> dir0 = "dir" <mask> dir1 = "dir_1" <mask> fn1 = "file_1" <mask> fn2 = "file_2" <mask> fn3 = "file_3" <mask> fn4 = "file_4" <mask> ) <mask> <mask> fp1 := path.Join(dir0, fn1)...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
"dir_0/file_1": &fstest.MapFile{Data: []byte{1}}, "dir_0/file_2": &fstest.MapFile{Data: []byte{2}}, "dir_0/dir_1/file_3": &fstest.MapFile{Data: []byte{3}},
<mask> fp2 := path.Join(dir0, fn2) <mask> fp3 := path.Join(dir0, dir1, fn3) <mask> <mask> gsfs := fstest.MapFS{ <mask> fp1: &fstest.MapFile{Data: []byte{1}}, <mask> fp2: &fstest.MapFile{Data: []byte{2}}, <mask> fp3: &fstest.MapFile{Data: []byte{3}}, <mask> } <mask> <mask> testCases := []struct { ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
name string paths []string want []string
<mask> fp3: &fstest.MapFile{Data: []byte{3}}, <mask> } <mask> <mask> testCases := []struct { <mask> name string <mask> wantErr error <mask> want []string <mask> paths []string <mask> }{{ <mask> name: "no_paths", <mask> wantErr: nil, <mask> want: nil, <mask> paths: nil,...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
name: "no_paths", paths: nil, want: nil,
<mask> wantErr error <mask> want []string <mask> paths []string <mask> }{{ <mask> name: "no_paths", <mask> wantErr: nil, <mask> want: nil, <mask> paths: nil, <mask> }, { <mask> name: "single_file", <mask> wantErr: nil, <mask> want: []string{fp1}, <mask> paths: [...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
name: "single_file", paths: []string{"dir_0/file_1"}, want: []string{"dir_0/file_1"},
<mask> wantErr: nil, <mask> want: nil, <mask> paths: nil, <mask> }, { <mask> name: "single_file", <mask> wantErr: nil, <mask> want: []string{fp1}, <mask> paths: []string{fp1}, <mask> }, { <mask> name: "several_files", <mask> wantErr: nil, <mask> want: []string{fp1, f...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
name: "several_files", paths: []string{"dir_0/file_1", "dir_0/file_2"}, want: []string{"dir_0/file_1", "dir_0/file_2"},
<mask> wantErr: nil, <mask> want: []string{fp1}, <mask> paths: []string{fp1}, <mask> }, { <mask> name: "several_files", <mask> wantErr: nil, <mask> want: []string{fp1, fp2}, <mask> paths: []string{fp1, fp2}, <mask> }, { <mask> name: "whole_dir", <mask> wantErr: nil, <mask...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
name: "whole_dir", paths: []string{"dir_0"}, want: []string{"dir_0/*"},
<mask> wantErr: nil, <mask> want: []string{fp1, fp2}, <mask> paths: []string{fp1, fp2}, <mask> }, { <mask> name: "whole_dir", <mask> wantErr: nil, <mask> want: []string{path.Join(dir0, "*")}, <mask> paths: []string{dir0}, <mask> }, { <mask> name: "file_and_dir", <mask> wan...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
name: "file_and_dir", paths: []string{"dir_0/file_1", "dir_0/dir_1"}, want: []string{"dir_0/file_1", "dir_0/dir_1/*"},
<mask> wantErr: nil, <mask> want: []string{path.Join(dir0, "*")}, <mask> paths: []string{dir0}, <mask> }, { <mask> name: "file_and_dir", <mask> wantErr: nil, <mask> want: []string{fp1, path.Join(dir0, dir1, "*")}, <mask> paths: []string{fp1, path.Join(dir0, dir1)}, <mask> }, { <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
name: "non-existing", paths: []string{path.Join("dir_0", "file_3")}, want: nil,
<mask> wantErr: nil, <mask> want: []string{fp1, path.Join(dir0, dir1, "*")}, <mask> paths: []string{fp1, path.Join(dir0, dir1)}, <mask> }, { <mask> name: "non-existing", <mask> wantErr: nil, <mask> want: nil, <mask> paths: []string{path.Join(dir0, "file_3")}, <mask> }} <mask> <m...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
<mask> <mask> for _, tc := range testCases { <mask> t.Run(tc.name, func(t *testing.T) { <mask> patterns, err := pathsToPatterns(gsfs, tc.paths) <mask> if tc.wantErr != nil { <mask> assert.ErrorIs(t, err, tc.wantErr) <mask> <mask> return <mask> } <mask> <mask> require.NoError(t, err)...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
<mask> <mask> testdata := os.DirFS("./testdata") <mask> <mask> nRewrites := func(t *testing.T, res *urlfilter.DNSResult, n int) (rws []*rules.DNSRewrite) { <mask> t.Helper() <mask> <mask> rewrites := res.DNSRewrites() <mask> assert.Len(t, rewrites, n) <mask> <mask> for _, rewrite := range rewrit...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
require.Len(t, rewrites, n)
<mask> nRewrites := func(t *testing.T, res *urlfilter.DNSResult, n int) (rws []*rules.DNSRewrite) { <mask> t.Helper() <mask> <mask> rewrites := res.DNSRewrites() <mask> assert.Len(t, rewrites, n) <mask> <mask> for _, rewrite := range rewrites { <mask> require.Equal(t, listID, rewrite.FilterListID)...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
}, { name: "other_line_alias", req: urlfilter.DNSRequest{ Hostname: "hello.world.again", DNSType: dns.TypeA, }, testTail: func(t *testing.T, res *urlfilter.DNSResult) { assert.Equal(t, "hello", nRewrites(t, res, 1)[0].NewCNAME) },
<mask> testTail: func(t *testing.T, res *urlfilter.DNSResult) { <mask> assert.Equal(t, "hello", nRewrites(t, res, 1)[0].NewCNAME) <mask> }, <mask> }, { <mask> name: "hello_subdomain", <mask> req: urlfilter.DNSRequest{ <mask> Hostname: "say.hello", <mask> DNSType: dns.TypeA, </s> Pull request...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
ip := net.IP{127, 0, 0, 1} ipStr := ip.String()
<mask> } <mask> } <mask> <mask> func TestUniqueRules_ParseLine(t *testing.T) { <mask> const ( <mask> hostname = "localhost" <mask> alias = "hocallost" <mask> ) <mask> <mask> knownIP := net.IP{127, 0, 0, 1} <mask> <mask> testCases := []struct { <mask> name string <mask> line st...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
line: ipStr + ` hostname`, wantIP: ip, wantHosts: []string{"hostname"},
<mask> wantIP net.IP <mask> wantHosts []string <mask> }{{ <mask> name: "simple", <mask> line: strings.Join([]string{knownIP.String(), hostname}, sp), <mask> wantIP: knownIP, <mask> wantHosts: []string{"localhost"}, <mask> }, { <mask> name: "aliases", <mask> line: st...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
line: ipStr + ` hostname alias`, wantIP: ip, wantHosts: []string{"hostname", "alias"},
<mask> wantIP: knownIP, <mask> wantHosts: []string{"localhost"}, <mask> }, { <mask> name: "aliases", <mask> line: strings.Join([]string{knownIP.String(), hostname, alias}, sp), <mask> wantIP: knownIP, <mask> wantHosts: []string{"localhost", "hocallost"}, <mask> }, { <mask> name:...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
line: ipStr,
<mask> wantIP: knownIP, <mask> wantHosts: []string{"localhost", "hocallost"}, <mask> }, { <mask> name: "invalid_line", <mask> line: knownIP.String(), <mask> wantIP: nil, <mask> wantHosts: nil, <mask> }, { <mask> name: "invalid_line_hostname", <mask> line: strings.Jo...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
line: ipStr + ` # hostname`, wantIP: ip,
<mask> wantIP: nil, <mask> wantHosts: nil, <mask> }, { <mask> name: "invalid_line_hostname", <mask> line: strings.Join([]string{knownIP.String(), "#" + hostname}, sp), <mask> wantIP: knownIP, <mask> wantHosts: nil, <mask> }, { <mask> name: "commented_aliases", <mask> lin...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
line: ipStr + ` hostname # alias`, wantIP: ip, wantHosts: []string{"hostname"},
<mask> wantIP: knownIP, <mask> wantHosts: nil, <mask> }, { <mask> name: "commented_aliases", <mask> line: strings.Join([]string{knownIP.String(), hostname, "#" + alias}, sp), <mask> wantIP: knownIP, <mask> wantHosts: []string{"localhost"}, <mask> }, { <mask> name: "whole_co...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
line: `# ` + ipStr + ` hostname`,
<mask> wantIP: knownIP, <mask> wantHosts: []string{"localhost"}, <mask> }, { <mask> name: "whole_comment", <mask> line: strings.Join([]string{"#", knownIP.String(), hostname}, sp), <mask> wantIP: nil, <mask> wantHosts: nil, <mask> }, { <mask> name: "partial_comment", <mask...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
line: ipStr + ` host#name`, wantIP: ip, wantHosts: []string{"host"},
<mask> wantIP: nil, <mask> wantHosts: nil, <mask> }, { <mask> name: "partial_comment", <mask> line: strings.Join([]string{knownIP.String(), hostname[:4] + "#" + hostname[4:]}, sp), <mask> wantIP: knownIP, <mask> wantHosts: []string{hostname[:4]}, <mask> }, { <mask> name: "e...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
got, hosts := hp.parseLine(tc.line) assert.True(t, tc.wantIP.Equal(got))
<mask> <mask> for _, tc := range testCases { <mask> hp := hostsParser{} <mask> t.Run(tc.name, func(t *testing.T) { <mask> ip, hosts := hp.parseLine(tc.line) <mask> assert.True(t, tc.wantIP.Equal(ip)) <mask> assert.Equal(t, tc.wantHosts, hosts) <mask> }) <mask> } <mask> } </s> Pull request: ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/hostscontainer_test.go
# See https://github.com/AdguardTeam/AdGuardHome/issues/4079. 1.0.0.0 hello.world.again # Duplicates of a main host and an alias. 1.0.0.1 simplehost 1.0.0.0 hello.world
<mask> 1.0.0.3 * <mask> 1.0.0.4 *.com <mask> <mask> # Same for IPv6. <mask> ::1 simplehost <mask> :: hello hello.world <mask> ::2 a.whole lot.of aliases for.testing </s> Pull request: 4079 fix hosts container aliases Merge in DNS/adguard-home from 4079-hosts-again to master Updates #4079. Squashed commit o...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/aghnet/testdata/etc_hosts
hosts, ok := v.(*aghnet.Hosts)
<mask> clients.rmHostsBySrc(ClientSourceHostsFile) <mask> <mask> n := 0 <mask> hosts.Range(func(ip net.IP, v interface{}) (cont bool) { <mask> names, ok := v.(*stringutil.Set) <mask> if !ok { <mask> log.Error("dns: bad type %T in ipToRC for %s", v, ip) <mask> } <mask> <mask> names.Range(func(n...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/home/clients.go
return true
<mask> hosts.Range(func(ip net.IP, v interface{}) (cont bool) { <mask> hosts, ok := v.(*aghnet.Hosts) <mask> if !ok { <mask> log.Error("dns: bad type %T in ipToRC for %s", v, ip) <mask> } <mask> <mask> if clients.addHostLocked(ip, hosts.Main, ClientSourceHostsFile) { <mask> n++ <mask> } <mas...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/home/clients.go
if clients.addHostLocked(ip, hosts.Main, ClientSourceHostsFile) { n++ } hosts.Aliases.Range(func(name string) (cont bool) {
<mask> if !ok { <mask> log.Error("dns: bad type %T in ipToRC for %s", v, ip) <mask> } <mask> <mask> names.Range(func(name string) (cont bool) { <mask> if clients.addHostLocked(ip, name, ClientSourceHostsFile) { <mask> n++ <mask> } <mask> <mask> return true </s> Pull request: 4079 fix ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad
internal/home/clients.go
// Create - create object func Create(config ServerConfig) *Server { s := Server{} s.conf = config return &s }
<mask> } <mask> <mask> // Init checks the configuration and initializes the server <mask> func (s *Server) Init(config ServerConfig) error { <mask> err := s.setConfig(config) <mask> if err != nil { <mask> return err </s> * dhcp,clients: DHCP server module is passed to Clients module during initialization. ...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273
dhcpd/dhcpd.go
// WriteDiskConfig - write configuration func (s *Server) WriteDiskConfig(c *ServerConfig) { *c = s.conf }
<mask> } <mask> <mask> func (s *Server) setConfig(config ServerConfig) error { <mask> s.conf = config <mask> s.conf.DBFilePath = filepath.Join(config.WorkDir, dbFilename) <mask> </s> * dhcp,clients: DHCP server module is passed to Clients module during initialization. </s> remove func (clients *clientsContai...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273
dhcpd/dhcpd.go
"github.com/AdguardTeam/AdGuardHome/dhcpd"
<mask> "strings" <mask> "sync" <mask> "time" <mask> <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/AdguardTeam/golibs/utils" <mask> ) <mask> <mask> const ( </s> * dhcp,clients: DHCP server module is passed to Clients module during initialization. </s> remove config.clients.Init(config.C...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273
home/clients.go
dhcpServer *dhcpd.Server
<mask> idIndex map[string]*Client // IP -> client <mask> ipHost map[string]*ClientHost // IP -> Hostname <mask> lock sync.Mutex <mask> } <mask> <mask> // Init initializes clients container <mask> // Note: this function must be called only once <mask> func (clients *clientsContainer) Init(objects []c...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273
home/clients.go
func (clients *clientsContainer) Init(objects []clientObject, dhcpServer *dhcpd.Server) {
<mask> } <mask> <mask> // Init initializes clients container <mask> // Note: this function must be called only once <mask> func (clients *clientsContainer) Init(objects []clientObject) { <mask> if clients.list != nil { <mask> log.Fatal("clients.list != nil") <mask> } <mask> clients.list = make(map[string...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273
home/clients.go
clients.dhcpServer = dhcpServer
<mask> clients.list = make(map[string]*Client) <mask> clients.idIndex = make(map[string]*Client) <mask> clients.ipHost = make(map[string]*ClientHost) <mask> clients.addFromConfig(objects) <mask> <mask> go clients.periodicUpdate() <mask> } <mask> </s> * dhcp,clients: DHCP server module is passed to Clien...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273
home/clients.go