stats

package
v0.107.0-b.9 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package stats provides units for managing statistics of the filtering DNS server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	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.
	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))
	// contains filtered or unexported fields
}

Config - module configuration

type DiskConfig

type DiskConfig struct {
	Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days)
}

DiskConfig - configuration settings that are stored on disk

type Entry

type Entry struct {
	// Clients is the client's primary ID.
	//
	// TODO(a.garipov): Make this a {net.IP, string} enum?
	Client string

	Domain string
	Result Result
	Time   uint32 // processing time (msec)
}

Entry is a statistics data entry.

type Result

type Result int

Result of DNS request processing

const (
	RNotFiltered Result = iota + 1
	RFiltered
	RSafeBrowsing
	RSafeSearch
	RParental
)

Supported result values

type Stats

type Stats interface {
	Start()

	// Close object.
	// This function is not thread safe
	//  (can't be called in parallel with any other function of this interface).
	Close()

	// Update counters
	Update(e Entry)

	// Get IP addresses of the clients with the most number of requests
	GetTopClientsIP(limit uint) []net.IP

	// WriteDiskConfig - write configuration
	WriteDiskConfig(dc *DiskConfig)
}

Stats - main interface

func New

func New(conf Config) (Stats, error)

New - create object

type TimeUnit

type TimeUnit int

TimeUnit - time unit

const (
	Hours TimeUnit = iota
	Days
)

Supported time units

Jump to

Keyboard shortcuts

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