package dns import ( "bytes" "fmt" "io" "time" "github.com/libdns/libdns" ) // WriteTo writes the DNS data for the cluster func (mgr *Manager) WriteTo(w io.Writer) (int64, error) { var buf bytes.Buffer records := mgr.genAllAddrRecords() for i := range records { r := &records[i] r.Name = fmt.Sprintf("%s.%s.", r.Name, mgr.domain) } for _, rr1 := range records { for _, rr2 := range rr1.Export() { writeRecord(&buf, rr2) } } return buf.WriteTo(w) } func writeRecord(w io.Writer, rr libdns.Record) { _, _ = fmt.Fprintf(w, "%s\t%v\tIN\t%s\t%s\n", rr.Name, int(rr.TTL/time.Second), rr.Type, rr.Value) }