stats

package
v0.104.3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

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 {
	Domain string
	Client net.IP
	Result Result
	Time   uint32 // processing time (msec)
}

Entry - data to add

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) []string

	// 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