receiver

package
v0.0.0-...-1e0ddcb Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CookerLock   = 1001
	CookerNoLock = 1002
)
View Source
const (
	// we have to filter zone in two mode
	// with respect of duplications and
	// without (as bpf does not have yet
	// multiple RR)
	ImportFilterStrict = 1011

	// loosed version, no duplications check
	ImportFilterLoosed = 1012

	// skip types of fqdn to be cached
	SkipByLength = 1001
	SkipByCount  = 1002
	SkipByType   = 1003
)
View Source
const (
	SnapshotMemoryEmpty  = 1001
	SnapshotMemoryExists = 1002
)
View Source
const (
	// metric counter for example plugin
	MetricNameCounter = "counter"

	// monitor class for check
	MonitorClass = "receiver"
)
View Source
const (
	NetUDP = "udp"
	NetTCP = "tcp"
)
View Source
const (
	// objects to manage, first RR - is a RRset
	// actually we should have RRset includes only
	// one RR
	ObjectRR = iota

	// internal variants for operations
	ObjectCreate = iota
	ObjectRemove

	ObjectList
	ObjectClean
)
View Source
const (
	// codes indicating result of exists DNS RR
	// function, it checks if key in correspoding rrmap
	// exists. If exists it checks also ttl and IP
	// addresses requested rr and looked up
	NoExists       = 1001
	ExistsNotEqual = 1002
	ExistsEqual    = 1003

	ExistsUnknown = 0
)
View Source
const (
	// zone could be transferred via TSIG
	DefaultEmptyTSIG = ""

	// job to transfer zone
	ClassJobTransfer = 1011

	// job to process notifu received
	ClassJobNotifier = 1012
)
View Source
const (
	// possible configured type of zone
	// transfer axfr and http
	TransferTypeAXFR = "axfr"

	// http also could mean file (if primary
	// has file:// prefix
	TransferTypeHTTP = "http"

	// by default we do not use TSIG
	DefaultTSIGKey = ""
)
View Source
const (
	TickStepOnce = "once"
	TickStepNext = "next"
)
View Source
const (
	// plugin name is used by controller to link
	// code and configuration
	NamePlugin = "receiver"

	// default workers count for transfer pool
	DefaultTransferPoolWorkers = 5

	// in many places we dump lists of rrsets
	// settings below defines a maximum number of rrsets
	// to dump
	DefaultDumpMaxRRsets = 10

	// snapshot default max counts, should be at least 2?
	DefaultSnapshotCount = 4

	// default time interval state update in
	// seconds to update zone data
	DefaultTransfersInterval = 10 * time.Second

	// default suffix for snapshot files
	DefaultSnapshotSuffix = "yadns-xdp.blob"
)
View Source
const (
	SourceHTTP = 101
	SourceFile = 102
	SourceAXFR = 103

	SourceUnknown = 0

	// default zone snapshot options
	DefaultZoneSnapshotIncremental = true
)
View Source
const (
	// checking SOA serials for
	// first and last RR as AXFR
	// envelope
	SnapshotSOAFirst = 1
	SnapshotSOALast  = 2

	// constants to iterate over IXFR data
	SectionUnknown  = 0
	SectionAddition = 1
	SectionDeletion = 2
)
View Source
const (
	DryrunApply = "(APPLY)"
	DryrunSkip  = "(DRYRUN)"
)
View Source
const (
	HmacSHA1   = "hmac-sha1."
	HmacSHA224 = "hmac-sha224."
	HmacSHA256 = "hmac-sha256."
	HmacSHA384 = "hmac-sha384."
	HmacSHA512 = "hmac-sha512."

	HmacMD5 = "hmac-md5.sig-alg.reg.int." // Deprecated: HmacMD5 is no longer supported. But!

	// default TSIG algo
	DefaultTsigAlgo string = "HMAC-MD5.SIG-ALG.REG.INT"
)

HMAC hashing codes. These are transmitted as domain names.

