server

package
v0.0.0-...-e613796 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 5 Hours
	MinStaleTime  = 600 * 5
	MaxLogRecords = 5000
)
View Source
const (
	Timeout        = 360000
	NanoConv       = 1_000_000
	BlockedIp      = "Blocked!"
	NoServer       = "127.0.0.1"
	Ok        int8 = 0
	Block     int8 = 1
	NotFound  int8 = 2
)

Variables

This section is empty.

Functions

func DnsServer

func DnsServer(port int, net string, server *Server) *dns.Server

Types

type Config

type Config struct {
	Hosts      map[string]interface{} `json:"hosts"`
	Blocks     map[string]bool        `json:"blocks"`
	DnsServers []string               `json:"servers"`
	NoCache    []string               `json:"noCache"`
	DohServer  *string                `json:"dohServer"`
}

type ContextualDnsServer

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

func MakeContextualServer

func MakeContextualServer(handler ContextualHandler, context interface{}) *ContextualDnsServer

func (*ContextualDnsServer) ServeDNS

func (server *ContextualDnsServer) ServeDNS(w dns.ResponseWriter, r *dns.Msg)

type ContextualHandler

type ContextualHandler interface {
	ServeDNS(w dns.ResponseWriter, r *dns.Msg, context interface{})
}

Handler is implemented by any value that implements ServeDNS.

type Domain

type Domain struct {
	Name          string   `json:"name"`
	Time          int64    `json:"time"`
	Ip            string   `json:"ip"`
	Block         bool     `json:"block"`
	Requests      int64    `json:"requests"`
	Server        string   `json:"server"`
	Type          uint16   `json:"type"`
	Ttl           uint32   `json:"ttl"`
	Managed       bool     `json:"managed"`
	LastRequested int64    `json:"lastRequested"`
	History       []string `json:"-"`
}

func (*Domain) IsExpired

func (this *Domain) IsExpired() bool

func (*Domain) SecondsSinceLastRequest

func (this *Domain) SecondsSinceLastRequest() uint

type LatencyStats

type LatencyStats struct {
	Average string `json:"average"`
	Median  string `json:"median"`
	Min     string `json:"min"`
	Max     string `json:"max"`
}

type Log

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

type LogCallback

type LogCallback = func(*Log)

type LogHook

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

func Hook

func Hook(callback LogCallback) LogHook

func (LogHook) Fire

func (hook LogHook) Fire(entry *logrus.Entry) (err error)

func (LogHook) Levels

func (hook LogHook) Levels() []logrus.Level

Levels are the available logging levels.

type Metric

type Metric struct {
	MetricType string `json:"type"`
	Time       int64  `json:"time"`
	Ip         string `json:"ip"`
	Server     string `json:"server"`
	Blocked    bool   `json:"blocked"`
	Domain     string `json:"domain"`
}

type RequestLog

type RequestLog = map[string][]string

type Server

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

func NewServer

func NewServer() *Server

func (*Server) GetMessages

func (this *Server) GetMessages() []string

func (*Server) PreStart

func (this *Server) PreStart()

func (*Server) ServeDNS

func (this *Server) ServeDNS(w dns.ResponseWriter, r *dns.Msg, context interface{})

type Stats

type Stats struct {
	Started           int64
	Running           *string        `json:"running"`
	Requests          int64          `json:"requests"`
	LookupRequests    int64          `json:"lookupRequests"`
	CachedRequests    int64          `json:"cachedRequests"`
	BlockedRequests   int64          `json:"blockedRequests"`
	FailedRequests    int64          `json:"failedRequests"`
	LatencyStats      LatencyStats   `json:"latency"`
	UnhandledRequests map[uint16]int `json:"unhandled"`
	Domains           []*Domain      `json:"domains"`
	FailedDomains     []string       `json:"failedDomains"`
	RequestLog        RequestLog     `json:"ipLog"`
	Metrics           []Metric       `json:"metrics"`
	Info              []string       `json:"info"`
	Latencies         []int64        `json:"-"`
}

func (*Stats) AddInfo

func (stats *Stats) AddInfo(info string)

Jump to

Keyboard shortcuts

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