Fix linter errors

This commit is contained in:
Daniel
2020-09-23 14:12:23 +02:00
parent 12b0ff973d
commit af056780fc
5 changed files with 21 additions and 14 deletions

View File

@@ -79,6 +79,7 @@ func ZeroIP(msg string) ResponderFunc {
}
}
// Localhost is a ResponderFunc than replies with localhost IP addresses.
func Localhost(msg string) ResponderFunc {
return func(ctx context.Context, request *dns.Msg) *dns.Msg {
reply := new(dns.Msg)
@@ -145,7 +146,9 @@ func ServerFailure(msg string) ResponderFunc {
}
}
func MakeMessageRecord(level log.Severity, msg string) (dns.RR, error) {
// MakeMessageRecord creates an informational resource record that can be added
// to the extra section of a reply.
func MakeMessageRecord(level log.Severity, msg string) (dns.RR, error) { //nolint:interfacer
return dns.NewRR(fmt.Sprintf(
`%s.portmaster. 0 IN TXT "%s"`,
strings.ToLower(level.String()),
@@ -153,6 +156,10 @@ func MakeMessageRecord(level log.Severity, msg string) (dns.RR, error) {
))
}
// AddMessageToReply creates an information resource records using
// MakeMessageRecord and immediately adds it the the extra section of the given
// reply. If an error occurs, the resource record will not be added, and the
// error will be logged.
func AddMessageToReply(ctx context.Context, reply *dns.Msg, level log.Severity, msg string) {
if msg != "" {
rr, err := MakeMessageRecord(level, msg)