@@ -38,15 +38,20 @@ func (f *File) Records() int64 {
38
38
}
39
39
40
40
// WriteComment adds a comment to the zone file
41
- func (f * File ) WriteComment (key , value string ) error {
41
+ func (f * File ) WriteComment (comment string ) error {
42
42
err := f .fileReady ()
43
43
if err != nil {
44
44
return err
45
45
}
46
- _ , err = f .bufWriter .WriteString (fmt .Sprintf ("; %s: %s \n " , key , value ))
46
+ _ , err = f .bufWriter .WriteString (fmt .Sprintf ("; %s" , comment ))
47
47
return err
48
48
}
49
49
50
+ // WriteCommentKey adds a comment to the zone file
51
+ func (f * File ) WriteCommentKey (key , value string ) error {
52
+ return f .WriteComment (fmt .Sprintf ("%s: %s\n " , key , value ))
53
+ }
54
+
50
55
// ErrFileClosed returned when attempting to write to a closed file
51
56
var ErrFileClosed = errors .New ("file is already closed" )
52
57
@@ -65,18 +70,13 @@ func (f *File) fileReady() error {
65
70
f .gzWriter = gzip .NewWriter (f .fileWriter )
66
71
f .gzWriter .ModTime = time .Now ()
67
72
f .gzWriter .Name = fmt .Sprintf ("%s.zone" , f .zone [:len (f .zone )- 1 ])
68
- f .gzWriter .Comment = "generated by allxfr"
69
73
f .bufWriter = bufio .NewWriter (f .gzWriter )
70
74
// Save metadata to zone file as comment
71
- _ , err = f .bufWriter .WriteString ("; Generated by ALLXFR (https://github.com/lanrat/allxfr)\n " )
72
- if err != nil {
73
- return err
74
- }
75
- err = f .WriteComment ("timestamp" , time .Now ().Format (time .RFC3339 ))
75
+ err = f .WriteCommentKey ("timestamp" , time .Now ().Format (time .RFC3339 ))
76
76
if err != nil {
77
77
return err
78
78
}
79
- err = f .WriteComment ("zone" , f .zone )
79
+ err = f .WriteCommentKey ("zone" , f .zone )
80
80
if err != nil {
81
81
return err
82
82
}
@@ -105,7 +105,7 @@ func (f *File) Finish() error {
105
105
// function to finish/close/safe the files when done
106
106
if f .records > 1 {
107
107
// save record count comment at end of zone file
108
- err := f .WriteComment ("records" , fmt .Sprintf ("%d" , f .records ))
108
+ err := f .WriteCommentKey ("records" , fmt .Sprintf ("%d" , f .records ))
109
109
if err != nil {
110
110
return err
111
111
}
0 commit comments