dnsServer

package
Version: v0.0.0-...-172d49c Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2019 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const DnsPathPrefix = "containerdns"
View Source
const Version = "2.1.1"

Variables

View Source
var (
	EtcdCachesLock       sync.RWMutex                                                  // lcok EtcdRecordCaches
	EtcdRecordCaches     map[string][]ServiceRecord = make(map[string][]ServiceRecord) //
	EtcdRecordUpdateTime map[string]time.Time       = make(map[string]time.Time)       //
)
View Source
var MsgCachePool *queue.Queue

Functions

func CacheKey

func CacheKey(q dns.Question, tcp bool) string

func DnsDomain

func DnsDomain(s string) string

Domain is the opposite of Path.

func DnsPath

func DnsPath(s string) string

Path converts a domainname to an etcd path. If s looks like service.staging.containerdns.local., the resulting key will be /containerdns/local/containerdns/staging/service .

func FitUdpSize

func FitUdpSize(m *dns.Msg) *dns.Msg

func New

func New(backend Backend, domains []string, addr, ipMonitorPath string, forwardNameServers []string, subDomainServers map[string][]string, cacheSize int, random, hold bool, skip bool) *server

New returns a new containerdns server.

Types

type Backend

type Backend interface {
	Records(name string) ([]ServiceRecord, error)
	ReverseRecord(name string) (*ServiceRecord, error)
	Get(name string) ([]ServiceRecord, int64, error)
	GetRaw(name string) (*clientv3.GetResponse, error)
}

type Cache

type Cache struct {
	sync.RWMutex

	AvaliableIps           map[string]bool // the host alive
	AvaliableIpsUpdateTime time.Time
	// contains filtered or unexported fields
}

Cache is a cache that holds on the a number of RRs or DNS messages. The cache eviction is randomized.

func NewMsgCache

func NewMsgCache(capacity int, randomOne bool, ipHold bool, minTtl uint32) *Cache

New returns a new cache with the capacity and the ttl specified.

func (*Cache) Add2MsgCache

func (c *Cache) Add2MsgCache(s string, msg *dns.Msg, remoteIp string, timeNow time.Time, forwarding bool)

func (*Cache) CacheForwardTtlGet

func (c *Cache) CacheForwardTtlGet() uint64

func (*Cache) CacheForwardTtlSet

func (c *Cache) CacheForwardTtlSet(ttl uint64)

func (*Cache) CacheSizeUsed

func (c *Cache) CacheSizeUsed() int

func (*Cache) Capacity

func (c *Cache) Capacity() int

func (*Cache) DelCachedDataCnameTypeAMap

func (c *Cache) DelCachedDataCnameTypeAMap(host, alias string)

func (*Cache) DeleteCacheDnsDomain

func (c *Cache) DeleteCacheDnsDomain(domain string, tcp bool) bool

func (*Cache) EnsureNoExist

func (c *Cache) EnsureNoExist(name string, qtype uint16, tcp bool)

func (*Cache) GetAllDomianStats

func (c *Cache) GetAllDomianStats() DomainList

func (*Cache) InsertCachedDataCnameTypeAMap

func (c *Cache) InsertCachedDataCnameTypeAMap(host, alias string)

func (*Cache) KeyTypeA

func (c *Cache) KeyTypeA(name string, dnssec, tcp bool) string

the key in cache is diff from domain

func (*Cache) Remove

func (c *Cache) Remove(s string)

func (*Cache) SearchRecordInCache

func (c *Cache) SearchRecordInCache(question dns.Question, tcp bool, msgid uint16, remoteIp string, queryNow time.Time) *dns.Msg

func (*Cache) ShowCacheDnsDomain

func (c *Cache) ShowCacheDnsDomain(domain string, tcp bool) *dns.Msg

func (*Cache) ShowCacheStats

func (c *Cache) ShowCacheStats(domain string, tcp bool) (int64, time.Time, time.Time)

func (*Cache) SyncCachedDataCnameMap

func (c *Cache) SyncCachedDataCnameMap(records map[string][]string, timenow time.Time)

func (*Cache) SyncCheckCachedRecords

func (c *Cache) SyncCheckCachedRecords(mAnswers map[string][]dns.RR)

func (*Cache) UpdateRcacheDelete

func (c *Cache) UpdateRcacheDelete(valA interface{})

func (*Cache) UpdateRcacheSet

func (c *Cache) UpdateRcacheSet(val interface{})

func (*Cache) UpdateRcacheUpdate

func (c *Cache) UpdateRcacheUpdate(valAOld interface{}, valANew interface{})

type DomainList

type DomainList []*DomainTop

func (DomainList) Len

func (s DomainList) Len() int

func (DomainList) Less

func (s DomainList) Less(i, j int) bool

func (DomainList) Swap

func (s DomainList) Swap(i, j int)

type DomainTop

type DomainTop struct {
	RequestCount int64  `json:"reqCount,omitempty"`
	Domain       string `json:"domain,omitempty"`
}

type ServiceRecord

type ServiceRecord struct {
	Dnstype      string `json:"type,omitempty"`
	RecordSource string `json:"source,omitempty"`
	DnsHost      string `json:"host,omitempty"`
	DnsTtl       uint32 `json:"ttl,omitempty"`

	DnsPort     int `json:"port,omitempty"`
	DnsPriority int `json:"priority,omitempty"`
	DnsWeight   int `json:"weight,omitempty"`

	DnsText string `json:"text,omitempty"`
	DnsMail bool   `json:"mail,omitempty"`
	Cluster string `json:"cluster,omitempty"`
	// Etcd key
	Key string `json:"-"`
}

func (*ServiceRecord) NewRecordA

func (s *ServiceRecord) NewRecordA(name string, ip net.IP) *dns.A

NewRecordA returns a new A record based on the Service.

func (*ServiceRecord) NewRecordAAAA

func (s *ServiceRecord) NewRecordAAAA(name string, ip net.IP) *dns.AAAA

NewRecordAAAA returns a new AAAA record based on the Service.

func (*ServiceRecord) NewRecordCname

func (s *ServiceRecord) NewRecordCname(name string, target string) *dns.CNAME

NewRecordCname returns a new CNAME record based on the Service.

func (*ServiceRecord) NewRecordMx

func (s *ServiceRecord) NewRecordMx(name string) *dns.MX

NewRecordMx returns a new MX record based on the Service.

func (*ServiceRecord) NewRecordNS

func (s *ServiceRecord) NewRecordNS(name string, target string) *dns.NS

NewRecordNS returns a new NS record based on the Service.

func (*ServiceRecord) NewRecordPTR

func (s *ServiceRecord) NewRecordPTR(name string, ttl uint32) *dns.PTR

NewRecordPTR returns a new PTR record based on the Service.

func (*ServiceRecord) NewRecordSRV

func (s *ServiceRecord) NewRecordSRV(name string, weight uint16) *dns.SRV

NewRecordSRV returns a new SRV record based on the Service.

func (*ServiceRecord) NewRecordTXT

func (s *ServiceRecord) NewRecordTXT(name string) *dns.TXT

NewRecordTXT returns a new TXT record based on the Service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to