Documentation
¶
Overview ¶
Package querylog defines the AdGuard DNS query log constants and types and provides implementations of the log.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmptyMetrics ¶
type EmptyMetrics struct{}
EmptyMetrics is the implementation of the Metrics interface that does nothing.
func (EmptyMetrics) ObserveItemSize ¶
func (EmptyMetrics) ObserveItemSize(_ context.Context, _ datasize.ByteSize)
ObserveItemSize implements the Metrics interface for EmptyMetrics.
func (EmptyMetrics) ObserveWrite ¶
func (EmptyMetrics) ObserveWrite(_ context.Context, _ time.Duration)
ObserveWrite implements the Metrics interface for EmptyMetrics.
type Entry ¶
type Entry struct { // RemoteIP is the remote IP address of the client. RemoteIP netip.Addr // RequestResult is the result of filtering the DNS request. RequestResult filter.Result // ResponseResult is the result of filtering the DNS response. ResponseResult filter.Result // Time is the time of receiving the request. Time time.Time // ProfileID is the detected profile ID, if any. ProfileID agd.ProfileID // DeviceID is the detected device ID, if any. DeviceID agd.DeviceID // ClientCountry is the detected country of the client's IP address, if any. ClientCountry geoip.Country // ResponseCountry is the detected country of the first IP in the response // sent to the client, if any. ResponseCountry geoip.Country // DomainFQDN is the fully-qualified name of the requested resource. DomainFQDN string // RequestID is the ID of the request. // // TODO(a.garipov): Remove once not necessary anymore. RequestID agd.RequestID // Elapsed is the time passed since the beginning of the request processing. Elapsed time.Duration // ClientASN is the detected autonomous system number of the client's IP // address, if any. ClientASN geoip.ASN // RequestType is the type of the resource record of the query. RequestType dnsmsg.RRType // ResponseCode is the response code sent to the client. ResponseCode dnsmsg.RCode // Protocol is the DNS protocol used. Protocol agd.Protocol // DNSSEC is set to true if the response was validated with DNSSEC. DNSSEC bool }
Entry is a single query log entry.
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem is the filesystem implementation of the AdGuard DNS query log.
func NewFileSystem ¶
func NewFileSystem(c *FileSystemConfig) (l *FileSystem)
NewFileSystem creates a new filesystem query log. The log is safe for concurrent use. c must not be nil.
type FileSystemConfig ¶
type FileSystemConfig struct { // Logger is used for debug logging. It must not be nil. Logger *slog.Logger // Metrics is used for the collection of the query log statistics. It must // not be nil. Metrics Metrics // Semaphore is used to limit the number of simultaneous writes. This is // important to prevent excessive thread creation arising from i/o latency // issues. It must not be nil. Semaphore syncutil.Semaphore // Path is the path to the log file. It must not be empty. Path string // RandSeed is used to set the "rn" property in JSON objects. RandSeed [32]byte }
FileSystemConfig is the configuration of the filesystem query log. All fields must not be empty.
type Interface ¶
type Interface interface { // Write writes the entry into the query log. e must not be nil. Write(ctx context.Context, e *Entry) (err error) }
Interface is the query log interface. All methods must be safe for concurrent use.
type Metrics ¶
type Metrics interface { // ObserveItemSize stores the size of written query log entry. ObserveItemSize(ctx context.Context, size datasize.ByteSize) // ObserveWrite stores the duration of the write operation and increments // the write counter. ObserveWrite(ctx context.Context, dur time.Duration) }
Metrics is an interface that is used for the collection of the query log statistics.