docstring_tokens
stringlengths 18
16.9k
| code_tokens
stringlengths 75
1.81M
| html_url
stringlengths 74
116
| file_name
stringlengths 3
311
|
---|---|---|---|
keep replace replace replace keep keep replace replace | <mask>
<mask> // New - create object
<mask> func New(conf Config) (Stats, error) {
<mask> return createObject(conf)
<mask> }
<mask>
<mask> // Stats - main interface
<mask> type Stats interface {
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove limit uint32 // maximum time we need to keep data for (in hours)
}
</s> add // Filename is the name of the database file.
Filename string </s> remove // Close object.
// This function is not thread safe
// (can't be called in parallel with any other function of this interface).
</s> add // Close stops the statistics collecting. </s> remove stats.Stats
</s> add stats.Interface </s> remove Stats stats.Stats
</s> add Stats stats.Interface </s> remove // createObject creates s from conf and properly initializes it.
func createObject(conf Config) (s *statsCtx, err error) {
</s> add // isEnabled is a helper that check if the statistics collecting is enabled.
func (s *StatsCtx) isEnabled() (ok bool) {
return atomic.LoadUint32(&s.limitHours) != 0
}
// New creates s from conf and properly initializes it. Don't use s before
// calling it's Start method.
func New(conf Config) (s *StatsCtx, err error) { | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/stats.go |
keep replace replace replace keep keep replace keep keep keep keep | <mask>
<mask> // Close object.
<mask> // This function is not thread safe
<mask> // (can't be called in parallel with any other function of this interface).
<mask> Close()
<mask>
<mask> // Update counters
<mask> Update(e Entry)
<mask>
<mask> // Get IP addresses of the clients with the most number of requests
<mask> GetTopClientsIP(limit uint) []net.IP
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove // Get IP addresses of the clients with the most number of requests
</s> add // GetTopClientIP returns at most limit IP addresses corresponding to the
// clients with the most number of requests. </s> remove // Stats - main interface
type Stats interface {
</s> add // Interface is the statistics interface to be used by other packages.
type Interface interface {
// Start begins the statistics collecting. </s> remove // WriteDiskConfig - write configuration
</s> add // WriteDiskConfig puts the Interface's configuration to the dc. </s> remove // top:
domains map[string]uint64 // number of requests per domain
blockedDomains map[string]uint64 // number of blocked requests per domain
clients map[string]uint64 // number of requests per client
</s> add old, s.curr = s.curr, with
return old </s> remove nTotal uint64 // total requests
nResult []uint64 // number of requests per one result
timeSum uint64 // sum of processing time of all requests (usec)
</s> add // swapCurrent swaps the current unit with another and returns it. It's safe
// for concurrent use.
func (s *StatsCtx) swapCurrent(with *unit) (old *unit) {
s.currMu.Lock()
defer s.currMu.Unlock() | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/stats.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> // Update counters
<mask> Update(e Entry)
<mask>
<mask> // Get IP addresses of the clients with the most number of requests
<mask> GetTopClientsIP(limit uint) []net.IP
<mask>
<mask> // WriteDiskConfig - write configuration
<mask> WriteDiskConfig(dc *DiskConfig)
<mask> }
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove // WriteDiskConfig - write configuration
</s> add // WriteDiskConfig puts the Interface's configuration to the dc. </s> remove // Update counters
</s> add // Update collects the incoming statistics data. </s> remove // TimeUnit - time unit
</s> add // TimeUnit is the unit of measuring time while aggregating the statistics. </s> remove // Close object.
// This function is not thread safe
// (can't be called in parallel with any other function of this interface).
</s> add // Close stops the statistics collecting. </s> remove // top:
domains map[string]uint64 // number of requests per domain
blockedDomains map[string]uint64 // number of blocked requests per domain
clients map[string]uint64 // number of requests per client
</s> add old, s.curr = s.curr, with
return old </s> remove nTotal uint64 // total requests
nResult []uint64 // number of requests per one result
timeSum uint64 // sum of processing time of all requests (usec)
</s> add // swapCurrent swaps the current unit with another and returns it. It's safe
// for concurrent use.
func (s *StatsCtx) swapCurrent(with *unit) (old *unit) {
s.currMu.Lock()
defer s.currMu.Unlock() | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/stats.go |
keep keep keep keep replace keep keep keep replace | <mask>
<mask> // Get IP addresses of the clients with the most number of requests
<mask> GetTopClientsIP(limit uint) []net.IP
<mask>
<mask> // WriteDiskConfig - write configuration
<mask> WriteDiskConfig(dc *DiskConfig)
<mask> }
<mask>
<mask> // TimeUnit - time unit
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove // Get IP addresses of the clients with the most number of requests
</s> add // GetTopClientIP returns at most limit IP addresses corresponding to the
// clients with the most number of requests. </s> remove // Update counters
</s> add // Update collects the incoming statistics data. </s> remove nTotal uint64 // total requests
nResult []uint64 // number of requests per one result
timeSum uint64 // sum of processing time of all requests (usec)
</s> add // swapCurrent swaps the current unit with another and returns it. It's safe
// for concurrent use.
func (s *StatsCtx) swapCurrent(with *unit) (old *unit) {
s.currMu.Lock()
defer s.currMu.Unlock() </s> remove // top:
domains map[string]uint64 // number of requests per domain
blockedDomains map[string]uint64 // number of blocked requests per domain
clients map[string]uint64 // number of requests per client
</s> add old, s.curr = s.curr, with
return old </s> remove id uint32 // unit ID. Default: absolute hour since Jan 1, 1970
</s> add // mu protects all the fields of a unit.
mu *sync.RWMutex
// id is the unique unit's identifier. It's set to an absolute hour number
// since the beginning of UNIX time by the default ID generating function.
id uint32
// nTotal stores the total number of requests.
nTotal uint64
// nResult stores the number of requests grouped by it's result.
nResult []uint64
// timeSum stores the sum of processing time in milliseconds of each request
// written by the unit.
timeSum uint64
// domains stores the number of requests for each domain.
domains map[string]uint64
// blockedDomains stores the number of requests for each domain that has
// been blocked.
blockedDomains map[string]uint64
// clients stores the number of requests from each client.
clients map[string]uint64
}
// ongoing returns the current unit. It's safe for concurrent use.
//
// Note that the unit itself should be locked before accessing.
func (s *StatsCtx) ongoing() (u *unit) {
s.currMu.Lock()
defer s.currMu.Unlock()
return s.curr
} | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/stats.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> // TimeUnit - time unit
<mask> type TimeUnit int
<mask>
<mask> // Supported time units
<mask> const (
<mask> Hours TimeUnit = iota
<mask> Days
<mask> )
<mask>
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove // TimeUnit - time unit
</s> add // TimeUnit is the unit of measuring time while aggregating the statistics. </s> remove // Result of DNS request processing
</s> add // Result is the resulting code of processing the DNS request. </s> remove // WriteDiskConfig - write configuration
</s> add // WriteDiskConfig puts the Interface's configuration to the dc. </s> remove // Supported result values
</s> add // Supported Result values.
//
// TODO(e.burkov): Think about better naming. </s> remove // DiskConfig - configuration settings that are stored on disk
</s> add // DiskConfig is the configuration structure that is stored in file. </s> remove // Config - module configuration
</s> add // Config is the configuration structure for the statistics collecting. | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/stats.go |
keep keep keep keep replace keep keep keep keep keep | <mask> Hours TimeUnit = iota
<mask> Days
<mask> )
<mask>
<mask> // Result of DNS request processing
<mask> type Result int
<mask>
<mask> // Supported result values
<mask> const (
<mask> RNotFiltered Result = iota + 1
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove // Supported result values
</s> add // Supported Result values.
//
// TODO(e.burkov): Think about better naming. </s> remove // Supported time units
</s> add // Supported TimeUnit values. </s> remove // TimeUnit - time unit
</s> add // TimeUnit is the unit of measuring time while aggregating the statistics. </s> add // Result is the result of processing the request. </s> add // Domain is the domain name requested. </s> remove Time uint32 // processing time (msec)
</s> add // Time is the duration of the request processing in milliseconds.
Time uint32 | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/stats.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> // Result of DNS request processing
<mask> type Result int
<mask>
<mask> // Supported result values
<mask> const (
<mask> RNotFiltered Result = iota + 1
<mask> RFiltered
<mask> RSafeBrowsing
<mask> RSafeSearch
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove // Result of DNS request processing
</s> add // Result is the resulting code of processing the DNS request. </s> add // Result is the result of processing the request. </s> add // Domain is the domain name requested. </s> remove Time uint32 // processing time (msec)
</s> add // Time is the duration of the request processing in milliseconds.
Time uint32 </s> remove // Supported time units
</s> add // Supported TimeUnit values. </s> remove rLast
</s> add resultLast = RParental + 1 | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/stats.go |
keep keep keep keep replace keep keep keep keep keep | <mask> RFiltered
<mask> RSafeBrowsing
<mask> RSafeSearch
<mask> RParental
<mask> rLast
<mask> )
<mask>
<mask> // Entry is a statistics data entry.
<mask> type Entry struct {
<mask> // Clients is the client's primary ID.
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove // Supported result values
</s> add // Supported Result values.
//
// TODO(e.burkov): Think about better naming. </s> remove type unitIDCallback func() uint32
</s> add // UnitIDGenFunc is the signature of a function that generates a unique ID for
// the statistics unit.
type UnitIDGenFunc func() (id uint32) </s> remove // data for 1 time unit
</s> add // unit collects the statistics data for a specific period of time. </s> remove db *bolt.DB
conf *Config
</s> add // filename is the name of database file.
filename string
// limitHours is the maximum number of hours to collect statistics into the
// current unit.
limitHours uint32 </s> remove // Config - module configuration
</s> add // Config is the configuration structure for the statistics collecting. </s> remove NTotal uint64
</s> add // NTotal is the total number of requests.
NTotal uint64
// NResult is the number of requests by the result's kind. | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/stats.go |
keep add keep keep keep keep keep | <mask> Client string
<mask>
<mask> Domain string
<mask>
<mask> // Result is the result of processing the request.
<mask> Result Result
<mask>
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> add // Result is the result of processing the request. </s> remove Time uint32 // processing time (msec)
</s> add // Time is the duration of the request processing in milliseconds.
Time uint32 </s> remove // Result of DNS request processing
</s> add // Result is the resulting code of processing the DNS request. </s> remove // Supported result values
</s> add // Supported Result values.
//
// TODO(e.burkov): Think about better naming. </s> remove // top:
domains map[string]uint64 // number of requests per domain
blockedDomains map[string]uint64 // number of blocked requests per domain
clients map[string]uint64 // number of requests per client
</s> add old, s.curr = s.curr, with
return old </s> remove db *bolt.DB
conf *Config
</s> add // filename is the name of database file.
filename string
// limitHours is the maximum number of hours to collect statistics into the
// current unit.
limitHours uint32 | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/stats.go |
keep keep add keep keep keep keep | <mask>
<mask> // Domain is the domain name requested.
<mask> Domain string
<mask> Result Result
<mask>
<mask> // Time is the duration of the request processing in milliseconds.
<mask> Time uint32
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove Time uint32 // processing time (msec)
</s> add // Time is the duration of the request processing in milliseconds.
Time uint32 </s> add // Domain is the domain name requested. </s> remove // Result of DNS request processing
</s> add // Result is the resulting code of processing the DNS request. </s> remove // Supported result values
</s> add // Supported Result values.
//
// TODO(e.burkov): Think about better naming. </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"`
</s> add HTTPRegister aghhttp.RegisterFunc `yaml:"-"` </s> remove TimeAvg uint32 // usec
</s> add // TimeAvg is the average of processing times in milliseconds of all the
// requests in the unit.
TimeAvg uint32 | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/stats.go |
keep keep keep keep replace keep | <mask> Client string
<mask>
<mask> Domain string
<mask> Result Result
<mask> Time uint32 // processing time (msec)
<mask> }
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> add // Domain is the domain name requested. </s> add // Result is the result of processing the request. </s> remove // Result of DNS request processing
</s> add // Result is the resulting code of processing the DNS request. </s> remove // Supported result values
</s> add // Supported Result values.
//
// TODO(e.burkov): Think about better naming. </s> remove // Config - module configuration
</s> add // Config is the configuration structure for the statistics collecting. </s> remove limit uint32 // maximum time we need to keep data for (in hours)
}
</s> add // Filename is the name of the database file.
Filename string | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/stats.go |
keep keep keep keep replace keep keep keep keep keep | <mask> Filename: "./stats.db",
<mask> LimitDays: 1,
<mask> }
<mask>
<mask> s, err := createObject(conf)
<mask> require.NoError(t, err)
<mask> testutil.CleanupAndRequireSuccess(t, func() (err error) {
<mask> s.clear()
<mask> s.Close()
<mask>
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove s, err := createObject(conf)
</s> add s, err := New(conf) </s> remove ) (f func(name []byte, b *bolt.Bucket) (err error)) {
return func(name []byte, _ *bolt.Bucket) (err error) {
</s> add ) (f func(name []byte, b *bbolt.Bucket) (err error)) {
return func(name []byte, _ *bbolt.Bucket) (err error) { </s> remove func (s *statsCtx) dbOpen() bool {
var err error
</s> add // dbOpen returns an error if the database can't be opened from the specified
// file. It's safe for concurrent use.
func (s *StatsCtx) dbOpen() (err error) { </s> remove log.Debug("tx.Commit: %s", err)
</s> add log.Error("stats: committing a transaction: %s", err)
</s> remove log.Error("db.Begin: %s", err)
</s> add log.Error("stats: opening a transaction: %s", err)
</s> remove // createObject creates s from conf and properly initializes it.
func createObject(conf Config) (s *statsCtx, err error) {
</s> add // isEnabled is a helper that check if the statistics collecting is enabled.
func (s *StatsCtx) isEnabled() (ok bool) {
return atomic.LoadUint32(&s.limitHours) != 0
}
// New creates s from conf and properly initializes it. Don't use s before
// calling it's Start method.
func New(conf Config) (s *StatsCtx, err error) { | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/stats_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> Filename: "./stats.db",
<mask> LimitDays: 1,
<mask> UnitID: newID,
<mask> }
<mask> s, err := createObject(conf)
<mask> require.NoError(t, err)
<mask> testutil.CleanupAndRequireSuccess(t, func() (err error) {
<mask> s.Close()
<mask>
<mask> return os.Remove(conf.Filename)
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove s, err := createObject(conf)
</s> add s, err := New(conf) </s> remove ) (f func(name []byte, b *bolt.Bucket) (err error)) {
return func(name []byte, _ *bolt.Bucket) (err error) {
</s> add ) (f func(name []byte, b *bbolt.Bucket) (err error)) {
return func(name []byte, _ *bbolt.Bucket) (err error) { </s> remove func (s *statsCtx) dbOpen() bool {
var err error
</s> add // dbOpen returns an error if the database can't be opened from the specified
// file. It's safe for concurrent use.
func (s *StatsCtx) dbOpen() (err error) { </s> remove log.Debug("tx.Commit: %s", err)
</s> add log.Error("stats: committing a transaction: %s", err)
</s> remove log.Error("db.Begin: %s", err)
</s> add log.Error("stats: opening a transaction: %s", err)
</s> remove log.Tracef("db.Begin...")
tx, err := db.Begin(wr)
</s> add log.Tracef("opening a database transaction")
tx, err := db.Begin(writable) | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/stats_test.go |
keep keep keep add keep keep keep keep keep | <mask> "net"
<mask> "os"
<mask> "sort"
<mask> "sync"
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/log"
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove "net/http"
</s> add </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> remove "net/http"
</s> add </s> add "encoding" | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep add keep keep keep keep keep keep | <mask> "time"
<mask>
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "go.etcd.io/bbolt"
<mask> )
<mask>
<mask> // TODO(a.garipov): Rewrite all of this. Add proper error handling and
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove bolt "go.etcd.io/bbolt"
</s> add "go.etcd.io/bbolt" </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> add "sync/atomic" </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> remove TimeAvg uint32 // usec
</s> add // TimeAvg is the average of processing times in milliseconds of all the
// requests in the unit.
TimeAvg uint32 </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace keep keep keep keep keep | <mask> "time"
<mask>
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> bolt "go.etcd.io/bbolt"
<mask> )
<mask>
<mask> // TODO(a.garipov): Rewrite all of this. Add proper error handling and
<mask> // inspection. Improve logging. Decrease complexity.
<mask>
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> add "sync/atomic" </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> remove TimeAvg uint32 // usec
</s> add // TimeAvg is the average of processing times in milliseconds of all the
// requests in the unit.
TimeAvg uint32 </s> remove Clients []countPair
</s> add // Clients is the number of requests from each client.
Clients []countPair | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep replace replace replace replace replace replace keep replace replace keep | <mask>
<mask> // statsCtx - global context
<mask> type statsCtx struct {
<mask> // mu protects unit.
<mask> mu *sync.Mutex
<mask> // current is the actual statistics collection result.
<mask> current *unit
<mask>
<mask> db *bolt.DB
<mask> conf *Config
<mask> }
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove // data for 1 time unit
</s> add // unit collects the statistics data for a specific period of time. </s> remove // Config - module configuration
</s> add // Config is the configuration structure for the statistics collecting. </s> remove id uint32 // unit ID. Default: absolute hour since Jan 1, 1970
</s> add // mu protects all the fields of a unit.
mu *sync.RWMutex
// id is the unique unit's identifier. It's set to an absolute hour number
// since the beginning of UNIX time by the default ID generating function.
id uint32
// nTotal stores the total number of requests.
nTotal uint64
// nResult stores the number of requests grouped by it's result.
nResult []uint64
// timeSum stores the sum of processing time in milliseconds of each request
// written by the unit.
timeSum uint64
// domains stores the number of requests for each domain.
domains map[string]uint64
// blockedDomains stores the number of requests for each domain that has
// been blocked.
blockedDomains map[string]uint64
// clients stores the number of requests from each client.
clients map[string]uint64
}
// ongoing returns the current unit. It's safe for concurrent use.
//
// Note that the unit itself should be locked before accessing.
func (s *StatsCtx) ongoing() (u *unit) {
s.currMu.Lock()
defer s.currMu.Unlock()
return s.curr
} </s> remove // New - create object
func New(conf Config) (Stats, error) {
return createObject(conf)
</s> add // LimitDays is the maximum number of days to collect statistics into the
// current unit.
LimitDays uint32 </s> remove Filename string // database file name
LimitDays uint32 // time limit (in days)
UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used.
</s> add // UnitID is the function to generate the identifier for current unit. If
// nil, the default function is used, see newUnitID.
UnitID UnitIDGenFunc | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep replace keep replace keep | <mask>
<mask> // data for 1 time unit
<mask> type unit struct {
<mask> id uint32 // unit ID. Default: absolute hour since Jan 1, 1970
<mask>
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove db *bolt.DB
conf *Config
</s> add // filename is the name of database file.
filename string
// limitHours is the maximum number of hours to collect statistics into the
// current unit.
limitHours uint32 </s> remove nTotal uint64 // total requests
nResult []uint64 // number of requests per one result
timeSum uint64 // sum of processing time of all requests (usec)
</s> add // swapCurrent swaps the current unit with another and returns it. It's safe
// for concurrent use.
func (s *StatsCtx) swapCurrent(with *unit) (old *unit) {
s.currMu.Lock()
defer s.currMu.Unlock() </s> remove // Config - module configuration
</s> add // Config is the configuration structure for the statistics collecting. </s> remove // Get unit ID for the current hour
func newUnitID() uint32 {
return uint32(time.Now().Unix() / (60 * 60))
</s> add // newUnitID is the default UnitIDGenFunc that generates the unique id hourly.
func newUnitID() (id uint32) {
const secsInHour = int64(time.Hour / time.Second)
return uint32(time.Now().Unix() / secsInHour) </s> remove Filename string // database file name
LimitDays uint32 // time limit (in days)
UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used.
</s> add // UnitID is the function to generate the identifier for current unit. If
// nil, the default function is used, see newUnitID.
UnitID UnitIDGenFunc | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep replace replace replace keep replace replace replace replace keep keep keep keep | <mask> type unit struct {
<mask> id uint32 // unit ID. Default: absolute hour since Jan 1, 1970
<mask>
<mask> nTotal uint64 // total requests
<mask> nResult []uint64 // number of requests per one result
<mask> timeSum uint64 // sum of processing time of all requests (usec)
<mask>
<mask> // top:
<mask> domains map[string]uint64 // number of requests per domain
<mask> blockedDomains map[string]uint64 // number of blocked requests per domain
<mask> clients map[string]uint64 // number of requests per client
<mask> }
<mask>
<mask> // name-count pair
<mask> type countPair struct {
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove id uint32 // unit ID. Default: absolute hour since Jan 1, 1970
</s> add // mu protects all the fields of a unit.
mu *sync.RWMutex
// id is the unique unit's identifier. It's set to an absolute hour number
// since the beginning of UNIX time by the default ID generating function.
id uint32
// nTotal stores the total number of requests.
nTotal uint64
// nResult stores the number of requests grouped by it's result.
nResult []uint64
// timeSum stores the sum of processing time in milliseconds of each request
// written by the unit.
timeSum uint64
// domains stores the number of requests for each domain.
domains map[string]uint64
// blockedDomains stores the number of requests for each domain that has
// been blocked.
blockedDomains map[string]uint64
// clients stores the number of requests from each client.
clients map[string]uint64
}
// ongoing returns the current unit. It's safe for concurrent use.
//
// Note that the unit itself should be locked before accessing.
func (s *StatsCtx) ongoing() (u *unit) {
s.currMu.Lock()
defer s.currMu.Unlock()
return s.curr
} </s> remove // data for 1 time unit
</s> add // unit collects the statistics data for a specific period of time. </s> remove // name-count pair
</s> add // database returns the database if it's opened. It's safe for concurrent use.
func (s *StatsCtx) database() (db *bbolt.DB) {
s.dbMu.Lock()
defer s.dbMu.Unlock()
return s.db
}
// swapDatabase swaps the database with another one and returns it. It's safe
// for concurrent use.
func (s *StatsCtx) swapDatabase(with *bbolt.DB) (old *bbolt.DB) {
s.dbMu.Lock()
defer s.dbMu.Unlock()
old, s.db = s.db, with
return old
}
// countPair is a single name-number pair for deserializing statistics data into
// the database. </s> remove Domains []countPair
</s> add // Domains is the number of requests for each domain name.
Domains []countPair
// BlockedDomains is the number of requests blocked for each domain name. </s> remove NTotal uint64
</s> add // NTotal is the total number of requests.
NTotal uint64
// NResult is the number of requests by the result's kind. | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace keep keep keep keep keep | <mask> blockedDomains map[string]uint64 // number of blocked requests per domain
<mask> clients map[string]uint64 // number of requests per client
<mask> }
<mask>
<mask> // name-count pair
<mask> type countPair struct {
<mask> Name string
<mask> Count uint64
<mask> }
<mask>
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove // top:
domains map[string]uint64 // number of requests per domain
blockedDomains map[string]uint64 // number of blocked requests per domain
clients map[string]uint64 // number of requests per client
</s> add old, s.curr = s.curr, with
return old </s> remove nTotal uint64 // total requests
nResult []uint64 // number of requests per one result
timeSum uint64 // sum of processing time of all requests (usec)
</s> add // swapCurrent swaps the current unit with another and returns it. It's safe
// for concurrent use.
func (s *StatsCtx) swapCurrent(with *unit) (old *unit) {
s.currMu.Lock()
defer s.currMu.Unlock() </s> remove id uint32 // unit ID. Default: absolute hour since Jan 1, 1970
</s> add // mu protects all the fields of a unit.
mu *sync.RWMutex
// id is the unique unit's identifier. It's set to an absolute hour number
// since the beginning of UNIX time by the default ID generating function.
id uint32
// nTotal stores the total number of requests.
nTotal uint64
// nResult stores the number of requests grouped by it's result.
nResult []uint64
// timeSum stores the sum of processing time in milliseconds of each request
// written by the unit.
timeSum uint64
// domains stores the number of requests for each domain.
domains map[string]uint64
// blockedDomains stores the number of requests for each domain that has
// been blocked.
blockedDomains map[string]uint64
// clients stores the number of requests from each client.
clients map[string]uint64
}
// ongoing returns the current unit. It's safe for concurrent use.
//
// Note that the unit itself should be locked before accessing.
func (s *StatsCtx) ongoing() (u *unit) {
s.currMu.Lock()
defer s.currMu.Unlock()
return s.curr
} </s> remove Domains []countPair
</s> add // Domains is the number of requests for each domain name.
Domains []countPair
// BlockedDomains is the number of requests blocked for each domain name. </s> remove // data for 1 time unit
</s> add // unit collects the statistics data for a specific period of time. </s> remove NTotal uint64
</s> add // NTotal is the total number of requests.
NTotal uint64
// NResult is the number of requests by the result's kind. | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep replace keep replace keep | <mask> }
<mask>
<mask> // structure for storing data in file
<mask> type unitDB struct {
<mask> NTotal uint64
<mask> NResult []uint64
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove Domains []countPair
</s> add // Domains is the number of requests for each domain name.
Domains []countPair
// BlockedDomains is the number of requests blocked for each domain name. </s> remove // data for 1 time unit
</s> add // unit collects the statistics data for a specific period of time. </s> remove // DiskConfig - configuration settings that are stored on disk
</s> add // DiskConfig is the configuration structure that is stored in file. </s> remove // Config - module configuration
</s> add // Config is the configuration structure for the statistics collecting. </s> remove id uint32 // unit ID. Default: absolute hour since Jan 1, 1970
</s> add // mu protects all the fields of a unit.
mu *sync.RWMutex
// id is the unique unit's identifier. It's set to an absolute hour number
// since the beginning of UNIX time by the default ID generating function.
id uint32
// nTotal stores the total number of requests.
nTotal uint64
// nResult stores the number of requests grouped by it's result.
nResult []uint64
// timeSum stores the sum of processing time in milliseconds of each request
// written by the unit.
timeSum uint64
// domains stores the number of requests for each domain.
domains map[string]uint64
// blockedDomains stores the number of requests for each domain that has
// been blocked.
blockedDomains map[string]uint64
// clients stores the number of requests from each client.
clients map[string]uint64
}
// ongoing returns the current unit. It's safe for concurrent use.
//
// Note that the unit itself should be locked before accessing.
func (s *StatsCtx) ongoing() (u *unit) {
s.currMu.Lock()
defer s.currMu.Unlock()
return s.curr
} | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep replace keep replace keep keep keep | <mask> NTotal uint64
<mask> NResult []uint64
<mask>
<mask> Domains []countPair
<mask> BlockedDomains []countPair
<mask> Clients []countPair
<mask>
<mask> TimeAvg uint32 // usec
<mask> }
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove NTotal uint64
</s> add // NTotal is the total number of requests.
NTotal uint64
// NResult is the number of requests by the result's kind. </s> remove TimeAvg uint32 // usec
</s> add // TimeAvg is the average of processing times in milliseconds of all the
// requests in the unit.
TimeAvg uint32 </s> remove // structure for storing data in file
</s> add // unitDB is the structure for deserializing statistics data into the database. </s> remove pair := countPair{}
pair.Name = k
pair.Count = v
a = append(a, pair)
</s> add a = append(a, countPair{Name: k, Count: v}) </s> remove // data for 1 time unit
</s> add // unit collects the statistics data for a specific period of time. | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace keep keep keep keep keep | <mask> Domains []countPair
<mask> BlockedDomains []countPair
<mask> Clients []countPair
<mask>
<mask> TimeAvg uint32 // usec
<mask> }
<mask>
<mask> // withRecovered turns the value recovered from panic if any into an error and
<mask> // combines it with the one pointed by orig. orig must be non-nil.
<mask> func withRecovered(orig *error) {
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove Clients []countPair
</s> add // Clients is the number of requests from each client.
Clients []countPair </s> remove Domains []countPair
</s> add // Domains is the number of requests for each domain name.
Domains []countPair
// BlockedDomains is the number of requests blocked for each domain name. </s> remove NTotal uint64
</s> add // NTotal is the total number of requests.
NTotal uint64
// NResult is the number of requests by the result's kind. </s> remove // structure for storing data in file
</s> add // unitDB is the structure for deserializing statistics data into the database. </s> remove func (s *statsCtx) ongoing() (u *unit) {
s.mu.Lock()
defer s.mu.Unlock()
return s.current
}
</s> add </s> remove // Stats - main interface
type Stats interface {
</s> add // Interface is the statistics interface to be used by other packages.
type Interface interface {
// Start begins the statistics collecting. | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep replace replace keep keep replace replace keep | <mask> *orig = errors.WithDeferred(*orig, err)
<mask> }
<mask>
<mask> // createObject creates s from conf and properly initializes it.
<mask> func createObject(conf Config) (s *statsCtx, err error) {
<mask> defer withRecovered(&err)
<mask>
<mask> s = &statsCtx{
<mask> mu: &sync.Mutex{},
<mask> }
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove if !checkInterval(conf.LimitDays) {
conf.LimitDays = 1
</s> add if s.limitHours = conf.LimitDays * 24; !checkInterval(conf.LimitDays) {
s.limitHours = 24 </s> remove func (s *statsCtx) Start() {
</s> add // Start makes s process the incoming data.
func (s *StatsCtx) Start() { </s> remove // name-count pair
</s> add // database returns the database if it's opened. It's safe for concurrent use.
func (s *StatsCtx) database() (db *bbolt.DB) {
s.dbMu.Lock()
defer s.dbMu.Unlock()
return s.db
}
// swapDatabase swaps the database with another one and returns it. It's safe
// for concurrent use.
func (s *StatsCtx) swapDatabase(with *bbolt.DB) (old *bbolt.DB) {
s.dbMu.Lock()
defer s.dbMu.Unlock()
old, s.db = s.db, with
return old
}
// countPair is a single name-number pair for deserializing statistics data into
// the database. </s> remove // Delete unit's data from file
func (s *statsCtx) deleteUnit(tx *bolt.Tx, id uint32) bool {
</s> add // deleteUnit removes the unit by it's id from the database the tx belongs to.
func (s *StatsCtx) deleteUnit(tx *bbolt.Tx, id uint32) bool { </s> remove func (s *statsCtx) dbOpen() bool {
var err error
</s> add // dbOpen returns an error if the database can't be opened from the specified
// file. It's safe for concurrent use.
func (s *StatsCtx) dbOpen() (err error) { | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask>
<mask> s = &statsCtx{
<mask> mu: &sync.Mutex{},
<mask> }
<mask> if !checkInterval(conf.LimitDays) {
<mask> conf.LimitDays = 1
<mask> }
<mask>
<mask> s.conf = &Config{}
<mask> *s.conf = conf
<mask> s.conf.limit = conf.LimitDays * 24
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove
s.conf = &Config{}
*s.conf = conf
s.conf.limit = conf.LimitDays * 24
if conf.UnitID == nil {
s.conf.UnitID = newUnitID
</s> add if s.unitIDGen = newUnitID; conf.UnitID != nil {
s.unitIDGen = conf.UnitID </s> remove s = &statsCtx{
mu: &sync.Mutex{},
</s> add s = &StatsCtx{
currMu: &sync.Mutex{},
dbMu: &sync.Mutex{},
filename: conf.Filename,
configModified: conf.ConfigModified,
httpRegister: conf.HTTPRegister, </s> remove // createObject creates s from conf and properly initializes it.
func createObject(conf Config) (s *statsCtx, err error) {
</s> add // isEnabled is a helper that check if the statistics collecting is enabled.
func (s *StatsCtx) isEnabled() (ok bool) {
return atomic.LoadUint32(&s.limitHours) != 0
}
// New creates s from conf and properly initializes it. Don't use s before
// calling it's Start method.
func New(conf Config) (s *StatsCtx, err error) { </s> remove func (s *statsCtx) setLimit(limitDays int) {
s.conf.limit = uint32(limitDays) * 24
</s> add func (s *StatsCtx) setLimit(limitDays int) {
atomic.StoreUint32(&s.limitHours, uint32(24*limitDays)) </s> remove func (s *statsCtx) WriteDiskConfig(dc *DiskConfig) {
dc.Interval = s.conf.limit / 24
</s> add func (s *StatsCtx) WriteDiskConfig(dc *DiskConfig) {
dc.Interval = atomic.LoadUint32(&s.limitHours) / 24 </s> remove log.Debug("stats: set limit: %d", limitDays)
</s> add log.Debug("stats: set limit: %d days", limitDays) | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep replace replace replace replace replace replace keep keep replace replace keep keep keep keep | <mask> if !checkInterval(conf.LimitDays) {
<mask> conf.LimitDays = 1
<mask> }
<mask>
<mask> s.conf = &Config{}
<mask> *s.conf = conf
<mask> s.conf.limit = conf.LimitDays * 24
<mask> if conf.UnitID == nil {
<mask> s.conf.UnitID = newUnitID
<mask> }
<mask>
<mask> if !s.dbOpen() {
<mask> return nil, fmt.Errorf("open database")
<mask> }
<mask>
<mask> id := s.conf.UnitID()
<mask> tx := s.beginTxn(true)
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove if !checkInterval(conf.LimitDays) {
conf.LimitDays = 1
</s> add if s.limitHours = conf.LimitDays * 24; !checkInterval(conf.LimitDays) {
s.limitHours = 24 </s> remove id := s.conf.UnitID()
tx := s.beginTxn(true)
</s> add id := s.unitIDGen()
tx := beginTxn(s.db, true) </s> remove s = &statsCtx{
mu: &sync.Mutex{},
</s> add s = &StatsCtx{
currMu: &sync.Mutex{},
dbMu: &sync.Mutex{},
filename: conf.Filename,
configModified: conf.ConfigModified,
httpRegister: conf.HTTPRegister, </s> remove func (s *statsCtx) Close() {
u := s.swapUnit(nil)
udb := serialize(u)
tx := s.beginTxn(true)
if tx != nil {
if s.flushUnitToDB(tx, u.id, udb) {
</s> add func (s *StatsCtx) Close() {
u := s.swapCurrent(nil)
db := s.database()
if tx := beginTxn(db, true); tx != nil {
udb := u.serialize()
if flushUnitToDB(tx, u.id, udb) { </s> remove func (s *statsCtx) setLimit(limitDays int) {
s.conf.limit = uint32(limitDays) * 24
</s> add func (s *StatsCtx) setLimit(limitDays int) {
atomic.StoreUint32(&s.limitHours, uint32(24*limitDays)) | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace replace keep keep keep replace keep keep keep keep | <mask> if !s.dbOpen() {
<mask> return nil, fmt.Errorf("open database")
<mask> }
<mask>
<mask> id := s.conf.UnitID()
<mask> tx := s.beginTxn(true)
<mask> var udb *unitDB
<mask> if tx != nil {
<mask> log.Tracef("Deleting old units...")
<mask> firstID := id - s.conf.limit - 1
<mask> unitDel := 0
<mask>
<mask> err = tx.ForEach(newBucketWalker(tx, &unitDel, firstID))
<mask> if err != nil && !errors.Is(err, errStop) {
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove if !s.dbOpen() {
return nil, fmt.Errorf("open database")
</s> add if err = s.dbOpen(); err != nil {
return nil, fmt.Errorf("opening database: %w", err) </s> remove curID := cur.id
</s> add var curID uint32
if cur != nil {
curID = atomic.LoadUint32(&cur.id)
} else {
curID = s.unitIDGen()
} </s> remove
s.conf = &Config{}
*s.conf = conf
s.conf.limit = conf.LimitDays * 24
if conf.UnitID == nil {
s.conf.UnitID = newUnitID
</s> add if s.unitIDGen = newUnitID; conf.UnitID != nil {
s.unitIDGen = conf.UnitID </s> remove func (s *statsCtx) Close() {
u := s.swapUnit(nil)
udb := serialize(u)
tx := s.beginTxn(true)
if tx != nil {
if s.flushUnitToDB(tx, u.id, udb) {
</s> add func (s *StatsCtx) Close() {
u := s.swapCurrent(nil)
db := s.database()
if tx := beginTxn(db, true); tx != nil {
udb := u.serialize()
if flushUnitToDB(tx, u.id, udb) { </s> remove func (s *statsCtx) flushUnitToDB(tx *bolt.Tx, id uint32, udb *unitDB) bool {
</s> add func flushUnitToDB(tx *bbolt.Tx, id uint32, udb *unitDB) bool { | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace replace replace replace replace replace keep keep keep keep keep | <mask> }
<mask> }
<mask> }
<mask>
<mask> u := unit{}
<mask> s.initUnit(&u, id)
<mask> if udb != nil {
<mask> deserialize(&u, udb)
<mask> }
<mask> s.current = &u
<mask>
<mask> log.Debug("stats: initialized")
<mask>
<mask> return s, nil
<mask> }
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove nu := unit{}
s.initUnit(&nu, id)
u := s.swapUnit(&nu)
udb := serialize(u)
</s> add nu := newUnit(id)
u := s.swapCurrent(nu)
udb := u.serialize() </s> remove func (s *statsCtx) Close() {
u := s.swapUnit(nil)
udb := serialize(u)
tx := s.beginTxn(true)
if tx != nil {
if s.flushUnitToDB(tx, u.id, udb) {
</s> add func (s *StatsCtx) Close() {
u := s.swapCurrent(nil)
db := s.database()
if tx := beginTxn(db, true); tx != nil {
udb := u.serialize()
if flushUnitToDB(tx, u.id, udb) { </s> remove u := unit{}
s.initUnit(&u, s.conf.UnitID())
_ = s.swapUnit(&u)
</s> add u := newUnit(s.unitIDGen())
_ = s.swapCurrent(u) </s> remove err := os.Remove(s.conf.Filename)
</s> add err := os.Remove(s.filename) </s> remove s.mu.Lock()
defer s.mu.Unlock()
</s> add u := s.ongoing()
if u == nil {
return
} </s> remove tx := s.beginTxn(true)
</s> add tx := beginTxn(s.database(), true) | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep replace keep keep replace replace | <mask> func newBucketWalker(
<mask> tx *bolt.Tx,
<mask> unitDelPtr *int,
<mask> firstID uint32,
<mask> ) (f func(name []byte, b *bolt.Bucket) (err error)) {
<mask> return func(name []byte, _ *bolt.Bucket) (err error) {
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove s, err := createObject(conf)
</s> add s, err := New(conf) </s> remove s, err := createObject(conf)
</s> add s, err := New(conf) </s> remove func (s *statsCtx) flushUnitToDB(tx *bolt.Tx, id uint32, udb *unitDB) bool {
</s> add func flushUnitToDB(tx *bbolt.Tx, id uint32, udb *unitDB) bool { </s> remove func (s *statsCtx) dbOpen() bool {
var err error
</s> add // dbOpen returns an error if the database can't be opened from the specified
// file. It's safe for concurrent use.
func (s *StatsCtx) dbOpen() (err error) { </s> remove firstID := id - s.conf.limit - 1
</s> add firstID := id - s.limitHours - 1 | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep replace keep keep keep keep replace keep | <mask> }
<mask>
<mask> func (s *statsCtx) Start() {
<mask> s.initWeb()
<mask> go s.periodicFlush()
<mask> }
<mask>
<mask> func checkInterval(days uint32) bool {
<mask> return days == 0 || days == 1 || days == 7 || days == 30 || days == 90
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove func (s *statsCtx) dbOpen() bool {
var err error
</s> add // dbOpen returns an error if the database can't be opened from the specified
// file. It's safe for concurrent use.
func (s *StatsCtx) dbOpen() (err error) { </s> remove e.Result >= rLast ||
</s> add e.Result >= resultLast || </s> remove func (s *statsCtx) Update(e Entry) {
if s.conf.limit == 0 {
</s> add func (s *StatsCtx) Update(e Entry) {
if !s.isEnabled() { </s> remove ok1 := s.flushUnitToDB(tx, u.id, udb)
ok2 := s.deleteUnit(tx, id-s.conf.limit)
if ok1 || ok2 {
</s> add flushOK := flushUnitToDB(tx, u.id, udb)
delOK := s.deleteUnit(tx, id-atomic.LoadUint32(&s.limitHours))
if flushOK || delOK { </s> remove func (s *statsCtx) periodicFlush() {
for {
ptr := s.ongoing()
if ptr == nil {
break
}
id := s.conf.UnitID()
if ptr.id == id || s.conf.limit == 0 {
</s> add func (s *StatsCtx) periodicFlush() {
for ptr := s.ongoing(); ptr != nil; ptr = s.ongoing() {
id := s.unitIDGen()
// Access the unit's ID with atomic to avoid locking the whole unit.
if !s.isEnabled() || atomic.LoadUint32(&ptr.id) == id { | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep replace replace keep replace keep keep keep keep | <mask> return days == 0 || days == 1 || days == 7 || days == 30 || days == 90
<mask> }
<mask>
<mask> func (s *statsCtx) dbOpen() bool {
<mask> var err error
<mask> log.Tracef("db.Open...")
<mask> s.db, err = bolt.Open(s.conf.Filename, 0o644, nil)
<mask> if err != nil {
<mask> log.Error("stats: open DB: %s: %s", s.conf.Filename, err)
<mask> if err.Error() == "invalid argument" {
<mask> log.Error("AdGuard Home cannot be initialized due to an incompatible file system.\nPlease read the explanation here: https://github.com/AdguardTeam/AdGuardHome/wiki/Getting-Started#limitations")
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove log.Error("stats: open DB: %s: %s", s.conf.Filename, err)
</s> add log.Error("stats: open DB: %s: %s", s.filename, err) </s> remove func checkInterval(days uint32) bool {
</s> add // checkInterval returns true if days is valid to be used as statistics
// retention interval. The valid values are 0, 1, 7, 30 and 90.
func checkInterval(days uint32) (ok bool) { </s> remove return false
}
log.Tracef("db.Open")
return true
}
</s> add </s> remove e.Result >= rLast ||
</s> add e.Result >= resultLast || </s> remove func (s *statsCtx) Update(e Entry) {
if s.conf.limit == 0 {
</s> add func (s *StatsCtx) Update(e Entry) {
if !s.isEnabled() { | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace keep keep keep replace replace replace replace replace | <mask> var err error
<mask> log.Tracef("db.Open...")
<mask> s.db, err = bolt.Open(s.conf.Filename, 0o644, nil)
<mask> if err != nil {
<mask> log.Error("stats: open DB: %s: %s", s.conf.Filename, err)
<mask> if err.Error() == "invalid argument" {
<mask> log.Error("AdGuard Home cannot be initialized due to an incompatible file system.\nPlease read the explanation here: https://github.com/AdguardTeam/AdGuardHome/wiki/Getting-Started#limitations")
<mask> }
<mask> return false
<mask> }
<mask> log.Tracef("db.Open")
<mask> return true
<mask> }
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove s.db, err = bolt.Open(s.conf.Filename, 0o644, nil)
</s> add s.dbMu.Lock()
defer s.dbMu.Unlock()
s.db, err = bbolt.Open(s.filename, 0o644, nil) </s> remove func (s *statsCtx) dbOpen() bool {
var err error
</s> add // dbOpen returns an error if the database can't be opened from the specified
// file. It's safe for concurrent use.
func (s *StatsCtx) dbOpen() (err error) { </s> remove log.Debug("tx.Commit: %s", err)
</s> add log.Error("stats: committing a transaction: %s", err)
</s> remove log.Error("db.Begin: %s", err)
</s> add log.Error("stats: opening a transaction: %s", err)
</s> remove log.Tracef("db.Begin...")
tx, err := db.Begin(wr)
</s> add log.Tracef("opening a database transaction")
tx, err := db.Begin(writable) | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace replace replace replace replace keep replace replace keep keep | <mask> log.Tracef("db.Open")
<mask> return true
<mask> }
<mask>
<mask> // Atomically swap the currently active unit with a new value
<mask> // Return old value
<mask> func (s *statsCtx) swapUnit(new *unit) (u *unit) {
<mask> s.mu.Lock()
<mask> defer s.mu.Unlock()
<mask>
<mask> u = s.current
<mask> s.current = new
<mask>
<mask> return u
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove return false
}
log.Tracef("db.Open")
return true
}
</s> add </s> remove func (s *statsCtx) ongoing() (u *unit) {
s.mu.Lock()
defer s.mu.Unlock()
return s.current
}
</s> add </s> remove return u
</s> add return nil </s> remove s.mu.Lock()
defer s.mu.Unlock()
</s> add u := s.ongoing()
if u == nil {
return
} </s> remove u := s.current
</s> add u.mu.Lock()
defer u.mu.Unlock() | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> u = s.current
<mask> s.current = new
<mask>
<mask> return u
<mask> }
<mask>
<mask> // Get unit ID for the current hour
<mask> func newUnitID() uint32 {
<mask> return uint32(time.Now().Unix() / (60 * 60))
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove // Get unit ID for the current hour
func newUnitID() uint32 {
return uint32(time.Now().Unix() / (60 * 60))
</s> add // newUnitID is the default UnitIDGenFunc that generates the unique id hourly.
func newUnitID() (id uint32) {
const secsInHour = int64(time.Hour / time.Second)
return uint32(time.Now().Unix() / secsInHour) </s> remove u = s.current
s.current = new
</s> add log.Tracef("db.Open") </s> remove // Atomically swap the currently active unit with a new value
// Return old value
func (s *statsCtx) swapUnit(new *unit) (u *unit) {
s.mu.Lock()
defer s.mu.Unlock()
</s> add return err
} </s> remove // Initialize a unit
func (s *statsCtx) initUnit(u *unit, id uint32) {
u.id = id
u.nResult = make([]uint64, rLast)
u.domains = make(map[string]uint64)
u.blockedDomains = make(map[string]uint64)
u.clients = make(map[string]uint64)
</s> add // newUnit allocates the new *unit.
func newUnit(id uint32) (u *unit) {
return &unit{
mu: &sync.RWMutex{},
id: id,
nResult: make([]uint64, resultLast),
domains: make(map[string]uint64),
blockedDomains: make(map[string]uint64),
clients: make(map[string]uint64),
} </s> remove func (s *statsCtx) ongoing() (u *unit) {
s.mu.Lock()
defer s.mu.Unlock()
return s.current
}
</s> add </s> remove u := unit{}
s.initUnit(&u, id)
if udb != nil {
deserialize(&u, udb)
}
s.current = &u
</s> add u := newUnit(id)
// This use of deserialize is safe since the accessed unit has just been
// created.
u.deserialize(udb)
s.curr = u | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep replace replace replace keep keep replace replace replace replace replace replace replace keep keep keep | <mask> }
<mask>
<mask> // Get unit ID for the current hour
<mask> func newUnitID() uint32 {
<mask> return uint32(time.Now().Unix() / (60 * 60))
<mask> }
<mask>
<mask> // Initialize a unit
<mask> func (s *statsCtx) initUnit(u *unit, id uint32) {
<mask> u.id = id
<mask> u.nResult = make([]uint64, rLast)
<mask> u.domains = make(map[string]uint64)
<mask> u.blockedDomains = make(map[string]uint64)
<mask> u.clients = make(map[string]uint64)
<mask> }
<mask>
<mask> // Open a DB transaction
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove return u
</s> add return nil </s> remove // Open a DB transaction
func (s *statsCtx) beginTxn(wr bool) *bolt.Tx {
db := s.db
</s> add // beginTxn opens a new database transaction. If writable is true, the
// transaction will be opened for writing, and for reading otherwise. It
// returns nil if the transaction can't be created.
func beginTxn(db *bbolt.DB, writable bool) (tx *bbolt.Tx) { </s> remove u.timeSum = uint64(udb.TimeAvg) * u.nTotal
</s> add u.timeSum = uint64(udb.TimeAvg) * udb.NTotal </s> remove u = s.current
s.current = new
</s> add log.Tracef("db.Open") </s> add u.mu.Lock()
defer u.mu.Unlock()
u.nTotal = udb.NTotal
u.nResult = make([]uint64, resultLast)
copy(u.nResult, udb.NResult) | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep replace replace replace keep keep keep keep replace replace keep | <mask> }
<mask>
<mask> // Open a DB transaction
<mask> func (s *statsCtx) beginTxn(wr bool) *bolt.Tx {
<mask> db := s.db
<mask> if db == nil {
<mask> return nil
<mask> }
<mask>
<mask> log.Tracef("db.Begin...")
<mask> tx, err := db.Begin(wr)
<mask> if err != nil {
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove // Initialize a unit
func (s *statsCtx) initUnit(u *unit, id uint32) {
u.id = id
u.nResult = make([]uint64, rLast)
u.domains = make(map[string]uint64)
u.blockedDomains = make(map[string]uint64)
u.clients = make(map[string]uint64)
</s> add // newUnit allocates the new *unit.
func newUnit(id uint32) (u *unit) {
return &unit{
mu: &sync.RWMutex{},
id: id,
nResult: make([]uint64, resultLast),
domains: make(map[string]uint64),
blockedDomains: make(map[string]uint64),
clients: make(map[string]uint64),
} </s> remove log.Error("db.Begin: %s", err)
</s> add log.Error("stats: opening a transaction: %s", err)
</s> remove func (s *statsCtx) clear() {
tx := s.beginTxn(true)
</s> add func (s *StatsCtx) clear() {
db := s.database()
tx := beginTxn(db, true) </s> remove if s.db != nil {
</s> add if db != nil { </s> remove log.Debug("tx.Commit: %s", err)
</s> add log.Error("stats: committing a transaction: %s", err)
| https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep replace keep keep replace keep keep keep keep | <mask> if err != nil {
<mask> log.Error("db.Begin: %s", err)
<mask> return nil
<mask> }
<mask> log.Tracef("db.Begin")
<mask> return tx
<mask> }
<mask>
<mask> func (s *statsCtx) commitTxn(tx *bolt.Tx) {
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove func (s *statsCtx) commitTxn(tx *bolt.Tx) {
</s> add // commitTxn applies the changes made in tx to the database.
func (s *StatsCtx) commitTxn(tx *bbolt.Tx) { </s> remove log.Debug("tx.Commit: %s", err)
</s> add log.Error("stats: committing a transaction: %s", err)
</s> remove log.Tracef("db.Begin...")
tx, err := db.Begin(wr)
</s> add log.Tracef("opening a database transaction")
tx, err := db.Begin(writable) </s> remove func (s *statsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) {
</s> add func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> remove // Delete unit's data from file
func (s *statsCtx) deleteUnit(tx *bolt.Tx, id uint32) bool {
</s> add // deleteUnit removes the unit by it's id from the database the tx belongs to.
func (s *StatsCtx) deleteUnit(tx *bbolt.Tx, id uint32) bool { | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep replace keep keep replace keep keep | <mask> }
<mask>
<mask> func (s *statsCtx) commitTxn(tx *bolt.Tx) {
<mask> err := tx.Commit()
<mask> if err != nil {
<mask> log.Debug("tx.Commit: %s", err)
<mask> return
<mask> }
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove log.Tracef("db.Begin")
</s> add log.Tracef("transaction has been opened")
</s> remove log.Error("db.Begin: %s", err)
</s> add log.Error("stats: opening a transaction: %s", err)
</s> remove func (s *statsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) {
</s> add func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> remove log.Tracef("db.Begin...")
tx, err := db.Begin(wr)
</s> add log.Tracef("opening a database transaction")
tx, err := db.Begin(writable) </s> remove err := os.Remove(s.conf.Filename)
</s> add err := os.Remove(s.filename) | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace keep keep keep keep keep | <mask> if err != nil {
<mask> log.Debug("tx.Commit: %s", err)
<mask> return
<mask> }
<mask> log.Tracef("tx.Commit")
<mask> }
<mask>
<mask> // bucketNameLen is the length of a bucket, a 64-bit unsigned integer.
<mask> //
<mask> // TODO(a.garipov): Find out why a 64-bit integer is used when IDs seem to
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove log.Debug("tx.Commit: %s", err)
</s> add log.Error("stats: committing a transaction: %s", err)
</s> remove func (s *statsCtx) commitTxn(tx *bolt.Tx) {
</s> add // commitTxn applies the changes made in tx to the database.
func (s *StatsCtx) commitTxn(tx *bbolt.Tx) { </s> remove log.Error("db.Begin: %s", err)
</s> add log.Error("stats: opening a transaction: %s", err)
</s> remove name = make([]byte, bucketNameLen)
binary.BigEndian.PutUint64(name, uint64(id))
</s> add n := [bucketNameLen]byte{}
binary.BigEndian.PutUint64(n[:], uint64(id)) </s> remove func (s *statsCtx) ongoing() (u *unit) {
s.mu.Lock()
defer s.mu.Unlock()
return s.current
}
</s> add </s> remove log.Tracef("db.Begin...")
tx, err := db.Begin(wr)
</s> add log.Tracef("opening a database transaction")
tx, err := db.Begin(writable) | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace replace keep replace | <mask> const bucketNameLen = 8
<mask>
<mask> // idToUnitName converts a numerical ID into a database unit name.
<mask> func idToUnitName(id uint32) (name []byte) {
<mask> name = make([]byte, bucketNameLen)
<mask> binary.BigEndian.PutUint64(name, uint64(id))
<mask>
<mask> return name
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove // Get unit ID for the current hour
func newUnitID() uint32 {
return uint32(time.Now().Unix() / (60 * 60))
</s> add // newUnitID is the default UnitIDGenFunc that generates the unique id hourly.
func newUnitID() (id uint32) {
const secsInHour = int64(time.Hour / time.Second)
return uint32(time.Now().Unix() / secsInHour) </s> remove db *bolt.DB
conf *Config
</s> add // filename is the name of database file.
filename string
// limitHours is the maximum number of hours to collect statistics into the
// current unit.
limitHours uint32 </s> remove log.Tracef("tx.Commit")
</s> add log.Tracef("transaction has been committed") </s> remove // Initialize a unit
func (s *statsCtx) initUnit(u *unit, id uint32) {
u.id = id
u.nResult = make([]uint64, rLast)
u.domains = make(map[string]uint64)
u.blockedDomains = make(map[string]uint64)
u.clients = make(map[string]uint64)
</s> add // newUnit allocates the new *unit.
func newUnit(id uint32) (u *unit) {
return &unit{
mu: &sync.RWMutex{},
id: id,
nResult: make([]uint64, resultLast),
domains: make(map[string]uint64),
blockedDomains: make(map[string]uint64),
clients: make(map[string]uint64),
} </s> remove type unitIDCallback func() uint32
</s> add // UnitIDGenFunc is the signature of a function that generates a unique ID for
// the statistics unit.
type UnitIDGenFunc func() (id uint32) | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace replace replace replace replace replace replace keep keep keep keep keep | <mask>
<mask> return uint32(binary.BigEndian.Uint64(name)), true
<mask> }
<mask>
<mask> func (s *statsCtx) ongoing() (u *unit) {
<mask> s.mu.Lock()
<mask> defer s.mu.Unlock()
<mask>
<mask> return s.current
<mask> }
<mask>
<mask> // Flush the current unit to DB and delete an old unit when a new hour is started
<mask> // If a unit must be flushed:
<mask> // . lock DB
<mask> // . atomically set a new empty unit as the current one and get the old unit
<mask> // This is important to do it inside DB lock, so the reader won't get inconsistent results.
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove func (s *statsCtx) periodicFlush() {
for {
ptr := s.ongoing()
if ptr == nil {
break
}
id := s.conf.UnitID()
if ptr.id == id || s.conf.limit == 0 {
</s> add func (s *StatsCtx) periodicFlush() {
for ptr := s.ongoing(); ptr != nil; ptr = s.ongoing() {
id := s.unitIDGen()
// Access the unit's ID with atomic to avoid locking the whole unit.
if !s.isEnabled() || atomic.LoadUint32(&ptr.id) == id { </s> remove // Atomically swap the currently active unit with a new value
// Return old value
func (s *statsCtx) swapUnit(new *unit) (u *unit) {
s.mu.Lock()
defer s.mu.Unlock()
</s> add return err
} </s> remove u = s.current
s.current = new
</s> add log.Tracef("db.Open") </s> remove return false
}
log.Tracef("db.Open")
return true
}
</s> add </s> remove Filename string // database file name
LimitDays uint32 // time limit (in days)
UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used.
</s> add // UnitID is the function to generate the identifier for current unit. If
// nil, the default function is used, see newUnitID.
UnitID UnitIDGenFunc </s> remove // Called when the configuration is changed by HTTP request
</s> add // ConfigModified will be called each time the configuration changed via web
// interface. | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace replace replace replace replace replace replace replace replace keep keep keep keep keep | <mask> // This is important to do it inside DB lock, so the reader won't get inconsistent results.
<mask> // . write the unit to DB
<mask> // . remove the stale unit from DB
<mask> // . unlock DB
<mask> func (s *statsCtx) periodicFlush() {
<mask> for {
<mask> ptr := s.ongoing()
<mask> if ptr == nil {
<mask> break
<mask> }
<mask>
<mask> id := s.conf.UnitID()
<mask> if ptr.id == id || s.conf.limit == 0 {
<mask> time.Sleep(time.Second)
<mask>
<mask> continue
<mask> }
<mask>
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove func (s *statsCtx) ongoing() (u *unit) {
s.mu.Lock()
defer s.mu.Unlock()
return s.current
}
</s> add </s> remove // Initialize a unit
func (s *statsCtx) initUnit(u *unit, id uint32) {
u.id = id
u.nResult = make([]uint64, rLast)
u.domains = make(map[string]uint64)
u.blockedDomains = make(map[string]uint64)
u.clients = make(map[string]uint64)
</s> add // newUnit allocates the new *unit.
func newUnit(id uint32) (u *unit) {
return &unit{
mu: &sync.RWMutex{},
id: id,
nResult: make([]uint64, resultLast),
domains: make(map[string]uint64),
blockedDomains: make(map[string]uint64),
clients: make(map[string]uint64),
} </s> remove // Open a DB transaction
func (s *statsCtx) beginTxn(wr bool) *bolt.Tx {
db := s.db
</s> add // beginTxn opens a new database transaction. If writable is true, the
// transaction will be opened for writing, and for reading otherwise. It
// returns nil if the transaction can't be created.
func beginTxn(db *bbolt.DB, writable bool) (tx *bbolt.Tx) { </s> remove // Delete unit's data from file
func (s *statsCtx) deleteUnit(tx *bolt.Tx, id uint32) bool {
</s> add // deleteUnit removes the unit by it's id from the database the tx belongs to.
func (s *StatsCtx) deleteUnit(tx *bbolt.Tx, id uint32) bool { </s> remove func (s *statsCtx) dbOpen() bool {
var err error
</s> add // dbOpen returns an error if the database can't be opened from the specified
// file. It's safe for concurrent use.
func (s *StatsCtx) dbOpen() (err error) { </s> remove func checkInterval(days uint32) bool {
</s> add // checkInterval returns true if days is valid to be used as statistics
// retention interval. The valid values are 0, 1, 7, 30 and 90.
func checkInterval(days uint32) (ok bool) { | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep replace keep replace replace replace replace keep | <mask>
<mask> tx := s.beginTxn(true)
<mask>
<mask> nu := unit{}
<mask> s.initUnit(&nu, id)
<mask> u := s.swapUnit(&nu)
<mask> udb := serialize(u)
<mask>
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove func (s *statsCtx) Close() {
u := s.swapUnit(nil)
udb := serialize(u)
tx := s.beginTxn(true)
if tx != nil {
if s.flushUnitToDB(tx, u.id, udb) {
</s> add func (s *StatsCtx) Close() {
u := s.swapCurrent(nil)
db := s.database()
if tx := beginTxn(db, true); tx != nil {
udb := u.serialize()
if flushUnitToDB(tx, u.id, udb) { </s> remove u := unit{}
s.initUnit(&u, id)
if udb != nil {
deserialize(&u, udb)
}
s.current = &u
</s> add u := newUnit(id)
// This use of deserialize is safe since the accessed unit has just been
// created.
u.deserialize(udb)
s.curr = u </s> remove id := s.conf.UnitID()
tx := s.beginTxn(true)
</s> add id := s.unitIDGen()
tx := beginTxn(s.db, true) </s> remove firstID := id - s.conf.limit - 1
</s> add firstID := id - s.limitHours - 1 </s> remove func (s *statsCtx) WriteDiskConfig(dc *DiskConfig) {
dc.Interval = s.conf.limit / 24
</s> add func (s *StatsCtx) WriteDiskConfig(dc *DiskConfig) {
dc.Interval = atomic.LoadUint32(&s.limitHours) / 24 | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace replace replace keep keep keep keep keep | <mask> if tx == nil {
<mask> continue
<mask> }
<mask>
<mask> ok1 := s.flushUnitToDB(tx, u.id, udb)
<mask> ok2 := s.deleteUnit(tx, id-s.conf.limit)
<mask> if ok1 || ok2 {
<mask> s.commitTxn(tx)
<mask> } else {
<mask> _ = tx.Rollback()
<mask> }
<mask> }
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove func (s *statsCtx) Close() {
u := s.swapUnit(nil)
udb := serialize(u)
tx := s.beginTxn(true)
if tx != nil {
if s.flushUnitToDB(tx, u.id, udb) {
</s> add func (s *StatsCtx) Close() {
u := s.swapCurrent(nil)
db := s.database()
if tx := beginTxn(db, true); tx != nil {
udb := u.serialize()
if flushUnitToDB(tx, u.id, udb) { </s> remove func (s *statsCtx) clear() {
tx := s.beginTxn(true)
</s> add func (s *StatsCtx) clear() {
db := s.database()
tx := beginTxn(db, true) </s> remove if s.db != nil {
</s> add if db != nil { </s> remove nu := unit{}
s.initUnit(&nu, id)
u := s.swapUnit(&nu)
udb := serialize(u)
</s> add nu := newUnit(id)
u := s.swapCurrent(nu)
udb := u.serialize() </s> remove units, _ := s.loadUnits(s.conf.limit)
</s> add units, _ := s.loadUnits(atomic.LoadUint32(&s.limitHours)) </s> remove u.NResult = make([]uint64, rLast)
</s> add u.NResult = make([]uint64, resultLast) | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask>
<mask> log.Tracef("periodicFlush() exited")
<mask> }
<mask>
<mask> // Delete unit's data from file
<mask> func (s *statsCtx) deleteUnit(tx *bolt.Tx, id uint32) bool {
<mask> err := tx.DeleteBucket(idToUnitName(id))
<mask> if err != nil {
<mask> log.Tracef("stats: bolt DeleteBucket: %s", err)
<mask>
<mask> return false
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove func (s *statsCtx) flushUnitToDB(tx *bolt.Tx, id uint32, udb *unitDB) bool {
</s> add func flushUnitToDB(tx *bbolt.Tx, id uint32, udb *unitDB) bool { </s> remove func (s *statsCtx) loadUnitFromDB(tx *bolt.Tx, id uint32) *unitDB {
</s> add func (s *StatsCtx) loadUnitFromDB(tx *bbolt.Tx, id uint32) *unitDB { </s> remove log.Debug("tx.Commit: %s", err)
</s> add log.Error("stats: committing a transaction: %s", err)
</s> remove func (s *statsCtx) dbOpen() bool {
var err error
</s> add // dbOpen returns an error if the database can't be opened from the specified
// file. It's safe for concurrent use.
func (s *StatsCtx) dbOpen() (err error) { </s> remove log.Error("stats: open DB: %s: %s", s.conf.Filename, err)
</s> add log.Error("stats: open DB: %s: %s", s.filename, err) </s> remove log.Tracef("db.Begin")
</s> add log.Tracef("transaction has been opened")
| https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace replace replace replace keep keep keep keep keep | <mask>
<mask> func convertMapToSlice(m map[string]uint64, max int) []countPair {
<mask> a := []countPair{}
<mask> for k, v := range m {
<mask> pair := countPair{}
<mask> pair.Name = k
<mask> pair.Count = v
<mask> a = append(a, pair)
<mask> }
<mask> less := func(i, j int) bool {
<mask> return a[j].Count < a[i].Count
<mask> }
<mask> sort.Slice(a, less)
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove ent := map[string]uint64{}
ent[it.Name] = it.Count
m = append(m, ent)
</s> add m = append(m, map[string]uint64{it.Name: it.Count}) </s> remove func convertTopSlice(a []countPair) []map[string]uint64 {
m := []map[string]uint64{}
</s> add func convertTopSlice(a []countPair) (m []map[string]uint64) {
m = make([]map[string]uint64, 0, len(a)) </s> remove func (s *statsCtx) setLimit(limitDays int) {
s.conf.limit = uint32(limitDays) * 24
</s> add func (s *StatsCtx) setLimit(limitDays int) {
atomic.StoreUint32(&s.limitHours, uint32(24*limitDays)) </s> remove for _, it := range pg(u) {
m[it.Name] += it.Count
</s> add for _, cp := range pg(u) {
m[cp.Name] += cp.Count </s> remove // topsCollector collects statistics about highest values fro the given *unitDB
</s> add // topsCollector collects statistics about highest values from the given *unitDB </s> remove func deserialize(u *unit, udb *unitDB) {
u.nTotal = udb.NTotal
n := len(udb.NResult)
if n < len(u.nResult) {
n = len(u.nResult) // n = min(len(udb.NResult), len(u.nResult))
}
for i := 1; i < n; i++ {
u.nResult[i] = udb.NResult[i]
</s> add // deserealize assigns the appropriate values from udb to u. u must not be nil.
// It's safe for concurrent use.
func (u *unit) deserialize(udb *unitDB) {
if udb == nil {
return | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace replace replace replace replace keep keep keep keep keep | <mask> }
<mask> return m
<mask> }
<mask>
<mask> func serialize(u *unit) *unitDB {
<mask> udb := unitDB{}
<mask> udb.NTotal = u.nTotal
<mask>
<mask> udb.NResult = append(udb.NResult, u.nResult...)
<mask>
<mask> if u.nTotal != 0 {
<mask> udb.TimeAvg = uint32(u.timeSum / u.nTotal)
<mask> }
<mask>
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove udb.TimeAvg = uint32(u.timeSum / u.nTotal)
</s> add timeAvg = uint32(u.timeSum / u.nTotal) </s> remove udb.Domains = convertMapToSlice(u.domains, maxDomains)
udb.BlockedDomains = convertMapToSlice(u.blockedDomains, maxDomains)
udb.Clients = convertMapToSlice(u.clients, maxClients)
return &udb
</s> add return &unitDB{
NTotal: u.nTotal,
NResult: append([]uint64{}, u.nResult...),
Domains: convertMapToSlice(u.domains, maxDomains),
BlockedDomains: convertMapToSlice(u.blockedDomains, maxDomains),
Clients: convertMapToSlice(u.clients, maxClients),
TimeAvg: timeAvg,
} </s> add var timeAvg uint32 = 0 </s> remove func deserialize(u *unit, udb *unitDB) {
u.nTotal = udb.NTotal
n := len(udb.NResult)
if n < len(u.nResult) {
n = len(u.nResult) // n = min(len(udb.NResult), len(u.nResult))
}
for i := 1; i < n; i++ {
u.nResult[i] = udb.NResult[i]
</s> add // deserealize assigns the appropriate values from udb to u. u must not be nil.
// It's safe for concurrent use.
func (u *unit) deserialize(udb *unitDB) {
if udb == nil {
return </s> remove u.timeSum = uint64(udb.TimeAvg) * u.nTotal
</s> add u.timeSum = uint64(udb.TimeAvg) * udb.NTotal </s> add u.mu.Lock()
defer u.mu.Unlock()
u.nTotal = udb.NTotal
u.nResult = make([]uint64, resultLast)
copy(u.nResult, udb.NResult) | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep add keep keep keep keep keep keep | <mask> defer u.mu.RUnlock()
<mask>
<mask> if u.nTotal != 0 {
<mask> timeAvg = uint32(u.timeSum / u.nTotal)
<mask> }
<mask>
<mask> return &unitDB{
<mask> NTotal: u.nTotal,
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove udb.Domains = convertMapToSlice(u.domains, maxDomains)
udb.BlockedDomains = convertMapToSlice(u.blockedDomains, maxDomains)
udb.Clients = convertMapToSlice(u.clients, maxClients)
return &udb
</s> add return &unitDB{
NTotal: u.nTotal,
NResult: append([]uint64{}, u.nResult...),
Domains: convertMapToSlice(u.domains, maxDomains),
BlockedDomains: convertMapToSlice(u.blockedDomains, maxDomains),
Clients: convertMapToSlice(u.clients, maxClients),
TimeAvg: timeAvg,
} </s> remove udb.TimeAvg = uint32(u.timeSum / u.nTotal)
</s> add timeAvg = uint32(u.timeSum / u.nTotal) </s> remove func serialize(u *unit) *unitDB {
udb := unitDB{}
udb.NTotal = u.nTotal
udb.NResult = append(udb.NResult, u.nResult...)
</s> add // serialize converts u to the *unitDB. It's safe for concurrent use.
func (u *unit) serialize() (udb *unitDB) {
u.mu.RLock()
defer u.mu.RUnlock() </s> remove log.Debug("stats: set limit: %d", limitDays)
</s> add log.Debug("stats: set limit: %d days", limitDays) </s> add u.mu.Lock()
defer u.mu.Unlock()
u.nTotal = udb.NTotal
u.nResult = make([]uint64, resultLast)
copy(u.nResult, udb.NResult) </s> remove s.mu.Lock()
defer s.mu.Unlock()
</s> add u := s.ongoing()
if u == nil {
return
} | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep replace keep keep replace replace replace replace replace keep | <mask>
<mask> if u.nTotal != 0 {
<mask> udb.TimeAvg = uint32(u.timeSum / u.nTotal)
<mask> }
<mask>
<mask> udb.Domains = convertMapToSlice(u.domains, maxDomains)
<mask> udb.BlockedDomains = convertMapToSlice(u.blockedDomains, maxDomains)
<mask> udb.Clients = convertMapToSlice(u.clients, maxClients)
<mask>
<mask> return &udb
<mask> }
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> add var timeAvg uint32 = 0 </s> remove func serialize(u *unit) *unitDB {
udb := unitDB{}
udb.NTotal = u.nTotal
udb.NResult = append(udb.NResult, u.nResult...)
</s> add // serialize converts u to the *unitDB. It's safe for concurrent use.
func (u *unit) serialize() (udb *unitDB) {
u.mu.RLock()
defer u.mu.RUnlock() </s> remove func deserialize(u *unit, udb *unitDB) {
u.nTotal = udb.NTotal
n := len(udb.NResult)
if n < len(u.nResult) {
n = len(u.nResult) // n = min(len(udb.NResult), len(u.nResult))
}
for i := 1; i < n; i++ {
u.nResult[i] = udb.NResult[i]
</s> add // deserealize assigns the appropriate values from udb to u. u must not be nil.
// It's safe for concurrent use.
func (u *unit) deserialize(udb *unitDB) {
if udb == nil {
return </s> remove log.Debug("stats: set limit: %d", limitDays)
</s> add log.Debug("stats: set limit: %d days", limitDays) </s> remove func convertTopSlice(a []countPair) []map[string]uint64 {
m := []map[string]uint64{}
</s> add func convertTopSlice(a []countPair) (m []map[string]uint64) {
m = make([]map[string]uint64, 0, len(a)) | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace replace replace replace replace replace replace replace replace keep keep keep keep keep | <mask>
<mask> return &udb
<mask> }
<mask>
<mask> func deserialize(u *unit, udb *unitDB) {
<mask> u.nTotal = udb.NTotal
<mask>
<mask> n := len(udb.NResult)
<mask> if n < len(u.nResult) {
<mask> n = len(u.nResult) // n = min(len(udb.NResult), len(u.nResult))
<mask> }
<mask> for i := 1; i < n; i++ {
<mask> u.nResult[i] = udb.NResult[i]
<mask> }
<mask>
<mask> u.domains = convertSliceToMap(udb.Domains)
<mask> u.blockedDomains = convertSliceToMap(udb.BlockedDomains)
<mask> u.clients = convertSliceToMap(udb.Clients)
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove u.timeSum = uint64(udb.TimeAvg) * u.nTotal
</s> add u.timeSum = uint64(udb.TimeAvg) * udb.NTotal </s> add u.mu.Lock()
defer u.mu.Unlock()
u.nTotal = udb.NTotal
u.nResult = make([]uint64, resultLast)
copy(u.nResult, udb.NResult) </s> remove udb.Domains = convertMapToSlice(u.domains, maxDomains)
udb.BlockedDomains = convertMapToSlice(u.blockedDomains, maxDomains)
udb.Clients = convertMapToSlice(u.clients, maxClients)
return &udb
</s> add return &unitDB{
NTotal: u.nTotal,
NResult: append([]uint64{}, u.nResult...),
Domains: convertMapToSlice(u.domains, maxDomains),
BlockedDomains: convertMapToSlice(u.blockedDomains, maxDomains),
Clients: convertMapToSlice(u.clients, maxClients),
TimeAvg: timeAvg,
} </s> remove u.NResult = make([]uint64, rLast)
</s> add u.NResult = make([]uint64, resultLast) </s> remove curID := cur.id
</s> add var curID uint32
if cur != nil {
curID = atomic.LoadUint32(&cur.id)
} else {
curID = s.unitIDGen()
} </s> remove func (s *statsCtx) flushUnitToDB(tx *bolt.Tx, id uint32, udb *unitDB) bool {
</s> add func flushUnitToDB(tx *bbolt.Tx, id uint32, udb *unitDB) bool { | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep add keep keep keep keep keep keep | <mask> }
<mask>
<mask> u.domains = convertSliceToMap(udb.Domains)
<mask> u.blockedDomains = convertSliceToMap(udb.BlockedDomains)
<mask> u.clients = convertSliceToMap(udb.Clients)
<mask> u.timeSum = uint64(udb.TimeAvg) * udb.NTotal
<mask> }
<mask>
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove u.timeSum = uint64(udb.TimeAvg) * u.nTotal
</s> add u.timeSum = uint64(udb.TimeAvg) * udb.NTotal </s> remove func deserialize(u *unit, udb *unitDB) {
u.nTotal = udb.NTotal
n := len(udb.NResult)
if n < len(u.nResult) {
n = len(u.nResult) // n = min(len(udb.NResult), len(u.nResult))
}
for i := 1; i < n; i++ {
u.nResult[i] = udb.NResult[i]
</s> add // deserealize assigns the appropriate values from udb to u. u must not be nil.
// It's safe for concurrent use.
func (u *unit) deserialize(udb *unitDB) {
if udb == nil {
return </s> remove func (s *statsCtx) flushUnitToDB(tx *bolt.Tx, id uint32, udb *unitDB) bool {
</s> add func flushUnitToDB(tx *bbolt.Tx, id uint32, udb *unitDB) bool { </s> remove // Initialize a unit
func (s *statsCtx) initUnit(u *unit, id uint32) {
u.id = id
u.nResult = make([]uint64, rLast)
u.domains = make(map[string]uint64)
u.blockedDomains = make(map[string]uint64)
u.clients = make(map[string]uint64)
</s> add // newUnit allocates the new *unit.
func newUnit(id uint32) (u *unit) {
return &unit{
mu: &sync.RWMutex{},
id: id,
nResult: make([]uint64, resultLast),
domains: make(map[string]uint64),
blockedDomains: make(map[string]uint64),
clients: make(map[string]uint64),
} </s> remove if !checkInterval(conf.LimitDays) {
conf.LimitDays = 1
</s> add if s.limitHours = conf.LimitDays * 24; !checkInterval(conf.LimitDays) {
s.limitHours = 24 </s> remove // Open a DB transaction
func (s *statsCtx) beginTxn(wr bool) *bolt.Tx {
db := s.db
</s> add // beginTxn opens a new database transaction. If writable is true, the
// transaction will be opened for writing, and for reading otherwise. It
// returns nil if the transaction can't be created.
func beginTxn(db *bbolt.DB, writable bool) (tx *bbolt.Tx) { | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep replace keep keep replace keep keep keep keep | <mask> u.blockedDomains = convertSliceToMap(udb.BlockedDomains)
<mask> u.clients = convertSliceToMap(udb.Clients)
<mask> u.timeSum = uint64(udb.TimeAvg) * u.nTotal
<mask> }
<mask>
<mask> func (s *statsCtx) flushUnitToDB(tx *bolt.Tx, id uint32, udb *unitDB) bool {
<mask> log.Tracef("Flushing unit %d", id)
<mask>
<mask> bkt, err := tx.CreateBucketIfNotExists(idToUnitName(id))
<mask> if err != nil {
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> add u.mu.Lock()
defer u.mu.Unlock()
u.nTotal = udb.NTotal
u.nResult = make([]uint64, resultLast)
copy(u.nResult, udb.NResult) </s> remove func deserialize(u *unit, udb *unitDB) {
u.nTotal = udb.NTotal
n := len(udb.NResult)
if n < len(u.nResult) {
n = len(u.nResult) // n = min(len(udb.NResult), len(u.nResult))
}
for i := 1; i < n; i++ {
u.nResult[i] = udb.NResult[i]
</s> add // deserealize assigns the appropriate values from udb to u. u must not be nil.
// It's safe for concurrent use.
func (u *unit) deserialize(udb *unitDB) {
if udb == nil {
return </s> remove // Delete unit's data from file
func (s *statsCtx) deleteUnit(tx *bolt.Tx, id uint32) bool {
</s> add // deleteUnit removes the unit by it's id from the database the tx belongs to.
func (s *StatsCtx) deleteUnit(tx *bbolt.Tx, id uint32) bool { </s> remove // Initialize a unit
func (s *statsCtx) initUnit(u *unit, id uint32) {
u.id = id
u.nResult = make([]uint64, rLast)
u.domains = make(map[string]uint64)
u.blockedDomains = make(map[string]uint64)
u.clients = make(map[string]uint64)
</s> add // newUnit allocates the new *unit.
func newUnit(id uint32) (u *unit) {
return &unit{
mu: &sync.RWMutex{},
id: id,
nResult: make([]uint64, resultLast),
domains: make(map[string]uint64),
blockedDomains: make(map[string]uint64),
clients: make(map[string]uint64),
} </s> remove if !s.dbOpen() {
return nil, fmt.Errorf("open database")
</s> add if err = s.dbOpen(); err != nil {
return nil, fmt.Errorf("opening database: %w", err) | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> return true
<mask> }
<mask>
<mask> func (s *statsCtx) loadUnitFromDB(tx *bolt.Tx, id uint32) *unitDB {
<mask> bkt := tx.Bucket(idToUnitName(id))
<mask> if bkt == nil {
<mask> return nil
<mask> }
<mask>
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove // Delete unit's data from file
func (s *statsCtx) deleteUnit(tx *bolt.Tx, id uint32) bool {
</s> add // deleteUnit removes the unit by it's id from the database the tx belongs to.
func (s *StatsCtx) deleteUnit(tx *bbolt.Tx, id uint32) bool { </s> remove func (s *statsCtx) GetTopClientsIP(maxCount uint) []net.IP {
if s.conf.limit == 0 {
</s> add func (s *StatsCtx) GetTopClientsIP(maxCount uint) []net.IP {
if !s.isEnabled() { </s> remove func (s *statsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) {
tx := s.beginTxn(false)
</s> add func (s *StatsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) {
tx := beginTxn(s.database(), false) </s> remove if !s.dbOpen() {
return nil, fmt.Errorf("open database")
</s> add if err = s.dbOpen(); err != nil {
return nil, fmt.Errorf("opening database: %w", err) </s> remove func (s *statsCtx) flushUnitToDB(tx *bolt.Tx, id uint32, udb *unitDB) bool {
</s> add func flushUnitToDB(tx *bbolt.Tx, id uint32, udb *unitDB) bool { </s> remove func checkInterval(days uint32) bool {
</s> add // checkInterval returns true if days is valid to be used as statistics
// retention interval. The valid values are 0, 1, 7, 30 and 90.
func checkInterval(days uint32) (ok bool) { | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep replace replace keep replace replace replace keep | <mask>
<mask> func convertTopSlice(a []countPair) []map[string]uint64 {
<mask> m := []map[string]uint64{}
<mask> for _, it := range a {
<mask> ent := map[string]uint64{}
<mask> ent[it.Name] = it.Count
<mask> m = append(m, ent)
<mask> }
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove for _, it := range pg(u) {
m[it.Name] += it.Count
</s> add for _, cp := range pg(u) {
m[cp.Name] += cp.Count </s> remove // topsCollector collects statistics about highest values fro the given *unitDB
</s> add // topsCollector collects statistics about highest values from the given *unitDB </s> remove pair := countPair{}
pair.Name = k
pair.Count = v
a = append(a, pair)
</s> add a = append(a, countPair{Name: k, Count: v}) </s> remove NResult: make([]uint64, rLast),
</s> add NResult: make([]uint64, resultLast), </s> remove func serialize(u *unit) *unitDB {
udb := unitDB{}
udb.NTotal = u.nTotal
udb.NResult = append(udb.NResult, u.nResult...)
</s> add // serialize converts u to the *unitDB. It's safe for concurrent use.
func (u *unit) serialize() (udb *unitDB) {
u.mu.RLock()
defer u.mu.RUnlock() | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep replace replace keep keep keep keep replace keep keep | <mask>
<mask> func (s *statsCtx) setLimit(limitDays int) {
<mask> s.conf.limit = uint32(limitDays) * 24
<mask> if limitDays == 0 {
<mask> s.clear()
<mask> }
<mask>
<mask> log.Debug("stats: set limit: %d", limitDays)
<mask> }
<mask>
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove func (s *statsCtx) WriteDiskConfig(dc *DiskConfig) {
dc.Interval = s.conf.limit / 24
</s> add func (s *StatsCtx) WriteDiskConfig(dc *DiskConfig) {
dc.Interval = atomic.LoadUint32(&s.limitHours) / 24 </s> remove func (s *statsCtx) Update(e Entry) {
if s.conf.limit == 0 {
</s> add func (s *StatsCtx) Update(e Entry) {
if !s.isEnabled() { </s> remove ent := map[string]uint64{}
ent[it.Name] = it.Count
m = append(m, ent)
</s> add m = append(m, map[string]uint64{it.Name: it.Count}) </s> remove if !checkInterval(conf.LimitDays) {
conf.LimitDays = 1
</s> add if s.limitHours = conf.LimitDays * 24; !checkInterval(conf.LimitDays) {
s.limitHours = 24 </s> remove
s.conf = &Config{}
*s.conf = conf
s.conf.limit = conf.LimitDays * 24
if conf.UnitID == nil {
s.conf.UnitID = newUnitID
</s> add if s.unitIDGen = newUnitID; conf.UnitID != nil {
s.unitIDGen = conf.UnitID | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep replace replace keep keep replace replace replace replace replace replace keep keep keep | <mask>
<mask> func (s *statsCtx) WriteDiskConfig(dc *DiskConfig) {
<mask> dc.Interval = s.conf.limit / 24
<mask> }
<mask>
<mask> func (s *statsCtx) Close() {
<mask> u := s.swapUnit(nil)
<mask> udb := serialize(u)
<mask> tx := s.beginTxn(true)
<mask> if tx != nil {
<mask> if s.flushUnitToDB(tx, u.id, udb) {
<mask> s.commitTxn(tx)
<mask> } else {
<mask> _ = tx.Rollback()
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove ok1 := s.flushUnitToDB(tx, u.id, udb)
ok2 := s.deleteUnit(tx, id-s.conf.limit)
if ok1 || ok2 {
</s> add flushOK := flushUnitToDB(tx, u.id, udb)
delOK := s.deleteUnit(tx, id-atomic.LoadUint32(&s.limitHours))
if flushOK || delOK { </s> remove log.Debug("stats: set limit: %d", limitDays)
</s> add log.Debug("stats: set limit: %d days", limitDays) </s> remove func (s *statsCtx) clear() {
tx := s.beginTxn(true)
</s> add func (s *StatsCtx) clear() {
db := s.database()
tx := beginTxn(db, true) </s> remove nu := unit{}
s.initUnit(&nu, id)
u := s.swapUnit(&nu)
udb := serialize(u)
</s> add nu := newUnit(id)
u := s.swapCurrent(nu)
udb := u.serialize() </s> remove db := s.db
s.db = nil
</s> add _ = s.swapDatabase(nil) | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep replace keep keep keep keep keep keep keep replace keep | <mask> }
<mask> }
<mask>
<mask> if s.db != nil {
<mask> log.Tracef("db.Close...")
<mask> _ = s.db.Close()
<mask> log.Tracef("db.Close")
<mask> }
<mask>
<mask> if s.db != nil {
<mask> log.Tracef("db.Close...")
<mask> _ = s.db.Close()
<mask> log.Tracef("db.Close")
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove db := s.db
s.db = nil
</s> add _ = s.swapDatabase(nil) </s> remove u := unit{}
s.initUnit(&u, s.conf.UnitID())
_ = s.swapUnit(&u)
</s> add u := newUnit(s.unitIDGen())
_ = s.swapCurrent(u) </s> remove func (s *statsCtx) clear() {
tx := s.beginTxn(true)
</s> add func (s *StatsCtx) clear() {
db := s.database()
tx := beginTxn(db, true) </s> remove units = append(units, serialize(cur))
</s> add if cur != nil {
units = append(units, cur.serialize())
} </s> remove err := os.Remove(s.conf.Filename)
</s> add err := os.Remove(s.filename) | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace replace keep replace replace keep | <mask> log.Debug("stats: closed")
<mask> }
<mask>
<mask> // Reset counters and clear database
<mask> func (s *statsCtx) clear() {
<mask> tx := s.beginTxn(true)
<mask> if tx != nil {
<mask> db := s.db
<mask> s.db = nil
<mask> _ = tx.Rollback()
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove _ = s.db.Close()
</s> add _ = db.Close() </s> remove if s.db != nil {
</s> add if db != nil { </s> remove func (s *statsCtx) Close() {
u := s.swapUnit(nil)
udb := serialize(u)
tx := s.beginTxn(true)
if tx != nil {
if s.flushUnitToDB(tx, u.id, udb) {
</s> add func (s *StatsCtx) Close() {
u := s.swapCurrent(nil)
db := s.database()
if tx := beginTxn(db, true); tx != nil {
udb := u.serialize()
if flushUnitToDB(tx, u.id, udb) { </s> remove // Open a DB transaction
func (s *statsCtx) beginTxn(wr bool) *bolt.Tx {
db := s.db
</s> add // beginTxn opens a new database transaction. If writable is true, the
// transaction will be opened for writing, and for reading otherwise. It
// returns nil if the transaction can't be created.
func beginTxn(db *bbolt.DB, writable bool) (tx *bbolt.Tx) { </s> remove firstID := id - s.conf.limit - 1
</s> add firstID := id - s.limitHours - 1 | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep replace replace replace keep replace | <mask> // all active transactions are now closed
<mask> }
<mask>
<mask> u := unit{}
<mask> s.initUnit(&u, s.conf.UnitID())
<mask> _ = s.swapUnit(&u)
<mask>
<mask> err := os.Remove(s.conf.Filename)
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove db := s.db
s.db = nil
</s> add _ = s.swapDatabase(nil) </s> remove u := unit{}
s.initUnit(&u, id)
if udb != nil {
deserialize(&u, udb)
}
s.current = &u
</s> add u := newUnit(id)
// This use of deserialize is safe since the accessed unit has just been
// created.
u.deserialize(udb)
s.curr = u </s> remove func (s *statsCtx) clear() {
tx := s.beginTxn(true)
</s> add func (s *StatsCtx) clear() {
db := s.database()
tx := beginTxn(db, true) </s> remove // Atomically swap the currently active unit with a new value
// Return old value
func (s *statsCtx) swapUnit(new *unit) (u *unit) {
s.mu.Lock()
defer s.mu.Unlock()
</s> add return err
} </s> remove nu := unit{}
s.initUnit(&nu, id)
u := s.swapUnit(&nu)
udb := serialize(u)
</s> add nu := newUnit(id)
u := s.swapCurrent(nu)
udb := u.serialize() | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep replace replace keep keep keep keep replace keep | <mask>
<mask> func (s *statsCtx) Update(e Entry) {
<mask> if s.conf.limit == 0 {
<mask> return
<mask> }
<mask>
<mask> if e.Result == 0 ||
<mask> e.Result >= rLast ||
<mask> e.Domain == "" ||
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove func checkInterval(days uint32) bool {
</s> add // checkInterval returns true if days is valid to be used as statistics
// retention interval. The valid values are 0, 1, 7, 30 and 90.
func checkInterval(days uint32) (ok bool) { </s> remove func (s *statsCtx) dbOpen() bool {
var err error
</s> add // dbOpen returns an error if the database can't be opened from the specified
// file. It's safe for concurrent use.
func (s *StatsCtx) dbOpen() (err error) { </s> remove func (s *statsCtx) periodicFlush() {
for {
ptr := s.ongoing()
if ptr == nil {
break
}
id := s.conf.UnitID()
if ptr.id == id || s.conf.limit == 0 {
</s> add func (s *StatsCtx) periodicFlush() {
for ptr := s.ongoing(); ptr != nil; ptr = s.ongoing() {
id := s.unitIDGen()
// Access the unit's ID with atomic to avoid locking the whole unit.
if !s.isEnabled() || atomic.LoadUint32(&ptr.id) == id { </s> remove ok1 := s.flushUnitToDB(tx, u.id, udb)
ok2 := s.deleteUnit(tx, id-s.conf.limit)
if ok1 || ok2 {
</s> add flushOK := flushUnitToDB(tx, u.id, udb)
delOK := s.deleteUnit(tx, id-atomic.LoadUint32(&s.limitHours))
if flushOK || delOK { </s> remove func (s *statsCtx) GetTopClientsIP(maxCount uint) []net.IP {
if s.conf.limit == 0 {
</s> add func (s *StatsCtx) GetTopClientsIP(maxCount uint) []net.IP {
if !s.isEnabled() { | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep replace replace keep keep keep keep keep keep keep keep replace keep | <mask> clientID = ip.String()
<mask> }
<mask>
<mask> s.mu.Lock()
<mask> defer s.mu.Unlock()
<mask>
<mask> u := s.current
<mask>
<mask> u.nResult[e.Result]++
<mask>
<mask> s.mu.Lock()
<mask> defer s.mu.Unlock()
<mask>
<mask> u := s.current
<mask>
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove u = s.current
s.current = new
</s> add log.Tracef("db.Open") </s> remove // Atomically swap the currently active unit with a new value
// Return old value
func (s *statsCtx) swapUnit(new *unit) (u *unit) {
s.mu.Lock()
defer s.mu.Unlock()
</s> add return err
} </s> remove func (s *statsCtx) ongoing() (u *unit) {
s.mu.Lock()
defer s.mu.Unlock()
return s.current
}
</s> add </s> remove return u
</s> add return nil </s> remove u := unit{}
s.initUnit(&u, id)
if udb != nil {
deserialize(&u, udb)
}
s.current = &u
</s> add u := newUnit(id)
// This use of deserialize is safe since the accessed unit has just been
// created.
u.deserialize(udb)
s.curr = u | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> u.timeSum += uint64(e.Time)
<mask> u.nTotal++
<mask> }
<mask>
<mask> func (s *statsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) {
<mask> tx := s.beginTxn(false)
<mask> if tx == nil {
<mask> return nil, 0
<mask> }
<mask>
<mask> cur := s.ongoing()
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove curID := cur.id
</s> add var curID uint32
if cur != nil {
curID = atomic.LoadUint32(&cur.id)
} else {
curID = s.unitIDGen()
} </s> remove func (s *statsCtx) loadUnitFromDB(tx *bolt.Tx, id uint32) *unitDB {
</s> add func (s *StatsCtx) loadUnitFromDB(tx *bbolt.Tx, id uint32) *unitDB { </s> remove id := s.conf.UnitID()
tx := s.beginTxn(true)
</s> add id := s.unitIDGen()
tx := beginTxn(s.db, true) </s> remove func (s *statsCtx) Close() {
u := s.swapUnit(nil)
udb := serialize(u)
tx := s.beginTxn(true)
if tx != nil {
if s.flushUnitToDB(tx, u.id, udb) {
</s> add func (s *StatsCtx) Close() {
u := s.swapCurrent(nil)
db := s.database()
if tx := beginTxn(db, true); tx != nil {
udb := u.serialize()
if flushUnitToDB(tx, u.id, udb) { </s> remove if !s.dbOpen() {
return nil, fmt.Errorf("open database")
</s> add if err = s.dbOpen(); err != nil {
return nil, fmt.Errorf("opening database: %w", err) </s> remove // Delete unit's data from file
func (s *statsCtx) deleteUnit(tx *bolt.Tx, id uint32) bool {
</s> add // deleteUnit removes the unit by it's id from the database the tx belongs to.
func (s *StatsCtx) deleteUnit(tx *bbolt.Tx, id uint32) bool { | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace keep keep keep keep keep | <mask> return nil, 0
<mask> }
<mask>
<mask> cur := s.ongoing()
<mask> curID := cur.id
<mask>
<mask> // Per-hour units.
<mask> units := []*unitDB{}
<mask> firstID := curID - limit + 1
<mask> for i := firstID; i != curID; i++ {
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove u.NResult = make([]uint64, rLast)
</s> add u.NResult = make([]uint64, resultLast) </s> remove id := s.conf.UnitID()
tx := s.beginTxn(true)
</s> add id := s.unitIDGen()
tx := beginTxn(s.db, true) </s> remove func (s *statsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) {
tx := s.beginTxn(false)
</s> add func (s *StatsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) {
tx := beginTxn(s.database(), false) </s> remove firstID := id - s.conf.limit - 1
</s> add firstID := id - s.limitHours - 1 </s> remove func deserialize(u *unit, udb *unitDB) {
u.nTotal = udb.NTotal
n := len(udb.NResult)
if n < len(u.nResult) {
n = len(u.nResult) // n = min(len(udb.NResult), len(u.nResult))
}
for i := 1; i < n; i++ {
u.nResult[i] = udb.NResult[i]
</s> add // deserealize assigns the appropriate values from udb to u. u must not be nil.
// It's safe for concurrent use.
func (u *unit) deserialize(udb *unitDB) {
if udb == nil {
return </s> remove func (s *statsCtx) getData() (statsResponse, bool) {
limit := s.conf.limit
</s> add func (s *StatsCtx) getData() (statsResponse, bool) {
limit := atomic.LoadUint32(&s.limitHours)
if limit == 0 {
return statsResponse{
TimeUnits: "days",
TopBlocked: []topAddrs{},
TopClients: []topAddrs{},
TopQueried: []topAddrs{},
BlockedFiltering: []uint64{},
DNSQueries: []uint64{},
ReplacedParental: []uint64{},
ReplacedSafebrowsing: []uint64{},
}, true
} | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace keep keep keep keep keep | <mask> for i := firstID; i != curID; i++ {
<mask> u := s.loadUnitFromDB(tx, i)
<mask> if u == nil {
<mask> u = &unitDB{}
<mask> u.NResult = make([]uint64, rLast)
<mask> }
<mask> units = append(units, u)
<mask> }
<mask>
<mask> _ = tx.Rollback()
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove curID := cur.id
</s> add var curID uint32
if cur != nil {
curID = atomic.LoadUint32(&cur.id)
} else {
curID = s.unitIDGen()
} </s> remove units = append(units, serialize(cur))
</s> add if cur != nil {
units = append(units, cur.serialize())
} </s> remove func deserialize(u *unit, udb *unitDB) {
u.nTotal = udb.NTotal
n := len(udb.NResult)
if n < len(u.nResult) {
n = len(u.nResult) // n = min(len(udb.NResult), len(u.nResult))
}
for i := 1; i < n; i++ {
u.nResult[i] = udb.NResult[i]
</s> add // deserealize assigns the appropriate values from udb to u. u must not be nil.
// It's safe for concurrent use.
func (u *unit) deserialize(udb *unitDB) {
if udb == nil {
return </s> remove s.mu.Lock()
defer s.mu.Unlock()
</s> add u := s.ongoing()
if u == nil {
return
} </s> remove NResult: make([]uint64, rLast),
</s> add NResult: make([]uint64, resultLast), </s> remove func (s *statsCtx) Close() {
u := s.swapUnit(nil)
udb := serialize(u)
tx := s.beginTxn(true)
if tx != nil {
if s.flushUnitToDB(tx, u.id, udb) {
</s> add func (s *StatsCtx) Close() {
u := s.swapCurrent(nil)
db := s.database()
if tx := beginTxn(db, true); tx != nil {
udb := u.serialize()
if flushUnitToDB(tx, u.id, udb) { | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask>
<mask> _ = tx.Rollback()
<mask>
<mask> units = append(units, serialize(cur))
<mask>
<mask> if len(units) != int(limit) {
<mask> log.Fatalf("len(units) != limit: %d %d", len(units), limit)
<mask> }
<mask>
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove u.NResult = make([]uint64, rLast)
</s> add u.NResult = make([]uint64, resultLast) </s> remove log.Debug("stats: set limit: %d", limitDays)
</s> add log.Debug("stats: set limit: %d days", limitDays) </s> remove if s.db != nil {
</s> add if db != nil { </s> remove func (s *statsCtx) setLimit(limitDays int) {
s.conf.limit = uint32(limitDays) * 24
</s> add func (s *StatsCtx) setLimit(limitDays int) {
atomic.StoreUint32(&s.limitHours, uint32(24*limitDays)) </s> remove _ = s.db.Close()
</s> add _ = db.Close() </s> remove func (s *statsCtx) WriteDiskConfig(dc *DiskConfig) {
dc.Interval = s.conf.limit / 24
</s> add func (s *StatsCtx) WriteDiskConfig(dc *DiskConfig) {
dc.Interval = atomic.LoadUint32(&s.limitHours) / 24 | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep replace keep keep keep keep replace replace keep keep | <mask>
<mask> // topsCollector collects statistics about highest values fro the given *unitDB
<mask> // slice using pg to retrieve data.
<mask> func topsCollector(units []*unitDB, max int, pg pairsGetter) []map[string]uint64 {
<mask> m := map[string]uint64{}
<mask> for _, u := range units {
<mask> for _, it := range pg(u) {
<mask> m[it.Name] += it.Count
<mask> }
<mask> }
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove ent := map[string]uint64{}
ent[it.Name] = it.Count
m = append(m, ent)
</s> add m = append(m, map[string]uint64{it.Name: it.Count}) </s> remove func convertTopSlice(a []countPair) []map[string]uint64 {
m := []map[string]uint64{}
</s> add func convertTopSlice(a []countPair) (m []map[string]uint64) {
m = make([]map[string]uint64, 0, len(a)) </s> remove NResult: make([]uint64, rLast),
</s> add NResult: make([]uint64, resultLast), </s> remove pair := countPair{}
pair.Name = k
pair.Count = v
a = append(a, pair)
</s> add a = append(a, countPair{Name: k, Count: v}) </s> remove func serialize(u *unit) *unitDB {
udb := unitDB{}
udb.NTotal = u.nTotal
udb.NResult = append(udb.NResult, u.nResult...)
</s> add // serialize converts u to the *unitDB. It's safe for concurrent use.
func (u *unit) serialize() (udb *unitDB) {
u.mu.RLock()
defer u.mu.RUnlock() | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> * safesearch-blocked
<mask> * parental-blocked
<mask> These values are just the sum of data for all units.
<mask> */
<mask> func (s *statsCtx) getData() (statsResponse, bool) {
<mask> limit := s.conf.limit
<mask>
<mask> timeUnit := Hours
<mask> if limit/24 > 7 {
<mask> timeUnit = Days
<mask> }
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove func (s *statsCtx) setLimit(limitDays int) {
s.conf.limit = uint32(limitDays) * 24
</s> add func (s *StatsCtx) setLimit(limitDays int) {
atomic.StoreUint32(&s.limitHours, uint32(24*limitDays)) </s> remove func checkInterval(days uint32) bool {
</s> add // checkInterval returns true if days is valid to be used as statistics
// retention interval. The valid values are 0, 1, 7, 30 and 90.
func checkInterval(days uint32) (ok bool) { </s> remove if !checkInterval(conf.LimitDays) {
conf.LimitDays = 1
</s> add if s.limitHours = conf.LimitDays * 24; !checkInterval(conf.LimitDays) {
s.limitHours = 24 </s> remove // Initialize a unit
func (s *statsCtx) initUnit(u *unit, id uint32) {
u.id = id
u.nResult = make([]uint64, rLast)
u.domains = make(map[string]uint64)
u.blockedDomains = make(map[string]uint64)
u.clients = make(map[string]uint64)
</s> add // newUnit allocates the new *unit.
func newUnit(id uint32) (u *unit) {
return &unit{
mu: &sync.RWMutex{},
id: id,
nResult: make([]uint64, resultLast),
domains: make(map[string]uint64),
blockedDomains: make(map[string]uint64),
clients: make(map[string]uint64),
} </s> remove curID := cur.id
</s> add var curID uint32
if cur != nil {
curID = atomic.LoadUint32(&cur.id)
} else {
curID = s.unitIDGen()
} </s> remove u.timeSum = uint64(udb.TimeAvg) * u.nTotal
</s> add u.timeSum = uint64(udb.TimeAvg) * udb.NTotal | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask>
<mask> // Total counters:
<mask> sum := unitDB{
<mask> NResult: make([]uint64, rLast),
<mask> }
<mask> timeN := 0
<mask> for _, u := range units {
<mask> sum.NTotal += u.NTotal
<mask> sum.TimeAvg += u.TimeAvg
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove for _, it := range pg(u) {
m[it.Name] += it.Count
</s> add for _, cp := range pg(u) {
m[cp.Name] += cp.Count </s> remove u.NResult = make([]uint64, rLast)
</s> add u.NResult = make([]uint64, resultLast) </s> remove // topsCollector collects statistics about highest values fro the given *unitDB
</s> add // topsCollector collects statistics about highest values from the given *unitDB </s> remove func (s *statsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) {
tx := s.beginTxn(false)
</s> add func (s *StatsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) {
tx := beginTxn(s.database(), false) </s> remove func convertTopSlice(a []countPair) []map[string]uint64 {
m := []map[string]uint64{}
</s> add func convertTopSlice(a []countPair) (m []map[string]uint64) {
m = make([]map[string]uint64, 0, len(a)) </s> remove ent := map[string]uint64{}
ent[it.Name] = it.Count
m = append(m, ent)
</s> add m = append(m, map[string]uint64{it.Name: it.Count}) | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep replace replace keep keep keep replace keep keep | <mask> return data, true
<mask> }
<mask>
<mask> func (s *statsCtx) GetTopClientsIP(maxCount uint) []net.IP {
<mask> if s.conf.limit == 0 {
<mask> return nil
<mask> }
<mask>
<mask> units, _ := s.loadUnits(s.conf.limit)
<mask> if units == nil {
<mask> return nil
</s> Pull request: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master
Updates #4358.
Updates #4342.
Squashed commit of the following:
commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 18:20:54 2022 +0300
stats: rm races test
commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 17:13:36 2022 +0300
stats: try to imp test
commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 16:38:57 2022 +0300
stats: fix nil ptr deref
commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <[email protected]>
Date: Thu Apr 7 16:02:51 2022 +0300
stats: fix races finally, imp tests
commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:56:49 2022 +0300
aghhttp: add register func
commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <[email protected]>
Date: Thu Aug 4 00:36:01 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 21:00:42 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:46:19 2022 +0300
stats: imp code, docs
commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:16:13 2022 +0300
all: log changes
commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:09:10 2022 +0300
Merge branch 'master' into 4358-fix-stats
commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 3 18:07:39 2022 +0300
stats: imp docs, code
commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 2 17:09:30 2022 +0300
all: refactor stats & add mutexes
commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 27 15:30:09 2022 +0300
WIP </s> remove func (s *statsCtx) loadUnitFromDB(tx *bolt.Tx, id uint32) *unitDB {
</s> add func (s *StatsCtx) loadUnitFromDB(tx *bbolt.Tx, id uint32) *unitDB { </s> remove func (s *statsCtx) Update(e Entry) {
if s.conf.limit == 0 {
</s> add func (s *StatsCtx) Update(e Entry) {
if !s.isEnabled() { </s> remove func (s *statsCtx) initWeb() {
if s.conf.HTTPRegister == nil {
</s> add func (s *StatsCtx) initWeb() {
if s.httpRegister == nil { </s> remove func (s *statsCtx) setLimit(limitDays int) {
s.conf.limit = uint32(limitDays) * 24
</s> add func (s *StatsCtx) setLimit(limitDays int) {
atomic.StoreUint32(&s.limitHours, uint32(24*limitDays)) </s> remove func (s *statsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) {
tx := s.beginTxn(false)
</s> add func (s *StatsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) {
tx := beginTxn(s.database(), false) | https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc | internal/stats/unit.go |
keep keep keep keep replace keep keep keep keep keep | <mask> "install_devices_android_list_1": "From the Android Menu home screen, tap Settings.",
<mask> "install_devices_android_list_2": "Tap Wi-Fi on the menu. The screen listing all of the available networks will be shown (it is impossible to set custom DNS for mobile connection).",
<mask> "install_devices_android_list_3": "Long press the network you're connected to, and tap Modify Network.",
<mask> "install_devices_android_list_4": "On some devices, you may need to check the box for Advanced to see further settings. To adjust your Android DNS settings, you will need to switch the IP settings from DHCP to Static.",
<mask> "install_devices_android_list_5": "Change set DNS 1 and DNS 2 values to your AdGuard Home server addresses.",
<mask> "install_devices_ios_list_1": "From the home screen, tap Settings.",
<mask> "install_devices_ios_list_2": "Choose Wi-Fi in the left menu (it is impossible to configure DNS for mobile networks).",
<mask> "install_devices_ios_list_3": "Tap on the name of the currently active network.",
<mask> "install_devices_ios_list_4": "In the DNS field enter your AdGuard Home server addresses.",
<mask> "get_started": "Get Started",
</s> Pull request: client: imp en locale
Merge in DNS/adguard-home from imp-i18n-en to master
Squashed commit of the following:
commit 7d0f46dc0a9b28e709ac9ad1748b17ae9ad4a520
Author: Ainar Garipov <[email protected]>
Date: Thu May 13 16:04:22 2021 +0300
client: imp en locale </s> remove "client_identifier_desc": "Clients can be identified by the IP address, CIDR, MAC address or a special client ID (can be used for DoT/DoH/DoQ). <0>Here</0> you can learn more about how to identify clients.",
</s> add "client_identifier_desc": "Clients can be identified by the IP address, CIDR, MAC address, or a special client ID (can be used for DoT/DoH/DoQ). <0>Here</0> you can learn more about how to identify clients.", </s> remove "filter_category_security_desc": "Lists that specialize on blocking malware, phishing or scam domains",
</s> add "filter_category_security_desc": "Lists that specialize on blocking malware, phishing, or scam domains", </s> remove "access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in queries' questions. Here you can specify the exact domain names, wildcards and URL filter rules, e.g. \"example.org\", \"*.example.org\" or \"||example.org^\".",
</s> add "access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in queries' questions. Here you can specify the exact domain names, wildcards, and URL filter rules, e.g. \"example.org\", \"*.example.org\", or \"||example.org^\".", | https://github.com/AdguardTeam/AdGuardHome/commit/42ec9cae76bd747391d670c6a046ec4800ca60f5 | client/src/__locales/en.json |
keep keep keep keep replace keep keep keep keep keep | <mask> "client_new": "New Client",
<mask> "client_edit": "Edit Client",
<mask> "client_identifier": "Identifier",
<mask> "ip_address": "IP address",
<mask> "client_identifier_desc": "Clients can be identified by the IP address, CIDR, MAC address or a special client ID (can be used for DoT/DoH/DoQ). <0>Here</0> you can learn more about how to identify clients.",
<mask> "form_enter_ip": "Enter IP",
<mask> "form_enter_subnet_ip": "Enter an IP address in the subnet \"{{cidr}}\"",
<mask> "form_enter_mac": "Enter MAC",
<mask> "form_enter_id": "Enter identifier",
<mask> "form_add_id": "Add identifier",
</s> Pull request: client: imp en locale
Merge in DNS/adguard-home from imp-i18n-en to master
Squashed commit of the following:
commit 7d0f46dc0a9b28e709ac9ad1748b17ae9ad4a520
Author: Ainar Garipov <[email protected]>
Date: Thu May 13 16:04:22 2021 +0300
client: imp en locale </s> remove "install_devices_android_list_5": "Change set DNS 1 and DNS 2 values to your AdGuard Home server addresses.",
</s> add "install_devices_android_list_5": "Change DNS 1 and DNS 2 values to your AdGuard Home server addresses.", </s> remove "access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in queries' questions. Here you can specify the exact domain names, wildcards and URL filter rules, e.g. \"example.org\", \"*.example.org\" or \"||example.org^\".",
</s> add "access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in queries' questions. Here you can specify the exact domain names, wildcards, and URL filter rules, e.g. \"example.org\", \"*.example.org\", or \"||example.org^\".", </s> remove "filter_category_security_desc": "Lists that specialize on blocking malware, phishing or scam domains",
</s> add "filter_category_security_desc": "Lists that specialize on blocking malware, phishing, or scam domains", | https://github.com/AdguardTeam/AdGuardHome/commit/42ec9cae76bd747391d670c6a046ec4800ca60f5 | client/src/__locales/en.json |
keep keep keep keep replace keep keep keep keep keep | <mask> "access_allowed_desc": "A list of CIDR or IP addresses. If configured, AdGuard Home will accept requests from these IP addresses only.",
<mask> "access_disallowed_title": "Disallowed clients",
<mask> "access_disallowed_desc": "A list of CIDR or IP addresses. If configured, AdGuard Home will drop requests from these IP addresses.",
<mask> "access_blocked_title": "Disallowed domains",
<mask> "access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in queries' questions. Here you can specify the exact domain names, wildcards and URL filter rules, e.g. \"example.org\", \"*.example.org\" or \"||example.org^\".",
<mask> "access_settings_saved": "Access settings successfully saved",
<mask> "updates_checked": "Updates successfully checked",
<mask> "updates_version_equal": "AdGuard Home is up-to-date",
<mask> "check_updates_now": "Check for updates now",
<mask> "dns_privacy": "DNS Privacy",
</s> Pull request: client: imp en locale
Merge in DNS/adguard-home from imp-i18n-en to master
Squashed commit of the following:
commit 7d0f46dc0a9b28e709ac9ad1748b17ae9ad4a520
Author: Ainar Garipov <[email protected]>
Date: Thu May 13 16:04:22 2021 +0300
client: imp en locale </s> remove "client_identifier_desc": "Clients can be identified by the IP address, CIDR, MAC address or a special client ID (can be used for DoT/DoH/DoQ). <0>Here</0> you can learn more about how to identify clients.",
</s> add "client_identifier_desc": "Clients can be identified by the IP address, CIDR, MAC address, or a special client ID (can be used for DoT/DoH/DoQ). <0>Here</0> you can learn more about how to identify clients.", </s> remove "install_devices_android_list_5": "Change set DNS 1 and DNS 2 values to your AdGuard Home server addresses.",
</s> add "install_devices_android_list_5": "Change DNS 1 and DNS 2 values to your AdGuard Home server addresses.", </s> remove "filter_category_security_desc": "Lists that specialize on blocking malware, phishing or scam domains",
</s> add "filter_category_security_desc": "Lists that specialize on blocking malware, phishing, or scam domains", | https://github.com/AdguardTeam/AdGuardHome/commit/42ec9cae76bd747391d670c6a046ec4800ca60f5 | client/src/__locales/en.json |
keep keep keep keep replace keep keep keep keep keep | <mask> "filter_category_security": "Security",
<mask> "filter_category_regional": "Regional",
<mask> "filter_category_other": "Other",
<mask> "filter_category_general_desc": "Lists that block tracking and advertising on most of the devices",
<mask> "filter_category_security_desc": "Lists that specialize on blocking malware, phishing or scam domains",
<mask> "filter_category_regional_desc": "Lists that focus on regional ads and tracking servers",
<mask> "filter_category_other_desc": "Other blocklists",
<mask> "setup_config_to_enable_dhcp_server": "Setup configuration to enable DHCP server",
<mask> "original_response": "Original response",
<mask> "click_to_view_queries": "Click to view queries",
</s> Pull request: client: imp en locale
Merge in DNS/adguard-home from imp-i18n-en to master
Squashed commit of the following:
commit 7d0f46dc0a9b28e709ac9ad1748b17ae9ad4a520
Author: Ainar Garipov <[email protected]>
Date: Thu May 13 16:04:22 2021 +0300
client: imp en locale </s> remove "install_devices_android_list_5": "Change set DNS 1 and DNS 2 values to your AdGuard Home server addresses.",
</s> add "install_devices_android_list_5": "Change DNS 1 and DNS 2 values to your AdGuard Home server addresses.", </s> remove "access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in queries' questions. Here you can specify the exact domain names, wildcards and URL filter rules, e.g. \"example.org\", \"*.example.org\" or \"||example.org^\".",
</s> add "access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in queries' questions. Here you can specify the exact domain names, wildcards, and URL filter rules, e.g. \"example.org\", \"*.example.org\", or \"||example.org^\".", </s> remove "client_identifier_desc": "Clients can be identified by the IP address, CIDR, MAC address or a special client ID (can be used for DoT/DoH/DoQ). <0>Here</0> you can learn more about how to identify clients.",
</s> add "client_identifier_desc": "Clients can be identified by the IP address, CIDR, MAC address, or a special client ID (can be used for DoT/DoH/DoQ). <0>Here</0> you can learn more about how to identify clients.", | https://github.com/AdguardTeam/AdGuardHome/commit/42ec9cae76bd747391d670c6a046ec4800ca60f5 | client/src/__locales/en.json |
keep add keep keep keep keep | <mask> DisableIPv6 bool `json:"disable_ipv6"`
<mask> UpstreamMode string `json:"upstream_mode"`
<mask> }
<mask>
<mask> func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) {
<mask> resp := dnsConfigJSON{}
</s> + dns: new settings for cache
Squashed commit of the following:
commit e5b488249a4d972efd63c6e96830d9f30829aee1
Author: Simon Zolin <[email protected]>
Date: Tue Jun 16 15:38:27 2020 +0300
+ dns: new settings for cache </s> add if req.CacheMinTTL > req.CacheMaxTTL {
httpError(r, w, http.StatusBadRequest, "cache_ttl_min must be less or equal than cache_ttl_max")
return
}
</s> add if js.Exists("cache_size") {
s.conf.CacheSize = req.CacheSize
restart = true
}
if js.Exists("cache_ttl_min") {
s.conf.CacheMinTTL = req.CacheMinTTL
restart = true
}
if js.Exists("cache_ttl_max") {
s.conf.CacheMaxTTL = req.CacheMaxTTL
restart = true
}
</s> add resp.CacheSize = s.conf.CacheSize
resp.CacheMinTTL = s.conf.CacheMinTTL
resp.CacheMaxTTL = s.conf.CacheMaxTTL </s> add cache_size:
type: integer
cache_ttl_min:
type: integer
cache_ttl_max:
type: integer | https://github.com/AdguardTeam/AdGuardHome/commit/4303b3dd2f6c4e1f64e8cd8575070de35b3d6df7 | dnsforward/dnsforward_http.go |
keep add keep keep keep keep keep | <mask> resp.DNSSECEnabled = s.conf.EnableDNSSEC
<mask> resp.DisableIPv6 = s.conf.AAAADisabled
<mask> if s.conf.FastestAddr {
<mask> resp.UpstreamMode = "fastest_addr"
<mask> } else if s.conf.AllServers {
<mask> resp.UpstreamMode = "parallel"
<mask> }
</s> + dns: new settings for cache
Squashed commit of the following:
commit e5b488249a4d972efd63c6e96830d9f30829aee1
Author: Simon Zolin <[email protected]>
Date: Tue Jun 16 15:38:27 2020 +0300
+ dns: new settings for cache </s> add if js.Exists("cache_size") {
s.conf.CacheSize = req.CacheSize
restart = true
}
if js.Exists("cache_ttl_min") {
s.conf.CacheMinTTL = req.CacheMinTTL
restart = true
}
if js.Exists("cache_ttl_max") {
s.conf.CacheMaxTTL = req.CacheMaxTTL
restart = true
}
</s> add if req.CacheMinTTL > req.CacheMaxTTL {
httpError(r, w, http.StatusBadRequest, "cache_ttl_min must be less or equal than cache_ttl_max")
return
}
</s> add CacheSize uint32 `json:"cache_size"`
CacheMinTTL uint32 `json:"cache_ttl_min"`
CacheMaxTTL uint32 `json:"cache_ttl_max"` </s> add cache_size:
type: integer
cache_ttl_min:
type: integer
cache_ttl_max:
type: integer | https://github.com/AdguardTeam/AdGuardHome/commit/4303b3dd2f6c4e1f64e8cd8575070de35b3d6df7 | dnsforward/dnsforward_http.go |
keep keep add keep keep keep keep keep keep | <mask> return
<mask> }
<mask>
<mask> restart := false
<mask> s.Lock()
<mask>
<mask> if js.Exists("upstream_dns") {
<mask> s.conf.UpstreamDNS = req.Upstreams
<mask> restart = true
</s> + dns: new settings for cache
Squashed commit of the following:
commit e5b488249a4d972efd63c6e96830d9f30829aee1
Author: Simon Zolin <[email protected]>
Date: Tue Jun 16 15:38:27 2020 +0300
+ dns: new settings for cache </s> add if js.Exists("cache_size") {
s.conf.CacheSize = req.CacheSize
restart = true
}
if js.Exists("cache_ttl_min") {
s.conf.CacheMinTTL = req.CacheMinTTL
restart = true
}
if js.Exists("cache_ttl_max") {
s.conf.CacheMaxTTL = req.CacheMaxTTL
restart = true
}
</s> add resp.CacheSize = s.conf.CacheSize
resp.CacheMinTTL = s.conf.CacheMinTTL
resp.CacheMaxTTL = s.conf.CacheMaxTTL </s> add CacheSize uint32 `json:"cache_size"`
CacheMinTTL uint32 `json:"cache_ttl_min"`
CacheMaxTTL uint32 `json:"cache_ttl_max"` </s> add cache_size:
type: integer
cache_ttl_min:
type: integer
cache_ttl_max:
type: integer | https://github.com/AdguardTeam/AdGuardHome/commit/4303b3dd2f6c4e1f64e8cd8575070de35b3d6df7 | dnsforward/dnsforward_http.go |
keep keep add keep keep keep keep keep keep | <mask> s.conf.AAAADisabled = req.DisableIPv6
<mask> }
<mask>
<mask> if js.Exists("upstream_mode") {
<mask> s.conf.FastestAddr = false
<mask> s.conf.AllServers = false
<mask> switch req.UpstreamMode {
<mask> case "":
<mask> //
</s> + dns: new settings for cache
Squashed commit of the following:
commit e5b488249a4d972efd63c6e96830d9f30829aee1
Author: Simon Zolin <[email protected]>
Date: Tue Jun 16 15:38:27 2020 +0300
+ dns: new settings for cache </s> add resp.CacheSize = s.conf.CacheSize
resp.CacheMinTTL = s.conf.CacheMinTTL
resp.CacheMaxTTL = s.conf.CacheMaxTTL </s> add if req.CacheMinTTL > req.CacheMaxTTL {
httpError(r, w, http.StatusBadRequest, "cache_ttl_min must be less or equal than cache_ttl_max")
return
}
</s> add CacheSize uint32 `json:"cache_size"`
CacheMinTTL uint32 `json:"cache_ttl_min"`
CacheMaxTTL uint32 `json:"cache_ttl_max"` </s> add cache_size:
type: integer
cache_ttl_min:
type: integer
cache_ttl_max:
type: integer | https://github.com/AdguardTeam/AdGuardHome/commit/4303b3dd2f6c4e1f64e8cd8575070de35b3d6df7 | dnsforward/dnsforward_http.go |
keep keep keep add keep keep keep keep keep | <mask> edns_cs_enabled:
<mask> type: boolean
<mask> dnssec_enabled:
<mask> type: boolean
<mask> upstream_mode:
<mask> enum:
<mask> - ""
<mask> - parallel
<mask> - fastest_addr
</s> + dns: new settings for cache
Squashed commit of the following:
commit e5b488249a4d972efd63c6e96830d9f30829aee1
Author: Simon Zolin <[email protected]>
Date: Tue Jun 16 15:38:27 2020 +0300
+ dns: new settings for cache </s> add if js.Exists("cache_size") {
s.conf.CacheSize = req.CacheSize
restart = true
}
if js.Exists("cache_ttl_min") {
s.conf.CacheMinTTL = req.CacheMinTTL
restart = true
}
if js.Exists("cache_ttl_max") {
s.conf.CacheMaxTTL = req.CacheMaxTTL
restart = true
}
</s> add if req.CacheMinTTL > req.CacheMaxTTL {
httpError(r, w, http.StatusBadRequest, "cache_ttl_min must be less or equal than cache_ttl_max")
return
}
</s> add resp.CacheSize = s.conf.CacheSize
resp.CacheMinTTL = s.conf.CacheMinTTL
resp.CacheMaxTTL = s.conf.CacheMaxTTL </s> add CacheSize uint32 `json:"cache_size"`
CacheMinTTL uint32 `json:"cache_ttl_min"`
CacheMaxTTL uint32 `json:"cache_ttl_max"` | https://github.com/AdguardTeam/AdGuardHome/commit/4303b3dd2f6c4e1f64e8cd8575070de35b3d6df7 | openapi/openapi.yaml |
keep add keep keep keep keep keep keep | <mask> }
<mask> },
<mask> "tmp": {
<mask> "version": "0.0.33",
<mask> "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
<mask> "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==",
<mask> "dev": true,
<mask> "requires": {
</s> Add update check
Closes #338 </s> add processingVersion: true, </s> add "tiny-version-compare": "^0.9.1", </s> add .nav-version__value {
font-weight: 600;
}
</s> remove font-size: 0.9rem;
</s> add font-size: 0.85rem; </s> add getGlobalVersion() {
const { path, method } = this.GLOBAL_VERSION;
return this.makeRequest(path, method);
}
</s> add this.props.getVersion(); | https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255 | client/package-lock.json |
keep add keep keep keep keep keep keep | <mask> "svg-url-loader": "^2.3.2",
<mask> "tabler-react": "^1.10.0",
<mask> "whatwg-fetch": "2.0.3"
<mask> },
<mask> "devDependencies": {
<mask> "autoprefixer": "^8.6.3",
<mask> "babel-core": "6.26.0",
<mask> "babel-eslint": "^8.2.3",
</s> Add update check
Closes #338 </s> add "tiny-version-compare": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/tiny-version-compare/-/tiny-version-compare-0.9.1.tgz",
"integrity": "sha512-kYim94l7ptSmj9rqxUMkrcMCJ448CS+hwqjA7OFcRi0ISdi0zjgdSUklQ4velVVECCjCo5frU3tNZ3oSgIKzsA=="
}, </s> add GLOBAL_VERSION = { path: 'version.json', method: 'GET' }; </s> add this.props.getVersion(); </s> add getGlobalVersion() {
const { path, method } = this.GLOBAL_VERSION;
return this.makeRequest(path, method);
}
</s> add .nav-version__value {
font-weight: 600;
}
</s> remove font-size: 0.9rem;
</s> add font-size: 0.85rem; | https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255 | client/package.json |
keep keep keep add keep keep keep keep keep | <mask> dispatch(getStatsFailure());
<mask> }
<mask> };
<mask>
<mask> export const getTopStatsRequest = createAction('GET_TOP_STATS_REQUEST');
<mask> export const getTopStatsFailure = createAction('GET_TOP_STATS_FAILURE');
<mask> export const getTopStatsSuccess = createAction('GET_TOP_STATS_SUCCESS');
<mask>
<mask> export const getTopStats = () => async (dispatch, getState) => {
</s> Add update check
Closes #338 </s> add getVersion: PropTypes.func, </s> remove version {dnsVersion} / address: {dnsAddress}:{dnsPort}
</s> add <div className="nav-version__text">
version: <span className="nav-version__value">{dnsVersion}</span>
</div>
<div className="nav-version__text">
address: <span className="nav-version__value">{dnsAddress}:{dnsPort}</span>
</div> </s> add this.props.getVersion(); </s> add processingVersion: true, </s> add import versionCompare from 'tiny-version-compare'; </s> add const updateAvailable =
!dashboard.processingVersions &&
dashboard.isCoreRunning &&
dashboard.isUpdateAvailable;
| https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255 | client/src/actions/index.js |
keep keep keep add keep keep keep keep | <mask> GLOBAL_QUERY_LOG = { path: 'querylog', method: 'GET' };
<mask> GLOBAL_QUERY_LOG_ENABLE = { path: 'querylog_enable', method: 'POST' };
<mask> GLOBAL_QUERY_LOG_DISABLE = { path: 'querylog_disable', method: 'POST' };
<mask> GLOBAL_SET_UPSTREAM_DNS = { path: 'set_upstream_dns', method: 'POST' };
<mask>
<mask> restartGlobalFiltering() {
<mask> const { path, method } = this.GLOBAL_RESTART;
<mask> return this.makeRequest(path, method);
</s> Add update check
Closes #338 </s> add getGlobalVersion() {
const { path, method } = this.GLOBAL_VERSION;
return this.makeRequest(path, method);
}
</s> add this.props.getVersion(); </s> add const updateAvailable =
!dashboard.processingVersions &&
dashboard.isCoreRunning &&
dashboard.isUpdateAvailable;
</s> add export const getVersionRequest = createAction('GET_VERSION_REQUEST');
export const getVersionFailure = createAction('GET_VERSION_FAILURE');
export const getVersionSuccess = createAction('GET_VERSION_SUCCESS');
export const getVersion = () => async (dispatch) => {
dispatch(getVersionRequest());
try {
const newVersion = await apiClient.getGlobalVersion();
dispatch(getVersionSuccess(newVersion));
} catch (error) {
dispatch(addErrorToast({ error }));
dispatch(getVersionFailure());
}
};
</s> remove version {dnsVersion} / address: {dnsAddress}:{dnsPort}
</s> add <div className="nav-version__text">
version: <span className="nav-version__value">{dnsVersion}</span>
</div>
<div className="nav-version__text">
address: <span className="nav-version__value">{dnsAddress}:{dnsPort}</span>
</div> </s> add .nav-version__value {
font-weight: 600;
}
| https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255 | client/src/api/Api.js |
keep keep add keep keep keep keep keep | <mask> return this.makeRequest(path, method, config);
<mask> }
<mask>
<mask> // Filtering
<mask> FILTERING_STATUS = { path: 'filtering/status', method: 'GET' };
<mask> FILTERING_ENABLE = { path: 'filtering/enable', method: 'POST' };
<mask> FILTERING_DISABLE = { path: 'filtering/disable', method: 'POST' };
<mask> FILTERING_ADD_FILTER = { path: 'filtering/add_url', method: 'PUT' };
</s> Add update check
Closes #338 </s> add GLOBAL_VERSION = { path: 'version.json', method: 'GET' }; </s> add this.props.getVersion(); </s> add const updateAvailable =
!dashboard.processingVersions &&
dashboard.isCoreRunning &&
dashboard.isUpdateAvailable;
</s> add export const getVersionRequest = createAction('GET_VERSION_REQUEST');
export const getVersionFailure = createAction('GET_VERSION_FAILURE');
export const getVersionSuccess = createAction('GET_VERSION_SUCCESS');
export const getVersion = () => async (dispatch) => {
dispatch(getVersionRequest());
try {
const newVersion = await apiClient.getGlobalVersion();
dispatch(getVersionSuccess(newVersion));
} catch (error) {
dispatch(addErrorToast({ error }));
dispatch(getVersionFailure());
}
};
</s> remove version {dnsVersion} / address: {dnsAddress}:{dnsPort}
</s> add <div className="nav-version__text">
version: <span className="nav-version__value">{dnsVersion}</span>
</div>
<div className="nav-version__text">
address: <span className="nav-version__value">{dnsAddress}:{dnsPort}</span>
</div> </s> add .nav-version__value {
font-weight: 600;
}
| https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255 | client/src/api/Api.js |
keep add keep keep keep keep keep | <mask> import Toasts from '../Toasts';
<mask> import Status from '../ui/Status';
<mask>
<mask> class App extends Component {
<mask> componentDidMount() {
<mask> this.props.getDnsStatus();
<mask> this.props.getVersion();
</s> Add update check
Closes #338 </s> add this.props.getVersion(); </s> add import versionCompare from 'tiny-version-compare'; </s> add GLOBAL_VERSION = { path: 'version.json', method: 'GET' }; </s> add getGlobalVersion() {
const { path, method } = this.GLOBAL_VERSION;
return this.makeRequest(path, method);
}
</s> add .nav-version__value {
font-weight: 600;
}
</s> add "tiny-version-compare": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/tiny-version-compare/-/tiny-version-compare-0.9.1.tgz",
"integrity": "sha512-kYim94l7ptSmj9rqxUMkrcMCJ448CS+hwqjA7OFcRi0ISdi0zjgdSUklQ4velVVECCjCo5frU3tNZ3oSgIKzsA=="
}, | https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255 | client/src/components/App/index.js |
keep keep keep add keep keep keep keep keep | <mask>
<mask> class App extends Component {
<mask> componentDidMount() {
<mask> this.props.getDnsStatus();
<mask> }
<mask>
<mask> handleStatusChange = () => {
<mask> this.props.enableDns();
<mask> };
</s> Add update check
Closes #338 </s> add import Update from '../ui/Update'; </s> add export const getVersionRequest = createAction('GET_VERSION_REQUEST');
export const getVersionFailure = createAction('GET_VERSION_FAILURE');
export const getVersionSuccess = createAction('GET_VERSION_SUCCESS');
export const getVersion = () => async (dispatch) => {
dispatch(getVersionRequest());
try {
const newVersion = await apiClient.getGlobalVersion();
dispatch(getVersionSuccess(newVersion));
} catch (error) {
dispatch(addErrorToast({ error }));
dispatch(getVersionFailure());
}
};
</s> add getGlobalVersion() {
const { path, method } = this.GLOBAL_VERSION;
return this.makeRequest(path, method);
}
</s> add GLOBAL_VERSION = { path: 'version.json', method: 'GET' }; </s> add import versionCompare from 'tiny-version-compare'; </s> add .nav-version__value {
font-weight: 600;
}
| https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255 | client/src/components/App/index.js |
keep keep keep add keep keep keep keep keep | <mask> };
<mask>
<mask> render() {
<mask> const { dashboard } = this.props;
<mask> return (
<mask> <HashRouter hashType='noslash'>
<mask> <Fragment>
<mask> {updateAvailable &&
<mask> <Update
</s> Add update check
Closes #338 </s> add {updateAvailable &&
<Update
announcement={dashboard.announcement}
announcementUrl={dashboard.announcementUrl}
/>
} </s> remove version {dnsVersion} / address: {dnsAddress}:{dnsPort}
</s> add <div className="nav-version__text">
version: <span className="nav-version__value">{dnsVersion}</span>
</div>
<div className="nav-version__text">
address: <span className="nav-version__value">{dnsAddress}:{dnsPort}</span>
</div> </s> add getGlobalVersion() {
const { path, method } = this.GLOBAL_VERSION;
return this.makeRequest(path, method);
}
</s> add GLOBAL_VERSION = { path: 'version.json', method: 'GET' }; </s> add this.props.getVersion(); </s> add export const getVersionRequest = createAction('GET_VERSION_REQUEST');
export const getVersionFailure = createAction('GET_VERSION_FAILURE');
export const getVersionSuccess = createAction('GET_VERSION_SUCCESS');
export const getVersion = () => async (dispatch) => {
dispatch(getVersionRequest());
try {
const newVersion = await apiClient.getGlobalVersion();
dispatch(getVersionSuccess(newVersion));
} catch (error) {
dispatch(addErrorToast({ error }));
dispatch(getVersionFailure());
}
};
| https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255 | client/src/components/App/index.js |
keep add keep keep keep keep keep keep | <mask> <HashRouter hashType='noslash'>
<mask> <Fragment>
<mask> <LoadingBar className="loading-bar" updateTime={1000} />
<mask> <Route component={Header} />
<mask> <div className="container container--wrap">
<mask> {!dashboard.processing && !dashboard.isCoreRunning &&
<mask> <div className="row row-cards">
<mask> <div className="col-lg-12">
</s> Add update check
Closes #338 </s> add const updateAvailable =
!dashboard.processingVersions &&
dashboard.isCoreRunning &&
dashboard.isUpdateAvailable;
</s> remove version {dnsVersion} / address: {dnsAddress}:{dnsPort}
</s> add <div className="nav-version__text">
version: <span className="nav-version__value">{dnsVersion}</span>
</div>
<div className="nav-version__text">
address: <span className="nav-version__value">{dnsAddress}:{dnsPort}</span>
</div> </s> add processingVersion: true, </s> add import versionCompare from 'tiny-version-compare'; </s> remove font-size: 0.9rem;
</s> add font-size: 0.85rem; </s> add .nav-version__value {
font-weight: 600;
}
| https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255 | client/src/components/App/index.js |
keep add keep keep keep | <mask> isCoreRunning: PropTypes.bool,
<mask> error: PropTypes.string,
<mask> };
<mask>
<mask> export default App;
</s> Add update check
Closes #338 </s> add export const getVersionRequest = createAction('GET_VERSION_REQUEST');
export const getVersionFailure = createAction('GET_VERSION_FAILURE');
export const getVersionSuccess = createAction('GET_VERSION_SUCCESS');
export const getVersion = () => async (dispatch) => {
dispatch(getVersionRequest());
try {
const newVersion = await apiClient.getGlobalVersion();
dispatch(getVersionSuccess(newVersion));
} catch (error) {
dispatch(addErrorToast({ error }));
dispatch(getVersionFailure());
}
};
</s> remove version {dnsVersion} / address: {dnsAddress}:{dnsPort}
</s> add <div className="nav-version__text">
version: <span className="nav-version__value">{dnsVersion}</span>
</div>
<div className="nav-version__text">
address: <span className="nav-version__value">{dnsAddress}:{dnsPort}</span>
</div> </s> add GLOBAL_VERSION = { path: 'version.json', method: 'GET' }; </s> add getGlobalVersion() {
const { path, method } = this.GLOBAL_VERSION;
return this.makeRequest(path, method);
}
</s> add this.props.getVersion(); </s> add const updateAvailable =
!dashboard.processingVersions &&
dashboard.isCoreRunning &&
dashboard.isUpdateAvailable;
| https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255 | client/src/components/App/index.js |
keep keep keep keep replace replace keep keep keep keep keep | <mask> overflow: hidden;
<mask> }
<mask>
<mask> .nav-version {
<mask> padding: 16px 0;
<mask> font-size: 0.85rem;
<mask> text-align: right;
<mask> }
<mask>
<mask> .header-brand-img {
<mask> height: 26px;
</s> Add update check
Closes #338 </s> remove font-size: 0.9rem;
</s> add font-size: 0.85rem; </s> add .nav-version__value {
font-weight: 600;
}
</s> add getGlobalVersion() {
const { path, method } = this.GLOBAL_VERSION;
return this.makeRequest(path, method);
}
</s> add this.props.getVersion(); </s> add import versionCompare from 'tiny-version-compare'; </s> add "tiny-version-compare": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/tiny-version-compare/-/tiny-version-compare-0.9.1.tgz",
"integrity": "sha512-kYim94l7ptSmj9rqxUMkrcMCJ448CS+hwqjA7OFcRi0ISdi0zjgdSUklQ4velVVECCjCo5frU3tNZ3oSgIKzsA=="
}, | https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255 | client/src/components/Header/Header.css |
keep keep keep add keep keep keep keep keep | <mask> font-size: 0.80rem;
<mask> text-align: right;
<mask> }
<mask>
<mask> .header-brand-img {
<mask> height: 26px;
<mask> }
<mask>
<mask> @media screen and (min-width: 992px) {
</s> Add update check
Closes #338 </s> remove padding: 16px 0;
font-size: 0.85rem;
</s> add padding: 7px 0;
font-size: 0.80rem; </s> remove font-size: 0.9rem;
</s> add font-size: 0.85rem; </s> add getGlobalVersion() {
const { path, method } = this.GLOBAL_VERSION;
return this.makeRequest(path, method);
}
</s> add this.props.getVersion(); </s> add import versionCompare from 'tiny-version-compare'; </s> add "tiny-version-compare": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/tiny-version-compare/-/tiny-version-compare-0.9.1.tgz",
"integrity": "sha512-kYim94l7ptSmj9rqxUMkrcMCJ448CS+hwqjA7OFcRi0ISdi0zjgdSUklQ4velVVECCjCo5frU3tNZ3oSgIKzsA=="
}, | https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255 | client/src/components/Header/Header.css |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask>
<mask> .nav-version {
<mask> padding: 0;
<mask> font-size: 0.9rem;
<mask> }
<mask> }
<mask>
<mask> .dns-status {
<mask> padding: 0.35em 0.5em;
</s> Add update check
Closes #338 </s> remove padding: 16px 0;
font-size: 0.85rem;
</s> add padding: 7px 0;
font-size: 0.80rem; </s> add .nav-version__value {
font-weight: 600;
}
</s> add getGlobalVersion() {
const { path, method } = this.GLOBAL_VERSION;
return this.makeRequest(path, method);
}
</s> add import versionCompare from 'tiny-version-compare'; </s> add this.props.getVersion(); </s> remove version {dnsVersion} / address: {dnsAddress}:{dnsPort}
</s> add <div className="nav-version__text">
version: <span className="nav-version__value">{dnsVersion}</span>
</div>
<div className="nav-version__text">
address: <span className="nav-version__value">{dnsAddress}:{dnsPort}</span>
</div> | https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255 | client/src/components/Header/Header.css |
keep keep keep keep replace keep keep keep keep keep | <mask> export default function Version(props) {
<mask> const { dnsVersion, dnsAddress, dnsPort } = props;
<mask> return (
<mask> <div className="nav-version">
<mask> version {dnsVersion} / address: {dnsAddress}:{dnsPort}
<mask> </div>
<mask> );
<mask> }
<mask>
<mask> Version.propTypes = {
</s> Add update check
Closes #338 </s> add const updateAvailable =
!dashboard.processingVersions &&
dashboard.isCoreRunning &&
dashboard.isUpdateAvailable;
</s> add export const getVersionRequest = createAction('GET_VERSION_REQUEST');
export const getVersionFailure = createAction('GET_VERSION_FAILURE');
export const getVersionSuccess = createAction('GET_VERSION_SUCCESS');
export const getVersion = () => async (dispatch) => {
dispatch(getVersionRequest());
try {
const newVersion = await apiClient.getGlobalVersion();
dispatch(getVersionSuccess(newVersion));
} catch (error) {
dispatch(addErrorToast({ error }));
dispatch(getVersionFailure());
}
};
</s> add getGlobalVersion() {
const { path, method } = this.GLOBAL_VERSION;
return this.makeRequest(path, method);
}
</s> add .nav-version__value {
font-weight: 600;
}
</s> add GLOBAL_VERSION = { path: 'version.json', method: 'GET' }; </s> remove font-size: 0.9rem;
</s> add font-size: 0.85rem; | https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255 | client/src/components/Header/Version.js |
keep keep add keep keep keep keep keep keep | <mask> import { combineReducers } from 'redux';
<mask> import { handleActions } from 'redux-actions';
<mask> import { loadingBarReducer } from 'react-redux-loading-bar';
<mask> import nanoid from 'nanoid';
<mask>
<mask> import * as actions from '../actions';
<mask>
<mask> const settings = handleActions({
<mask> [actions.initSettingsRequest]: state => ({ ...state, processing: true }),
</s> Add update check
Closes #338 </s> add import Update from '../ui/Update'; </s> add processingVersion: true, </s> add this.props.getVersion(); </s> add export const getVersionRequest = createAction('GET_VERSION_REQUEST');
export const getVersionFailure = createAction('GET_VERSION_FAILURE');
export const getVersionSuccess = createAction('GET_VERSION_SUCCESS');
export const getVersion = () => async (dispatch) => {
dispatch(getVersionRequest());
try {
const newVersion = await apiClient.getGlobalVersion();
dispatch(getVersionSuccess(newVersion));
} catch (error) {
dispatch(addErrorToast({ error }));
dispatch(getVersionFailure());
}
};
</s> add .nav-version__value {
font-weight: 600;
}
</s> remove font-size: 0.9rem;
</s> add font-size: 0.85rem; | https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255 | client/src/reducers/index.js |
keep keep add keep keep keep keep keep keep | <mask> processingTopStats: true,
<mask> processingStats: true,
<mask> logStatusProcessing: false,
<mask> });
<mask>
<mask> const queryLogs = handleActions({
<mask> [actions.getLogsRequest]: state => ({ ...state, getLogsProcessing: true }),
<mask> [actions.getLogsFailure]: state => ({ ...state, getLogsProcessing: false }),
<mask> [actions.getLogsSuccess]: (state, { payload }) => {
</s> Add update check
Closes #338 </s> add import versionCompare from 'tiny-version-compare'; </s> add export const getVersionRequest = createAction('GET_VERSION_REQUEST');
export const getVersionFailure = createAction('GET_VERSION_FAILURE');
export const getVersionSuccess = createAction('GET_VERSION_SUCCESS');
export const getVersion = () => async (dispatch) => {
dispatch(getVersionRequest());
try {
const newVersion = await apiClient.getGlobalVersion();
dispatch(getVersionSuccess(newVersion));
} catch (error) {
dispatch(addErrorToast({ error }));
dispatch(getVersionFailure());
}
};
</s> add "tiny-version-compare": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/tiny-version-compare/-/tiny-version-compare-0.9.1.tgz",
"integrity": "sha512-kYim94l7ptSmj9rqxUMkrcMCJ448CS+hwqjA7OFcRi0ISdi0zjgdSUklQ4velVVECCjCo5frU3tNZ3oSgIKzsA=="
}, </s> add this.props.getVersion(); </s> add GLOBAL_VERSION = { path: 'version.json', method: 'GET' }; </s> add getGlobalVersion() {
const { path, method } = this.GLOBAL_VERSION;
return this.makeRequest(path, method);
}
| https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255 | client/src/reducers/index.js |
keep keep add keep keep keep keep keep keep | <mask> "custom_ip": "Custom IP",
<mask> "blocking_ipv4": "Blocking IPv4",
<mask> "blocking_ipv6": "Blocking IPv6",
<mask> "dns_over_https": "DNS-over-HTTPS",
<mask> "dns_over_tls": "DNS-over-TLS",
<mask> "dns_over_quic": "DNS-over-QUIC",
<mask> "client_id": "Client ID",
<mask> "client_id_placeholder": "Enter client ID",
<mask> "client_id_desc": "Different clients can be identified by a special client ID. <a>Here</a> you can learn more about how to identify clients.",
</s> Pull request: 2662 dnscrypt logs
Merge in DNS/adguard-home from 2662-dnscrypt-logs to master
Closes #2662.
Squashed commit of the following:
commit 05f6742b5c73e1d150834965ae3a54ca06ef8e24
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:58:08 2021 +0300
all: imp docs
commit ee0b8c574c1cb5302a5ffb62d2fec4126509b2e8
Merge: aaa8c6b8 e64df20e
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:56:44 2021 +0300
Merge branch 'master' into 2662-dnscrypt-logs
commit aaa8c6b8085679f4acd234527bd03cb0b2520b4f
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:38:49 2021 +0300
all: document changes
commit 57b6a4d8e95e87d928274d095dc2004f1591d940
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:36:22 2021 +0300
all: fix dnscrypt in logs </s> remove } </s> add </s> add } </s> add ClientProtoDNSCrypt, </s> add dnscrypt: 'dnscrypt', | https://github.com/AdguardTeam/AdGuardHome/commit/44168292d5f466b9e7cda271987f03363ab6d6a8 | client/src/__locales/en.json |
keep keep keep keep replace | <mask> "port_53_faq_link": "Port 53 is often occupied by \"DNSStubListener\" or \"systemd-resolved\" services. Please read <0>this instruction</0> on how to resolve this.",
<mask> "adg_will_drop_dns_queries": "AdGuard Home will be dropping all DNS queries from this client.",
<mask> "client_not_in_allowed_clients": "The client is not allowed because it is not in the \"Allowed clients\" list.",
<mask> "experimental": "Experimental"
<mask> } </s> Pull request: 2662 dnscrypt logs
Merge in DNS/adguard-home from 2662-dnscrypt-logs to master
Closes #2662.
Squashed commit of the following:
commit 05f6742b5c73e1d150834965ae3a54ca06ef8e24
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:58:08 2021 +0300
all: imp docs
commit ee0b8c574c1cb5302a5ffb62d2fec4126509b2e8
Merge: aaa8c6b8 e64df20e
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:56:44 2021 +0300
Merge branch 'master' into 2662-dnscrypt-logs
commit aaa8c6b8085679f4acd234527bd03cb0b2520b4f
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:38:49 2021 +0300
all: document changes
commit 57b6a4d8e95e87d928274d095dc2004f1591d940
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:36:22 2021 +0300
all: fix dnscrypt in logs </s> add } </s> add "dnscrypt": "DNSCrypt", </s> add ClientProtoDNSCrypt, </s> add dnscrypt: 'dnscrypt', | https://github.com/AdguardTeam/AdGuardHome/commit/44168292d5f466b9e7cda271987f03363ab6d6a8 | client/src/__locales/en.json |
keep keep keep add | <mask> "adg_will_drop_dns_queries": "AdGuard Home will be dropping all DNS queries from this client.",
<mask> "client_not_in_allowed_clients": "The client is not allowed because it is not in the \"Allowed clients\" list.",
<mask> "experimental": "Experimental"
<mask> }
</s> Pull request: 2662 dnscrypt logs
Merge in DNS/adguard-home from 2662-dnscrypt-logs to master
Closes #2662.
Squashed commit of the following:
commit 05f6742b5c73e1d150834965ae3a54ca06ef8e24
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:58:08 2021 +0300
all: imp docs
commit ee0b8c574c1cb5302a5ffb62d2fec4126509b2e8
Merge: aaa8c6b8 e64df20e
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:56:44 2021 +0300
Merge branch 'master' into 2662-dnscrypt-logs
commit aaa8c6b8085679f4acd234527bd03cb0b2520b4f
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:38:49 2021 +0300
all: document changes
commit 57b6a4d8e95e87d928274d095dc2004f1591d940
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:36:22 2021 +0300
all: fix dnscrypt in logs </s> remove } </s> add </s> add "dnscrypt": "DNSCrypt", </s> add ClientProtoDNSCrypt, </s> add dnscrypt: 'dnscrypt', | https://github.com/AdguardTeam/AdGuardHome/commit/44168292d5f466b9e7cda271987f03363ab6d6a8 | client/src/__locales/en.json |
keep add keep keep keep keep keep keep | <mask>
<mask> export const SCHEME_TO_PROTOCOL_MAP = {
<mask> doh: 'dns_over_https',
<mask> dot: 'dns_over_tls',
<mask> doq: 'dns_over_quic',
<mask> '': 'plain_dns',
<mask> };
<mask>
</s> Pull request: 2662 dnscrypt logs
Merge in DNS/adguard-home from 2662-dnscrypt-logs to master
Closes #2662.
Squashed commit of the following:
commit 05f6742b5c73e1d150834965ae3a54ca06ef8e24
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:58:08 2021 +0300
all: imp docs
commit ee0b8c574c1cb5302a5ffb62d2fec4126509b2e8
Merge: aaa8c6b8 e64df20e
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:56:44 2021 +0300
Merge branch 'master' into 2662-dnscrypt-logs
commit aaa8c6b8085679f4acd234527bd03cb0b2520b4f
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:38:49 2021 +0300
all: document changes
commit 57b6a4d8e95e87d928274d095dc2004f1591d940
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:36:22 2021 +0300
all: fix dnscrypt in logs </s> add ClientProtoDNSCrypt, </s> add } </s> remove } </s> add </s> add "dnscrypt": "DNSCrypt", | https://github.com/AdguardTeam/AdGuardHome/commit/44168292d5f466b9e7cda271987f03363ab6d6a8 | client/src/helpers/constants.js |
keep keep add keep keep keep keep keep | <mask> ClientProtoDOH,
<mask> ClientProtoDOQ,
<mask> ClientProtoDOT,
<mask> ClientProtoPlain:
<mask>
<mask> return cp, nil
<mask> default:
<mask> return "", fmt.Errorf("invalid client proto: %q", s)
</s> Pull request: 2662 dnscrypt logs
Merge in DNS/adguard-home from 2662-dnscrypt-logs to master
Closes #2662.
Squashed commit of the following:
commit 05f6742b5c73e1d150834965ae3a54ca06ef8e24
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:58:08 2021 +0300
all: imp docs
commit ee0b8c574c1cb5302a5ffb62d2fec4126509b2e8
Merge: aaa8c6b8 e64df20e
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:56:44 2021 +0300
Merge branch 'master' into 2662-dnscrypt-logs
commit aaa8c6b8085679f4acd234527bd03cb0b2520b4f
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:38:49 2021 +0300
all: document changes
commit 57b6a4d8e95e87d928274d095dc2004f1591d940
Author: Ainar Garipov <[email protected]>
Date: Thu Feb 11 12:36:22 2021 +0300
all: fix dnscrypt in logs </s> add "dnscrypt": "DNSCrypt", </s> add } </s> remove } </s> add </s> add dnscrypt: 'dnscrypt', | https://github.com/AdguardTeam/AdGuardHome/commit/44168292d5f466b9e7cda271987f03363ab6d6a8 | internal/querylog/qlog.go |
keep replace replace replace keep replace replace | <mask> func (s *Server) registerHandlers() {
<mask> s.conf.HTTPRegister("GET", "/control/dns_info", s.handleGetConfig)
<mask> s.conf.HTTPRegister("POST", "/control/dns_config", s.handleSetConfig)
<mask> s.conf.HTTPRegister("POST", "/control/test_upstream_dns", s.handleTestUpstreamDNS)
<mask>
<mask> s.conf.HTTPRegister("GET", "/control/access/list", s.handleAccessList)
<mask> s.conf.HTTPRegister("POST", "/control/access/set", s.handleAccessSet)
</s> Pull request: all: imp http handlers, imp docs
Merge in DNS/adguard-home from fix-openapi to master
Squashed commit of the following:
commit 0e7530472fb566e5cab73d178c8ec16e5ef11dcb
Author: Ainar Garipov <[email protected]>
Date: Wed Jan 13 17:02:06 2021 +0300
all: imp http handlers, imp docs </s> remove func handleStatus(w http.ResponseWriter, r *http.Request) {
</s> add func handleStatus(w http.ResponseWriter, _ *http.Request) { </s> remove return ensure("POST", handler)
</s> add return ensure(http.MethodPost, handler) </s> remove Context.mux.Handle("/control/login", postInstallHandler(ensureHandler("POST", handleLogin)))
httpRegister("GET", "/control/logout", handleLogout)
</s> add Context.mux.Handle("/control/login", postInstallHandler(ensureHandler(http.MethodPost, handleLogin)))
httpRegister(http.MethodGet, "/control/logout", handleLogout) </s> remove return ensure("GET", handler)
</s> add return ensure(http.MethodGet, handler) </s> remove if method == "POST" || method == "PUT" || method == "DELETE" {
</s> add if method == http.MethodPost || method == http.MethodPut || method == http.MethodDelete { | https://github.com/AdguardTeam/AdGuardHome/commit/4474e9fcf9073af593df76b4844f4091c1c7946e | internal/dnsforward/http.go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.