querylog

package
v0.0.0-...-f179113 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

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 Empty

type Empty struct{}

Empty is a query log does nothing and returns nil values.

func (Empty) Write

func (Empty) Write(_ context.Context, _ *Entry) (err error)

Write implements the Interface interface for Empty. It does nothing and returns nil.

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 file system implementation of the AdGuard DNS query log.

func NewFileSystem

func NewFileSystem(c *FileSystemConfig) (l *FileSystem)

NewFileSystem creates a new file system query log. The log is safe for concurrent use. c must not be nil.

func (*FileSystem) Write

func (l *FileSystem) Write(ctx context.Context, e *Entry) (err error)

Write implements the Interface interface for *FileSystem.

type FileSystemConfig

type FileSystemConfig struct {
	// Logger is used for debug logging.
	Logger *slog.Logger

	// Path is the path to the log file.
	Path string

	// RandSeed is used to set the "rn" property in JSON objects.
	RandSeed uint64
}

FileSystemConfig is the configuration of the file system 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL