aboutsummaryrefslogtreecommitdiff
path: root/middleware/pkg/rcode/rcode.go
blob: 32863f0b2b545f800ae3b8458eb4c7007d2ab1c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package rcode

import (
	"strconv"

	"github.com/miekg/dns"
)

// ToString convert the rcode to the official DNS string, or to "RCODE"+value if the RCODE
// value is unknown.
func ToString(rcode int) string {
	if str, ok := dns.RcodeToString[rcode]; ok {
		return str
	}
	return "RCODE" + strconv.Itoa(rcode)
}