View Source
const (
	// we could transfer in AXFR or IXFR
	// but for the last we need additional
	// options such as Serial, NS, Mbox???
	TransferModeAXFR = 1001
	TransferModeIXFR = 1002
	TransferModeHTTP = 1003
	TransferModeNONE = 1004

	// some error conditions
	TransferModeUnknown = 0
)
View Source
const (
	// default collector monitor intervals
	// for different types of collecting metrics:
	// merics, histograms
	DefaultMonitorMetricsInterval = 10

	// default watcher interval
	DefaultWatcherInterval = 17

	// if monitor should zero metrics after
	// fetching them from bpf maps
	DefaultMonitorZero = false

	// historgrams need some more time to
	// gather statistics
	DefaultMoniorHistogramsInterval = 60 * time.Second

	// current number of runtime goroutine
	MetricsRuntimeNumGoroutine = "runtime-goroutine"

	MeticsRuntimeMemHeapAlloc    = "runtime-mem-heapalloc"
	MeticsRuntimeMemTotalAlloc   = "runtime-mem-totalalloc"
	MeticsRuntimeMemSys          = "runtime-mem-sys"
	MeticsRuntimeMemLookups      = "runtime-mem-lookups"
	MeticsRuntimeMemMallocs      = "runtime-mem-mallocs"
	MeticsRuntimeMemFrees        = "runtime-mem-frees"
	MeticsRuntimeMemHeapSys      = "runtime-mem-heapsys"
	MeticsRuntimeMemHeapIdle     = "runtime-mem-heapidle"
	MeticsRuntimeMemHeapInuse    = "runtime-mem-heapinuse"
	MeticsRuntimeMemHeapReleased = "runtime-mem-heapreleased"
	MeticsRuntimeMemHeapObjects  = "runtime-mem-heapobjects"
	MeticsRuntimeMemStackInuse   = "runtime-mem-stackinuse"
	MeticsRuntimeMemStackSys     = "runtime-mem-stacksys"
	MeticsRuntimeMemMSpanInuse   = "runtime-mem-mspaninuse"
	MeticsRuntimeMemMSpanSys     = "runtime-mem-mspansys"
	MeticsRuntimeMemMCacheInuse  = "runtime-mem-mcacheinuse"
	MeticsRuntimeMemMCacheSys    = "runtime-mem-mcachesys"
	MeticsRuntimeMemBuckHashSys  = "runtime-mem-buckhashsys"
	MeticsRuntimeMemPauseTotalNs = "runtime-mem-pause-totalns"
	MeticsRuntimeMemNumGC        = "runtime-mem-numgc"
	MeticsRuntimeMemNumForcedGC  = "runtime-mem-numforcedgc"

	MetricsCookerCookTime = "cooker-cooktime"

	// verify on cook stage
	MetricsCookerVerifyTotal       = "cooker-verifytotal"
	MetricsCookerVerifyVerified    = "cooker-verifyverified"
	MetricsCookerVerifyMissed      = "cooker-verifymissed"
	MetricsCookerVerifyDifferOnTTL = "cooker-differonttl"
	MetricsCookerVerifyDifferOnIP  = "cooker-differonip"
	MetricsCookerVerifyUnexpected  = "cooker-unexpected"

	MetricsVerifyTotal       = "verifier-verifytotal"
	MetricsVerifyVerified    = "verifier-verifyverified"
	MetricsVerifyMissed      = "verifier-verifymissed"
	MetricsVerifyDifferOnTTL = "verifier-differonttl"
	MetricsVerifyDifferOnIP  = "verifier-differonip"
	MetricsVerifyUnexpected  = "verifier-unexpected"

	// sync map on cook stage
	MetricsCookerSyncCreated = "cooker-synccreated"
	MetricsCookerSyncRemoved = "cooker-syncremoved"

	// age for snapshots blobs files zones (configured)
	MetricsCookerSnapshotsAgeMin = "cooker-snapshotsage-min"
	MetricsCookerSnapshotsAgeMax = "cooker-snapshotsage-max"
	MetricsCookerSnapshotsAgeAvg = "cooker-snapshotsage-avg"
	MetricsCookerSnapshotsCount  = "cooker-snapshots-count"

	// time zone to be received
	MetricsReceiverZoneTime = "receiver-zonetime"

	// bpf metrics
	MetricsBpfPacketsRX    = "bpf-packetsrx"
	MetricsBpfPacketsTX    = "bpf-packetstx"
	MetricsBpfPacketsPass  = "bpf-packetspass"
	MetricsBpfPacketsError = "bpf-packetserror"

	MetricsBpfTimeMin = "bpf-timemin"
	MetricsBpfTimeMax = "bpf-timemax"
	MetricsBpfTimeAvg = "bpf-timeavg"
	MetricsBpfTimeCnt = "bpf-timecnt"

	BpfPacketsRX    = 0
	BpfPacketsTX    = 1
	BpfPacketsPass  = 2
	BpfPacketsError = 3

	BpfTimeMin = 4
	BpfTimeMax = 5
	BpfTimeSum = 6
	BpfTimeCnt = 7

	MetricsBpfTimeHistogram = "bpf-timehistogram"
)
View Source
const (
	CollectorBpfMetrics     = 1001
	CollectorBpfHistograms  = 1002
	CollectorRuntimeMetrics = 1003
	CollectorGarbage        = 1004
	CollectorDumper         = 1005
	CollectorUnknown        = 0
)
View Source
const (
	ActionON  = "on"
	ActionOFF = "off"
)
View Source
const (
	ZoneStateUnknown = 0

	// zone state clean
	ZoneStateClean = 110

	// zone state dirty
	ZoneStateDirty = 111
)
View Source
const (
	// operations for changed set as CREATE
	// and REMOVE (update should be done as
	// REMOVE + CREATE of the same key)
	ChangeCreate = 1001
	ChangeRemove = 1002
)
View Source
const (
	// dirty detection methods via SOA
	// zones comparision
	DirtyViaSOA = "soa"

	// dirty method via "rrsets+data"
	DirtyViaRRsetData = "rrsets+data"
)
View Source
const (
	// default cooker interval in seconds
	DefaultCookerInterval = 70 * time.Second
)
View Source
const (
	// default number of cooker workers
	DefaultCookerWorkers = 2
)
View Source
const (
	// default verifier inrterval in seconds
	DefaultVerifierInterval = 120 * time.Second
)
View Source
const (
	EmptySuffix = ""
)

Variables

This section is empty.

Functions

func ChangeAsString

func ChangeAsString(change int) string

func CollectorTypeToString

func CollectorTypeToString(mode int) string

func Dot

func Dot(s string) string

func DryrunString

func DryrunString(dryrun bool) string

func Exists

func Exists(name string) bool

func ExitsAsString

func ExitsAsString(mode int) string

func GetFileAge

func GetFileAge(file string) float64

func GetSnapshotFilename

func GetSnapshotFilename(p *TReceiverPlugin, zone string) string

func GetSnapshotID

func GetSnapshotID(zone string) string

func GetTSIGOptions

func GetTSIGOptions(key string) (string, map[string]string, error)

convering TSIG in algo:user:secret notation into algorithm, and dns map to use in transfer function

func GetTSIGUser

func GetTSIGUser(tsig map[string]string) string

func IntInSlice

func IntInSlice(key int, list []int) bool

func Md5

func Md5(s string) string

md5 checksum as string

func NewXFR

func NewXFR(data string) ([]dns.RR, error)

func ObjectModeAsString

func ObjectModeAsString(mode int) string

func PackName

func PackName(qname string) (offloader.RRQname, error)

packing qname given as an fqdn name into dns based qname representation of type 0x6yandex0x3net

func RemoveDot

func RemoveDot(s string) string

func SectionString

func SectionString(section int) string

func SliceInSlice

func SliceInSlice(s1 []string, s2 []string) bool

func SlicesDelete

