models

package
v0.0.0-...-ac9b390 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DNS Record Types
	A     = int(dns.TypeA)
	NS    = int(dns.TypeNS)
	CNAME = int(dns.TypeCNAME)
	SOA   = int(dns.TypeSOA)
	MX    = int(dns.TypeMX)
	TXT   = int(dns.TypeTXT)

	// DNS Record Route Types
	Single   = 0
	Weighted = 1

	// DNS Record TTLs
	DefaultTTLSec      = 300
	DefaultLastSeenTTL = 60
)

Variables

This section is empty.

Functions

func MarshalJSON

func MarshalJSON(record DNSRecord) ([]byte, error)

Types

type ARecord

type ARecord struct {
	RecordCommon

	Data ARecordData `json:"data"`
}

func (*ARecord) GetCommon

func (r *ARecord) GetCommon() RecordCommon

func (*ARecord) GetData

func (r *ARecord) GetData() []byte

func (*ARecord) GetResponse

func (r *ARecord) GetResponse() dns.RR

GetResponse returns a pre-processed DNS response for an A Record

type ARecordData

type ARecordData struct {
	Address string `json:"address"`

	// Fallback (Optional)
	LastSeen time.Time `json:"last_seen,omitempty"`
	Fallback string    `json:"fallback,omitempty"`
}

type CNAMERecord

type CNAMERecord struct {
	RecordCommon

	Data CNAMERecordData `json:"data"`
}

func (*CNAMERecord) GetCommon

func (r *CNAMERecord) GetCommon() RecordCommon

func (*CNAMERecord) GetData

func (r *CNAMERecord) GetData() []byte

func (*CNAMERecord) GetResponse

func (r *CNAMERecord) GetResponse() dns.RR

GetResponse returns a pre-processed DNS response for an A Record

type CNAMERecordData

type CNAMERecordData struct {
	Alias string `json:"alias"`
}

type DNSRecord

type DNSRecord interface {
	GetCommon() RecordCommon
	GetData() []byte
	GetResponse() dns.RR
}

func ParseRecord

func ParseRecord(common RecordCommon, data []byte) (DNSRecord, error)

func UnmarshalJSON

func UnmarshalJSON(data []byte) (DNSRecord, error)

type MXRecord

type MXRecord struct {
	RecordCommon

	Data MXRecordData `json:"data"`
}

func (*MXRecord) GetCommon

func (r *MXRecord) GetCommon() RecordCommon

func (*MXRecord) GetData

func (r *MXRecord) GetData() []byte

func (*MXRecord) GetResponse

func (r *MXRecord) GetResponse() dns.RR

GetResponse returns a pre-processed DNS response for an A Record

type MXRecordData

type MXRecordData struct {
	MailServer string `json:"mail_server"`
	Preference uint16 `json:"preference"`
}

type NSRecord

type NSRecord struct {
	RecordCommon

	Data NSRecordData `json:"data"`
}

func (*NSRecord) GetCommon

func (r *NSRecord) GetCommon() RecordCommon

func (*NSRecord) GetData

func (r *NSRecord) GetData() []byte

func (*NSRecord) GetResponse

func (r *NSRecord) GetResponse() dns.RR

GetResponse returns a pre-processed DNS response for an A Record

type NSRecordData

type NSRecordData struct {
	NameServer string `json:"server"`
}

type RecordBlueprint

type RecordBlueprint struct {
	Id        int    `json:"id"`
	Type      string `json:"type"`
	Domain    string `json:"domain"`
	Subdomain string `json:"subdomain"`
	TTL       int    `json:"ttl"`

	Data interface{} `json:"data"`
}

func (RecordBlueprint) Build

func (r RecordBlueprint) Build() DNSRecord

func (*RecordBlueprint) Override

func (r *RecordBlueprint) Override(rb DNSRecord)

type RecordCommon

type RecordCommon struct {
	Id        int    `json:"id"`
	Domain    string `json:"domain"`
	Subdomain string `json:"subdomain"`

	// DNS Record Types
	Type      int `json:"type"`
	RouteType int `json:"route_type"`

	// Times Data
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
	DeactivatedAt time.Time `json:"deactivated_at"`
	ExpiredAt     time.Time `json:"expired_at"`
	TTL           int       `json:"ttl"` // Time to Live (in seconds)

	// Allow and Deny Lists (IPs and Subnets)
	Allow []string `json:"allow"`
	Deny  []string `json:"deny"`
}

func (RecordCommon) GetFQDN

func (r RecordCommon) GetFQDN() string

func (RecordCommon) GetType

func (r RecordCommon) GetType() string

type SOARecord

type SOARecord struct {
	RecordCommon

	Data SOARecordData `json:"data"`
}

func (*SOARecord) GetCommon

func (r *SOARecord) GetCommon() RecordCommon

func (*SOARecord) GetData

func (r *SOARecord) GetData() []byte

func (*SOARecord) GetResponse

func (r *SOARecord) GetResponse() dns.RR

GetResponse returns a pre-processed DNS response for an A Record

type SOARecordData

type SOARecordData struct {
	Ns      string `json:"ns_server"`  // ns.tundra-dns.io
	Mbox    string `json:"ns_mailbox"` // admin.tundra-dns.io
	Serial  uint32 `json:"serial"`
	Refresh uint32 `json:"refresh"`
	Retry   uint32 `json:"retry"`
	Expire  uint32 `json:"expire"`
	Minttl  uint32 `json:"minttl"`
}

type TXTRecord

type TXTRecord struct {
	RecordCommon

	Data TXTRecordData `json:"data"`
}

func (*TXTRecord) GetCommon

func (r *TXTRecord) GetCommon() RecordCommon

func (*TXTRecord) GetData

func (r *TXTRecord) GetData() []byte

func (*TXTRecord) GetResponse

func (r *TXTRecord) GetResponse() dns.RR

GetResponse returns a pre-processed DNS response for an A Record

type TXTRecordData

type TXTRecordData struct {
	Content []string `json:"content"`
}

Jump to

Keyboard shortcuts

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