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
QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file // QueryLogInterval is the interval for query log's files rotation. QueryLogInterval Duration `yaml:"querylog_interval"` QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats
<mask> <mask> // time interval for statistics (in days) <mask> StatsInterval uint32 `yaml:"statistics_interval"` <mask> <mask> QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled <mask> QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file <mask> QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days) <mask> QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk <mask> AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats <mask> <mask> dnsforward.FilteringConfig `yaml:",inline"` <mask> <mask> FilteringEnabled bool `yaml:"filtering_enabled"` // whether or not use filter lists <mask> FiltersUpdateIntervalHours uint32 `yaml:"filters_update_interval"` // time period to update filters (in hours) </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove // RotationIvl is the interval for log rotation, in days. After that // period, the old log file will be renamed, NOT deleted, so the actual // log retention time is twice the interval. RotationIvl uint32 </s> add // RotationIvl is the interval for log rotation. After that period, the // old log file will be renamed, NOT deleted, so the actual log // retention time is twice the interval. The value must be one of: // // 6 * time.Hour // 24 * time.Hour // 7 * 24 * time.Hour // 30 * 24 * time.Hour // 90 * 24 * time.Hour // RotationIvl time.Duration </s> remove Enabled bool `json:"enabled"` Interval uint32 `json:"interval"` AnonymizeClientIP bool `json:"anonymize_client_ip"` </s> add Enabled bool `json:"enabled"` // Use float64 here to support fractional numbers and not mess the API // users by changing the units. Interval float64 `json:"interval"` AnonymizeClientIP bool `json:"anonymize_client_ip"` </s> remove UpstreamTimeout: Duration{dnsforward.DefaultTimeout}, </s> add UpstreamTimeout: Duration{Duration: dnsforward.DefaultTimeout}, </s> remove 'type': 'integer' 'description': 'Time period to keep data (1 | 7 | 30 | 90)' </s> add 'description': > Time period for query log rotation. 'type': 'number' 'enum': - 0.25 - 1 - 7 - 30 - 90
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/home/config.go
UpstreamTimeout: Duration{Duration: dnsforward.DefaultTimeout},
<mask> MaxGoroutines: 300, <mask> }, <mask> FilteringEnabled: true, // whether or not use filter lists <mask> FiltersUpdateIntervalHours: 24, <mask> UpstreamTimeout: Duration{dnsforward.DefaultTimeout}, <mask> LocalDomainName: "lan", <mask> ResolveClients: true, <mask> UsePrivateRDNS: true, <mask> }, <mask> TLS: tlsConfigSettings{ </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days) QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats </s> add QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file // QueryLogInterval is the interval for query log's files rotation. QueryLogInterval Duration `yaml:"querylog_interval"` QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/home/config.go
config.DNS.QueryLogInterval = Duration{Duration: 90 * 24 * time.Hour}
<mask> config.WebSessionTTLHours = 30 * 24 <mask> <mask> config.DNS.QueryLogEnabled = true <mask> config.DNS.QueryLogFileEnabled = true <mask> config.DNS.QueryLogInterval = 90 <mask> config.DNS.QueryLogMemSize = 1000 <mask> <mask> config.DNS.CacheSize = 4 * 1024 * 1024 <mask> config.DNS.DnsfilterConf.SafeBrowsingCacheSize = 1 * 1024 * 1024 <mask> config.DNS.DnsfilterConf.SafeSearchCacheSize = 1 * 1024 * 1024 </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove func checkInterval(days uint32) bool { return days == 1 || days == 7 || days == 30 || days == 90 </s> add func checkInterval(ivl time.Duration) (ok bool) { // The constants for possible values of query log's rotation interval. const ( quarterDay = 6 * time.Hour day = 24 * time.Hour week = day * 7 month = day * 30 threeMonths = day * 90 ) return ivl == quarterDay || ivl == day || ivl == week || ivl == month || ivl == threeMonths </s> remove config.DNS.QueryLogInterval = dc.RotationIvl </s> add config.DNS.QueryLogInterval = Duration{Duration: dc.RotationIvl} </s> remove l.conf.RotationIvl = 1 </s> add l.conf.RotationIvl = 24 * time.Hour </s> remove oldest := l.readFileFirstTimeValue() if uint64(oldest)+intervalSeconds <= uint64(time.Now().Unix()) { _ = l.rotate() </s> add var oldest time.Time oldest, err = l.readFileFirstTimeValue() if err != nil { log.Debug("%s", err) } if oldest.Add(l.conf.RotationIvl).After(time.Now()) { err = l.rotate() if err != nil { log.Debug("%s", err) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/home/config.go
config.DNS.UpstreamTimeout = Duration{Duration: dnsforward.DefaultTimeout}
<mask> config.DNS.FiltersUpdateIntervalHours = 24 <mask> } <mask> <mask> if config.DNS.UpstreamTimeout.Duration == 0 { <mask> config.DNS.UpstreamTimeout = Duration{dnsforward.DefaultTimeout} <mask> } <mask> <mask> return nil <mask> } <mask> </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove func checkInterval(days uint32) bool { return days == 1 || days == 7 || days == 30 || days == 90 </s> add func checkInterval(ivl time.Duration) (ok bool) { // The constants for possible values of query log's rotation interval. const ( quarterDay = 6 * time.Hour day = 24 * time.Hour week = day * 7 month = day * 30 threeMonths = day * 90 ) return ivl == quarterDay || ivl == day || ivl == week || ivl == month || ivl == threeMonths </s> remove oldest := l.readFileFirstTimeValue() if uint64(oldest)+intervalSeconds <= uint64(time.Now().Unix()) { _ = l.rotate() </s> add var oldest time.Time oldest, err = l.readFileFirstTimeValue() if err != nil { log.Debug("%s", err) } if oldest.Add(l.conf.RotationIvl).After(time.Now()) { err = l.rotate() if err != nil { log.Debug("%s", err) } </s> remove buf = buf[:r] </s> add </s> remove defer func() { derr := f.Close() if derr != nil { log.Error("querylog: closing file: %s", derr) } }() </s> add </s> remove func (l *queryLog) readFileFirstTimeValue() int64 { f, err := os.Open(l.logFile) </s> add func (l *queryLog) readFileFirstTimeValue() (first time.Time, err error) { var f *os.File f, err = os.Open(l.logFile)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/home/config.go
config.DNS.QueryLogInterval = Duration{Duration: dc.RotationIvl}
<mask> dc := querylog.Config{} <mask> Context.queryLog.WriteDiskConfig(&dc) <mask> config.DNS.QueryLogEnabled = dc.Enabled <mask> config.DNS.QueryLogFileEnabled = dc.FileEnabled <mask> config.DNS.QueryLogInterval = dc.RotationIvl <mask> config.DNS.QueryLogMemSize = dc.MemSize <mask> config.DNS.AnonymizeClientIP = dc.AnonymizeClientIP <mask> } <mask> <mask> if Context.dnsFilter != nil { </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove config.DNS.QueryLogInterval = 90 </s> add config.DNS.QueryLogInterval = Duration{Duration: 90 * 24 * time.Hour} </s> remove oldest := l.readFileFirstTimeValue() if uint64(oldest)+intervalSeconds <= uint64(time.Now().Unix()) { _ = l.rotate() </s> add var oldest time.Time oldest, err = l.readFileFirstTimeValue() if err != nil { log.Debug("%s", err) } if oldest.Add(l.conf.RotationIvl).After(time.Now()) { err = l.rotate() if err != nil { log.Debug("%s", err) } </s> remove buf = buf[:r] </s> add </s> remove defer func() { derr := f.Close() if derr != nil { log.Error("querylog: closing file: %s", derr) } }() </s> add </s> remove val := readJSONValue(string(buf), `"T":"`) </s> add val := readJSONValue(string(buf[:r]), `"T":"`)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/home/config.go
RotationIvl: config.DNS.QueryLogInterval.Duration,
<mask> ConfigModified: onConfigModified, <mask> HTTPRegister: httpRegister, <mask> FindClient: Context.clients.findMultiple, <mask> BaseDir: baseDir, <mask> RotationIvl: config.DNS.QueryLogInterval, <mask> MemSize: config.DNS.QueryLogMemSize, <mask> Enabled: config.DNS.QueryLogEnabled, <mask> FileEnabled: config.DNS.QueryLogFileEnabled, <mask> AnonymizeClientIP: config.DNS.AnonymizeClientIP, <mask> } </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/home/dns.go
// // TODO(e.burkov): Make it able to parse larger units like days.
<mask> <mask> // UnmarshalText implements the encoding.TextUnmarshaler interface for <mask> // *Duration. <mask> func (d *Duration) UnmarshalText(b []byte) (err error) { <mask> defer func() { err = errors.Annotate(err, "unmarshalling duration: %w") }() <mask> <mask> d.Duration, err = time.ParseDuration(string(b)) <mask> </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove func (l *queryLog) readFileFirstTimeValue() int64 { f, err := os.Open(l.logFile) </s> add func (l *queryLog) readFileFirstTimeValue() (first time.Time, err error) { var f *os.File f, err = os.Open(l.logFile) </s> remove buf := make([]byte, 500) r, err := f.Read(buf) </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() buf := make([]byte, 512) var r int r, err = f.Read(buf) </s> remove defer func() { derr := f.Close() if derr != nil { log.Error("querylog: closing file: %s", derr) } }() </s> add </s> remove return -1 </s> add return time.Time{}, err </s> remove intervalSeconds := uint64(l.conf.RotationIvl) * 24 * 60 * 60 </s> add defer log.OnPanic("querylog: rotating") var err error
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/home/duration.go
"time"
<mask> "path/filepath" <mask> "runtime" <mask> "strconv" <mask> "strings" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghnet" <mask> "github.com/AdguardTeam/golibs/errors" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/google/renameio/maybe" </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove 'type': 'integer' 'description': 'Time period to keep data (1 | 7 | 30 | 90)' </s> add 'description': > Time period for query log rotation. 'type': 'number' 'enum': - 0.25 - 1 - 7 - 30 - 90 </s> remove RotationIvl: config.DNS.QueryLogInterval, </s> add RotationIvl: config.DNS.QueryLogInterval.Duration, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove func checkInterval(days uint32) bool { return days == 1 || days == 7 || days == 30 || days == 90 </s> add func checkInterval(ivl time.Duration) (ok bool) { // The constants for possible values of query log's rotation interval. const ( quarterDay = 6 * time.Hour day = 24 * time.Hour week = day * 7 month = day * 30 threeMonths = day * 90 ) return ivl == quarterDay || ivl == day || ivl == week || ivl == month || ivl == threeMonths
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/home/upgrade.go
const currentSchemaVersion = 12
<mask> yaml "gopkg.in/yaml.v2" <mask> ) <mask> <mask> // currentSchemaVersion is the current schema version. <mask> const currentSchemaVersion = 11 <mask> <mask> // These aliases are provided for convenience. <mask> type ( <mask> any = interface{} <mask> yarr = []any </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove // RotationIvl is the interval for log rotation, in days. After that // period, the old log file will be renamed, NOT deleted, so the actual // log retention time is twice the interval. RotationIvl uint32 </s> add // RotationIvl is the interval for log rotation. After that period, the // old log file will be renamed, NOT deleted, so the actual log // retention time is twice the interval. The value must be one of: // // 6 * time.Hour // 24 * time.Hour // 7 * 24 * time.Hour // 30 * 24 * time.Hour // 90 * 24 * time.Hour // RotationIvl time.Duration </s> remove QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days) QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats </s> add QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file // QueryLogInterval is the interval for query log's files rotation. QueryLogInterval Duration `yaml:"querylog_interval"` QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats </s> remove Enabled bool `json:"enabled"` Interval uint32 `json:"interval"` AnonymizeClientIP bool `json:"anonymize_client_ip"` </s> add Enabled bool `json:"enabled"` // Use float64 here to support fractional numbers and not mess the API // users by changing the units. Interval float64 `json:"interval"` AnonymizeClientIP bool `json:"anonymize_client_ip"` </s> remove export const QUERY_LOG_INTERVALS_DAYS = [1, 7, 30, 90]; </s> add export const QUERY_LOG_INTERVALS_DAYS = [0.25, 1, 7, 30, 90];
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/home/upgrade.go
upgradeSchema11to12,
<mask> upgradeSchema8to9, <mask> upgradeSchema9to10, <mask> upgradeSchema10to11, <mask> } <mask> <mask> n := 0 <mask> for i, u := range upgrades { </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove wantLen: 0, </s> add </s> remove config.DNS.UpstreamTimeout = Duration{dnsforward.DefaultTimeout} </s> add config.DNS.UpstreamTimeout = Duration{Duration: dnsforward.DefaultTimeout} </s> remove intervalSeconds := uint64(l.conf.RotationIvl) * 24 * 60 * 60 </s> add defer log.OnPanic("querylog: rotating") var err error </s> remove return t.Unix() </s> add return t, nil
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/home/upgrade.go
"time"
<mask> package home <mask> <mask> import ( <mask> "testing" <mask> <mask> "github.com/stretchr/testify/assert" <mask> "github.com/stretchr/testify/require" <mask> ) <mask> </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove const getIntervalFields = (processing, t, toNumber) => QUERY_LOG_INTERVALS_DAYS.map((interval) => { const title = interval === 1 ? t('interval_24_hour') : t('interval_days', { count: interval }); </s> add const getIntervalTitle = (interval, t) => { switch (interval) { case 0.25: return t('interval_6_hour'); case 1: return t('interval_24_hour'); default: return t('interval_days', { count: interval }); } }; </s> remove import { CheckboxField, renderRadioField, toNumber } from '../../../helpers/form'; </s> add import { CheckboxField, renderRadioField, toFloatNumber } from '../../../helpers/form'; </s> remove const currentSchemaVersion = 11 </s> add const currentSchemaVersion = 12 </s> remove l.conf.RotationIvl = 1 </s> add l.conf.RotationIvl = 24 * time.Hour </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour,
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/home/upgrade_test.go
Enabled bool `json:"enabled"` // Use float64 here to support fractional numbers and not mess the API // users by changing the units. Interval float64 `json:"interval"` AnonymizeClientIP bool `json:"anonymize_client_ip"`
<mask> "golang.org/x/net/idna" <mask> ) <mask> <mask> type qlogConfig struct { <mask> Enabled bool `json:"enabled"` <mask> Interval uint32 `json:"interval"` <mask> AnonymizeClientIP bool `json:"anonymize_client_ip"` <mask> } <mask> <mask> // Register web handlers <mask> func (l *queryLog) initWeb() { <mask> l.conf.HTTPRegister(http.MethodGet, "/control/querylog", l.handleQueryLog) </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days) QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats </s> add QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file // QueryLogInterval is the interval for query log's files rotation. QueryLogInterval Duration `yaml:"querylog_interval"` QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats </s> remove func checkInterval(days uint32) bool { return days == 1 || days == 7 || days == 30 || days == 90 </s> add func checkInterval(ivl time.Duration) (ok bool) { // The constants for possible values of query log's rotation interval. const ( quarterDay = 6 * time.Hour day = 24 * time.Hour week = day * 7 month = day * 30 threeMonths = day * 90 ) return ivl == quarterDay || ivl == day || ivl == week || ivl == month || ivl == threeMonths </s> remove func (l *queryLog) readFileFirstTimeValue() int64 { f, err := os.Open(l.logFile) </s> add func (l *queryLog) readFileFirstTimeValue() (first time.Time, err error) { var f *os.File f, err = os.Open(l.logFile) </s> remove return -1 </s> add return time.Time{}, err </s> remove resp.Interval = l.conf.RotationIvl </s> add resp.Interval = l.conf.RotationIvl.Hours() / 24
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/http.go
resp.Interval = l.conf.RotationIvl.Hours() / 24
<mask> // Get configuration <mask> func (l *queryLog) handleQueryLogInfo(w http.ResponseWriter, r *http.Request) { <mask> resp := qlogConfig{} <mask> resp.Enabled = l.conf.Enabled <mask> resp.Interval = l.conf.RotationIvl <mask> resp.AnonymizeClientIP = l.conf.AnonymizeClientIP <mask> <mask> jsonVal, err := json.Marshal(resp) <mask> if err != nil { <mask> httpError(r, w, http.StatusInternalServerError, "json encode: %s", err) </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove oldest := l.readFileFirstTimeValue() if uint64(oldest)+intervalSeconds <= uint64(time.Now().Unix()) { _ = l.rotate() </s> add var oldest time.Time oldest, err = l.readFileFirstTimeValue() if err != nil { log.Debug("%s", err) } if oldest.Add(l.conf.RotationIvl).After(time.Now()) { err = l.rotate() if err != nil { log.Debug("%s", err) } </s> remove return -1 </s> add return time.Time{}, err </s> remove func (l *queryLog) readFileFirstTimeValue() int64 { f, err := os.Open(l.logFile) </s> add func (l *queryLog) readFileFirstTimeValue() (first time.Time, err error) { var f *os.File f, err = os.Open(l.logFile) </s> remove buf := make([]byte, 500) r, err := f.Read(buf) </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() buf := make([]byte, 512) var r int r, err = f.Read(buf) </s> remove if req.Exists("interval") && !checkInterval(d.Interval) { </s> add ivl := time.Duration(24*d.Interval) * time.Hour if req.Exists("interval") && !checkInterval(ivl) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/http.go
ivl := time.Duration(24*d.Interval) * time.Hour if req.Exists("interval") && !checkInterval(ivl) {
<mask> httpError(r, w, http.StatusBadRequest, "%s", err) <mask> return <mask> } <mask> <mask> if req.Exists("interval") && !checkInterval(d.Interval) { <mask> httpError(r, w, http.StatusBadRequest, "Unsupported interval") <mask> return <mask> } <mask> <mask> l.lock.Lock() </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove resp.Interval = l.conf.RotationIvl </s> add resp.Interval = l.conf.RotationIvl.Hours() / 24 </s> remove conf.RotationIvl = d.Interval </s> add conf.RotationIvl = ivl </s> remove oldest := l.readFileFirstTimeValue() if uint64(oldest)+intervalSeconds <= uint64(time.Now().Unix()) { _ = l.rotate() </s> add var oldest time.Time oldest, err = l.readFileFirstTimeValue() if err != nil { log.Debug("%s", err) } if oldest.Add(l.conf.RotationIvl).After(time.Now()) { err = l.rotate() if err != nil { log.Debug("%s", err) } </s> remove defer func() { derr := f.Close() if derr != nil { log.Error("querylog: closing file: %s", derr) } }() </s> add </s> remove return -1 </s> add return time.Time{}, err
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/http.go
conf.RotationIvl = ivl
<mask> if req.Exists("enabled") { <mask> conf.Enabled = d.Enabled <mask> } <mask> if req.Exists("interval") { <mask> conf.RotationIvl = d.Interval <mask> } <mask> if req.Exists("anonymize_client_ip") { <mask> conf.AnonymizeClientIP = d.AnonymizeClientIP <mask> } <mask> l.conf = &conf </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove if req.Exists("interval") && !checkInterval(d.Interval) { </s> add ivl := time.Duration(24*d.Interval) * time.Hour if req.Exists("interval") && !checkInterval(ivl) { </s> remove oldest := l.readFileFirstTimeValue() if uint64(oldest)+intervalSeconds <= uint64(time.Now().Unix()) { _ = l.rotate() </s> add var oldest time.Time oldest, err = l.readFileFirstTimeValue() if err != nil { log.Debug("%s", err) } if oldest.Add(l.conf.RotationIvl).After(time.Now()) { err = l.rotate() if err != nil { log.Debug("%s", err) } </s> remove config.DNS.UpstreamTimeout = Duration{dnsforward.DefaultTimeout} </s> add config.DNS.UpstreamTimeout = Duration{Duration: dnsforward.DefaultTimeout} </s> remove buf = buf[:r] </s> add </s> remove defer func() { derr := f.Close() if derr != nil { log.Error("querylog: closing file: %s", derr) } }() </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/http.go
func checkInterval(ivl time.Duration) (ok bool) { // The constants for possible values of query log's rotation interval. const ( quarterDay = 6 * time.Hour day = 24 * time.Hour week = day * 7 month = day * 30 threeMonths = day * 90 ) return ivl == quarterDay || ivl == day || ivl == week || ivl == month || ivl == threeMonths
<mask> func (l *queryLog) Close() { <mask> _ = l.flushLogBuffer(true) <mask> } <mask> <mask> func checkInterval(days uint32) bool { <mask> return days == 1 || days == 7 || days == 30 || days == 90 <mask> } <mask> <mask> func (l *queryLog) WriteDiskConfig(c *Config) { <mask> *c = *l.conf <mask> } </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove config.DNS.UpstreamTimeout = Duration{dnsforward.DefaultTimeout} </s> add config.DNS.UpstreamTimeout = Duration{Duration: dnsforward.DefaultTimeout} </s> remove func (l *queryLog) readFileFirstTimeValue() int64 { f, err := os.Open(l.logFile) </s> add func (l *queryLog) readFileFirstTimeValue() (first time.Time, err error) { var f *os.File f, err = os.Open(l.logFile) </s> remove intervalSeconds := uint64(l.conf.RotationIvl) * 24 * 60 * 60 </s> add defer log.OnPanic("querylog: rotating") var err error </s> remove return t.Unix() </s> add return t, nil </s> remove return -1 </s> add return time.Time{}, err
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/qlog.go
RotationIvl: 24 * time.Hour,
<mask> func TestQueryLog(t *testing.T) { <mask> l := newQueryLog(Config{ <mask> Enabled: true, <mask> FileEnabled: true, <mask> RotationIvl: 1, <mask> MemSize: 100, <mask> BaseDir: t.TempDir(), <mask> }) <mask> <mask> // Add disk entries. </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: config.DNS.QueryLogInterval, </s> add RotationIvl: config.DNS.QueryLogInterval.Duration,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/qlog_test.go
RotationIvl: 24 * time.Hour,
<mask> <mask> func TestQueryLogOffsetLimit(t *testing.T) { <mask> l := newQueryLog(Config{ <mask> Enabled: true, <mask> RotationIvl: 1, <mask> MemSize: 100, <mask> BaseDir: t.TempDir(), <mask> }) <mask> <mask> const ( </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: config.DNS.QueryLogInterval, </s> add RotationIvl: config.DNS.QueryLogInterval.Duration,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/qlog_test.go
want string wantLen int
<mask> testCases := []struct { <mask> name string <mask> offset int <mask> limit int <mask> }{{ <mask> name: "page_1", <mask> want: firstPageDomain, <mask> wantLen: 10, </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove wantLen int want string </s> add </s> remove wantLen: 10, want: firstPageDomain, </s> add
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/qlog_test.go
<mask> testCases := []struct { <mask> name string <mask> offset int <mask> limit int <mask> wantLen int <mask> want string <mask> }{{ <mask> name: "page_1", <mask> offset: 0, <mask> limit: 10, <mask> wantLen: 10, </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove wantLen: 10, want: firstPageDomain, </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/qlog_test.go
want: firstPageDomain, wantLen: 10,
<mask> offset int <mask> limit int <mask> }{{ <mask> name: "page_1", <mask> offset: 0, <mask> limit: 10, <mask> }, { <mask> name: "page_2", <mask> want: secondPageDomain, <mask> wantLen: 10, </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove wantLen int want string </s> add </s> remove wantLen: 10, want: firstPageDomain, </s> add </s> remove wantLen: 10, want: secondPageDomain, </s> add
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/qlog_test.go
<mask> }{{ <mask> name: "page_1", <mask> offset: 0, <mask> limit: 10, <mask> wantLen: 10, <mask> want: firstPageDomain, <mask> }, { <mask> name: "page_2", <mask> offset: 10, <mask> limit: 10, <mask> wantLen: 10, </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove wantLen: 10, want: secondPageDomain, </s> add </s> remove wantLen: 5, want: secondPageDomain, </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/qlog_test.go
want: secondPageDomain, wantLen: 10,
<mask> offset: 0, <mask> limit: 10, <mask> }, { <mask> name: "page_2", <mask> offset: 10, <mask> limit: 10, <mask> }, { <mask> name: "page_2.5", <mask> want: secondPageDomain, <mask> wantLen: 5, </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove wantLen: 10, want: secondPageDomain, </s> add </s> remove wantLen: 5, want: secondPageDomain, </s> add </s> remove wantLen: 10, want: firstPageDomain, </s> add
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/qlog_test.go
<mask> }, { <mask> name: "page_2", <mask> offset: 10, <mask> limit: 10, <mask> wantLen: 10, <mask> want: secondPageDomain, <mask> }, { <mask> name: "page_2.5", <mask> offset: 15, <mask> limit: 10, <mask> wantLen: 5, </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove wantLen: 5, want: secondPageDomain, </s> add </s> remove wantLen: 10, want: firstPageDomain, </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/qlog_test.go
want: secondPageDomain, wantLen: 5,
<mask> }, { <mask> name: "page_2.5", <mask> offset: 15, <mask> limit: 10, <mask> }, { <mask> name: "page_3", <mask> want: "", <mask> wantLen: 0, </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove wantLen: 5, want: secondPageDomain, </s> add </s> remove wantLen: 10, want: secondPageDomain, </s> add </s> remove wantLen: 10, want: firstPageDomain, </s> add
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/qlog_test.go
<mask> }, { <mask> name: "page_2.5", <mask> offset: 15, <mask> limit: 10, <mask> wantLen: 5, <mask> want: secondPageDomain, <mask> }, { <mask> name: "page_3", <mask> offset: 20, <mask> limit: 10, <mask> wantLen: 0, </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove wantLen: 10, want: secondPageDomain, </s> add </s> remove wantLen: 10, want: firstPageDomain, </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/qlog_test.go
want: "", wantLen: 0,
<mask> offset: 15, <mask> limit: 10, <mask> }, { <mask> name: "page_3", <mask> offset: 20, <mask> limit: 10, <mask> }} <mask> <mask> for _, tc := range testCases { <mask> t.Run(tc.name, func(t *testing.T) { </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove wantLen: 0, </s> add </s> remove wantLen: 5, want: secondPageDomain, </s> add </s> remove wantLen: 10, want: secondPageDomain, </s> add
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/qlog_test.go
<mask> }, { <mask> name: "page_3", <mask> offset: 20, <mask> limit: 10, <mask> wantLen: 0, <mask> }} <mask> <mask> for _, tc := range testCases { <mask> t.Run(tc.name, func(t *testing.T) { <mask> params.offset = tc.offset </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove wantLen: 5, want: secondPageDomain, </s> add </s> remove wantLen: 10, want: firstPageDomain, </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/qlog_test.go
RotationIvl: 24 * time.Hour,
<mask> func TestQueryLogMaxFileScanEntries(t *testing.T) { <mask> l := newQueryLog(Config{ <mask> Enabled: true, <mask> FileEnabled: true, <mask> RotationIvl: 1, <mask> MemSize: 100, <mask> BaseDir: t.TempDir(), <mask> }) <mask> <mask> const entNum = 10 </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: config.DNS.QueryLogInterval, </s> add RotationIvl: config.DNS.QueryLogInterval.Duration,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/qlog_test.go
RotationIvl: 24 * time.Hour,
<mask> func TestQueryLogFileDisabled(t *testing.T) { <mask> l := newQueryLog(Config{ <mask> Enabled: true, <mask> FileEnabled: false, <mask> RotationIvl: 1, <mask> MemSize: 2, <mask> BaseDir: t.TempDir(), <mask> }) <mask> <mask> addEntry(l, "example1.org", net.IPv4(1, 1, 1, 1), net.IPv4(2, 2, 2, 1)) </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: config.DNS.QueryLogInterval, </s> add RotationIvl: config.DNS.QueryLogInterval.Duration,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/qlog_test.go
// RotationIvl is the interval for log rotation. After that period, the // old log file will be renamed, NOT deleted, so the actual log // retention time is twice the interval. The value must be one of: // // 6 * time.Hour // 24 * time.Hour // 7 * 24 * time.Hour // 30 * 24 * time.Hour // 90 * 24 * time.Hour // RotationIvl time.Duration
<mask> <mask> // BaseDir is the base directory for log files. <mask> BaseDir string <mask> <mask> // RotationIvl is the interval for log rotation, in days. After that <mask> // period, the old log file will be renamed, NOT deleted, so the actual <mask> // log retention time is twice the interval. <mask> RotationIvl uint32 <mask> <mask> // MemSize is the number of entries kept in a memory buffer before they <mask> // are flushed to disk. <mask> MemSize uint32 <mask> </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days) QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats </s> add QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file // QueryLogInterval is the interval for query log's files rotation. QueryLogInterval Duration `yaml:"querylog_interval"` QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats </s> remove const currentSchemaVersion = 11 </s> add const currentSchemaVersion = 12 </s> remove Enabled bool `json:"enabled"` Interval uint32 `json:"interval"` AnonymizeClientIP bool `json:"anonymize_client_ip"` </s> add Enabled bool `json:"enabled"` // Use float64 here to support fractional numbers and not mess the API // users by changing the units. Interval float64 `json:"interval"` AnonymizeClientIP bool `json:"anonymize_client_ip"` </s> remove return t.Unix() </s> add return t, nil
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/querylog.go
l.conf.RotationIvl = 24 * time.Hour
<mask> log.Info( <mask> "querylog: warning: unsupported rotation interval %d, setting to 1 day", <mask> conf.RotationIvl, <mask> ) <mask> l.conf.RotationIvl = 1 <mask> } <mask> <mask> return l <mask> } </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove const getIntervalFields = (processing, t, toNumber) => QUERY_LOG_INTERVALS_DAYS.map((interval) => { const title = interval === 1 ? t('interval_24_hour') : t('interval_days', { count: interval }); </s> add const getIntervalTitle = (interval, t) => { switch (interval) { case 0.25: return t('interval_6_hour'); case 1: return t('interval_24_hour'); default: return t('interval_days', { count: interval }); } }; </s> remove func checkInterval(days uint32) bool { return days == 1 || days == 7 || days == 30 || days == 90 </s> add func checkInterval(ivl time.Duration) (ok bool) { // The constants for possible values of query log's rotation interval. const ( quarterDay = 6 * time.Hour day = 24 * time.Hour week = day * 7 month = day * 30 threeMonths = day * 90 ) return ivl == quarterDay || ivl == day || ivl == week || ivl == month || ivl == threeMonths </s> remove import { CheckboxField, renderRadioField, toNumber } from '../../../helpers/form'; </s> add import { CheckboxField, renderRadioField, toFloatNumber } from '../../../helpers/form'; </s> remove return ( <Field key={interval} name="interval" type="radio" component={renderRadioField} value={interval} placeholder={title} normalize={toNumber} disabled={processing} /> ); }); </s> add const getIntervalFields = (processing, t, toNumber) => QUERY_LOG_INTERVALS_DAYS.map((interval) => ( <Field key={interval} name="interval" type="radio" component={renderRadioField} value={interval} placeholder={getIntervalTitle(interval, t)} normalize={toNumber} disabled={processing} /> )); </s> remove config.DNS.QueryLogInterval = 90 </s> add config.DNS.QueryLogInterval = Duration{Duration: 90 * 24 * time.Hour}
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/querylog.go
func (l *queryLog) readFileFirstTimeValue() (first time.Time, err error) { var f *os.File f, err = os.Open(l.logFile)
<mask> <mask> return nil <mask> } <mask> <mask> func (l *queryLog) readFileFirstTimeValue() int64 { <mask> f, err := os.Open(l.logFile) <mask> if err != nil { <mask> return -1 <mask> } <mask> defer func() { <mask> derr := f.Close() </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove return -1 </s> add return time.Time{}, err </s> remove defer func() { derr := f.Close() if derr != nil { log.Error("querylog: closing file: %s", derr) } }() </s> add </s> remove buf = buf[:r] </s> add </s> remove buf := make([]byte, 500) r, err := f.Read(buf) </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() buf := make([]byte, 512) var r int r, err = f.Read(buf) </s> remove oldest := l.readFileFirstTimeValue() if uint64(oldest)+intervalSeconds <= uint64(time.Now().Unix()) { _ = l.rotate() </s> add var oldest time.Time oldest, err = l.readFileFirstTimeValue() if err != nil { log.Debug("%s", err) } if oldest.Add(l.conf.RotationIvl).After(time.Now()) { err = l.rotate() if err != nil { log.Debug("%s", err) }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/querylogfile.go
return time.Time{}, err
<mask> <mask> func (l *queryLog) readFileFirstTimeValue() int64 { <mask> f, err := os.Open(l.logFile) <mask> if err != nil { <mask> return -1 <mask> } <mask> defer func() { <mask> derr := f.Close() <mask> if derr != nil { <mask> log.Error("querylog: closing file: %s", derr) </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove defer func() { derr := f.Close() if derr != nil { log.Error("querylog: closing file: %s", derr) } }() </s> add </s> remove func (l *queryLog) readFileFirstTimeValue() int64 { f, err := os.Open(l.logFile) </s> add func (l *queryLog) readFileFirstTimeValue() (first time.Time, err error) { var f *os.File f, err = os.Open(l.logFile) </s> remove buf := make([]byte, 500) r, err := f.Read(buf) </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() buf := make([]byte, 512) var r int r, err = f.Read(buf) </s> remove buf = buf[:r] </s> add </s> remove oldest := l.readFileFirstTimeValue() if uint64(oldest)+intervalSeconds <= uint64(time.Now().Unix()) { _ = l.rotate() </s> add var oldest time.Time oldest, err = l.readFileFirstTimeValue() if err != nil { log.Debug("%s", err) } if oldest.Add(l.conf.RotationIvl).After(time.Now()) { err = l.rotate() if err != nil { log.Debug("%s", err) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/querylogfile.go
<mask> f, err := os.Open(l.logFile) <mask> if err != nil { <mask> return -1 <mask> } <mask> defer func() { <mask> derr := f.Close() <mask> if derr != nil { <mask> log.Error("querylog: closing file: %s", derr) <mask> } <mask> }() <mask> <mask> buf := make([]byte, 500) <mask> r, err := f.Read(buf) <mask> if err != nil { <mask> return -1 </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove return -1 </s> add return time.Time{}, err </s> remove buf := make([]byte, 500) r, err := f.Read(buf) </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() buf := make([]byte, 512) var r int r, err = f.Read(buf) </s> remove func (l *queryLog) readFileFirstTimeValue() int64 { f, err := os.Open(l.logFile) </s> add func (l *queryLog) readFileFirstTimeValue() (first time.Time, err error) { var f *os.File f, err = os.Open(l.logFile) </s> remove buf = buf[:r] </s> add </s> remove return -1 </s> add return time.Time{}, err
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/querylogfile.go
defer func() { err = errors.WithDeferred(err, f.Close()) }() buf := make([]byte, 512) var r int r, err = f.Read(buf)
<mask> log.Error("querylog: closing file: %s", derr) <mask> } <mask> }() <mask> <mask> buf := make([]byte, 500) <mask> r, err := f.Read(buf) <mask> if err != nil { <mask> return -1 <mask> } <mask> buf = buf[:r] <mask> </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove defer func() { derr := f.Close() if derr != nil { log.Error("querylog: closing file: %s", derr) } }() </s> add </s> remove return -1 </s> add return time.Time{}, err </s> remove buf = buf[:r] </s> add </s> remove return -1 </s> add return time.Time{}, err </s> remove val := readJSONValue(string(buf), `"T":"`) </s> add val := readJSONValue(string(buf[:r]), `"T":"`)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/querylogfile.go
return time.Time{}, err
<mask> <mask> buf := make([]byte, 500) <mask> r, err := f.Read(buf) <mask> if err != nil { <mask> return -1 <mask> } <mask> buf = buf[:r] <mask> <mask> val := readJSONValue(string(buf), `"T":"`) <mask> t, err := time.Parse(time.RFC3339Nano, val) </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove buf = buf[:r] </s> add </s> remove val := readJSONValue(string(buf), `"T":"`) </s> add val := readJSONValue(string(buf[:r]), `"T":"`) </s> remove buf := make([]byte, 500) r, err := f.Read(buf) </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() buf := make([]byte, 512) var r int r, err = f.Read(buf) </s> remove defer func() { derr := f.Close() if derr != nil { log.Error("querylog: closing file: %s", derr) } }() </s> add </s> remove return -1 </s> add return time.Time{}, err
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/querylogfile.go
<mask> r, err := f.Read(buf) <mask> if err != nil { <mask> return -1 <mask> } <mask> buf = buf[:r] <mask> <mask> val := readJSONValue(string(buf), `"T":"`) <mask> t, err := time.Parse(time.RFC3339Nano, val) <mask> if err != nil { <mask> return -1 </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove return -1 </s> add return time.Time{}, err </s> remove val := readJSONValue(string(buf), `"T":"`) </s> add val := readJSONValue(string(buf[:r]), `"T":"`) </s> remove return -1 </s> add return time.Time{}, err </s> remove defer func() { derr := f.Close() if derr != nil { log.Error("querylog: closing file: %s", derr) } }() </s> add </s> remove buf := make([]byte, 500) r, err := f.Read(buf) </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() buf := make([]byte, 512) var r int r, err = f.Read(buf)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/querylogfile.go
val := readJSONValue(string(buf[:r]), `"T":"`)
<mask> return -1 <mask> } <mask> buf = buf[:r] <mask> <mask> val := readJSONValue(string(buf), `"T":"`) <mask> t, err := time.Parse(time.RFC3339Nano, val) <mask> if err != nil { <mask> return -1 <mask> } <mask> </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove buf = buf[:r] </s> add </s> remove return -1 </s> add return time.Time{}, err </s> remove return -1 </s> add return time.Time{}, err </s> remove defer func() { derr := f.Close() if derr != nil { log.Error("querylog: closing file: %s", derr) } }() </s> add </s> remove buf := make([]byte, 500) r, err := f.Read(buf) </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() buf := make([]byte, 512) var r int r, err = f.Read(buf)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/querylogfile.go
return time.Time{}, err
<mask> <mask> val := readJSONValue(string(buf), `"T":"`) <mask> t, err := time.Parse(time.RFC3339Nano, val) <mask> if err != nil { <mask> return -1 <mask> } <mask> <mask> log.Debug("querylog: the oldest log entry: %s", val) <mask> return t.Unix() <mask> } </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove val := readJSONValue(string(buf), `"T":"`) </s> add val := readJSONValue(string(buf[:r]), `"T":"`) </s> remove buf = buf[:r] </s> add </s> remove return t.Unix() </s> add return t, nil </s> remove return -1 </s> add return time.Time{}, err </s> remove defer func() { derr := f.Close() if derr != nil { log.Error("querylog: closing file: %s", derr) } }() </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/querylogfile.go
return t, nil
<mask> return -1 <mask> } <mask> <mask> log.Debug("querylog: the oldest log entry: %s", val) <mask> return t.Unix() <mask> } <mask> <mask> func (l *queryLog) periodicRotate() { <mask> intervalSeconds := uint64(l.conf.RotationIvl) * 24 * 60 * 60 <mask> for { </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove intervalSeconds := uint64(l.conf.RotationIvl) * 24 * 60 * 60 </s> add defer log.OnPanic("querylog: rotating") var err error </s> remove return -1 </s> add return time.Time{}, err </s> remove oldest := l.readFileFirstTimeValue() if uint64(oldest)+intervalSeconds <= uint64(time.Now().Unix()) { _ = l.rotate() </s> add var oldest time.Time oldest, err = l.readFileFirstTimeValue() if err != nil { log.Debug("%s", err) } if oldest.Add(l.conf.RotationIvl).After(time.Now()) { err = l.rotate() if err != nil { log.Debug("%s", err) } </s> remove return -1 </s> add return time.Time{}, err </s> remove func checkInterval(days uint32) bool { return days == 1 || days == 7 || days == 30 || days == 90 </s> add func checkInterval(ivl time.Duration) (ok bool) { // The constants for possible values of query log's rotation interval. const ( quarterDay = 6 * time.Hour day = 24 * time.Hour week = day * 7 month = day * 30 threeMonths = day * 90 ) return ivl == quarterDay || ivl == day || ivl == week || ivl == month || ivl == threeMonths
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/querylogfile.go
defer log.OnPanic("querylog: rotating") var err error
<mask> return t.Unix() <mask> } <mask> <mask> func (l *queryLog) periodicRotate() { <mask> intervalSeconds := uint64(l.conf.RotationIvl) * 24 * 60 * 60 <mask> for { <mask> oldest := l.readFileFirstTimeValue() <mask> if uint64(oldest)+intervalSeconds <= uint64(time.Now().Unix()) { <mask> _ = l.rotate() <mask> } </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove oldest := l.readFileFirstTimeValue() if uint64(oldest)+intervalSeconds <= uint64(time.Now().Unix()) { _ = l.rotate() </s> add var oldest time.Time oldest, err = l.readFileFirstTimeValue() if err != nil { log.Debug("%s", err) } if oldest.Add(l.conf.RotationIvl).After(time.Now()) { err = l.rotate() if err != nil { log.Debug("%s", err) } </s> remove return t.Unix() </s> add return t, nil </s> remove func checkInterval(days uint32) bool { return days == 1 || days == 7 || days == 30 || days == 90 </s> add func checkInterval(ivl time.Duration) (ok bool) { // The constants for possible values of query log's rotation interval. const ( quarterDay = 6 * time.Hour day = 24 * time.Hour week = day * 7 month = day * 30 threeMonths = day * 90 ) return ivl == quarterDay || ivl == day || ivl == week || ivl == month || ivl == threeMonths </s> remove func (l *queryLog) readFileFirstTimeValue() int64 { f, err := os.Open(l.logFile) </s> add func (l *queryLog) readFileFirstTimeValue() (first time.Time, err error) { var f *os.File f, err = os.Open(l.logFile) </s> remove return -1 </s> add return time.Time{}, err
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/querylogfile.go
var oldest time.Time oldest, err = l.readFileFirstTimeValue() if err != nil { log.Debug("%s", err) } if oldest.Add(l.conf.RotationIvl).After(time.Now()) { err = l.rotate() if err != nil { log.Debug("%s", err) }
<mask> <mask> func (l *queryLog) periodicRotate() { <mask> intervalSeconds := uint64(l.conf.RotationIvl) * 24 * 60 * 60 <mask> for { <mask> oldest := l.readFileFirstTimeValue() <mask> if uint64(oldest)+intervalSeconds <= uint64(time.Now().Unix()) { <mask> _ = l.rotate() <mask> } <mask> <mask> time.Sleep(24 * time.Hour) <mask> } <mask> } </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove intervalSeconds := uint64(l.conf.RotationIvl) * 24 * 60 * 60 </s> add defer log.OnPanic("querylog: rotating") var err error </s> remove return t.Unix() </s> add return t, nil </s> remove func checkInterval(days uint32) bool { return days == 1 || days == 7 || days == 30 || days == 90 </s> add func checkInterval(ivl time.Duration) (ok bool) { // The constants for possible values of query log's rotation interval. const ( quarterDay = 6 * time.Hour day = 24 * time.Hour week = day * 7 month = day * 30 threeMonths = day * 90 ) return ivl == quarterDay || ivl == day || ivl == week || ivl == month || ivl == threeMonths </s> remove func (l *queryLog) readFileFirstTimeValue() int64 { f, err := os.Open(l.logFile) </s> add func (l *queryLog) readFileFirstTimeValue() (first time.Time, err error) { var f *os.File f, err = os.Open(l.logFile)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/querylogfile.go
// What?
<mask> log.Debug("%s", err) <mask> } <mask> } <mask> <mask> time.Sleep(24 * time.Hour) <mask> } <mask> } </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove oldest := l.readFileFirstTimeValue() if uint64(oldest)+intervalSeconds <= uint64(time.Now().Unix()) { _ = l.rotate() </s> add var oldest time.Time oldest, err = l.readFileFirstTimeValue() if err != nil { log.Debug("%s", err) } if oldest.Add(l.conf.RotationIvl).After(time.Now()) { err = l.rotate() if err != nil { log.Debug("%s", err) } </s> remove if req.Exists("interval") && !checkInterval(d.Interval) { </s> add ivl := time.Duration(24*d.Interval) * time.Hour if req.Exists("interval") && !checkInterval(ivl) { </s> remove return t.Unix() </s> add return t, nil </s> remove intervalSeconds := uint64(l.conf.RotationIvl) * 24 * 60 * 60 </s> add defer log.OnPanic("querylog: rotating") var err error </s> remove l.conf.RotationIvl = 1 </s> add l.conf.RotationIvl = 24 * time.Hour
[ "keep", "keep", "keep", "add", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/querylogfile.go
RotationIvl: 24 * time.Hour,
<mask> <mask> l := newQueryLog(Config{ <mask> FindClient: findClient, <mask> BaseDir: t.TempDir(), <mask> RotationIvl: 1, <mask> MemSize: 100, <mask> Enabled: true, <mask> FileEnabled: true, <mask> AnonymizeClientIP: false, <mask> }) </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: 1, </s> add RotationIvl: 24 * time.Hour, </s> remove RotationIvl: config.DNS.QueryLogInterval, </s> add RotationIvl: config.DNS.QueryLogInterval.Duration,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
internal/querylog/search_test.go
'description': > Time period for query log rotation. 'type': 'number' 'enum': - 0.25 - 1 - 7 - 30 - 90
<mask> 'enabled': <mask> 'type': 'boolean' <mask> 'description': 'Is query log enabled' <mask> 'interval': <mask> 'type': 'integer' <mask> 'description': 'Time period to keep data (1 | 7 | 30 | 90)' <mask> 'anonymize_client_ip': <mask> 'type': 'boolean' <mask> 'description': "Anonymize clients' IP addresses" <mask> 'ResultRule': <mask> 'description': 'Applied rule.' </s> Pull request: 2504 querylog interval Merge in DNS/adguard-home from 2504-querylog-ivl to master Updates #2504. Squashed commit of the following: commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21 Merge: 8cd5c30d 97073d0d Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:45:10 2021 +0300 Merge branch 'master' into 2504-querylog-ivl commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 18:35:50 2021 +0300 client: fix fmt commit e95d462c31d886bacec0735acc567fec7c962149 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:58:06 2021 +0300 home: imp code commit 48737b249c52a997a4f34dac45fbaf699477b007 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 17:23:18 2021 +0300 home: imp duration commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:55:31 2021 +0300 home: imp code, docs commit bb2826521b7e5d248ce2ab686528219c312b8ba2 Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 16:11:40 2021 +0300 all: imp code, docs commit d688aed1f340807a8bac8807c263956b0fc16f5b Author: Eugene Burkov <e.burkov@adguard.com> Date: Thu Jul 1 13:49:42 2021 +0300 all: change querylog interval setting format </s> remove QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days) QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats </s> add QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file // QueryLogInterval is the interval for query log's files rotation. QueryLogInterval Duration `yaml:"querylog_interval"` QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats </s> remove // RotationIvl is the interval for log rotation, in days. After that // period, the old log file will be renamed, NOT deleted, so the actual // log retention time is twice the interval. RotationIvl uint32 </s> add // RotationIvl is the interval for log rotation. After that period, the // old log file will be renamed, NOT deleted, so the actual log // retention time is twice the interval. The value must be one of: // // 6 * time.Hour // 24 * time.Hour // 7 * 24 * time.Hour // 30 * 24 * time.Hour // 90 * 24 * time.Hour // RotationIvl time.Duration </s> remove func checkInterval(days uint32) bool { return days == 1 || days == 7 || days == 30 || days == 90 </s> add func checkInterval(ivl time.Duration) (ok bool) { // The constants for possible values of query log's rotation interval. const ( quarterDay = 6 * time.Hour day = 24 * time.Hour week = day * 7 month = day * 30 threeMonths = day * 90 ) return ivl == quarterDay || ivl == day || ivl == week || ivl == month || ivl == threeMonths </s> remove return -1 </s> add return time.Time{}, err </s> remove l.conf.RotationIvl = 1 </s> add l.conf.RotationIvl = 24 * time.Hour
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e113b276e7db134f99f9f920c4c410467a698c92
openapi/openapi.yaml
<mask> package aghnet <mask> <mask> import ( <mask> "bufio" <mask> "io" <mask> "net" <mask> "os" <mask> "path/filepath" <mask> "runtime" <mask> "strings" </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove "github.com/AdguardTeam/golibs/errors" </s> add </s> remove const ( // errBadAddrPassed is returned when dialFunc can't parse an IP address. errBadAddrPassed errors.Error = "the passed string is not a valid IP address" // errFakeDial is an error which dialFunc is expected to return. errFakeDial errors.Error = "this error signals the successful dialFunc work" // errUnexpectedHostFormat is returned by validateDialedHost when the host has // more than one percent sign. errUnexpectedHostFormat errors.Error = "unexpected host format" ) </s> add </s> remove for s.Scan() { line := s.Text() if len(line) == 0 { continue } fields := strings.Fields(line) if len(fields) != 2 || fields[0] != "Address:" { continue } // If the address contains port then it is separated with '#'. ipStrs := strings.Split(fields[1], "#") if len(ipStrs) == 0 { continue } possibleIPs = append(possibleIPs, ipStrs[0]) } </s> add addrs = scanAddrs(s) </s> remove go func() { defer log.OnPanic("systemResolvers") defer func() { derr := stdin.Close() if derr != nil { log.Error("systemResolvers: closing stdin pipe: %s", derr) } }() _, werr := io.WriteString(stdin, "exit") if werr != nil { log.Error("systemResolvers: writing to command pipe: %s", werr) } }() </s> add go writeExit(stdin)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/etchostscontainer.go
// parseHostsLine parses hosts from the fields. func parseHostsLine(fields []string) (hosts []string) { for _, f := range fields { hashIdx := strings.IndexByte(f, '#') if hashIdx == 0 { // The rest of the fields are a part of the comment. // Skip immediately. return } else if hashIdx > 0 { // Only a part of the field is a comment. hosts = append(hosts, f[:hashIdx]) return hosts } hosts = append(hosts, f) } return hosts } // load reads IP-hostname pairs from the hosts file. Multiple hostnames per // line for one IP are supported. func (ehc *EtcHostsContainer) load( table map[string][]net.IP, tableRev map[string][]string, fn string, ) {
<mask> tableRev[ipStr] = append(tableRev[ipStr], newHost) <mask> log.Debug("etchostscontainer: added reverse-address %s -> %s", ipStr, newHost) <mask> } <mask> <mask> // Read IP-hostname pairs from file <mask> // Multiple hostnames per line (per one IP) is supported. <mask> func (ehc *EtcHostsContainer) load(table map[string][]net.IP, tableRev map[string][]string, fn string) { <mask> f, err := os.Open(fn) <mask> if err != nil { <mask> log.Error("etchostscontainer: %s", err) <mask> return <mask> } </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove for done := false; !done; { var line string line, err = r.ReadString('\n') if err == io.EOF { done = true } else if err != nil { log.Error("etchostscontainer: %s", err) return } line = strings.TrimSpace(line) if len(line) == 0 || line[0] == '#' { continue } </s> add s := bufio.NewScanner(f) for s.Scan() { line := strings.TrimSpace(s.Text()) </s> remove r := bufio.NewReader(f) </s> add </s> remove go func() { defer log.OnPanic("systemResolvers") defer func() { derr := stdin.Close() if derr != nil { log.Error("systemResolvers: closing stdin pipe: %s", derr) } }() _, werr := io.WriteString(stdin, "exit") if werr != nil { log.Error("systemResolvers: writing to command pipe: %s", werr) } }() </s> add go writeExit(stdin) </s> remove for s.Scan() { line := s.Text() if len(line) == 0 { continue } fields := strings.Fields(line) if len(fields) != 2 || fields[0] != "Address:" { continue } // If the address contains port then it is separated with '#'. ipStrs := strings.Split(fields[1], "#") if len(ipStrs) == 0 { continue } possibleIPs = append(possibleIPs, ipStrs[0]) } </s> add addrs = scanAddrs(s)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/etchostscontainer.go
<mask> log.Error("etchostscontainer: closing file: %s", err) <mask> } <mask> }() <mask> <mask> r := bufio.NewReader(f) <mask> log.Debug("etchostscontainer: loading hosts from file %s", fn) <mask> <mask> for done := false; !done; { <mask> var line string <mask> line, err = r.ReadString('\n') </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove for done := false; !done; { var line string line, err = r.ReadString('\n') if err == io.EOF { done = true } else if err != nil { log.Error("etchostscontainer: %s", err) return } line = strings.TrimSpace(line) if len(line) == 0 || line[0] == '#' { continue } </s> add s := bufio.NewScanner(f) for s.Scan() { line := strings.TrimSpace(s.Text()) </s> remove // Read IP-hostname pairs from file // Multiple hostnames per line (per one IP) is supported. func (ehc *EtcHostsContainer) load(table map[string][]net.IP, tableRev map[string][]string, fn string) { </s> add // parseHostsLine parses hosts from the fields. func parseHostsLine(fields []string) (hosts []string) { for _, f := range fields { hashIdx := strings.IndexByte(f, '#') if hashIdx == 0 { // The rest of the fields are a part of the comment. // Skip immediately. return } else if hashIdx > 0 { // Only a part of the field is a comment. hosts = append(hosts, f[:hashIdx]) return hosts } hosts = append(hosts, f) } return hosts } // load reads IP-hostname pairs from the hosts file. Multiple hostnames per // line for one IP are supported. func (ehc *EtcHostsContainer) load( table map[string][]net.IP, tableRev map[string][]string, fn string, ) { </s> remove go func() { defer log.OnPanic("systemResolvers") defer func() { derr := stdin.Close() if derr != nil { log.Error("systemResolvers: closing stdin pipe: %s", derr) } }() _, werr := io.WriteString(stdin, "exit") if werr != nil { log.Error("systemResolvers: writing to command pipe: %s", werr) } }() </s> add go writeExit(stdin) </s> remove for s.Scan() { line := s.Text() if len(line) == 0 { continue } fields := strings.Fields(line) if len(fields) != 2 || fields[0] != "Address:" { continue } // If the address contains port then it is separated with '#'. ipStrs := strings.Split(fields[1], "#") if len(ipStrs) == 0 { continue } possibleIPs = append(possibleIPs, ipStrs[0]) } </s> add addrs = scanAddrs(s)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/etchostscontainer.go
s := bufio.NewScanner(f) for s.Scan() { line := strings.TrimSpace(s.Text())
<mask> <mask> r := bufio.NewReader(f) <mask> log.Debug("etchostscontainer: loading hosts from file %s", fn) <mask> <mask> for done := false; !done; { <mask> var line string <mask> line, err = r.ReadString('\n') <mask> if err == io.EOF { <mask> done = true <mask> } else if err != nil { <mask> log.Error("etchostscontainer: %s", err) <mask> <mask> return <mask> } <mask> <mask> line = strings.TrimSpace(line) <mask> if len(line) == 0 || line[0] == '#' { <mask> continue <mask> } <mask> <mask> fields := strings.Fields(line) <mask> if len(fields) < 2 { <mask> continue <mask> } <mask> </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove r := bufio.NewReader(f) </s> add </s> remove if withinInterfaceCtx && len(line) == 0 { // An empty line resets our state. withinInterfaceCtx = false } if len(line) == 0 || line[0] == '#' { continue } </s> add </s> remove for s.Scan() { line := s.Text() if len(line) == 0 { continue } fields := strings.Fields(line) if len(fields) != 2 || fields[0] != "Address:" { continue } // If the address contains port then it is separated with '#'. ipStrs := strings.Split(fields[1], "#") if len(ipStrs) == 0 { continue } possibleIPs = append(possibleIPs, ipStrs[0]) } </s> add addrs = scanAddrs(s) </s> remove // Read IP-hostname pairs from file // Multiple hostnames per line (per one IP) is supported. func (ehc *EtcHostsContainer) load(table map[string][]net.IP, tableRev map[string][]string, fn string) { </s> add // parseHostsLine parses hosts from the fields. func parseHostsLine(fields []string) (hosts []string) { for _, f := range fields { hashIdx := strings.IndexByte(f, '#') if hashIdx == 0 { // The rest of the fields are a part of the comment. // Skip immediately. return } else if hashIdx > 0 { // Only a part of the field is a comment. hosts = append(hosts, f[:hashIdx]) return hosts } hosts = append(hosts, f) } return hosts } // load reads IP-hostname pairs from the hosts file. Multiple hostnames per // line for one IP are supported. func (ehc *EtcHostsContainer) load( table map[string][]net.IP, tableRev map[string][]string, fn string, ) { </s> remove if withinInterfaceCtx { if len(fields) >= 2 && fields[0] == "static" && strings.HasPrefix(fields[1], "ip_address=") { return true, nil } if len(fields) > 0 && fields[0] == "interface" { // Another interface found. withinInterfaceCtx = false } continue </s> add if len(fields) >= 2 && fields[0] == "static" && strings.HasPrefix(fields[1], "ip_address=") { return true, s.Err()
[ "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/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/etchostscontainer.go
hosts := parseHostsLine(fields[1:]) for _, host := range hosts {
<mask> if ip == nil { <mask> continue <mask> } <mask> <mask> for i := 1; i != len(fields); i++ { <mask> host := fields[i] <mask> if len(host) == 0 { <mask> break <mask> } <mask> <mask> sharp := strings.IndexByte(host, '#') <mask> if sharp == 0 { <mask> // Skip the comments. <mask> break <mask> } else if sharp > 0 { <mask> host = host[:sharp] <mask> } <mask> <mask> ehc.updateTable(table, host, ip) <mask> ehc.updateTableRev(tableRev, host, ip) <mask> if sharp >= 0 { <mask> // Skip the comments again. <mask> break </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove if sharp >= 0 { // Skip the comments again. break } </s> add </s> remove for s.Scan() { line := s.Text() if len(line) == 0 { continue } fields := strings.Fields(line) if len(fields) != 2 || fields[0] != "Address:" { continue } // If the address contains port then it is separated with '#'. ipStrs := strings.Split(fields[1], "#") if len(ipStrs) == 0 { continue } possibleIPs = append(possibleIPs, ipStrs[0]) } </s> add addrs = scanAddrs(s) </s> remove if len(fields) == 2 && fields[0] == "interface" && fields[1] == ifaceName { // The interface found. withinInterfaceCtx = true </s> add if len(fields) > 0 && fields[0] == "interface" { // Another interface found. break </s> remove // Read IP-hostname pairs from file // Multiple hostnames per line (per one IP) is supported. func (ehc *EtcHostsContainer) load(table map[string][]net.IP, tableRev map[string][]string, fn string) { </s> add // parseHostsLine parses hosts from the fields. func parseHostsLine(fields []string) (hosts []string) { for _, f := range fields { hashIdx := strings.IndexByte(f, '#') if hashIdx == 0 { // The rest of the fields are a part of the comment. // Skip immediately. return } else if hashIdx > 0 { // Only a part of the field is a comment. hosts = append(hosts, f[:hashIdx]) return hosts } hosts = append(hosts, f) } return hosts } // load reads IP-hostname pairs from the hosts file. Multiple hostnames per // line for one IP are supported. func (ehc *EtcHostsContainer) load( table map[string][]net.IP, tableRev map[string][]string, fn string, ) { </s> remove for done := false; !done; { var line string line, err = r.ReadString('\n') if err == io.EOF { done = true } else if err != nil { log.Error("etchostscontainer: %s", err) return } line = strings.TrimSpace(line) if len(line) == 0 || line[0] == '#' { continue } </s> add s := bufio.NewScanner(f) for s.Scan() { line := strings.TrimSpace(s.Text())
[ "keep", "keep", "keep", "keep", "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/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/etchostscontainer.go
<mask> } <mask> <mask> ehc.updateTable(table, host, ip) <mask> ehc.updateTableRev(tableRev, host, ip) <mask> if sharp >= 0 { <mask> // Skip the comments again. <mask> break <mask> } <mask> } <mask> } <mask> } <mask> <mask> // onlyWrites is a filter for (*fsnotify.Watcher).Events. </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove for i := 1; i != len(fields); i++ { host := fields[i] if len(host) == 0 { break } sharp := strings.IndexByte(host, '#') if sharp == 0 { // Skip the comments. break } else if sharp > 0 { host = host[:sharp] } </s> add hosts := parseHostsLine(fields[1:]) for _, host := range hosts { </s> remove // Read IP-hostname pairs from file // Multiple hostnames per line (per one IP) is supported. func (ehc *EtcHostsContainer) load(table map[string][]net.IP, tableRev map[string][]string, fn string) { </s> add // parseHostsLine parses hosts from the fields. func parseHostsLine(fields []string) (hosts []string) { for _, f := range fields { hashIdx := strings.IndexByte(f, '#') if hashIdx == 0 { // The rest of the fields are a part of the comment. // Skip immediately. return } else if hashIdx > 0 { // Only a part of the field is a comment. hosts = append(hosts, f[:hashIdx]) return hosts } hosts = append(hosts, f) } return hosts } // load reads IP-hostname pairs from the hosts file. Multiple hostnames per // line for one IP are supported. func (ehc *EtcHostsContainer) load( table map[string][]net.IP, tableRev map[string][]string, fn string, ) { </s> remove if len(fields) == 2 && fields[0] == "interface" && fields[1] == ifaceName { // The interface found. withinInterfaceCtx = true </s> add if len(fields) > 0 && fields[0] == "interface" { // Another interface found. break </s> remove for s.Scan() { line := s.Text() if len(line) == 0 { continue } fields := strings.Fields(line) if len(fields) != 2 || fields[0] != "Address:" { continue } // If the address contains port then it is separated with '#'. ipStrs := strings.Split(fields[1], "#") if len(ipStrs) == 0 { continue } possibleIPs = append(possibleIPs, ipStrs[0]) } </s> add addrs = scanAddrs(s)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/etchostscontainer.go
err = s.Err() if err != nil { log.Error("etchostscontainer: %s", err) }
<mask> } <mask> } <mask> } <mask> <mask> // onlyWrites is a filter for (*fsnotify.Watcher).Events. <mask> func (ehc *EtcHostsContainer) onlyWrites() { <mask> for event := range ehc.watcher.Events { </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove if sharp >= 0 { // Skip the comments again. break } </s> add </s> remove // Read IP-hostname pairs from file // Multiple hostnames per line (per one IP) is supported. func (ehc *EtcHostsContainer) load(table map[string][]net.IP, tableRev map[string][]string, fn string) { </s> add // parseHostsLine parses hosts from the fields. func parseHostsLine(fields []string) (hosts []string) { for _, f := range fields { hashIdx := strings.IndexByte(f, '#') if hashIdx == 0 { // The rest of the fields are a part of the comment. // Skip immediately. return } else if hashIdx > 0 { // Only a part of the field is a comment. hosts = append(hosts, f[:hashIdx]) return hosts } hosts = append(hosts, f) } return hosts } // load reads IP-hostname pairs from the hosts file. Multiple hostnames per // line for one IP are supported. func (ehc *EtcHostsContainer) load( table map[string][]net.IP, tableRev map[string][]string, fn string, ) { </s> remove for _, ip := range ips { resp.Answer = append(resp.Answer, &dns.A{ Hdr: dns.RR_Header{ Name: name, Rrtype: rrType, }, A: ip, }) </s> add for _, n := range names { ans := &dns.PTR{ Hdr: hdr, Ptr: n, } resp.Answer = append(resp.Answer, ans) </s> remove for _, n := range names { resp.Answer = append(resp.Answer, &dns.PTR{ Hdr: dns.RR_Header{ Name: n, Rrtype: rrType, }, Ptr: n, }) </s> add ans = &dns.AAAA{ Hdr: hdr, AAAA: ip, </s> remove for i := 1; i != len(fields); i++ { host := fields[i] if len(host) == 0 { break } sharp := strings.IndexByte(host, '#') if sharp == 0 { // Skip the comments. break } else if sharp > 0 { host = host[:sharp] } </s> add hosts := parseHostsLine(fields[1:]) for _, host := range hosts {
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/etchostscontainer.go
// findIfaceLine scans s until it finds the line that declares an interface with // the given name. If findIfaceLine can't find the line, it returns false. func findIfaceLine(s *bufio.Scanner, name string) (ok bool) { for s.Scan() { line := strings.TrimSpace(s.Text()) fields := strings.Fields(line) if len(fields) == 2 && fields[0] == "interface" && fields[1] == name { return true } } return false }
<mask> return false, ErrNoStaticIPInfo <mask> } <mask> <mask> // dhcpcdStaticConfig checks if interface is configured by /etc/dhcpcd.conf to <mask> // have a static IP. <mask> func dhcpcdStaticConfig(r io.Reader, ifaceName string) (has bool, err error) { <mask> s := bufio.NewScanner(r) <mask> ifaceFound := findIfaceLine(s, ifaceName) </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove var withinInterfaceCtx bool </s> add ifaceFound := findIfaceLine(s, ifaceName) if !ifaceFound { return false, s.Err() } </s> remove if len(fields) == 2 && fields[0] == "interface" && fields[1] == ifaceName { // The interface found. withinInterfaceCtx = true </s> add if len(fields) > 0 && fields[0] == "interface" { // Another interface found. break </s> remove // Read IP-hostname pairs from file // Multiple hostnames per line (per one IP) is supported. func (ehc *EtcHostsContainer) load(table map[string][]net.IP, tableRev map[string][]string, fn string) { </s> add // parseHostsLine parses hosts from the fields. func parseHostsLine(fields []string) (hosts []string) { for _, f := range fields { hashIdx := strings.IndexByte(f, '#') if hashIdx == 0 { // The rest of the fields are a part of the comment. // Skip immediately. return } else if hashIdx > 0 { // Only a part of the field is a comment. hosts = append(hosts, f[:hashIdx]) return hosts } hosts = append(hosts, f) } return hosts } // load reads IP-hostname pairs from the hosts file. Multiple hostnames per // line for one IP are supported. func (ehc *EtcHostsContainer) load( table map[string][]net.IP, tableRev map[string][]string, fn string, ) {
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/net_linux.go
ifaceFound := findIfaceLine(s, ifaceName) if !ifaceFound { return false, s.Err() }
<mask> // dhcpcdStaticConfig checks if interface is configured by /etc/dhcpcd.conf to <mask> // have a static IP. <mask> func dhcpcdStaticConfig(r io.Reader, ifaceName string) (has bool, err error) { <mask> s := bufio.NewScanner(r) <mask> var withinInterfaceCtx bool <mask> <mask> for s.Scan() { <mask> line := strings.TrimSpace(s.Text()) <mask> <mask> if withinInterfaceCtx && len(line) == 0 { </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove if withinInterfaceCtx && len(line) == 0 { // An empty line resets our state. withinInterfaceCtx = false } if len(line) == 0 || line[0] == '#' { continue } </s> add </s> remove if withinInterfaceCtx { if len(fields) >= 2 && fields[0] == "static" && strings.HasPrefix(fields[1], "ip_address=") { return true, nil } if len(fields) > 0 && fields[0] == "interface" { // Another interface found. withinInterfaceCtx = false } continue </s> add if len(fields) >= 2 && fields[0] == "static" && strings.HasPrefix(fields[1], "ip_address=") { return true, s.Err() </s> remove if len(fields) == 2 && fields[0] == "interface" && fields[1] == ifaceName { // The interface found. withinInterfaceCtx = true </s> add if len(fields) > 0 && fields[0] == "interface" { // Another interface found. break </s> remove // The output of nslookup looks like this: // // Default Server: 192-168-1-1.qualified.domain.ru // Address: 192.168.1.1 var possibleIPs []string </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/net_linux.go
<mask> var withinInterfaceCtx bool <mask> <mask> for s.Scan() { <mask> line := strings.TrimSpace(s.Text()) <mask> <mask> if withinInterfaceCtx && len(line) == 0 { <mask> // An empty line resets our state. <mask> withinInterfaceCtx = false <mask> } <mask> <mask> if len(line) == 0 || line[0] == '#' { <mask> continue <mask> } <mask> <mask> fields := strings.Fields(line) <mask> <mask> if withinInterfaceCtx { <mask> if len(fields) >= 2 && fields[0] == "static" && strings.HasPrefix(fields[1], "ip_address=") { <mask> return true, nil </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove if withinInterfaceCtx { if len(fields) >= 2 && fields[0] == "static" && strings.HasPrefix(fields[1], "ip_address=") { return true, nil } if len(fields) > 0 && fields[0] == "interface" { // Another interface found. withinInterfaceCtx = false } continue </s> add if len(fields) >= 2 && fields[0] == "static" && strings.HasPrefix(fields[1], "ip_address=") { return true, s.Err() </s> remove var withinInterfaceCtx bool </s> add ifaceFound := findIfaceLine(s, ifaceName) if !ifaceFound { return false, s.Err() } </s> remove for done := false; !done; { var line string line, err = r.ReadString('\n') if err == io.EOF { done = true } else if err != nil { log.Error("etchostscontainer: %s", err) return } line = strings.TrimSpace(line) if len(line) == 0 || line[0] == '#' { continue } </s> add s := bufio.NewScanner(f) for s.Scan() { line := strings.TrimSpace(s.Text()) </s> remove if len(fields) == 2 && fields[0] == "interface" && fields[1] == ifaceName { // The interface found. withinInterfaceCtx = true </s> add if len(fields) > 0 && fields[0] == "interface" { // Another interface found. break </s> remove for s.Scan() { line := s.Text() if len(line) == 0 { continue } fields := strings.Fields(line) if len(fields) != 2 || fields[0] != "Address:" { continue } // If the address contains port then it is separated with '#'. ipStrs := strings.Split(fields[1], "#") if len(ipStrs) == 0 { continue } possibleIPs = append(possibleIPs, ipStrs[0]) } </s> add addrs = scanAddrs(s)
[ "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/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/net_linux.go
if len(fields) >= 2 && fields[0] == "static" && strings.HasPrefix(fields[1], "ip_address=") { return true, s.Err()
<mask> continue <mask> } <mask> <mask> fields := strings.Fields(line) <mask> <mask> if withinInterfaceCtx { <mask> if len(fields) >= 2 && fields[0] == "static" && strings.HasPrefix(fields[1], "ip_address=") { <mask> return true, nil <mask> } <mask> if len(fields) > 0 && fields[0] == "interface" { <mask> // Another interface found. <mask> withinInterfaceCtx = false <mask> } <mask> continue <mask> } <mask> <mask> if len(fields) == 2 && fields[0] == "interface" && fields[1] == ifaceName { <mask> // The interface found. <mask> withinInterfaceCtx = true </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove if len(fields) == 2 && fields[0] == "interface" && fields[1] == ifaceName { // The interface found. withinInterfaceCtx = true </s> add if len(fields) > 0 && fields[0] == "interface" { // Another interface found. break </s> remove if withinInterfaceCtx && len(line) == 0 { // An empty line resets our state. withinInterfaceCtx = false } if len(line) == 0 || line[0] == '#' { continue } </s> add </s> remove var withinInterfaceCtx bool </s> add ifaceFound := findIfaceLine(s, ifaceName) if !ifaceFound { return false, s.Err() } </s> remove for s.Scan() { line := s.Text() if len(line) == 0 { continue } fields := strings.Fields(line) if len(fields) != 2 || fields[0] != "Address:" { continue } // If the address contains port then it is separated with '#'. ipStrs := strings.Split(fields[1], "#") if len(ipStrs) == 0 { continue } possibleIPs = append(possibleIPs, ipStrs[0]) } </s> add addrs = scanAddrs(s)
[ "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/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/net_linux.go
if len(fields) > 0 && fields[0] == "interface" { // Another interface found. break
<mask> } <mask> continue <mask> } <mask> <mask> if len(fields) == 2 && fields[0] == "interface" && fields[1] == ifaceName { <mask> // The interface found. <mask> withinInterfaceCtx = true <mask> } <mask> } <mask> <mask> return false, s.Err() <mask> } </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove if withinInterfaceCtx { if len(fields) >= 2 && fields[0] == "static" && strings.HasPrefix(fields[1], "ip_address=") { return true, nil } if len(fields) > 0 && fields[0] == "interface" { // Another interface found. withinInterfaceCtx = false } continue </s> add if len(fields) >= 2 && fields[0] == "static" && strings.HasPrefix(fields[1], "ip_address=") { return true, s.Err() </s> remove if withinInterfaceCtx && len(line) == 0 { // An empty line resets our state. withinInterfaceCtx = false } if len(line) == 0 || line[0] == '#' { continue } </s> add </s> remove var withinInterfaceCtx bool </s> add ifaceFound := findIfaceLine(s, ifaceName) if !ifaceFound { return false, s.Err() } </s> remove for s.Scan() { line := s.Text() if len(line) == 0 { continue } fields := strings.Fields(line) if len(fields) != 2 || fields[0] != "Address:" { continue } // If the address contains port then it is separated with '#'. ipStrs := strings.Split(fields[1], "#") if len(ipStrs) == 0 { continue } possibleIPs = append(possibleIPs, ipStrs[0]) } </s> add addrs = scanAddrs(s)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/net_linux.go
<mask> <mask> import ( <mask> "time" <mask> <mask> "github.com/AdguardTeam/golibs/errors" <mask> "github.com/AdguardTeam/golibs/log" <mask> ) <mask> <mask> // DefaultRefreshIvl is the default period of time between refreshing cached <mask> // addresses. </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove // Addr is the address for Address method. Addr string </s> add </s> remove const ( // errBadAddrPassed is returned when dialFunc can't parse an IP address. errBadAddrPassed errors.Error = "the passed string is not a valid IP address" // errFakeDial is an error which dialFunc is expected to return. errFakeDial errors.Error = "this error signals the successful dialFunc work" // errUnexpectedHostFormat is returned by validateDialedHost when the host has // more than one percent sign. errUnexpectedHostFormat errors.Error = "unexpected host format" ) </s> add </s> remove "io" </s> add </s> remove // Read IP-hostname pairs from file // Multiple hostnames per line (per one IP) is supported. func (ehc *EtcHostsContainer) load(table map[string][]net.IP, tableRev map[string][]string, fn string) { </s> add // parseHostsLine parses hosts from the fields. func parseHostsLine(fields []string) (hosts []string) { for _, f := range fields { hashIdx := strings.IndexByte(f, '#') if hashIdx == 0 { // The rest of the fields are a part of the comment. // Skip immediately. return } else if hashIdx > 0 { // Only a part of the field is a comment. hosts = append(hosts, f[:hashIdx]) return hosts } hosts = append(hosts, f) } return hosts } // load reads IP-hostname pairs from the hosts file. Multiple hostnames per // line for one IP are supported. func (ehc *EtcHostsContainer) load( table map[string][]net.IP, tableRev map[string][]string, fn string, ) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/systemresolvers.go
<mask> // safe for concurrent use. <mask> refresh() (err error) <mask> } <mask> <mask> const ( <mask> // errBadAddrPassed is returned when dialFunc can't parse an IP address. <mask> errBadAddrPassed errors.Error = "the passed string is not a valid IP address" <mask> <mask> // errFakeDial is an error which dialFunc is expected to return. <mask> errFakeDial errors.Error = "this error signals the successful dialFunc work" <mask> <mask> // errUnexpectedHostFormat is returned by validateDialedHost when the host has <mask> // more than one percent sign. <mask> errUnexpectedHostFormat errors.Error = "unexpected host format" <mask> ) <mask> <mask> // refreshWithTicker refreshes the cache of sr after each tick form tickCh. <mask> func refreshWithTicker(sr SystemResolvers, tickCh <-chan time.Time) { <mask> defer log.OnPanic("systemResolvers") <mask> <mask> // TODO(e.burkov): Implement a functionality to stop ticker. </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove // Addr is the address for Address method. Addr string </s> add </s> remove // Read IP-hostname pairs from file // Multiple hostnames per line (per one IP) is supported. func (ehc *EtcHostsContainer) load(table map[string][]net.IP, tableRev map[string][]string, fn string) { </s> add // parseHostsLine parses hosts from the fields. func parseHostsLine(fields []string) (hosts []string) { for _, f := range fields { hashIdx := strings.IndexByte(f, '#') if hashIdx == 0 { // The rest of the fields are a part of the comment. // Skip immediately. return } else if hashIdx > 0 { // Only a part of the field is a comment. hosts = append(hosts, f[:hashIdx]) return hosts } hosts = append(hosts, f) } return hosts } // load reads IP-hostname pairs from the hosts file. Multiple hostnames per // line for one IP are supported. func (ehc *EtcHostsContainer) load( table map[string][]net.IP, tableRev map[string][]string, fn string, ) {
[ "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/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/systemresolvers.go
const ( // errBadAddrPassed is returned when dialFunc can't parse an IP address. errBadAddrPassed errors.Error = "the passed string is not a valid IP address" // errFakeDial is an error which dialFunc is expected to return. errFakeDial errors.Error = "this error signals the successful dialFunc work" // errUnexpectedHostFormat is returned by validateDialedHost when the host has // more than one percent sign. errUnexpectedHostFormat errors.Error = "unexpected host format" )
<mask> addrs *aghstrings.Set <mask> addrsLock sync.RWMutex <mask> } <mask> <mask> func (sr *systemResolvers) refresh() (err error) { <mask> defer func() { err = errors.Annotate(err, "systemResolvers: %w") }() <mask> <mask> _, err = sr.resolver.LookupHost(context.Background(), sr.hostGenFunc()) </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove go func() { defer log.OnPanic("systemResolvers") defer func() { derr := stdin.Close() if derr != nil { log.Error("systemResolvers: closing stdin pipe: %s", derr) } }() _, werr := io.WriteString(stdin, "exit") if werr != nil { log.Error("systemResolvers: writing to command pipe: %s", werr) } }() </s> add go writeExit(stdin) </s> remove const ( // errBadAddrPassed is returned when dialFunc can't parse an IP address. errBadAddrPassed errors.Error = "the passed string is not a valid IP address" // errFakeDial is an error which dialFunc is expected to return. errFakeDial errors.Error = "this error signals the successful dialFunc work" // errUnexpectedHostFormat is returned by validateDialedHost when the host has // more than one percent sign. errUnexpectedHostFormat errors.Error = "unexpected host format" ) </s> add </s> remove for s.Scan() { line := s.Text() if len(line) == 0 { continue } fields := strings.Fields(line) if len(fields) != 2 || fields[0] != "Address:" { continue } // If the address contains port then it is separated with '#'. ipStrs := strings.Split(fields[1], "#") if len(ipStrs) == 0 { continue } possibleIPs = append(possibleIPs, ipStrs[0]) } </s> add addrs = scanAddrs(s) </s> remove r := bufio.NewReader(f) </s> add
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/systemresolvers_others.go
go writeExit(stdin)
<mask> if err != nil { <mask> return nil, fmt.Errorf("limiting stdout reader: %w", err) <mask> } <mask> <mask> go func() { <mask> defer log.OnPanic("systemResolvers") <mask> <mask> defer func() { <mask> derr := stdin.Close() <mask> if derr != nil { <mask> log.Error("systemResolvers: closing stdin pipe: %s", derr) <mask> } <mask> }() <mask> <mask> _, werr := io.WriteString(stdin, "exit") <mask> if werr != nil { <mask> log.Error("systemResolvers: writing to command pipe: %s", werr) <mask> } <mask> }() <mask> <mask> err = cmd.Start() <mask> if err != nil { <mask> return nil, fmt.Errorf("start command executing: %w", err) <mask> } </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove // The output of nslookup looks like this: // // Default Server: 192-168-1-1.qualified.domain.ru // Address: 192.168.1.1 var possibleIPs []string </s> add </s> remove for s.Scan() { line := s.Text() if len(line) == 0 { continue } fields := strings.Fields(line) if len(fields) != 2 || fields[0] != "Address:" { continue } // If the address contains port then it is separated with '#'. ipStrs := strings.Split(fields[1], "#") if len(ipStrs) == 0 { continue } possibleIPs = append(possibleIPs, ipStrs[0]) } </s> add addrs = scanAddrs(s) </s> remove for done := false; !done; { var line string line, err = r.ReadString('\n') if err == io.EOF { done = true } else if err != nil { log.Error("etchostscontainer: %s", err) return } line = strings.TrimSpace(line) if len(line) == 0 || line[0] == '#' { continue } </s> add s := bufio.NewScanner(f) for s.Scan() { line := strings.TrimSpace(s.Text()) </s> remove r := bufio.NewReader(f) </s> add
[ "keep", "keep", "keep", "keep", "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/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/systemresolvers_windows.go
<mask> if err != nil { <mask> return nil, fmt.Errorf("start command executing: %w", err) <mask> } <mask> <mask> // The output of nslookup looks like this: <mask> // <mask> // Default Server: 192-168-1-1.qualified.domain.ru <mask> // Address: 192.168.1.1 <mask> <mask> var possibleIPs []string <mask> s := bufio.NewScanner(stdoutLimited) <mask> for s.Scan() { <mask> line := s.Text() <mask> if len(line) == 0 { <mask> continue </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove for s.Scan() { line := s.Text() if len(line) == 0 { continue } fields := strings.Fields(line) if len(fields) != 2 || fields[0] != "Address:" { continue } // If the address contains port then it is separated with '#'. ipStrs := strings.Split(fields[1], "#") if len(ipStrs) == 0 { continue } possibleIPs = append(possibleIPs, ipStrs[0]) } </s> add addrs = scanAddrs(s) </s> remove go func() { defer log.OnPanic("systemResolvers") defer func() { derr := stdin.Close() if derr != nil { log.Error("systemResolvers: closing stdin pipe: %s", derr) } }() _, werr := io.WriteString(stdin, "exit") if werr != nil { log.Error("systemResolvers: writing to command pipe: %s", werr) } }() </s> add go writeExit(stdin) </s> remove for done := false; !done; { var line string line, err = r.ReadString('\n') if err == io.EOF { done = true } else if err != nil { log.Error("etchostscontainer: %s", err) return } line = strings.TrimSpace(line) if len(line) == 0 || line[0] == '#' { continue } </s> add s := bufio.NewScanner(f) for s.Scan() { line := strings.TrimSpace(s.Text()) </s> remove if withinInterfaceCtx && len(line) == 0 { // An empty line resets our state. withinInterfaceCtx = false } if len(line) == 0 || line[0] == '#' { continue } </s> add </s> remove var withinInterfaceCtx bool </s> add ifaceFound := findIfaceLine(s, ifaceName) if !ifaceFound { return false, s.Err() }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/systemresolvers_windows.go
addrs = scanAddrs(s)
<mask> // Address: 192.168.1.1 <mask> <mask> var possibleIPs []string <mask> s := bufio.NewScanner(stdoutLimited) <mask> for s.Scan() { <mask> line := s.Text() <mask> if len(line) == 0 { <mask> continue <mask> } <mask> <mask> fields := strings.Fields(line) <mask> if len(fields) != 2 || fields[0] != "Address:" { <mask> continue <mask> } <mask> <mask> // If the address contains port then it is separated with '#'. <mask> ipStrs := strings.Split(fields[1], "#") <mask> if len(ipStrs) == 0 { <mask> continue <mask> } <mask> <mask> possibleIPs = append(possibleIPs, ipStrs[0]) <mask> } <mask> <mask> err = cmd.Wait() <mask> if err != nil { <mask> return nil, fmt.Errorf("executing the command: %w", err) <mask> } </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove // The output of nslookup looks like this: // // Default Server: 192-168-1-1.qualified.domain.ru // Address: 192.168.1.1 var possibleIPs []string </s> add </s> remove for done := false; !done; { var line string line, err = r.ReadString('\n') if err == io.EOF { done = true } else if err != nil { log.Error("etchostscontainer: %s", err) return } line = strings.TrimSpace(line) if len(line) == 0 || line[0] == '#' { continue } </s> add s := bufio.NewScanner(f) for s.Scan() { line := strings.TrimSpace(s.Text()) </s> remove if withinInterfaceCtx && len(line) == 0 { // An empty line resets our state. withinInterfaceCtx = false } if len(line) == 0 || line[0] == '#' { continue } </s> add </s> remove if withinInterfaceCtx { if len(fields) >= 2 && fields[0] == "static" && strings.HasPrefix(fields[1], "ip_address=") { return true, nil } if len(fields) > 0 && fields[0] == "interface" { // Another interface found. withinInterfaceCtx = false } continue </s> add if len(fields) >= 2 && fields[0] == "static" && strings.HasPrefix(fields[1], "ip_address=") { return true, s.Err()
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", ...
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghnet/systemresolvers_windows.go
<mask> ) <mask> <mask> // TestUpstream is a mock of real upstream. <mask> type TestUpstream struct { <mask> // Addr is the address for Address method. <mask> Addr string <mask> // CName is a map of hostname to canonical name. <mask> CName map[string]string <mask> // IPv4 is a map of hostname to IPv4. <mask> IPv4 map[string][]net.IP <mask> // IPv6 is a map of hostname to IPv6. </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove const ( // errBadAddrPassed is returned when dialFunc can't parse an IP address. errBadAddrPassed errors.Error = "the passed string is not a valid IP address" // errFakeDial is an error which dialFunc is expected to return. errFakeDial errors.Error = "this error signals the successful dialFunc work" // errUnexpectedHostFormat is returned by validateDialedHost when the host has // more than one percent sign. errUnexpectedHostFormat errors.Error = "unexpected host format" ) </s> add </s> remove "github.com/AdguardTeam/golibs/errors" </s> add </s> remove // Read IP-hostname pairs from file // Multiple hostnames per line (per one IP) is supported. func (ehc *EtcHostsContainer) load(table map[string][]net.IP, tableRev map[string][]string, fn string) { </s> add // parseHostsLine parses hosts from the fields. func parseHostsLine(fields []string) (hosts []string) { for _, f := range fields { hashIdx := strings.IndexByte(f, '#') if hashIdx == 0 { // The rest of the fields are a part of the comment. // Skip immediately. return } else if hashIdx > 0 { // Only a part of the field is a comment. hosts = append(hosts, f[:hashIdx]) return hosts } hosts = append(hosts, f) } return hosts } // load reads IP-hostname pairs from the hosts file. Multiple hostnames per // line for one IP are supported. func (ehc *EtcHostsContainer) load( table map[string][]net.IP, tableRev map[string][]string, fn string, ) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghtest/upstream.go
// Addr is the address for Address method. Addr string
<mask> IPv6 map[string][]net.IP <mask> // Reverse is a map of address to domain name. <mask> Reverse map[string][]string <mask> } <mask> <mask> // Exchange implements upstream.Upstream interface for *TestUpstream. <mask> // <mask> // TODO(a.garipov): Split further into handlers. <mask> func (u *TestUpstream) Exchange(m *dns.Msg) (resp *dns.Msg, err error) { </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove // Addr is the address for Address method. Addr string </s> add </s> remove Hostname string Block bool requestsCount int lock sync.RWMutex </s> add Hostname string // lock protects reqNum. lock sync.RWMutex reqNum int Block bool </s> remove return u.requestsCount </s> add return u.reqNum
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghtest/upstream.go
// // TODO(a.garipov): Split further into handlers.
<mask> } <mask> <mask> // Exchange implements upstream.Upstream interface for *TestUpstream. <mask> func (u *TestUpstream) Exchange(m *dns.Msg) (resp *dns.Msg, err error) { <mask> resp = &dns.Msg{} <mask> resp.SetReply(m) <mask> <mask> if len(m.Question) == 0 { <mask> return nil, fmt.Errorf("question should not be empty") </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove Hostname string Block bool requestsCount int lock sync.RWMutex </s> add Hostname string // lock protects reqNum. lock sync.RWMutex reqNum int Block bool </s> remove return u.requestsCount </s> add return u.reqNum </s> remove u.requestsCount++ </s> add u.reqNum++ </s> remove var withinInterfaceCtx bool </s> add ifaceFound := findIfaceLine(s, ifaceName) if !ifaceFound { return false, s.Err() }
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghtest/upstream.go
ans := &dns.CNAME{
<mask> } <mask> name := m.Question[0].Name <mask> <mask> if cname, ok := u.CName[name]; ok { <mask> resp.Answer = append(resp.Answer, &dns.CNAME{ <mask> Hdr: dns.RR_Header{ <mask> Name: name, <mask> Rrtype: dns.TypeCNAME, <mask> }, <mask> Target: cname, </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove }) </s> add } resp.Answer = append(resp.Answer, ans) </s> remove var hasRec bool var rrType uint16 </s> add rrType := m.Question[0].Qtype hdr := dns.RR_Header{ Name: name, Rrtype: rrType, } var names []string </s> remove for _, ip := range ips { resp.Answer = append(resp.Answer, &dns.A{ Hdr: dns.RR_Header{ Name: name, Rrtype: rrType, }, A: ip, }) </s> add for _, n := range names { ans := &dns.PTR{ Hdr: hdr, Ptr: n, } resp.Answer = append(resp.Answer, ans) </s> remove for _, n := range names { resp.Answer = append(resp.Answer, &dns.PTR{ Hdr: dns.RR_Header{ Name: n, Rrtype: rrType, }, Ptr: n, }) </s> add ans = &dns.AAAA{ Hdr: hdr, AAAA: ip, </s> remove names, ok := u.Reverse[name] if !ok { break </s> add names = u.Reverse[name] } for _, ip := range ips { var ans dns.RR if rrType == dns.TypeA { ans = &dns.A{ Hdr: hdr, A: ip, } resp.Answer = append(resp.Answer, ans) continue
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghtest/upstream.go
} resp.Answer = append(resp.Answer, ans)
<mask> Name: name, <mask> Rrtype: dns.TypeCNAME, <mask> }, <mask> Target: cname, <mask> }) <mask> } <mask> <mask> var hasRec bool <mask> var rrType uint16 <mask> var ips []net.IP </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove var hasRec bool var rrType uint16 </s> add rrType := m.Question[0].Qtype hdr := dns.RR_Header{ Name: name, Rrtype: rrType, } var names []string </s> remove resp.Answer = append(resp.Answer, &dns.CNAME{ </s> add ans := &dns.CNAME{ </s> remove rrType = dns.TypeA if ipv4addr, ok := u.IPv4[name]; ok { hasRec = true ips = ipv4addr } </s> add ips = u.IPv4[name] </s> remove for _, ip := range ips { resp.Answer = append(resp.Answer, &dns.A{ Hdr: dns.RR_Header{ Name: name, Rrtype: rrType, }, A: ip, }) </s> add for _, n := range names { ans := &dns.PTR{ Hdr: hdr, Ptr: n, } resp.Answer = append(resp.Answer, ans) </s> remove for _, n := range names { resp.Answer = append(resp.Answer, &dns.PTR{ Hdr: dns.RR_Header{ Name: n, Rrtype: rrType, }, Ptr: n, }) </s> add ans = &dns.AAAA{ Hdr: hdr, AAAA: ip,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghtest/upstream.go
rrType := m.Question[0].Qtype hdr := dns.RR_Header{ Name: name, Rrtype: rrType, } var names []string
<mask> Target: cname, <mask> }) <mask> } <mask> <mask> var hasRec bool <mask> var rrType uint16 <mask> var ips []net.IP <mask> switch m.Question[0].Qtype { <mask> case dns.TypeA: <mask> rrType = dns.TypeA <mask> if ipv4addr, ok := u.IPv4[name]; ok { </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove rrType = dns.TypeA if ipv4addr, ok := u.IPv4[name]; ok { hasRec = true ips = ipv4addr } </s> add ips = u.IPv4[name] </s> remove }) </s> add } resp.Answer = append(resp.Answer, ans) </s> remove rrType = dns.TypeAAAA if ipv6addr, ok := u.IPv6[name]; ok { hasRec = true ips = ipv6addr } </s> add ips = u.IPv6[name] </s> remove names, ok := u.Reverse[name] if !ok { break </s> add names = u.Reverse[name] } for _, ip := range ips { var ans dns.RR if rrType == dns.TypeA { ans = &dns.A{ Hdr: hdr, A: ip, } resp.Answer = append(resp.Answer, ans) continue </s> remove resp.Answer = append(resp.Answer, &dns.CNAME{ </s> add ans := &dns.CNAME{
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghtest/upstream.go
ips = u.IPv4[name]
<mask> var rrType uint16 <mask> var ips []net.IP <mask> switch m.Question[0].Qtype { <mask> case dns.TypeA: <mask> rrType = dns.TypeA <mask> if ipv4addr, ok := u.IPv4[name]; ok { <mask> hasRec = true <mask> ips = ipv4addr <mask> } <mask> case dns.TypeAAAA: <mask> rrType = dns.TypeAAAA <mask> if ipv6addr, ok := u.IPv6[name]; ok { <mask> hasRec = true <mask> ips = ipv6addr </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove rrType = dns.TypeAAAA if ipv6addr, ok := u.IPv6[name]; ok { hasRec = true ips = ipv6addr } </s> add ips = u.IPv6[name] </s> remove var hasRec bool var rrType uint16 </s> add rrType := m.Question[0].Qtype hdr := dns.RR_Header{ Name: name, Rrtype: rrType, } var names []string </s> remove names, ok := u.Reverse[name] if !ok { break </s> add names = u.Reverse[name] } for _, ip := range ips { var ans dns.RR if rrType == dns.TypeA { ans = &dns.A{ Hdr: hdr, A: ip, } resp.Answer = append(resp.Answer, ans) continue </s> remove }) </s> add } resp.Answer = append(resp.Answer, ans) </s> remove resp.Answer = append(resp.Answer, &dns.CNAME{ </s> add ans := &dns.CNAME{
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghtest/upstream.go
ips = u.IPv6[name]
<mask> hasRec = true <mask> ips = ipv4addr <mask> } <mask> case dns.TypeAAAA: <mask> rrType = dns.TypeAAAA <mask> if ipv6addr, ok := u.IPv6[name]; ok { <mask> hasRec = true <mask> ips = ipv6addr <mask> } <mask> case dns.TypePTR: <mask> names, ok := u.Reverse[name] <mask> if !ok { <mask> break <mask> } </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove rrType = dns.TypeA if ipv4addr, ok := u.IPv4[name]; ok { hasRec = true ips = ipv4addr } </s> add ips = u.IPv4[name] </s> remove names, ok := u.Reverse[name] if !ok { break </s> add names = u.Reverse[name] } for _, ip := range ips { var ans dns.RR if rrType == dns.TypeA { ans = &dns.A{ Hdr: hdr, A: ip, } resp.Answer = append(resp.Answer, ans) continue </s> remove var hasRec bool var rrType uint16 </s> add rrType := m.Question[0].Qtype hdr := dns.RR_Header{ Name: name, Rrtype: rrType, } var names []string </s> remove for _, n := range names { resp.Answer = append(resp.Answer, &dns.PTR{ Hdr: dns.RR_Header{ Name: n, Rrtype: rrType, }, Ptr: n, }) </s> add ans = &dns.AAAA{ Hdr: hdr, AAAA: ip, </s> remove resp.Answer = append(resp.Answer, &dns.CNAME{ </s> add ans := &dns.CNAME{
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghtest/upstream.go
names = u.Reverse[name] } for _, ip := range ips { var ans dns.RR if rrType == dns.TypeA { ans = &dns.A{ Hdr: hdr, A: ip, } resp.Answer = append(resp.Answer, ans) continue
<mask> hasRec = true <mask> ips = ipv6addr <mask> } <mask> case dns.TypePTR: <mask> names, ok := u.Reverse[name] <mask> if !ok { <mask> break <mask> } <mask> <mask> for _, n := range names { <mask> resp.Answer = append(resp.Answer, &dns.PTR{ <mask> Hdr: dns.RR_Header{ </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove rrType = dns.TypeAAAA if ipv6addr, ok := u.IPv6[name]; ok { hasRec = true ips = ipv6addr } </s> add ips = u.IPv6[name] </s> remove for _, n := range names { resp.Answer = append(resp.Answer, &dns.PTR{ Hdr: dns.RR_Header{ Name: n, Rrtype: rrType, }, Ptr: n, }) </s> add ans = &dns.AAAA{ Hdr: hdr, AAAA: ip, </s> remove for _, ip := range ips { resp.Answer = append(resp.Answer, &dns.A{ Hdr: dns.RR_Header{ Name: name, Rrtype: rrType, }, A: ip, }) </s> add for _, n := range names { ans := &dns.PTR{ Hdr: hdr, Ptr: n, } resp.Answer = append(resp.Answer, ans) </s> remove rrType = dns.TypeA if ipv4addr, ok := u.IPv4[name]; ok { hasRec = true ips = ipv4addr } </s> add ips = u.IPv4[name]
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghtest/upstream.go
ans = &dns.AAAA{ Hdr: hdr, AAAA: ip,
<mask> if !ok { <mask> break <mask> } <mask> <mask> for _, n := range names { <mask> resp.Answer = append(resp.Answer, &dns.PTR{ <mask> Hdr: dns.RR_Header{ <mask> Name: n, <mask> Rrtype: rrType, <mask> }, <mask> Ptr: n, <mask> }) <mask> } <mask> } <mask> <mask> for _, ip := range ips { <mask> resp.Answer = append(resp.Answer, &dns.A{ </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove for _, ip := range ips { resp.Answer = append(resp.Answer, &dns.A{ Hdr: dns.RR_Header{ Name: name, Rrtype: rrType, }, A: ip, }) </s> add for _, n := range names { ans := &dns.PTR{ Hdr: hdr, Ptr: n, } resp.Answer = append(resp.Answer, ans) </s> remove names, ok := u.Reverse[name] if !ok { break </s> add names = u.Reverse[name] } for _, ip := range ips { var ans dns.RR if rrType == dns.TypeA { ans = &dns.A{ Hdr: hdr, A: ip, } resp.Answer = append(resp.Answer, ans) continue </s> remove resp.Answer = append(resp.Answer, &dns.CNAME{ </s> add ans := &dns.CNAME{ </s> remove }) </s> add } resp.Answer = append(resp.Answer, ans)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghtest/upstream.go
resp.Answer = append(resp.Answer, ans)
<mask> AAAA: ip, <mask> } <mask> } <mask> <mask> for _, n := range names { <mask> ans := &dns.PTR{ <mask> Hdr: hdr, </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove for _, n := range names { resp.Answer = append(resp.Answer, &dns.PTR{ Hdr: dns.RR_Header{ Name: n, Rrtype: rrType, }, Ptr: n, }) </s> add ans = &dns.AAAA{ Hdr: hdr, AAAA: ip, </s> remove names, ok := u.Reverse[name] if !ok { break </s> add names = u.Reverse[name] } for _, ip := range ips { var ans dns.RR if rrType == dns.TypeA { ans = &dns.A{ Hdr: hdr, A: ip, } resp.Answer = append(resp.Answer, ans) continue </s> remove for _, ip := range ips { resp.Answer = append(resp.Answer, &dns.A{ Hdr: dns.RR_Header{ Name: name, Rrtype: rrType, }, A: ip, }) </s> add for _, n := range names { ans := &dns.PTR{ Hdr: hdr, Ptr: n, } resp.Answer = append(resp.Answer, ans) </s> remove resp.Answer = append(resp.Answer, &dns.CNAME{ </s> add ans := &dns.CNAME{ </s> remove for i := 1; i != len(fields); i++ { host := fields[i] if len(host) == 0 { break } sharp := strings.IndexByte(host, '#') if sharp == 0 { // Skip the comments. break } else if sharp > 0 { host = host[:sharp] } </s> add hosts := parseHostsLine(fields[1:]) for _, host := range hosts {
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghtest/upstream.go
for _, n := range names { ans := &dns.PTR{ Hdr: hdr, Ptr: n, } resp.Answer = append(resp.Answer, ans)
<mask> }) <mask> } <mask> } <mask> <mask> for _, ip := range ips { <mask> resp.Answer = append(resp.Answer, &dns.A{ <mask> Hdr: dns.RR_Header{ <mask> Name: name, <mask> Rrtype: rrType, <mask> }, <mask> A: ip, <mask> }) <mask> } <mask> <mask> if len(resp.Answer) == 0 { <mask> if hasRec { <mask> // Set no error RCode if there are some records for </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove for _, n := range names { resp.Answer = append(resp.Answer, &dns.PTR{ Hdr: dns.RR_Header{ Name: n, Rrtype: rrType, }, Ptr: n, }) </s> add ans = &dns.AAAA{ Hdr: hdr, AAAA: ip, </s> remove if hasRec { // Set no error RCode if there are some records for // given Qname but we didn't apply them. resp.SetRcode(m, dns.RcodeSuccess) return resp, nil } // Set NXDomain RCode otherwise. </s> add </s> remove names, ok := u.Reverse[name] if !ok { break </s> add names = u.Reverse[name] } for _, ip := range ips { var ans dns.RR if rrType == dns.TypeA { ans = &dns.A{ Hdr: hdr, A: ip, } resp.Answer = append(resp.Answer, ans) continue </s> remove resp.Answer = append(resp.Answer, &dns.CNAME{ </s> add ans := &dns.CNAME{ </s> remove var hasRec bool var rrType uint16 </s> add rrType := m.Question[0].Qtype hdr := dns.RR_Header{ Name: name, Rrtype: rrType, } var names []string
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghtest/upstream.go
<mask> }) <mask> } <mask> <mask> if len(resp.Answer) == 0 { <mask> if hasRec { <mask> // Set no error RCode if there are some records for <mask> // given Qname but we didn't apply them. <mask> resp.SetRcode(m, dns.RcodeSuccess) <mask> <mask> return resp, nil <mask> } <mask> // Set NXDomain RCode otherwise. <mask> resp.SetRcode(m, dns.RcodeNameError) <mask> } <mask> <mask> return resp, nil <mask> } </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove for _, ip := range ips { resp.Answer = append(resp.Answer, &dns.A{ Hdr: dns.RR_Header{ Name: name, Rrtype: rrType, }, A: ip, }) </s> add for _, n := range names { ans := &dns.PTR{ Hdr: hdr, Ptr: n, } resp.Answer = append(resp.Answer, ans) </s> remove // Read IP-hostname pairs from file // Multiple hostnames per line (per one IP) is supported. func (ehc *EtcHostsContainer) load(table map[string][]net.IP, tableRev map[string][]string, fn string) { </s> add // parseHostsLine parses hosts from the fields. func parseHostsLine(fields []string) (hosts []string) { for _, f := range fields { hashIdx := strings.IndexByte(f, '#') if hashIdx == 0 { // The rest of the fields are a part of the comment. // Skip immediately. return } else if hashIdx > 0 { // Only a part of the field is a comment. hosts = append(hosts, f[:hashIdx]) return hosts } hosts = append(hosts, f) } return hosts } // load reads IP-hostname pairs from the hosts file. Multiple hostnames per // line for one IP are supported. func (ehc *EtcHostsContainer) load( table map[string][]net.IP, tableRev map[string][]string, fn string, ) { </s> remove for i := 1; i != len(fields); i++ { host := fields[i] if len(host) == 0 { break } sharp := strings.IndexByte(host, '#') if sharp == 0 { // Skip the comments. break } else if sharp > 0 { host = host[:sharp] } </s> add hosts := parseHostsLine(fields[1:]) for _, host := range hosts { </s> remove if withinInterfaceCtx { if len(fields) >= 2 && fields[0] == "static" && strings.HasPrefix(fields[1], "ip_address=") { return true, nil } if len(fields) > 0 && fields[0] == "interface" { // Another interface found. withinInterfaceCtx = false } continue </s> add if len(fields) >= 2 && fields[0] == "static" && strings.HasPrefix(fields[1], "ip_address=") { return true, s.Err() </s> remove for s.Scan() { line := s.Text() if len(line) == 0 { continue } fields := strings.Fields(line) if len(fields) != 2 || fields[0] != "Address:" { continue } // If the address contains port then it is separated with '#'. ipStrs := strings.Split(fields[1], "#") if len(ipStrs) == 0 { continue } possibleIPs = append(possibleIPs, ipStrs[0]) } </s> add addrs = scanAddrs(s)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghtest/upstream.go
Hostname string // lock protects reqNum. lock sync.RWMutex reqNum int Block bool
<mask> <mask> // TestBlockUpstream implements upstream.Upstream interface for replacing real <mask> // upstream in tests. <mask> type TestBlockUpstream struct { <mask> Hostname string <mask> Block bool <mask> requestsCount int <mask> lock sync.RWMutex <mask> } <mask> <mask> // Exchange returns a message unique for TestBlockUpstream's Hostname-Block <mask> // pair. <mask> func (u *TestBlockUpstream) Exchange(r *dns.Msg) (*dns.Msg, error) { </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove return u.requestsCount </s> add return u.reqNum </s> remove u.requestsCount++ </s> add u.reqNum++ </s> remove // Addr is the address for Address method. Addr string </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghtest/upstream.go
u.reqNum++
<mask> // pair. <mask> func (u *TestBlockUpstream) Exchange(r *dns.Msg) (*dns.Msg, error) { <mask> u.lock.Lock() <mask> defer u.lock.Unlock() <mask> u.requestsCount++ <mask> <mask> hash := sha256.Sum256([]byte(u.Hostname)) <mask> hashToReturn := hex.EncodeToString(hash[:]) <mask> if !u.Block { <mask> hashToReturn = hex.EncodeToString(hash[:])[:2] + strings.Repeat("ab", 28) </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove Hostname string Block bool requestsCount int lock sync.RWMutex </s> add Hostname string // lock protects reqNum. lock sync.RWMutex reqNum int Block bool </s> remove return u.requestsCount </s> add return u.reqNum </s> remove var withinInterfaceCtx bool </s> add ifaceFound := findIfaceLine(s, ifaceName) if !ifaceFound { return false, s.Err() }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghtest/upstream.go
return u.reqNum
<mask> func (u *TestBlockUpstream) RequestsCount() int { <mask> u.lock.Lock() <mask> defer u.lock.Unlock() <mask> <mask> return u.requestsCount <mask> } <mask> <mask> // TestErrUpstream implements upstream.Upstream interface for replacing real <mask> // upstream in tests. <mask> type TestErrUpstream struct { </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove Hostname string Block bool requestsCount int lock sync.RWMutex </s> add Hostname string // lock protects reqNum. lock sync.RWMutex reqNum int Block bool </s> remove u.requestsCount++ </s> add u.reqNum++ </s> remove // Addr is the address for Address method. Addr string </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/aghtest/upstream.go
assert.Equal(t, tc.want, pctx.Res.Answer[0].(*dns.PTR).Ptr)
<mask> require.NotNil(t, pctx.Res) <mask> require.Len(t, pctx.Res.Answer, tc.wantLen) <mask> <mask> if tc.wantLen > 0 { <mask> assert.Equal(t, tc.want, pctx.Res.Answer[0].Header().Name) <mask> } <mask> }) <mask> } <mask> } <mask> </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove if len(fields) == 2 && fields[0] == "interface" && fields[1] == ifaceName { // The interface found. withinInterfaceCtx = true </s> add if len(fields) > 0 && fields[0] == "interface" { // Another interface found. break </s> remove for _, ip := range ips { resp.Answer = append(resp.Answer, &dns.A{ Hdr: dns.RR_Header{ Name: name, Rrtype: rrType, }, A: ip, }) </s> add for _, n := range names { ans := &dns.PTR{ Hdr: hdr, Ptr: n, } resp.Answer = append(resp.Answer, ans) </s> remove for i := 1; i != len(fields); i++ { host := fields[i] if len(host) == 0 { break } sharp := strings.IndexByte(host, '#') if sharp == 0 { // Skip the comments. break } else if sharp > 0 { host = host[:sharp] } </s> add hosts := parseHostsLine(fields[1:]) for _, host := range hosts { </s> remove if hasRec { // Set no error RCode if there are some records for // given Qname but we didn't apply them. resp.SetRcode(m, dns.RcodeSuccess) return resp, nil } // Set NXDomain RCode otherwise. </s> add </s> remove assert.Equal(t, locDomain, proxyCtx.Res.Answer[0].Header().Name) </s> add assert.Equal(t, locDomain, proxyCtx.Res.Answer[0].(*dns.PTR).Ptr)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/dnsforward/dns_test.go
assert.Equal(t, locDomain, proxyCtx.Res.Answer[0].(*dns.PTR).Ptr)
<mask> rc := s.processLocalPTR(dnsCtx) <mask> require.Equal(t, resultCodeSuccess, rc) <mask> require.NotEmpty(t, proxyCtx.Res.Answer) <mask> <mask> assert.Equal(t, locDomain, proxyCtx.Res.Answer[0].Header().Name) <mask> }) <mask> <mask> t.Run("disabled", func(t *testing.T) { <mask> setup(false) <mask> </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove assert.Equal(t, tc.want, pctx.Res.Answer[0].Header().Name) </s> add assert.Equal(t, tc.want, pctx.Res.Answer[0].(*dns.PTR).Ptr) </s> remove for _, ip := range ips { resp.Answer = append(resp.Answer, &dns.A{ Hdr: dns.RR_Header{ Name: name, Rrtype: rrType, }, A: ip, }) </s> add for _, n := range names { ans := &dns.PTR{ Hdr: hdr, Ptr: n, } resp.Answer = append(resp.Answer, ans) </s> remove var hasRec bool var rrType uint16 </s> add rrType := m.Question[0].Qtype hdr := dns.RR_Header{ Name: name, Rrtype: rrType, } var names []string </s> remove for _, n := range names { resp.Answer = append(resp.Answer, &dns.PTR{ Hdr: dns.RR_Header{ Name: n, Rrtype: rrType, }, Ptr: n, }) </s> add ans = &dns.AAAA{ Hdr: hdr, AAAA: ip, </s> remove for i := 1; i != len(fields); i++ { host := fields[i] if len(host) == 0 { break } sharp := strings.IndexByte(host, '#') if sharp == 0 { // Skip the comments. break } else if sharp > 0 { host = host[:sharp] } </s> add hosts := parseHostsLine(fields[1:]) for _, host := range hosts {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/dnsforward/dns_test.go
resolver := s.internalProxy
<mask> Req: req, <mask> StartTime: time.Now(), <mask> } <mask> <mask> var resolver *proxy.Proxy = s.internalProxy <mask> if s.subnetDetector.IsLocallyServedNetwork(ip) { <mask> if !s.conf.UsePrivateRDNS { <mask> return "", nil <mask> } <mask> </s> Pull request: all: imp cyclo in new code Updates #2646, Squashed commit of the following: commit af6a6fa2b7229bc0f1c7c9083b0391a6bec7ae70 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 20:00:36 2021 +0300 all: imp code, docs commit 1cd4781b13e635a9e1bccb758104c1b76c78d34e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon May 31 18:51:23 2021 +0300 all: imp cyclo in new code </s> remove for done := false; !done; { var line string line, err = r.ReadString('\n') if err == io.EOF { done = true } else if err != nil { log.Error("etchostscontainer: %s", err) return } line = strings.TrimSpace(line) if len(line) == 0 || line[0] == '#' { continue } </s> add s := bufio.NewScanner(f) for s.Scan() { line := strings.TrimSpace(s.Text()) </s> remove go func() { defer log.OnPanic("systemResolvers") defer func() { derr := stdin.Close() if derr != nil { log.Error("systemResolvers: closing stdin pipe: %s", derr) } }() _, werr := io.WriteString(stdin, "exit") if werr != nil { log.Error("systemResolvers: writing to command pipe: %s", werr) } }() </s> add go writeExit(stdin) </s> remove for s.Scan() { line := s.Text() if len(line) == 0 { continue } fields := strings.Fields(line) if len(fields) != 2 || fields[0] != "Address:" { continue } // If the address contains port then it is separated with '#'. ipStrs := strings.Split(fields[1], "#") if len(ipStrs) == 0 { continue } possibleIPs = append(possibleIPs, ipStrs[0]) } </s> add addrs = scanAddrs(s) </s> remove if withinInterfaceCtx && len(line) == 0 { // An empty line resets our state. withinInterfaceCtx = false } if len(line) == 0 || line[0] == '#' { continue } </s> add </s> remove if withinInterfaceCtx { if len(fields) >= 2 && fields[0] == "static" && strings.HasPrefix(fields[1], "ip_address=") { return true, nil } if len(fields) > 0 && fields[0] == "interface" { // Another interface found. withinInterfaceCtx = false } continue </s> add if len(fields) >= 2 && fields[0] == "static" && strings.HasPrefix(fields[1], "ip_address=") { return true, s.Err()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e17e1f20fbd88b6af9be0e60e658aad720e32ba8
internal/dnsforward/dnsforward.go
dispatch(refreshFiltersRequest());
<mask> export const refreshFiltersFailure = createAction('FILTERING_REFRESH_FAILURE'); <mask> export const refreshFiltersSuccess = createAction('FILTERING_REFRESH_SUCCESS'); <mask> <mask> export const refreshFilters = () => async (dispatch) => { <mask> dispatch(refreshFiltersRequest); <mask> dispatch(showLoading()); <mask> try { <mask> const refreshText = await apiClient.refreshFilters(); <mask> dispatch(refreshFiltersSuccess); <mask> </s> Only allow single click on buttons Closes #544 </s> remove dispatch(refreshFiltersSuccess); </s> add dispatch(refreshFiltersSuccess()); </s> remove const { config, active } = this.props.dhcp; </s> add const { config, active, processingDhcp } = this.props.dhcp;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e1bb428a6a32e43ffad711ab641cd37eeec91769
client/src/actions/index.js
dispatch(refreshFiltersSuccess());
<mask> dispatch(refreshFiltersRequest); <mask> dispatch(showLoading()); <mask> try { <mask> const refreshText = await apiClient.refreshFilters(); <mask> dispatch(refreshFiltersSuccess); <mask> <mask> if (refreshText.includes('OK')) { <mask> if (refreshText.includes('OK 0')) { <mask> dispatch(addSuccessToast('all_filters_up_to_date_toast')); <mask> } else { </s> Only allow single click on buttons Closes #544 </s> remove dispatch(refreshFiltersRequest); </s> add dispatch(refreshFiltersRequest()); </s> remove const { config, active } = this.props.dhcp; </s> add const { config, active, processingDhcp } = this.props.dhcp; </s> remove renderButtons(queryLogEnabled) { </s> add renderButtons(queryLogEnabled, logStatusProcessing) { </s> remove <input type="text" className={inputNameClass} placeholder={ this.props.t('enter_name_hint') } onChange={this.handleNameChange} /> <input type="text" className={inputUrlClass} placeholder={ this.props.t('enter_url_hint') } onChange={this.handleUrlChange} /> </s> add <input type="text" className={inputNameClass} placeholder={this.props.t('enter_name_hint')} onChange={this.handleNameChange} /> <input type="text" className={inputUrlClass} placeholder={this.props.t('enter_url_hint')} onChange={this.handleUrlChange} /> </s> remove const { filters, userRules } = this.props.filtering; </s> add const { filters, userRules, processingRefreshFilters } = this.props.filtering;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e1bb428a6a32e43ffad711ab641cd37eeec91769
client/src/actions/index.js
position: fixed; top: 0; left: 0;
<mask> } <mask> } <mask> <mask> .loading-bar { <mask> position: absolute; <mask> z-index: 103; <mask> height: 3px; <mask> background: linear-gradient(45deg, rgba(99, 125, 120, 1) 0%, rgba(88, 177, 101, 1) 100%); <mask> } </s> Only allow single click on buttons Closes #544 </s> remove const { filters, userRules } = this.props.filtering; </s> add const { filters, userRules, processingRefreshFilters } = this.props.filtering; </s> remove const { config, active } = this.props.dhcp; </s> add const { config, active, processingDhcp } = this.props.dhcp; </s> remove const { protectionEnabled } = this.props.dashboard; </s> add const { protectionEnabled, processingProtection } = this.props.dashboard;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e1bb428a6a32e43ffad711ab641cd37eeec91769
client/src/components/App/index.css
const { protectionEnabled, processingProtection } = this.props.dashboard;
<mask> this.props.getTopStats(); <mask> } <mask> <mask> getToggleFilteringButton = () => { <mask> const { protectionEnabled } = this.props.dashboard; <mask> const buttonText = protectionEnabled ? 'disable_protection' : 'enable_protection'; <mask> const buttonClass = protectionEnabled ? 'btn-gray' : 'btn-success'; <mask> <mask> return ( <mask> <button type="button" className={`btn btn-sm mr-2 ${buttonClass}`} onClick={() => this.props.toggleProtection(protectionEnabled)}> </s> Only allow single click on buttons Closes #544 </s> remove <button type="button" className={`btn btn-sm mr-2 ${buttonClass}`} onClick={() => this.props.toggleProtection(protectionEnabled)}> </s> add <button type="button" className={`btn btn-sm mr-2 ${buttonClass}`} onClick={() => this.props.toggleProtection(protectionEnabled)} disabled={processingProtection} > </s> remove disabled={!filledConfig || activeDhcpFound} </s> add disabled={!filledConfig || activeDhcpFound || processingDhcp} </s> remove const { config, active } = this.props.dhcp; </s> add const { config, active, processingDhcp } = this.props.dhcp;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e1bb428a6a32e43ffad711ab641cd37eeec91769
client/src/components/Dashboard/index.js
<button type="button" className={`btn btn-sm mr-2 ${buttonClass}`} onClick={() => this.props.toggleProtection(protectionEnabled)} disabled={processingProtection} >
<mask> const buttonText = protectionEnabled ? 'disable_protection' : 'enable_protection'; <mask> const buttonClass = protectionEnabled ? 'btn-gray' : 'btn-success'; <mask> <mask> return ( <mask> <button type="button" className={`btn btn-sm mr-2 ${buttonClass}`} onClick={() => this.props.toggleProtection(protectionEnabled)}> <mask> <Trans>{buttonText}</Trans> <mask> </button> <mask> ); <mask> } <mask> </s> Only allow single click on buttons Closes #544 </s> remove const { protectionEnabled } = this.props.dashboard; </s> add const { protectionEnabled, processingProtection } = this.props.dashboard; </s> remove disabled={!filledConfig || activeDhcpFound} </s> add disabled={!filledConfig || activeDhcpFound || processingDhcp} </s> remove { !this.props.isFilterAdded && <div className="modal-footer"> <button type="button" className="btn btn-secondary" onClick={this.closeModal}><Trans>cancel_btn</Trans></button> <button type="button" className="btn btn-success" onClick={this.handleNext} disabled={isValidForSubmit}><Trans>add_filter_btn</Trans></button> </div> </s> add {!this.props.isFilterAdded && <div className="modal-footer"> <button type="button" className="btn btn-secondary" onClick={this.closeModal} > <Trans>cancel_btn</Trans> </button> <button type="button" className="btn btn-success" onClick={this.handleNext} disabled={isValidForSubmit || processingAddFilter} > <Trans>add_filter_btn</Trans> </button> </div>
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e1bb428a6a32e43ffad711ab641cd37eeec91769
client/src/components/Dashboard/index.js
processingProtection: PropTypes.bool,
<mask> isCoreRunning: PropTypes.bool, <mask> getFiltering: PropTypes.func, <mask> toggleProtection: PropTypes.func, <mask> t: PropTypes.func, <mask> }; <mask> <mask> export default withNamespaces()(Dashboard); </s> Only allow single click on buttons Closes #544 </s> remove dispatch(refreshFiltersRequest); </s> add dispatch(refreshFiltersRequest()); </s> remove const newState = { ...state, config: newConfig }; </s> add const newState = { ...state, config: newConfig, processingDhcp: false };
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e1bb428a6a32e43ffad711ab641cd37eeec91769
client/src/components/Dashboard/index.js
const { filters, userRules, processingRefreshFilters } = this.props.filtering;
<mask> ]; <mask> <mask> render() { <mask> const { t } = this.props; <mask> const { filters, userRules } = this.props.filtering; <mask> return ( <mask> <div> <mask> <PageTitle title={ t('filters') } /> <mask> <div className="content"> <mask> <div className="row"> </s> Only allow single click on buttons Closes #544 </s> remove <input type="text" className={inputNameClass} placeholder={ this.props.t('enter_name_hint') } onChange={this.handleNameChange} /> <input type="text" className={inputUrlClass} placeholder={ this.props.t('enter_url_hint') } onChange={this.handleUrlChange} /> </s> add <input type="text" className={inputNameClass} placeholder={this.props.t('enter_name_hint')} onChange={this.handleNameChange} /> <input type="text" className={inputUrlClass} placeholder={this.props.t('enter_url_hint')} onChange={this.handleUrlChange} /> </s> remove {this.renderButtons(queryLogEnabled)} </s> add {this.renderButtons(queryLogEnabled, dashboard.logStatusProcessing)} </s> remove isOpen={ isOpen } </s> add isOpen={isOpen}
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e1bb428a6a32e43ffad711ab641cd37eeec91769
client/src/components/Filters/index.js
<button className="btn btn-success btn-standart mr-2" type="submit" onClick={this.props.toggleFilteringModal} > <Trans>add_filter_btn</Trans> </button> <button className="btn btn-primary btn-standart" type="submit" onClick={this.props.refreshFilters} disabled={processingRefreshFilters} > <Trans>check_updates_btn</Trans> </button>
<mask> rowsText={ t('rows_table_footer_text') } <mask> noDataText={ t('no_filters_added') } <mask> /> <mask> <div className="card-actions"> <mask> <button className="btn btn-success btn-standart mr-2" type="submit" onClick={this.props.toggleFilteringModal}><Trans>add_filter_btn</Trans></button> <mask> <button className="btn btn-primary btn-standart" type="submit" onClick={this.props.refreshFilters}><Trans>check_updates_btn</Trans></button> <mask> </div> <mask> </Card> <mask> </div> <mask> <div className="col-md-12"> <mask> <UserRules </s> Only allow single click on buttons Closes #544 </s> remove { !this.props.isFilterAdded && <div className="modal-footer"> <button type="button" className="btn btn-secondary" onClick={this.closeModal}><Trans>cancel_btn</Trans></button> <button type="button" className="btn btn-success" onClick={this.handleNext} disabled={isValidForSubmit}><Trans>add_filter_btn</Trans></button> </div> </s> add {!this.props.isFilterAdded && <div className="modal-footer"> <button type="button" className="btn btn-secondary" onClick={this.closeModal} > <Trans>cancel_btn</Trans> </button> <button type="button" className="btn btn-success" onClick={this.handleNext} disabled={isValidForSubmit || processingAddFilter} > <Trans>add_filter_btn</Trans> </button> </div> </s> remove { renderBody()} </s> add {renderBody()}
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e1bb428a6a32e43ffad711ab641cd37eeec91769
client/src/components/Filters/index.js
processingAddFilter={this.props.filtering.processingAddFilter}
<mask> addFilter={this.props.addFilter} <mask> isFilterAdded={this.props.filtering.isFilterAdded} <mask> title={ t('new_filter_btn') } <mask> inputDescription={ t('enter_valid_filter_url') } <mask> /> <mask> </div> </s> Only allow single click on buttons Closes #544 </s> remove const { filters, userRules } = this.props.filtering; </s> add const { filters, userRules, processingRefreshFilters } = this.props.filtering; </s> remove {this.renderButtons(queryLogEnabled)} </s> add {this.renderButtons(queryLogEnabled, dashboard.logStatusProcessing)} </s> remove <button className="btn btn-success btn-standart mr-2" type="submit" onClick={this.props.toggleFilteringModal}><Trans>add_filter_btn</Trans></button> <button className="btn btn-primary btn-standart" type="submit" onClick={this.props.refreshFilters}><Trans>check_updates_btn</Trans></button> </s> add <button className="btn btn-success btn-standart mr-2" type="submit" onClick={this.props.toggleFilteringModal} > <Trans>add_filter_btn</Trans> </button> <button className="btn btn-primary btn-standart" type="submit" onClick={this.props.refreshFilters} disabled={processingRefreshFilters} > <Trans>check_updates_btn</Trans> </button> </s> remove <input type="text" className={inputNameClass} placeholder={ this.props.t('enter_name_hint') } onChange={this.handleNameChange} /> <input type="text" className={inputUrlClass} placeholder={ this.props.t('enter_url_hint') } onChange={this.handleUrlChange} /> </s> add <input type="text" className={inputNameClass} placeholder={this.props.t('enter_name_hint')} onChange={this.handleNameChange} /> <input type="text" className={inputUrlClass} placeholder={this.props.t('enter_url_hint')} onChange={this.handleUrlChange} /> </s> remove { !this.props.isFilterAdded && <div className="modal-footer"> <button type="button" className="btn btn-secondary" onClick={this.closeModal}><Trans>cancel_btn</Trans></button> <button type="button" className="btn btn-success" onClick={this.handleNext} disabled={isValidForSubmit}><Trans>add_filter_btn</Trans></button> </div> </s> add {!this.props.isFilterAdded && <div className="modal-footer"> <button type="button" className="btn btn-secondary" onClick={this.closeModal} > <Trans>cancel_btn</Trans> </button> <button type="button" className="btn btn-success" onClick={this.handleNext} disabled={isValidForSubmit || processingAddFilter} > <Trans>add_filter_btn</Trans> </button> </div>
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e1bb428a6a32e43ffad711ab641cd37eeec91769
client/src/components/Filters/index.js
processingAddFilter: PropTypes.bool, processingRefreshFilters: PropTypes.bool,
<mask> userRules: PropTypes.string, <mask> filters: PropTypes.array, <mask> isFilteringModalOpen: PropTypes.bool.isRequired, <mask> isFilterAdded: PropTypes.bool, <mask> }), <mask> removeFilter: PropTypes.func.isRequired, <mask> toggleFilterStatus: PropTypes.func.isRequired, <mask> addFilter: PropTypes.func.isRequired, </s> Only allow single click on buttons Closes #544
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e1bb428a6a32e43ffad711ab641cd37eeec91769
client/src/components/Filters/index.js
disabled={this.props.filtering.processingRules}
<mask> <button <mask> type="button" <mask> className={`btn btn-sm ${buttonClass}`} <mask> onClick={() => this.toggleBlocking(buttonType, domain)} <mask> > <mask> <Trans>{buttonText}</Trans> <mask> </button> <mask> </div> <mask> ); </s> Only allow single click on buttons Closes #544 </s> remove <button type="button" className={`btn btn-sm mr-2 ${buttonClass}`} onClick={() => this.props.toggleProtection(protectionEnabled)}> </s> add <button type="button" className={`btn btn-sm mr-2 ${buttonClass}`} onClick={() => this.props.toggleProtection(protectionEnabled)} disabled={processingProtection} > </s> remove { !this.props.isFilterAdded && <div className="modal-footer"> <button type="button" className="btn btn-secondary" onClick={this.closeModal}><Trans>cancel_btn</Trans></button> <button type="button" className="btn btn-success" onClick={this.handleNext} disabled={isValidForSubmit}><Trans>add_filter_btn</Trans></button> </div> </s> add {!this.props.isFilterAdded && <div className="modal-footer"> <button type="button" className="btn btn-secondary" onClick={this.closeModal} > <Trans>cancel_btn</Trans> </button> <button type="button" className="btn btn-success" onClick={this.handleNext} disabled={isValidForSubmit || processingAddFilter} > <Trans>add_filter_btn</Trans> </button> </div> </s> remove disabled={!filledConfig || activeDhcpFound} </s> add disabled={!filledConfig || activeDhcpFound || processingDhcp} </s> remove const { protectionEnabled } = this.props.dashboard; </s> add const { protectionEnabled, processingProtection } = this.props.dashboard;
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e1bb428a6a32e43ffad711ab641cd37eeec91769
client/src/components/Logs/index.js
renderButtons(queryLogEnabled, logStatusProcessing) {
<mask> const dataBlob = new Blob([jsonStr], { type: 'text/plain;charset=utf-8' }); <mask> saveAs(dataBlob, DOWNLOAD_LOG_FILENAME); <mask> }; <mask> <mask> renderButtons(queryLogEnabled) { <mask> if (queryLogEnabled) { <mask> return ( <mask> <Fragment> <mask> <button <mask> className="btn btn-gray btn-sm mr-2" </s> Only allow single click on buttons Closes #544 </s> remove dispatch(refreshFiltersSuccess); </s> add dispatch(refreshFiltersSuccess()); </s> remove const newState = { ...state, protectionEnabled: !state.protectionEnabled }; </s> add const newState = { ...state, protectionEnabled: !state.protectionEnabled, processingProtection: false, }; </s> remove const newState = { ...state, config: newConfig }; </s> add const newState = { ...state, config: newConfig, processingDhcp: false };
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e1bb428a6a32e43ffad711ab641cd37eeec91769
client/src/components/Logs/index.js
disabled={logStatusProcessing}
<mask> className="btn btn-gray btn-sm mr-2" <mask> type="submit" <mask> onClick={() => this.props.toggleLogStatus(queryLogEnabled)} <mask> ><Trans>disabled_log_btn</Trans></button> <mask> <button <mask> className="btn btn-primary btn-sm mr-2" <mask> type="submit" </s> Only allow single click on buttons Closes #544 </s> remove <button className="btn btn-success btn-standart mr-2" type="submit" onClick={this.props.toggleFilteringModal}><Trans>add_filter_btn</Trans></button> <button className="btn btn-primary btn-standart" type="submit" onClick={this.props.refreshFilters}><Trans>check_updates_btn</Trans></button> </s> add <button className="btn btn-success btn-standart mr-2" type="submit" onClick={this.props.toggleFilteringModal} > <Trans>add_filter_btn</Trans> </button> <button className="btn btn-primary btn-standart" type="submit" onClick={this.props.refreshFilters} disabled={processingRefreshFilters} > <Trans>check_updates_btn</Trans> </button> </s> remove renderButtons(queryLogEnabled) { </s> add renderButtons(queryLogEnabled, logStatusProcessing) { </s> remove <button type="button" className={`btn btn-sm mr-2 ${buttonClass}`} onClick={() => this.props.toggleProtection(protectionEnabled)}> </s> add <button type="button" className={`btn btn-sm mr-2 ${buttonClass}`} onClick={() => this.props.toggleProtection(protectionEnabled)} disabled={processingProtection} >
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e1bb428a6a32e43ffad711ab641cd37eeec91769
client/src/components/Logs/index.js
disabled={logStatusProcessing}
<mask> <button <mask> className="btn btn-success btn-sm mr-2" <mask> type="submit" <mask> onClick={() => this.props.toggleLogStatus(queryLogEnabled)} <mask> ><Trans>enabled_log_btn</Trans></button> <mask> ); <mask> } <mask> <mask> render() { <mask> const { queryLogs, dashboard, t } = this.props; </s> Only allow single click on buttons Closes #544 </s> remove <button className="btn btn-success btn-standart mr-2" type="submit" onClick={this.props.toggleFilteringModal}><Trans>add_filter_btn</Trans></button> <button className="btn btn-primary btn-standart" type="submit" onClick={this.props.refreshFilters}><Trans>check_updates_btn</Trans></button> </s> add <button className="btn btn-success btn-standart mr-2" type="submit" onClick={this.props.toggleFilteringModal} > <Trans>add_filter_btn</Trans> </button> <button className="btn btn-primary btn-standart" type="submit" onClick={this.props.refreshFilters} disabled={processingRefreshFilters} > <Trans>check_updates_btn</Trans> </button> </s> remove const { filters, userRules } = this.props.filtering; </s> add const { filters, userRules, processingRefreshFilters } = this.props.filtering; </s> remove renderButtons(queryLogEnabled) { </s> add renderButtons(queryLogEnabled, logStatusProcessing) { </s> remove { !this.props.isFilterAdded && <div className="modal-footer"> <button type="button" className="btn btn-secondary" onClick={this.closeModal}><Trans>cancel_btn</Trans></button> <button type="button" className="btn btn-success" onClick={this.handleNext} disabled={isValidForSubmit}><Trans>add_filter_btn</Trans></button> </div> </s> add {!this.props.isFilterAdded && <div className="modal-footer"> <button type="button" className="btn btn-secondary" onClick={this.closeModal} > <Trans>cancel_btn</Trans> </button> <button type="button" className="btn btn-success" onClick={this.handleNext} disabled={isValidForSubmit || processingAddFilter} > <Trans>add_filter_btn</Trans> </button> </div>
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e1bb428a6a32e43ffad711ab641cd37eeec91769
client/src/components/Logs/index.js
{this.renderButtons(queryLogEnabled, dashboard.logStatusProcessing)}
<mask> return ( <mask> <Fragment> <mask> <PageTitle title={ t('query_log') } subtitle={ t('last_dns_queries') }> <mask> <div className="page-title__actions"> <mask> {this.renderButtons(queryLogEnabled)} <mask> </div> <mask> </PageTitle> <mask> <Card> <mask> {queryLogEnabled && queryLogs.getLogsProcessing && <Loading />} <mask> {queryLogEnabled && !queryLogs.getLogsProcessing && </s> Only allow single click on buttons Closes #544 </s> remove { !this.props.isFilterAdded && <div className="modal-footer"> <button type="button" className="btn btn-secondary" onClick={this.closeModal}><Trans>cancel_btn</Trans></button> <button type="button" className="btn btn-success" onClick={this.handleNext} disabled={isValidForSubmit}><Trans>add_filter_btn</Trans></button> </div> </s> add {!this.props.isFilterAdded && <div className="modal-footer"> <button type="button" className="btn btn-secondary" onClick={this.closeModal} > <Trans>cancel_btn</Trans> </button> <button type="button" className="btn btn-success" onClick={this.handleNext} disabled={isValidForSubmit || processingAddFilter} > <Trans>add_filter_btn</Trans> </button> </div> </s> remove { renderBody()} </s> add {renderBody()} </s> remove const { filters, userRules } = this.props.filtering; </s> add const { filters, userRules, processingRefreshFilters } = this.props.filtering; </s> remove <input type="text" className={inputNameClass} placeholder={ this.props.t('enter_name_hint') } onChange={this.handleNameChange} /> <input type="text" className={inputUrlClass} placeholder={ this.props.t('enter_url_hint') } onChange={this.handleUrlChange} /> </s> add <input type="text" className={inputNameClass} placeholder={this.props.t('enter_name_hint')} onChange={this.handleNameChange} /> <input type="text" className={inputUrlClass} placeholder={this.props.t('enter_url_hint')} onChange={this.handleUrlChange} /> </s> remove const { config, active } = this.props.dhcp; </s> add const { config, active, processingDhcp } = this.props.dhcp;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e1bb428a6a32e43ffad711ab641cd37eeec91769
client/src/components/Logs/index.js
processingRules: PropTypes.bool, logStatusProcessing: PropTypes.bool,
<mask> setRules: PropTypes.func, <mask> addSuccessToast: PropTypes.func, <mask> t: PropTypes.func, <mask> }; <mask> <mask> export default withNamespaces()(Logs); </s> Only allow single click on buttons Closes #544 </s> remove dispatch(refreshFiltersRequest); </s> add dispatch(refreshFiltersRequest()); </s> remove const newState = { ...state, config: newConfig }; </s> add const newState = { ...state, config: newConfig, processingDhcp: false }; </s> remove const newState = { ...state, protectionEnabled: !state.protectionEnabled }; </s> add const newState = { ...state, protectionEnabled: !state.protectionEnabled, processingProtection: false, };
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e1bb428a6a32e43ffad711ab641cd37eeec91769
client/src/components/Logs/index.js
const { config, active, processingDhcp } = this.props.dhcp;
<mask> this.props.findActiveDhcp(config.interface_name); <mask> } <mask> <mask> getToggleDhcpButton = () => { <mask> const { config, active } = this.props.dhcp; <mask> const activeDhcpFound = active && active.found; <mask> const filledConfig = Object.keys(config).every((key) => { <mask> if (key === 'enabled') { <mask> return true; <mask> } </s> Only allow single click on buttons Closes #544 </s> remove dispatch(refreshFiltersSuccess); </s> add dispatch(refreshFiltersSuccess()); </s> remove <input type="text" className={inputNameClass} placeholder={ this.props.t('enter_name_hint') } onChange={this.handleNameChange} /> <input type="text" className={inputUrlClass} placeholder={ this.props.t('enter_url_hint') } onChange={this.handleUrlChange} /> </s> add <input type="text" className={inputNameClass} placeholder={this.props.t('enter_name_hint')} onChange={this.handleNameChange} /> <input type="text" className={inputUrlClass} placeholder={this.props.t('enter_url_hint')} onChange={this.handleUrlChange} /> </s> remove const { filters, userRules } = this.props.filtering; </s> add const { filters, userRules, processingRefreshFilters } = this.props.filtering; </s> remove const { protectionEnabled } = this.props.dashboard; </s> add const { protectionEnabled, processingProtection } = this.props.dashboard; </s> remove const newState = { ...state, protectionEnabled: !state.protectionEnabled }; </s> add const newState = { ...state, protectionEnabled: !state.protectionEnabled, processingProtection: false, };
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/e1bb428a6a32e43ffad711ab641cd37eeec91769
client/src/components/Settings/Dhcp/index.js