package pancheri import ( "github.com/miekg/dns" "net" ) const ( RuleTypeA = "A" RuleTypeAAAA = "AAAA" RuleTypeCNAME = "CNAME" RuleTypeTXT = "TXT" ) type RecordA struct { In string `yaml:"i"` Ip net.IP `yaml:"v4"` TTL uint `yaml:"t"` } func (record *RecordA) Render() *dns.A { r := new(dns.A) r.Hdr = dns.RR_Header{ Name: record.In, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: uint32(record.TTL), } r.A = record.Ip return r } type RecordAAAA struct { In string `yaml:"i"` Ip net.IP `yaml:"v6"` TTL uint `yaml:"t"` } func (record *RecordAAAA) Render() *dns.AAAA { r := new(dns.AAAA) r.Hdr = dns.RR_Header{ Name: record.In, Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl: uint32(record.TTL), } r.AAAA = record.Ip return r } type RecordCNAME struct { In string `yaml:"i"` Target string `yaml:"tr"` TTL uint `yaml:"t"` } func (record *RecordCNAME) Render() *dns.CNAME { r := new(dns.CNAME) r.Hdr = dns.RR_Header{ Name: record.In, Rrtype: dns.TypeCNAME, Class: dns.ClassINET, Ttl: uint32(record.TTL), } r.Target = record.Target return r } type RecordTXT struct { In string `yaml:"i"` Content []string `yaml:"c"` TTL uint `yaml:"t"` } func (record *RecordTXT) Render() *dns.TXT { r := new(dns.TXT) r.Hdr = dns.RR_Header{ Name: record.In, Rrtype: dns.TypeTXT, Class: dns.ClassINET, Ttl: uint32(record.TTL), } r.Txt = record.Content return r }