mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-29 10:28:53 +03:00
df34ee5c09
Merge in DNS/adguard-home from 2241-doq-logs to master
Squashed commit of the following:
commit a15cab05358e3c0b97f8257f8b9628fa590e7e7d
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Tue Nov 3 14:22:25 2020 +0300
* all: update dnsproxy
commit 5fb0919a7528dc6ee7a433a8096b550f3691771c
Merge: b22b1dff4 64c1a68fb
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Tue Nov 3 14:22:15 2020 +0300
Merge branch 'master' into 2241-doq-logs
commit b22b1dff43e541d77160fd5c234483bbf0f6d8de
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Tue Nov 3 12:37:23 2020 +0300
* dnsforward, querylog: set client_proto for logs correctly
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package querylog
|
|
|
|
import (
|
|
"net"
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/AdguardTeam/AdGuardHome/internal/dnsfilter"
|
|
"github.com/miekg/dns"
|
|
)
|
|
|
|
// QueryLog - main interface
|
|
type QueryLog interface {
|
|
Start()
|
|
|
|
// Close query log object
|
|
Close()
|
|
|
|
// Add a log entry
|
|
Add(params AddParams)
|
|
|
|
// WriteDiskConfig - write configuration
|
|
WriteDiskConfig(c *Config)
|
|
}
|
|
|
|
// Config - configuration object
|
|
type Config struct {
|
|
Enabled bool // enable the module
|
|
FileEnabled bool // write logs to file
|
|
BaseDir string // directory where log file is stored
|
|
Interval uint32 // interval to rotate logs (in days)
|
|
MemSize uint32 // number of entries kept in memory before they are flushed to disk
|
|
AnonymizeClientIP bool // anonymize clients' IP addresses
|
|
|
|
// Called when the configuration is changed by HTTP request
|
|
ConfigModified func()
|
|
|
|
// Register an HTTP handler
|
|
HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request))
|
|
}
|
|
|
|
// AddParams - parameters for Add()
|
|
type AddParams struct {
|
|
Question *dns.Msg
|
|
Answer *dns.Msg // The response we sent to the client (optional)
|
|
OrigAnswer *dns.Msg // The response from an upstream server (optional)
|
|
Result *dnsfilter.Result // Filtering result (optional)
|
|
Elapsed time.Duration // Time spent for processing the request
|
|
ClientIP net.IP
|
|
Upstream string // Upstream server URL
|
|
ClientProto ClientProto
|
|
}
|
|
|
|
// New - create a new instance of the query log
|
|
func New(conf Config) QueryLog {
|
|
return newQueryLog(conf)
|
|
}
|