func SlicesDelete(s []dns.RR, i, j int) []dns.RR

func StringInMapSlice

func StringInMapSlice(key string, maplist map[string][]string) bool

func StringInSlice

func StringInSlice(key string, list []string) bool

func TransferModeAsString

func TransferModeAsString(mode int) string

func TransferZone

func TransferZone(server string, zone string, options *TransferOptions) ([]dns.RR, error)

Transferring zone from server via axfr with possible TSIG key to match specific view (see rotation methods)

func UnpackName

func UnpackName(pqname offloader.RRQname) (string, error)

unpacking dns packed named into string notation

func ValidateSnapshotZoneFile

func ValidateSnapshotZoneFile(p *TReceiverPlugin, filename string, zone string) bool

func ZoneStateAsString

func ZoneStateAsString(state int) string

Types

type CollectorJob

type CollectorJob struct {
	ID int64 `json:"ID"`

	ClassJob int `json:"class-job"`

	// zone to operate (transfer, dump)
	Zone string `json:"zone"`

	// configuration of zone
	Config TConfigZone `json:"config"`

	// transfer options AXFR and IXFR
	Options *TransferOptions

	// ref: current state of zones fetched
	Zones *ZonesState
}

func (*CollectorJob) String

func (j *CollectorJob) String() string

type CollectorResult

type CollectorResult struct {
	Job *CollectorJob `json:"job"`

	ID int64 `json:"id"`

	// error for collector result or nil
	// if all is okey
	Error error `json:"error"`

	// processed time
	Processed int64 `json:"processed"`
}

type CollectorTransferOptions

type CollectorTransferOptions struct {
	Dryrun bool `json:"dryrun"`

	// number of workers to run
	Count int `json:"count"`
}

collector transfer options

type CollectorTransferPool

type CollectorTransferPool struct {
	// contains filtered or unexported fields
}

collector transfer pool

func (*CollectorTransferPool) Results

func (t *CollectorTransferPool) Results() <-chan CollectorResult

func (*CollectorTransferPool) Run

func (*CollectorTransferPool) TransferJob

func (t *CollectorTransferPool) TransferJob(zone string,
	v TConfigZone, mode int, soa dns.RR)

func (*CollectorTransferPool) Worker

func (t *CollectorTransferPool) Worker(ctx context.Context, index int, wg *sync.WaitGroup,
	jobs <-chan CollectorJob, results chan<- CollectorResult)

type ConvertRR

type ConvertRR struct {
	// contains filtered or unexported fields
}

func (*ConvertRR) AsString

func (c *ConvertRR) AsString() string

type CookerWorker

type CookerWorker struct {
	// contains filtered or unexported fields
}

cooker cooks data received by receiver into blob, keeping them in snapshot directory if enabled, later such snapshot could be imported

func NewCookerWorker

func NewCookerWorker(p *TReceiverPlugin, options *TConfigCooker,
	zones *ZonesState) (*CookerWorker, error)

func (*CookerWorker) Cook

func (j *CookerWorker) Cook(ctx context.Context, index int, dryrun bool) error

func (*CookerWorker) CookIncrementZone

func (j *CookerWorker) CookIncrementZone(ctx context.Context,
	zone string, mode int) (*TSyncMapResult, error)

func (*CookerWorker) Run

func (j *CookerWorker) Run(ctx context.Context) error

func (*CookerWorker) Stop

func (j *CookerWorker) Stop()

func (*CookerWorker) TickCooker

func (j *CookerWorker) TickCooker(ctx context.Context) error

type ImporterWorker

type ImporterWorker struct {
	// contains filtered or unexported fields
}

func NewImporterWorker

func NewImporterWorker(p *TReceiverPlugin, options *TConfigImporter) (*ImporterWorker, error)

func (*ImporterWorker) FilterZone

func (j *ImporterWorker) FilterZone(rr []dns.RR, mode int) (map[string][]dns.RR, dns.RR)

we need filter zone got iva tranfer zone containing only records we could push into zone and returning SOA (if any)

func (*ImporterWorker) GetZoneSnapshotAXFR

func (j *ImporterWorker) GetZoneSnapshotAXFR(zone string, options *TZoneSnapshotOptions) (*TSnapshotZone, error)

func (*ImporterWorker) GetZoneSnapshotHTTP

func (j *ImporterWorker) GetZoneSnapshotHTTP(ctx context.Context, source string,
	options *TZoneSnapshotOptions) (*TSnapshotZone, error)

func (*ImporterWorker) Import

func (j *ImporterWorker) Import(ctx context.Context) error

func (*ImporterWorker) Run

func (j *ImporterWorker) Run(ctx context.Context) error

func (*ImporterWorker) UpdateZoneState

func (j *ImporterWorker) UpdateZoneState(ctx context.Context, states *ZonesState, source int,
	zone string, config *TConfigZone, options *TUpdateZoneStateOptions) error

type NotifierJob

type NotifierJob struct {
	ID int64 `json:"ID"`

	ClassJob int `json:"class-job"`

	// zone to operate (transfer, dump)
	Zone string `json:"zone"`

	// serial number to make a IXFR transfer
	Serial uint32 `json:"serial"`

	// states of zones
	States *ZonesState
}

func (*NotifierJob) String

func (j *NotifierJob) String() string

type NotifierResult

type NotifierResult struct {
	Job *NotifierJob `json:"job"`

	ID int64 `json:"id"`

	// error for collector result or nil
	// if all is okey
	Error error `json:"error"`

	// processed time
	Processed int64 `json:"processed"`
}

type NotifierWorker

type NotifierWorker struct {
	// contains filtered or unexported fields
}

notifier listens for NOTIFY events from master server and makes SOA and or TRANSFER via AXFR or IXFR request

func NewNotifierWorker

func NewNotifierWorker(p *TReceiverPlugin, options *TConfigNotifier,
	zones *ZonesState) (*NotifierWorker, error)

