all: add todo
This commit is contained in:
parent
48a5879865
commit
f0b85ac1fe
1
go.mod
1
go.mod
|
@ -3,6 +3,7 @@ module github.com/AdguardTeam/AdGuardHome
|
|||
go 1.20
|
||||
|
||||
require (
|
||||
// TODO(e.burkov): !! Update to v0.57.0 when it's released.
|
||||
github.com/AdguardTeam/dnsproxy v0.56.4-0.20231031121835-8d20902c442f
|
||||
github.com/AdguardTeam/golibs v0.17.2
|
||||
github.com/AdguardTeam/urlfilter v0.17.3
|
||||
|
|
|
@ -23,6 +23,7 @@ func (s *Server) processQueryLogsAndStats(dctx *dnsContext) (rc resultCode) {
|
|||
pctx := dctx.proxyCtx
|
||||
q := pctx.Req.Question[0]
|
||||
host := aghnet.NormalizeDomain(q.Name)
|
||||
processingTime := time.Since(dctx.startTime)
|
||||
|
||||
ip, _ := netutil.IPAndPortFromAddr(pctx.Addr)
|
||||
ip = slices.Clone(ip)
|
||||
|
@ -41,7 +42,7 @@ func (s *Server) processQueryLogsAndStats(dctx *dnsContext) (rc resultCode) {
|
|||
defer s.serverLock.RUnlock()
|
||||
|
||||
if s.shouldLog(host, qt, cl, ids) {
|
||||
s.logQuery(dctx, ip)
|
||||
s.logQuery(dctx, ip, processingTime)
|
||||
} else {
|
||||
log.Debug(
|
||||
"dnsforward: request %s %s %q from %s ignored; not adding to querylog",
|
||||
|
@ -53,7 +54,7 @@ func (s *Server) processQueryLogsAndStats(dctx *dnsContext) (rc resultCode) {
|
|||
}
|
||||
|
||||
if s.shouldCountStat(host, qt, cl, ids) {
|
||||
s.updateStats(dctx, ipStr)
|
||||
s.updateStats(dctx, ipStr, processingTime)
|
||||
} else {
|
||||
log.Debug(
|
||||
"dnsforward: request %s %s %q from %s ignored; not counting in stats",
|
||||
|
@ -88,7 +89,7 @@ func (s *Server) shouldCountStat(host string, qt, cl uint16, ids []string) (ok b
|
|||
}
|
||||
|
||||
// logQuery pushes the request details into the query log.
|
||||
func (s *Server) logQuery(dctx *dnsContext, ip net.IP) {
|
||||
func (s *Server) logQuery(dctx *dnsContext, ip net.IP, processingTime time.Duration) {
|
||||
pctx := dctx.proxyCtx
|
||||
|
||||
p := &querylog.AddParams{
|
||||
|
@ -99,7 +100,7 @@ func (s *Server) logQuery(dctx *dnsContext, ip net.IP) {
|
|||
Result: dctx.result,
|
||||
ClientID: dctx.clientID,
|
||||
ClientIP: ip,
|
||||
Elapsed: time.Since(dctx.startTime),
|
||||
Elapsed: processingTime,
|
||||
AuthenticatedData: dctx.responseAD,
|
||||
}
|
||||
|
||||
|
@ -127,14 +128,14 @@ func (s *Server) logQuery(dctx *dnsContext, ip net.IP) {
|
|||
}
|
||||
|
||||
// updatesStats writes the request into statistics.
|
||||
func (s *Server) updateStats(dctx *dnsContext, clientIP string) {
|
||||
func (s *Server) updateStats(dctx *dnsContext, clientIP string, processingTime time.Duration) {
|
||||
pctx := dctx.proxyCtx
|
||||
|
||||
e := &stats.Entry{
|
||||
Domain: aghnet.NormalizeDomain(pctx.Req.Question[0].Name),
|
||||
Result: stats.RNotFiltered,
|
||||
ProcesssingTime: time.Since(dctx.startTime),
|
||||
UpstreamTime: pctx.QueryDuration,
|
||||
Domain: aghnet.NormalizeDomain(pctx.Req.Question[0].Name),
|
||||
Result: stats.RNotFiltered,
|
||||
ProcessingTime: processingTime,
|
||||
UpstreamTime: pctx.QueryDuration,
|
||||
}
|
||||
|
||||
if pctx.Upstream != nil {
|
||||
|
|
|
@ -33,10 +33,10 @@ func TestStats_races(t *testing.T) {
|
|||
|
||||
writeFunc := func(start, fin *sync.WaitGroup, waitCh <-chan unit, i int) {
|
||||
e := &Entry{
|
||||
Domain: fmt.Sprintf("example-%d.org", i),
|
||||
Client: fmt.Sprintf("client_%d", i),
|
||||
Result: Result(i)%(resultLast-1) + 1,
|
||||
ProcesssingTime: time.Since(startTime),
|
||||
Domain: fmt.Sprintf("example-%d.org", i),
|
||||
Client: fmt.Sprintf("client_%d", i),
|
||||
Result: Result(i)%(resultLast-1) + 1,
|
||||
ProcessingTime: time.Since(startTime),
|
||||
}
|
||||
|
||||
start.Done()
|
||||
|
|
|
@ -76,19 +76,19 @@ func TestStats(t *testing.T) {
|
|||
const respUpstream = "upstream"
|
||||
|
||||
entries := []*stats.Entry{{
|
||||
Domain: reqDomain,
|
||||
Client: cliIPStr,
|
||||
Result: stats.RFiltered,
|
||||
ProcesssingTime: time.Microsecond * 123456,
|
||||
Upstream: respUpstream,
|
||||
UpstreamTime: time.Microsecond * 222222,
|
||||
Domain: reqDomain,
|
||||
Client: cliIPStr,
|
||||
Result: stats.RFiltered,
|
||||
ProcessingTime: time.Microsecond * 123456,
|
||||
Upstream: respUpstream,
|
||||
UpstreamTime: time.Microsecond * 222222,
|
||||
}, {
|
||||
Domain: reqDomain,
|
||||
Client: cliIPStr,
|
||||
Result: stats.RNotFiltered,
|
||||
ProcesssingTime: time.Microsecond * 123456,
|
||||
Upstream: respUpstream,
|
||||
UpstreamTime: time.Microsecond * 222222,
|
||||
Domain: reqDomain,
|
||||
Client: cliIPStr,
|
||||
Result: stats.RNotFiltered,
|
||||
ProcessingTime: time.Microsecond * 123456,
|
||||
Upstream: respUpstream,
|
||||
UpstreamTime: time.Microsecond * 222222,
|
||||
}}
|
||||
|
||||
wantData := &stats.StatsResp{
|
||||
|
@ -198,10 +198,10 @@ func TestLargeNumbers(t *testing.T) {
|
|||
for i := 0; i < cliNumPerHour; i++ {
|
||||
ip := net.IP{127, 0, byte((i & 0xff00) >> 8), byte(i & 0xff)}
|
||||
e := &stats.Entry{
|
||||
Domain: fmt.Sprintf("domain%d.hour%d", i, h),
|
||||
Client: ip.String(),
|
||||
Result: stats.RNotFiltered,
|
||||
ProcesssingTime: 123456,
|
||||
Domain: fmt.Sprintf("domain%d.hour%d", i, h),
|
||||
Client: ip.String(),
|
||||
Result: stats.RNotFiltered,
|
||||
ProcessingTime: 123456,
|
||||
}
|
||||
s.Update(e)
|
||||
}
|
||||
|
|
|
@ -68,9 +68,9 @@ type Entry struct {
|
|||
// Result is the result of processing the request.
|
||||
Result Result
|
||||
|
||||
// ProcesssingTime is the duration of the request processing from the start
|
||||
// ProcessingTime is the duration of the request processing from the start
|
||||
// of the request including timeouts.
|
||||
ProcesssingTime time.Duration
|
||||
ProcessingTime time.Duration
|
||||
|
||||
// UpstreamTime is the duration of the successful request to the upstream.
|
||||
UpstreamTime time.Duration
|
||||
|
@ -327,7 +327,7 @@ func (u *unit) add(e *Entry) {
|
|||
}
|
||||
|
||||
u.clients[e.Client]++
|
||||
pt := uint64(e.ProcesssingTime.Microseconds())
|
||||
pt := uint64(e.ProcessingTime.Microseconds())
|
||||
u.timeSum += pt
|
||||
u.nTotal++
|
||||
|
||||
|
|
Loading…
Reference in New Issue