dns

package
v0.0.0-...-17edc22 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Automatic = Status(iota)
	Online
	Offline
	Maintenance
)

Status values of a check

Variables

View Source
var IntToStatusType = map[int]Status{
	0: Automatic,
	1: Online,
	2: Offline,
	3: Maintenance,
}

IntToStatusType converts int to status

View Source
var StatusTypeToString = map[Status]string{
	Automatic:   "automatic",
	Online:      "online",
	Offline:     "offline",
	Maintenance: "maintance",
}

StatusTypeToString converts status to string

View Source
var StringToStatusType = map[string]Status{
	"automatic":   Automatic,
	"online":      Online,
	"offline":     Offline,
	"maintenance": Maintenance,
}

StringToStatusType converts string to status

Functions

func AddLocalRecord

func AddLocalRecord(domain string, record Record)

AddLocalRecord adds a local record

func AllowForwarding

func AllowForwarding(cidr []string)

AllowForwarding return true if client is allowed to forward dns requests

func Debug

func Debug()

Debug Shows current state

func Discard

func Discard(node string)

Discard discards all dns entries of a node

func EnableProxyStats

func EnableProxyStats(b bool)

EnableProxyStats set to true to use proxy stats, or to false to use internal stats of dns manager

func FindTargets

func FindTargets(dnsmanager map[string]Domains, domain, name, request string) ([]string, []string, []string)

FindTargets returns all targets of matching records

func GetCache

func GetCache() map[string]Domains

GetCache Returns a copy current cached entries

func Listen

func Listen(server *dnssrv.Server) error

Listen starts the listener

func MarkOffline

func MarkOffline(node string)

MarkOffline marks all dns entries of a node as offline

func Remove

func Remove(node, domainName, hostName string)

Remove a specific dns entry

func RemoveLocalRecord

func RemoveLocalRecord(domain string, recordid int)

RemoveLocalRecord adds a local record

func RemoveLocalRecordByContent

func RemoveLocalRecordByContent(domainName string, hostName string, TTL int, Target string, Type string)

RemoveLocalRecordByContent remove content by record data

func Server

func Server(host string, port int, allowedRequests []string)

Server Process DNS Requests

func Update

func Update(node string, domain string, record Record)

Update Updates a dns entry in a node

func UpdateStatistics

func UpdateStatistics(clusterNode string, domain string, s *balancer.Statistics)

UpdateStatistics for node

func WebGLBStatus

func WebGLBStatus(w http.ResponseWriter, r *http.Request)

WebGLBStatus Provides a status page for GLB

Types

type Config

type Config struct {
	Domains         map[string]Domain `toml:"domains" json:"domains"`
	Binding         string            `toml:"binding" json:"binding"`
	AllowForwarding []string          `toml:"allow_forwarding" json:"allow_forwarding"`
	Port            int               `toml:"port" json:"port"`
	AllowedRequests []string          `toml:"allowed_requests" json:"allowed_requests"`
}

Config has the dns config

type Domain

type Domain struct {
	Records []Record `toml:"records" json:"records"`
	TTL     int      `json:"ttl"`
}

Domain is a dns domain

type Domains

type Domains struct {
	Domains map[string]Domain `toml:"domains" json:"domains"`
}

Domains is a collection of dns domains

type Record

type Record struct {
	Name                string               `toml:"name" json:"name"`                                   // hostname
	Type                string               `toml:"type" json:"type"`                                   // record type
	Target              string               `toml:"target" json:"target"`                               // reply of record
	TTL                 int                  `toml:"ttl" json:"ttl"`                                     // time to live
	BalanceMode         string               `toml:"balancemode" json:"balancemode"`                     // balance mode of dns
	ActivePassive       string               `toml:"activepassive" json:"activepassive"`                 // used for monitoring only: record is active/passive setup
	ServingClusterNodes int                  `toml:"serving_cluster_nodes" json:"serving_cluster_nodes"` // ammount of cluster nodes that should serve this domain (defaults to len(clusternodes))
	LocalNetwork        string               `toml:"localnetwork" json:"localnetwork"`                   // used by balance mode: topology
	Statistics          *balancer.Statistics `toml:"statistics" json:"statistics"`                       // stats
	Status              Status               `toml:"status" json:"status"`                               // is record online (do we serve it)
	Local               bool                 `toml:"local" json:"local"`                                 // true if record is of the local dns server
	UUID                string               `toml:"uuid" json:"uuid"`                                   // links record to check that added it,usefull for removing dead checks
}

Record of any type

func GetAllLocalDomainRecords

func GetAllLocalDomainRecords(domain string) []Record

GetAllLocalDomainRecords get all local records from domain

func GetRecordsByStats

func GetRecordsByStats(rec []Record, stat []balancer.Statistics) ([]Record, error)

GetRecordsByStats returns the statistics of all records

type Status

type Status uint8

Status holds the status of a check

func (Status) String

func (s Status) String() string

type StatusType

type StatusType struct {
	Status `json:"status" toml:"status"` // status container for toml conversion
}

StatusType contains the status

func (*StatusType) UnmarshalJSON

func (s *StatusType) UnmarshalJSON(text []byte) error

UnmarshalJSON converts json Status to Status uint8

func (*StatusType) UnmarshalText

func (s *StatusType) UnmarshalText(text []byte) error

UnmarshalText converts json Status to Status uint8

Jump to

Keyboard shortcuts

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