engine

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2019 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// metrics prefix
	MetricsPrefix = "gudgeon-"
	// metrics names are prefixed by the metrics prefix and delim
	TotalRules             = "active-rules"
	TotalQueries           = "total-session-queries"
	TotalLifetimeQueries   = "total-lifetime-queries"
	TotalIntervalQueries   = "total-interval-queries"
	CachedQueries          = "cached-queries"
	BlockedQueries         = "blocked-session-queries"
	BlockedLifetimeQueries = "blocked-lifetime-queries"
	BlockedIntervalQueries = "blocked-interval-queries"
	QueriesPerSecond       = "session-queries-ps"
	BlocksPerSecond        = "session-blocks-ps"
	QueryTime              = "query-time"
	// cache entries
	CurrentCacheEntries = "cache-entries"
	// rutnime metrics
	GoRoutines         = "goroutines"
	Threads            = "process-threads"
	CurrentlyAllocated = "allocated-bytes"    // heap allocation in go runtime stats
	UsedMemory         = "process-used-bytes" // from the process api
	FreeMemory         = "free-memory-bytes"
	SystemMemory       = "system-memory-bytes"
	// cpu metrics
	CPUHundredsPercent = "cpu-hundreds-percent" // 17 == 0.17 percent, expressed in integer terms
)

Variables

This section is empty.

Functions

func CacheMulticastMessages added in v0.6.1

func CacheMulticastMessages(cache *gocache.Cache, msgChan chan *dns.Msg)

func Download added in v0.1.9

func Download(engine Engine, config *config.GudgeonConfig, list *config.GudgeonList) error

func MulticastMdnsListen added in v0.6.1

func MulticastMdnsListen(msgChan chan *dns.Msg)

func MulticastMdnsQuery added in v0.6.1

func MulticastMdnsQuery()

func NewRecorder added in v0.6.1

func NewRecorder(engine *engine) (*recorder, error)

created from raw engine

func ParseMulticastMessage added in v0.6.1

func ParseMulticastMessage(msg *dns.Msg) map[string]string

func ReadCachedHostname added in v0.6.1

func ReadCachedHostname(cache *gocache.Cache, address string) string

Types

type CacheSizeFunction added in v0.6.1

type CacheSizeFunction = func() int64

type Engine

type Engine interface {
	IsDomainRuleMatched(consumer *net.IP, domain string) (rule.Match, *config.GudgeonList, string)
	Resolve(domainName string) (string, error)
	Reverse(address string) string

	// different direct handle methods
	Handle(address *net.IP, protocol string, request *dns.Msg) (*dns.Msg, *resolver.RequestContext, *resolver.ResolutionResult)
	HandleWithConsumerName(consumerName string, rCon *resolver.RequestContext, request *dns.Msg) (*dns.Msg, *resolver.RequestContext, *resolver.ResolutionResult)
	HandleWithConsumer(consumer *consumer, rCon *resolver.RequestContext, request *dns.Msg) (*dns.Msg, *resolver.RequestContext, *resolver.ResolutionResult)
	HandleWithGroups(groups []string, rCon *resolver.RequestContext, request *dns.Msg) (*dns.Msg, *resolver.RequestContext, *resolver.ResolutionResult)
	HandleWithResolvers(resolvers []string, rCon *resolver.RequestContext, request *dns.Msg) (*dns.Msg, *resolver.RequestContext, *resolver.ResolutionResult)

	// stats
	CacheSize() int64

	// inner providers
	QueryLog() QueryLog
	Metrics() Metrics

	// shutdown
	Shutdown()
}

func NewEngine added in v0.6.1

func NewEngine(conf *config.GudgeonConfig) (Engine, error)

type InfoRecord added in v0.6.1

type InfoRecord struct {
	// client address
	Address string

	// hold the information but aren't serialized
	Request        *dns.Msg                   `json:"-"`
	Response       *dns.Msg                   `json:"-"`
	Result         *resolver.ResolutionResult `json:"-"`
	RequestContext *resolver.RequestContext   `json:"-"`

	// generated/calculated values
	Consumer       string
	ClientName     string
	ConnectionType string
	RequestDomain  string
	RequestType    string
	ResponseText   string
	Rcode          string

	// hard consumer blocked
	Blocked bool

	// matching
	Match          rule.Match
	MatchList      string
	MatchListShort string
	MatchRule      string

	// cached in resolver cache store
	Cached bool

	// when this log record was created
	// todo: add when it was received and when it was completed
	//       through the context so we can compute a delta
	Created time.Time
}

info passed over channel and stored in database and that is recovered via the Query method

type Metric added in v0.6.1

type Metric struct {
	Count int64 `json:"count"`
}

func (*Metric) Clear added in v0.6.1

func (metric *Metric) Clear() *Metric

func (*Metric) Inc added in v0.6.1

func (metric *Metric) Inc(byValue int64) *Metric

func (*Metric) Set added in v0.6.1

func (metric *Metric) Set(newValue int64) *Metric

func (*Metric) Value added in v0.6.1

func (metric *Metric) Value() int64

type Metrics added in v0.6.1

type Metrics interface {
	GetAll() map[string]*Metric
	Get(name string) *Metric

	// use cache function
	UseCacheSizeFunction(function CacheSizeFunction)

	// Query metrics from db
	Query(start time.Time, end time.Time) ([]*MetricsEntry, error)
	QueryStream(returnChan chan *MetricsEntry, start time.Time, end time.Time) error

	// top information
	TopClients(limit int) []*TopInfo
	TopDomains(limit int) []*TopInfo
	TopQueryTypes(limit int) []*TopInfo
	TopLists(limit int) []*TopInfo
	TopRules(limit int) []*TopInfo

	// stop the metrics collection
	Stop()
	// contains filtered or unexported methods
}

func NewMetrics added in v0.6.1

func NewMetrics(config *config.GudgeonConfig, db *sql.DB) Metrics

type MetricsEntry added in v0.6.1

type MetricsEntry struct {
	FromTime        time.Time
	AtTime          time.Time
	Values          map[string]*Metric
	IntervalSeconds int
}

type QueryLog added in v0.6.1

type QueryLog interface {
	Query(query *QueryLogQuery) ([]*InfoRecord, uint64)
	QueryStream(query *QueryLogQuery, infoChan chan *InfoRecord, countChan chan uint64)
	Stop()
	// contains filtered or unexported methods
}

public interface

func NewQueryLog added in v0.6.1

func NewQueryLog(conf *config.GudgeonConfig, db *sql.DB) (QueryLog, error)

create a new query log according to configuration

type QueryLogQuery added in v0.6.1

type QueryLogQuery struct {
	// query on fields
	Address        string
	ClientName     string
	ConnectionType string
	RequestDomain  string
	RequestType    string
	ResponseText   string
	Blocked        *bool
	Cached         *bool
	Match          *rule.Match
	// query on created time
	After  *time.Time
	Before *time.Time
	// query limits for paging
	Skip  int
	Limit int
	// query sort
	SortBy    string
	Direction string
}

the type that is used to make queries against the query log (should be used by the web interface to find queries)

type ReverseLookupFunction added in v0.6.1

type ReverseLookupFunction = func(addres string) string

allows a dependency injection-way of defining a reverse lookup function, takes a string address (should be an IP) and returns a string that contains the domain name result

type TopInfo added in v0.6.1

type TopInfo struct {
	Desc  string
	Count uint64
}

info from db

Jump to

Keyboard shortcuts

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