func splitRR(rr dns.RR) []string { if debug { log.Printf("RR %v\n", rr.String()) } rrary := strings.SplitN(rr.String(), "\t", 5) return rrary }
func recordSummary(r dns.RR) string { s := r.String() parts := strings.Split(s, "\t") nparts := len(parts) if nparts < 2 { return s } return "(" + strings.Join(parts[nparts-2:], " ") + ")" }
// save record func saveRecord(rr dns.RR) (err error) { var key string if key, err = formatKey(rr.Header().Name, rr.Header().Rrtype); err != nil { return } err = DB.Update(func(tx *bolt.Tx) error { if err := tx.Bucket([]byte(bucket)).Put([]byte(key), []byte(rr.String())); err != nil { return err } return nil }) return err }
func storeRecord(rr dns.RR) (err error) { if *debug { Log.Printf("Store record: resource record: %+v\n", rr) } key, _ := getKey(rr.Header().Name, rr.Header().Rrtype) err = bdb.Update(func(tx *bolt.Tx) error { b := tx.Bucket([]byte(rrBucket)) err := b.Put([]byte(key), []byte(rr.String())) if err != nil { e := errors.New("Store record failed: " + rr.String()) Log.Println(e.Error()) return e } return nil }) return err }
// Return rdata func rdata(RR dns.RR) string { return strings.Replace(RR.String(), RR.Header().String(), "", -1) }
func dnsRRToString(rr dns.RR) string { parts := strings.SplitN(rr.String(), "\t", 5) return parts[0] + " " + parts[1] + " " + parts[3] + " " + parts[4] }
// DataRemoveRR calls DataRemove, but allows to directly use an dns.RR. // This method is not found in Unbound. func (u *Unbound) DataRemoveRR(data dns.RR) error { return u.DataRemove(data.String()) }
// DataAddRR calls DataAdd, but allows to directly use an dns.RR. // This method is not found in Unbound. func (u *Unbound) DataAddRR(data dns.RR) error { return u.DataAdd(data.String()) }
// AddTaRR calls AddTa, but allows to directly use an dns.RR. // This method is not found in Unbound. func (u *Unbound) AddTaRR(ta dns.RR) error { return u.AddTa(ta.String()) }