Skip to content

Commit

Permalink
refactor: add timestamp to recaxfr
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Mar 31, 2023
1 parent 9ab6a34 commit 15b493d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions xfr.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package main

import (
"fmt"
"os"
"path"
"strings"
"time"

"github.com/miekg/dns"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -45,7 +47,7 @@ func RecAXFR(label, server string) []dns.RR {
queried = make(map[string]bool)
all = make([]dns.RR, 0)

dir := strings.TrimPrefix(label, ".") + ".recaxfr"
dir := fmt.Sprintf("%s_%s_recaxfr", strings.TrimPrefix(label, "."), strings.ReplaceAll(time.Now().Format(time.UnixDate), " ", "-"))

// Create recursive AXFR directory if it doesn't exist
if _, err := os.Stat(dir); os.IsNotExist(err) {
Expand All @@ -56,7 +58,7 @@ func RecAXFR(label, server string) []dns.RR {
}

addToTree(label, dir, server)
log.Infof("AXFR complete, %d records written in %s", len(all), dir)
log.Infof("AXFR complete, %d records saved to %s", len(all), dir)

return all
}
Expand Down

0 comments on commit 15b493d

Please sign in to comment.