2023-12-09 14:21:28 -06:00

36 lines
654 B
Go

package main
import (
"bytes"
"text/template"
"pihole-blocklist/bind/assets"
"pihole-blocklist/bind/internal/config"
)
func buildBindResponsePolicyFile() error {
var (
output bytes.Buffer
)
outputTemplate := assets.BindRecord
t, err := template.New("response-policy-zone").Parse(string(outputTemplate))
if err != nil {
return err
}
if err := t.Execute(&output, cfg.ConfigFile.ZoneConfig); err != nil {
return err
}
bytesWritten, err := config.WriteFile(cfg.BindOutputFileName, output.Bytes())
if err != nil {
return err
}
cfg.Log.Debug("file created", "file", cfg.BindOutputFileName, "bytes", bytesWritten)
return nil
}