func (*NotifierWorker) CookerPoolRun

func (j *NotifierWorker) CookerPoolRun(ctx context.Context) error

func (*NotifierWorker) Handle

func (j *NotifierWorker) Handle(w dns.ResponseWriter, r *dns.Msg)

func (*NotifierWorker) MatchRequest

func (j *NotifierWorker) MatchRequest(r *dns.Msg) (*TMatchedRequest, error)

func (*NotifierWorker) NotifierServer

func (j *NotifierWorker) NotifierServer(ctx context.Context) error

func (*NotifierWorker) ReqString

func (j *NotifierWorker) ReqString(w dns.ResponseWriter, r *dns.Msg, q *dns.Msg) string

func (*NotifierWorker) Run

func (j *NotifierWorker) Run(ctx context.Context) error

func (*NotifierWorker) Stop

func (j *NotifierWorker) Stop()

func (*NotifierWorker) Worker

func (j *NotifierWorker) Worker(ctx context.Context, wg *sync.WaitGroup,
	options *TWorkerOptions)

type NotifierWorkerPool

type NotifierWorkerPool struct {
	// contains filtered or unexported fields
}

notifier cooker workers pool

func NewNotifierWorkerPool

func NewNotifierWorkerPool(p *TReceiverPlugin, count int, states *ZonesState) *NotifierWorkerPool

func (*NotifierWorkerPool) Job

func (p *NotifierWorkerPool) Job(zone string, serial uint32)

func (*NotifierWorkerPool) Results

func (p *NotifierWorkerPool) Results() <-chan NotifierResult

func (*NotifierWorkerPool) Run

func (p *NotifierWorkerPool) Run(ctx context.Context)

func (*NotifierWorkerPool) Worker

func (p *NotifierWorkerPool) Worker(ctx context.Context, index int, wg *sync.WaitGroup,
	jobs <-chan NotifierJob, results chan<- NotifierResult)

type Objects

type Objects struct {

	// some options to override behaviuor, etc, dryrun
	Dryrun bool

	// filter to list data
	Filter TObjectFilter
	// contains filtered or unexported fields
}

objects implements logics to read, update, remove a list of objects (mostly contained in bpf map)

func NewObjects

func NewObjects(p *TReceiverPlugin) *Objects

func (*Objects) CleanRR

func (o *Objects) CleanRR() (int, error)

func (*Objects) ConvertDNSRR

func (o *Objects) ConvertDNSRR(rr dns.RR) (*ConvertRR, error)

HEADS UP: we need optimize ip conversions

func (*Objects) CreateRR

func (o *Objects) CreateRR(raw string) error

func (*Objects) ExistsDNSRR

func (o *Objects) ExistsDNSRR(rrmap offloader.RRMap, rr dns.RR) int

func (*Objects) ImportRR

func (o *Objects) ImportRR() error

func (*Objects) IterateGenericMapRR

func (o *Objects) IterateGenericMapRR(mode int, rrmap offloader.RRMap) ([]dns.RR, int, error)

func (*Objects) ListRR

func (o *Objects) ListRR() ([]dns.RR, error)

we listing all supported types, A, AAAA for now

func (*Objects) LookupDNSRR

func (o *Objects) LookupDNSRR(rrmap offloader.RRMap, rr dns.RR) (*ConvertRR, uint32, netip.Addr, error)

func (*Objects) LookupGenericRR

func (o *Objects) LookupGenericRR(rrmap offloader.RRMap, qname offloader.RRQname,
	qtype uint16) (uint32, netip.Addr, error)

func (*Objects) MatchFilter

func (o *Objects) MatchFilter(e offloader.RREntry, filter TObjectFilter) bool

func (*Objects) RemoveRR

func (o *Objects) RemoveRR(raw string) error

func (*Objects) UpdateDNSRR

func (o *Objects) UpdateDNSRR(mode int, rrmap offloader.RRMap, rr dns.RR, dump bool) error

func (*Objects) UpdateGenericRR

func (o *Objects) UpdateGenericRR(mode int, rrmap offloader.RRMap, conv *ConvertRR) error

func (*Objects) UpdateRR

func (o *Objects) UpdateRR(mode int, raw string) error

type Switches

type Switches struct {
	// should it be global switch or local
	Dryrun bool
}

command line switches

type TAction

type TAction struct {
	// contains filtered or unexported fields
}

type TChangedSetZone

type TChangedSetZone struct {
	// contains filtered or unexported fields
}

func (*TChangedSetZone) AsActions

func (t *TChangedSetZone) AsActions() *TSnapshotActions

func (*TChangedSetZone) Dump

func (t *TChangedSetZone) Dump(p *TReceiverPlugin, did string)

type TConfigAxfrTransfer

type TConfigAxfrTransfer struct {
	// enabling axfr transfer
	Enabled bool `json:"enabled" yaml:"enabled"`

	// transfering zone method
	TransferVia string `json:"transfer-via" yaml:"transfer-via"`

	// detecting if zone changes
	DirtyVia string `json:"dirty-via" yaml:"dirty-via"`

	// transfer configuration
	Transfer TTransfer `json:"transfer" yaml:"transfer"`

	// zones configuration
	Zones TZones `json:"zones" yaml:"zones"`

	// notify configuration
	Notify TNotify `json:"notify" yaml:"notify"`
}

type TConfigCooker

type TConfigCooker struct {
	Dryrun bool `json:"dryrun" yaml:"dryrun"`
}

type TConfigDataCooker

type TConfigDataCooker struct {
	Enabled bool `json:"enabled" yaml:"enabled"`

	Dryrun bool `json:"dryrun" yaml:"dryrun"`

	// cooking interval in seconds
	Interval int `json:"interval" yaml:"interval"`

	// snapshot per bpf map
	Snapshots TSnapshotsDataCooker `json:"snapshots" yaml:"snapshots"`
}

type TConfigDataVerifier

type TConfigDataVerifier struct {
	Enabled bool `json:"enabled" yaml:"enabled"`

	Interval int `json:"interval" yaml:"interval"`

	VerifyOnCook bool `json:"verify-oncook" yaml:"verify-oncook"`
}

type TConfigHTTPTransfer

type TConfigHTTPTransfer struct {
	// enabling axfr transfer
	Enabled bool `json:"enabled" yaml:"enabled"`

	// zones configuration
	Zones TZones `json:"zones" yaml:"zones"`
}

type TConfigImporter

type TConfigImporter struct {
	// a list of files to import, assuming axfr
	File []string `json:"file" yaml:"file"`

	// server to transfer data
	Server string `json:"server" yaml:"server"`

	// a list of zones to transfer
	Zone []string `json:"zone" yaml:"zone"`

	// a list of (http) endpoints
	Endpoint []string `json:"endpoint" yaml:"endpoint"`

	// an optional TSIG key for transfer
	Key string `json:"key" yaml:"key"`

	// an optional fqdn suffix to append in import
	Suffix string `json:"suffix" yaml:"suffix"`

	// serial number if set try to use IXFR
	Incremental bool `json:"incremental" yaml:"incremental"`

	Dryrun bool `json:"dryrun" yaml:"dryrun"`
}

ConfigImporter includes two types of import via file (if file defines) or via dns axfr (if zone define and file is not)

func (*TConfigImporter) AsString

func (t *TConfigImporter) AsString() string

type TConfigMonitor

type TConfigMonitor struct {
	Collector TConfigMonitorCollector `json:"collector" yaml:"collector"`

	Watcher TConfigMonitorWatcher `json:"watcher" yaml:"watcher"`
}

type TConfigMonitorBpf

type TConfigMonitorBpf struct {
	Intervals TConfigMonitorIntervals `json:"intervals" yaml:"intervals"`
}

type TConfigMonitorCollector

type TConfigMonitorCollector struct {
	Enabled bool                  `json:"enabled" yaml:"enabled"`
	Bpf     TConfigMonitorBpf     `json:"bpf" yaml:"bpf"`
	Runtime TConfigMonitorRuntime `json:"runtime" yaml:"runtime"`

	DumpInterval int `json:"dump-interval" yaml:"dump-interval"`

	Verbose bool `json:"verbose" yaml:"verbose"`

	GarbageCollector TGarbageCollector `json:"garbage-collector" yaml:"garbage-collector"`
}

type TConfigMonitorIntervals

type TConfigMonitorIntervals struct {
	Metrics int `json:"metrics" yaml:"metrics"`

	Histograms int `json:"histograms" yaml:"histograms"`

	Zero bool `json:"zero" yaml:"zero"`
}

type TConfigMonitorRuntime

type TConfigMonitorRuntime struct {
	Intervals TConfigMonitorIntervals `json:"intervals" yaml:"intervals"`
}

type TConfigMonitorWatcher

type TConfigMonitorWatcher struct {
	// watcher checks some conditions and thresholds
	// for rules and make some actions (also exported
	// monitoring events via API)
	Enabled bool `json:"enabled" yaml:"enabled"`

	// check interval
	Interval int `json:"interval" yaml:"interval"`

	// a list of rules to check
	Rules map[string]TRule `json:"rules" yaml:"rules"`
}

type TConfigNotifier

type TConfigNotifier struct {
	Dryrun bool `json:"dryrun" yaml:"dryrun"`
}

type TConfigVerifier

type TConfigVerifier struct {
	// server to transfer data
	Server string `json:"server" yaml:"server"`

	// a list of zones to transfer
	Zone []string `json:"zone" yaml:"zone"`

	// an optional TSIG key for transfer
	Key string `json:"key" yaml:"key"`

	Dryrun bool `json:"dryrun" yaml:"dryrun"`
	Force  bool `json:"force" yaml:"force"`
}

func (*TConfigVerifier) AsString

func (t *TConfigVerifier) AsString() string

type TConfigZone

type TConfigZone struct {
	// zone could be disabled
	Enabled bool `json:"enabled" yaml:"enabled"`

	// primary master servers
	Primary []string `json:"primary" yaml:"primary"`

	// allowing notification from sources
	AllowNotify []string `json:"allow-notify" yaml:"allow-notify"`

	// override refresh counter
	Refresh int `json:"refresh" yaml:"refresh"`

	// a type of zone: could be axfr, http (of file)
	Type string `json:"type" yaml:"type"`
}

func CreateDefaultConfigZone

func CreateDefaultConfigZone(primary []string) TConfigZone

func (*TConfigZone) String

func (t *TConfigZone) String() string

type TDataReceiverOptions

type TDataReceiverOptions struct {
	Incremental bool `json:"incremental" yaml:"incremental"`

	// snapshot per zone
	Snapshots TSnapshotsDataReceiver `json:"snapshots" yaml:"snapshots"`
}

type TGarbageCollector

type TGarbageCollector struct {
	Interval int `json:"interval" yaml:"interval"`

	Keep int `json:"keep" yaml:"keep"`
}

type TImportActions

type TImportActions struct {
	// contains filtered or unexported fields
}

Temporary structure to define a current state of imports for zone (could be reused in recevier?)

type TMatchedRequest

type TMatchedRequest struct {
	// contains filtered or unexported fields
}

type TNotify

type TNotify struct {
	// enabling or disabling notify processing
	Enabled bool `json:"enabled" yaml:"enabled"`

	// a list of addresses to bind for notify listeners
	Listen []string `json:"listen" yaml:"listen"`

	// udp buffer size
	UDPBufferSize int `json:"udp-buffer-size" yaml:"udp-buffer-size"`

	// workers number for dns server server instance
	Workers int `json:"workers" yaml:"workers"`

	// global options to override allow notify
	AllowNotify []string `json:"allow-notify" yaml:"allow-notify"`

	// T.B.D some bind options for notify rate
	NotifyRate int `json:"notify-rate" yaml:"notify-rate"`

	// T.B.D. startup rate
	StartupNotifyRate int `json:"startup-notify-rate" yaml:"startup-notify-rate"`

	Cookers TNotifyCooker `json:"cookers" yaml:"cookers"`
}

type TNotifyCooker

type TNotifyCooker struct {
	Workers int `json:"workers" yaml:"workers"`
}

type TObjectFilter

type TObjectFilter struct {
	// a filter for operations "clean", "list"
	Names []string

	// max number of rr sets to return
	Count int
}

type TReceiverPlugin

type TReceiverPlugin struct {

	// some common attributes for all plugins, global
	// configuration ref, name and type
	plugins.Plugin
	// contains filtered or unexported fields
}

func NewPlugin

func NewPlugin(options *plugins.PluginOptions) (*TReceiverPlugin, error)

func (*TReceiverPlugin) L

func (*TReceiverPlugin) Metrics

func (t *TReceiverPlugin) Metrics(ctx echo.Context) error

func (*TReceiverPlugin) Monitor

func (t *TReceiverPlugin) Monitor(m *monitor.TMonitorPlugin)

func (*TReceiverPlugin) Run

func (t *TReceiverPlugin) Run(ctx context.Context, overrides *plugins.OverrideOptions) error

func (*TReceiverPlugin) SetupMethods

func (t *TReceiverPlugin) SetupMethods(group *echo.Group)

func (*TReceiverPlugin) Stop

func (t *TReceiverPlugin) Stop()

func (*TReceiverPlugin) TickStateServer

func (t *TReceiverPlugin) TickStateServer(ctx context.Context) error

func (*TReceiverPlugin) TickStateStep

func (t *TReceiverPlugin) TickStateStep(mode string)

func (*TReceiverPlugin) TransferPoolRun

func (t *TReceiverPlugin) TransferPoolRun(ctx context.Context) error

type TReceiverPluginConfig

type TReceiverPluginConfig struct {
	// could be disabled
	Enabled bool `json:"enabled" yaml:"enabled"`

	// pinpath to import/sync recevied data
	PinPath string `json:"pinpath" yaml:"pinpath"`

	// global recevier options
	Options TDataReceiverOptions `json:"options" yaml:"options"`

	// http and file transfer adapter
	HTTPTransfer TConfigHTTPTransfer `json:"http-transfer" yaml:"http-transfer"`

	// axfr transfer adapter
	AxfrTransfer TConfigAxfrTransfer `json:"axfr-transfer" yaml:"axfr-transfer"`

	// verifier configuration
	Verifier TConfigDataVerifier `json:"verifier" yaml:"verifier"`

	// cooker configuration
	Cooker TConfigDataCooker `json:"cooker" yaml:"cooker"`

	// monitor collector and its options
	Monitor TConfigMonitor `json:"monitor" yaml:"monitor"`
}

type TRule

type TRule struct {
	Higher  int      `json:"higher" yaml:"higher"`
	Lower   int      `json:"lower" yaml:"lower"`
	Actions []string `json:"actions" yaml:"actions"`
}

type TSnapshotActions

type TSnapshotActions struct {
	// contains filtered or unexported fields
}

func (*TSnapshotActions) Add

func (t *TSnapshotActions) Add(action int, section int, key string, r dns.RR)

func (*TSnapshotActions) Dump

func (t *TSnapshotActions) Dump(p *TReceiverPlugin)

type TSnapshotZone

type TSnapshotZone struct {
	// contains filtered or unexported fields
}

func NewSnapshotZone

func NewSnapshotZone(p *TReceiverPlugin, data string, zone string) (*TSnapshotZone, error)

func NewSnapshotZoneFromBlob

func NewSnapshotZoneFromBlob(p *TReceiverPlugin, path string,
	zone string) (*TSnapshotZone, error)

func NewSnapshotZoneFromEndpoint

func NewSnapshotZoneFromEndpoint(p *TReceiverPlugin, ctx context.Context,
	endpoint []string, zone string) (*TSnapshotZone, error)

func NewSnapshotZoneFromFile

func NewSnapshotZoneFromFile(p *TReceiverPlugin, filename string,
	zone string) (*TSnapshotZone, error)

func NewSnapshotZoneFromSnapshot

func NewSnapshotZoneFromSnapshot(p *TReceiverPlugin, zone string) (*TSnapshotZone, error)

func (*TSnapshotZone) Action

func (t *TSnapshotZone) Action(mode int, k string) (int, *dns.RR)

func (*TSnapshotZone) ApplyIXFR

func (t *TSnapshotZone) ApplyIXFR(ixfr []dns.RR) (dns.RR, int, *TSnapshotActions, error)

func (*TSnapshotZone) Dump

func (t *TSnapshotZone) Dump(p *TReceiverPlugin, did string, max int)

func (*TSnapshotZone) Equal

func (t *TSnapshotZone) Equal(s *TSnapshotZone) bool

func (*TSnapshotZone) Exists

func (t *TSnapshotZone) Exists(rr dns.RR, rrset []dns.RR) int

helper to detect if rr exists dns rrset, assuming that qname and qtype the same (as it derives from map in snapshot zone rrsets, returning an index

func (*TSnapshotZone) Fqdn

func (t *TSnapshotZone) Fqdn() (string, error)

func (*TSnapshotZone) LoadMaps

func (t *TSnapshotZone) LoadMaps() (map[uint16]offloader.RRMap, error)

func (*TSnapshotZone) Refresh

func (t *TSnapshotZone) Refresh() (uint32, error)

func (*TSnapshotZone) RemoveRRsets

func (t *TSnapshotZone) RemoveRRsets()

func (*TSnapshotZone) SOA

func (t *TSnapshotZone) SOA() (string, error)

func (*TSnapshotZone) Serial

func (t *TSnapshotZone) Serial() (uint32, error)

func (*TSnapshotZone) SyncMap

func (t *TSnapshotZone) SyncMap(mode int, sa *TSnapshotActions,
	dryrun bool) (*TSyncMapResult, error)

func (*TSnapshotZone) UnloadMaps

func (t *TSnapshotZone) UnloadMaps(rrmaps map[uint16]offloader.RRMap)

func (*TSnapshotZone) VerifyMap

func (t *TSnapshotZone) VerifyMap() (*TVerifyResult, *TChangedSetZone, error)

func (*TSnapshotZone) WriteSnapshotZone

func (t *TSnapshotZone) WriteSnapshotZone(dryrun bool) error

type TSnapshotsDataCooker

type TSnapshotsDataCooker struct {
	// if snapshots is not enabled, controller
	// should receive zones states as it starts
	// if enabled it read the last snapshot (if
	// configured below)
	Enabled bool `json:"enabled" yaml:"enabled"`

	// reading on startup
	ReadOnStartup bool `json:"read-onstartup" yaml:"read-onstartup"`

	// reading snapshots with specified age
	ReadValidInterval int `json:"read-validinterval" yaml:"read-validinterval"`

	// snapshots directory
	Directory string `json:"directory" yaml:"directory"`

	// number snapshots to keep
	Keep int `json:"keep" yaml:"keep"`
}

type TSnapshotsDataReceiver

type TSnapshotsDataReceiver struct {
	Enabled bool `json:"enabled" yaml:"enabled"`

	// reading on startup
	ReadOnStartup bool `json:"read-onstartup" yaml:"read-onstartup"`

	// reading snapshots with specified age
	ReadValidInterval int `json:"read-validinterval" yaml:"read-validinterval"`

	// syncing blob to bpf.Map age on startup
	StartupValidInterval int `json:"startup-validinterval" yaml:"startup-validinterval"`

	// snapshots directory
	Directory string `json:"directory" yaml:"directory"`
}

type TSnapshotsFilesState

type TSnapshotsFilesState struct {
	Max   int64 `json:"max"`
	Min   int64 `json:"min"`
	Avg   int64 `json:"avg"`
	Count int64 `json:"count"`
}

type TSyncMapResult

type TSyncMapResult struct {
	Created int `json:"created"`
	Removed int `json:"removed"`
}

func (*TSyncMapResult) AsString

func (t *TSyncMapResult) AsString() string

type TTransfer

type TTransfer struct {
	// number of max transfer
	TransfersIn int `json:"transfers-in" yaml:"transfers-in"`

	// method to receive job to make transfer
	TransfersVia []string `json:"transfers-via" yaml:"transfers-via"`

	// transfer interval
	TransfersInterval int `json:"transfers-interval" yaml:"transfers-interval"`
}

type TUpdateZoneStateOptions

type TUpdateZoneStateOptions struct {
	Incremental bool

	Server string

	Key string
}

type TVerifyResult

type TVerifyResult struct {
	// total count of rrsets
	Total int `json:"total"`

	// verified rrsets count
	Verified int `json:"verified"`

	// number of missed records
	Missed int `json:"missed"`

	// differ
	DifferOnTTL int `json:"differ-on-ttl"`
	DifferOnIP  int `json:"differ-on-ip"`

	// number of unexpected records
	Unexpected int `json:"unexpected"`
}

func (*TVerifyResult) AsJSON

func (t *TVerifyResult) AsJSON() []byte

func (*TVerifyResult) AsString

func (t *TVerifyResult) AsString() string

type TWorkerOptions

type TWorkerOptions struct {
	// contains filtered or unexported fields
}

type TZoneConfig

type TZoneConfig struct {
	Zone string `json:"zone"`
}

type TZoneSnapshotOptions

type TZoneSnapshotOptions struct {

	// if snapshot will be incremental (default)
	Incremental bool

	// possible source type of snapshot, possible
	// values: SourceHTTP, SourceFile, SourceAXFR
	Source int

	// primary server to fetch data
	Server string

	// optional key (if set to some value AXFR
	// transfer uses it), should be set in DIG
	// format
	Key string

	// setting if memory snapshots already has
	// a snapshot of zone requested
	SnapshotMode int
}

type TZoneState

type TZoneState struct {
	// a name of zone
	Zone string `json:"zone"`

	// static configuration (with primary server and
	// some options, e.g. overriding SOA zone min)
	Config *TConfigZone `json:"config"`

	// a zone state should be
	Snapshots map[int]TSnapshotZone `json:"snapshots"`

	// number of snapshots
	SnapshotCount int `json:"snapshot-count"`

	// current snapshot ID, should be [0...SnapshotCount-1]
	SnapshotID int `json:"snapshot"`

	// dirty flag calculated after current snapshot
	// is received, this could be done either by
	State int `json:"state"`
}

func (*TZoneState) DetectChangedRRset

func (t *TZoneState) DetectChangedRRset(rrset1 []dns.RR,
	rrset2 []dns.RR) bool

Detecting a change rrset for two rrsets, we should expect that we have one element in a slice

func (*TZoneState) DetectChangedState

func (t *TZoneState) DetectChangedState(s1 *TSnapshotZone,
	s2 *TSnapshotZone) (*TChangedSetZone, error)

Detecting a changed set as diff betweeen snapshots S1 and S2

func (*TZoneState) DetectState

func (t *TZoneState) DetectState(p *TReceiverPlugin, snapshot *TSnapshotZone) int

type TZones

type TZones struct {
	// optional configuration directory
	ZonesDirectory string `json:"zones-directory" yaml:"zones-directory"`

	// secondary zones configurations
	Secondary map[string]TConfigZone `json:"secondary" yaml:"secondary"`

	// if transfer should be incremental
	Incremental bool `json:"incremental" yaml:"incremental"`

	// Aliases primary map configuration (used in
	// zones configuration)
	Primary map[string]string `json:"primary" yaml:"primary"`
}

type TransferOptions

type TransferOptions struct {
	// a mode of data transfer
	Mode int `json:"mode"`

	// some options for IXFR
	Serial uint32 `json:"serial"`
	Ns     string `json:"ns"`
	Mbox   string `json:"mbox"`

	// optional TSIG key
	Key string `json:"key"`
}

func RequestSOA

func RequestSOA(server string, zone string) (*TransferOptions, error)

Getting SOA record of zone as transfer option

type TsigHMACProvider

type TsigHMACProvider string

HMAC Provider configuration, from md5

func (TsigHMACProvider) Generate

func (key TsigHMACProvider) Generate(msg []byte, t *dns.TSIG) ([]byte, error)

func (TsigHMACProvider) Verify

func (key TsigHMACProvider) Verify(msg []byte, t *dns.TSIG) error

type VerifierWorker

type VerifierWorker struct {
	// contains filtered or unexported fields
}

func NewVerifierWorker

func NewVerifierWorker(p *TReceiverPlugin, zones *ZonesState) (*VerifierWorker, error)

func (*VerifierWorker) CompareSnapshots

func (j *VerifierWorker) CompareSnapshots(src map[string][]dns.RR,
	dst map[string][]dns.RR) (*TVerifyResult, *TChangedSetZone, error)

func (*VerifierWorker) Run

func (j *VerifierWorker) Run(ctx context.Context) error

func (*VerifierWorker) Stop

func (j *VerifierWorker) Stop()

func (*VerifierWorker) TickBlobVerifier

func (j *VerifierWorker) TickBlobVerifier(ctx context.Context) error

func (*VerifierWorker) TickVerifier

func (j *VerifierWorker) TickVerifier(ctx context.Context) error

func (*VerifierWorker) Verify

func (j *VerifierWorker) Verify(options *VerifyOptions) (*TVerifyResult, error)

func (*VerifierWorker) VerifyBlob

func (j *VerifierWorker) VerifyBlob(ctx context.Context, options *VerifyOptions) (*TVerifyResult, error)

func (*VerifierWorker) VerifyZone

func (j *VerifierWorker) VerifyZone(ctx context.Context, zones []string,
	server string) (*TVerifyResult, error)

type VerifyOptions

type VerifyOptions struct {
	Dryrun bool
}

type WatcherWorker

type WatcherWorker struct {
	// contains filtered or unexported fields
}

monitor is responsible for collecting metrics, calculatings some monitored properties of application and processing, exporing metrics to api worker

func NewWatcherWorker

func NewWatcherWorker(p *TReceiverPlugin) *WatcherWorker

func (*WatcherWorker) AsJSON

func (m *WatcherWorker) AsJSON() ([]byte, error)

func (*WatcherWorker) CheckRules

func (m *WatcherWorker) CheckRules() error

func (*WatcherWorker) CollectBpfMetrics

func (m *WatcherWorker) CollectBpfMetrics(t int, zero bool) (map[string]int64, map[string][]int64, error)

func (*WatcherWorker) CollectRuntimeMetrics

func (m *WatcherWorker) CollectRuntimeMetrics() (map[string]int64, error)

func (*WatcherWorker) DumpMetrics

func (m *WatcherWorker) DumpMetrics(n int)

func (*WatcherWorker) GarbageMetrics

func (m *WatcherWorker) GarbageMetrics(n int)

func (*WatcherWorker) GetLastMetric

func (m *WatcherWorker) GetLastMetric(id string) []int64

func (*WatcherWorker) GetLastMetrics

func (m *WatcherWorker) GetLastMetrics() map[string][]int64

func (*WatcherWorker) GetXdpService

func (m *WatcherWorker) GetXdpService() *offloader.TXdpService

func (*WatcherWorker) PushFloatMetric

func (m *WatcherWorker) PushFloatMetric(id string, metric float64)

func (*WatcherWorker) PushHistograms

func (m *WatcherWorker) PushHistograms(metrics map[string][]int64)

func (*WatcherWorker) PushIntMetric

func (m *WatcherWorker) PushIntMetric(id string, metric int64)

func (*WatcherWorker) PushMetric

func (m *WatcherWorker) PushMetric(id string, values []int64)

func (*WatcherWorker) PushMetrics

func (m *WatcherWorker) PushMetrics(metrics map[string]int64)

func (*WatcherWorker) Run

func (m *WatcherWorker) Run(ctx context.Context) error

func (*WatcherWorker) TickCollector

func (m *WatcherWorker) TickCollector(ctx context.Context,
	t int, wg *sync.WaitGroup) error

func (*WatcherWorker) TickWatcher

func (m *WatcherWorker) TickWatcher(ctx context.Context,
	wg *sync.WaitGroup) error

type ZonesState

type ZonesState struct {
	// contains filtered or unexported fields
}

func NewZonesState

func NewZonesState(p *TReceiverPlugin) *ZonesState

func (*ZonesState) CreateBlob

func (z *ZonesState) CreateBlob() int

func (*ZonesState) DetectBlobState

func (z *ZonesState) DetectBlobState() int

func (*ZonesState) GetConfig

func (z *ZonesState) GetConfig(zone string) (*TConfigZone, error)

func (*ZonesState) GetLastZoneSnapshot

func (z *ZonesState) GetLastZoneSnapshot(zone string) *TSnapshotZone

func (*ZonesState) GetSnapshotsFilesState

func (z *ZonesState) GetSnapshotsFilesState() (*TSnapshotsFilesState, error)

func (*ZonesState) GetZonesConfigs

func (z *ZonesState) GetZonesConfigs() map[string]TConfigZone

func (*ZonesState) Primary

func (z *ZonesState) Primary(primary string) string

func (*ZonesState) RequestUpdate

func (z *ZonesState) RequestUpdate(pool *CollectorTransferPool,
	zone string, v TConfigZone)

func (*ZonesState) Update

func (z *ZonesState) Update(pool *CollectorTransferPool) error

Jump to

Keyboard shortcuts

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