代码拉取完成,页面将自动刷新
package dns
// This file contains the name mapping data used to convert various DNS IDs to
// their string values.
import (
"encoding/hex"
"fmt"
"strconv"
"strings"
mkdns "github.com/miekg/dns"
)
// dnsOpCodeToString converts a Opcode value to a string. If the type's
// string representation is unknown then the numeric value will be returned as
// a string.
func dnsOpCodeToString(opCode int) string {
s, exists := mkdns.OpcodeToString[opCode]
if !exists {
return strconv.Itoa(int(opCode))
}
return s
}
// dnsResponseCodeToString converts a Rcode value to a string. If
// the type's string representation is unknown then "Unknown <rcode value>"
// will be returned.
func dnsResponseCodeToString(rcode int) string {
s, exists := mkdns.RcodeToString[rcode]
if !exists {
return fmt.Sprintf("Unknown %d", int(rcode))
}
return s
}
// dnsTypeToString converts a RR type value to a string. If the type's
// string representation is unknown then the numeric value will be returned
// as a string.
func dnsTypeToString(t uint16) string {
s, exists := mkdns.TypeToString[uint16(t)]
if !exists {
return strconv.Itoa(int(t))
}
return s
}
// dnsClassToString converts a RR class value to a string. If the class'es
// string representation is unknown then the numeric value will be returned
// as a string.
func dnsClassToString(c uint16) string {
s, exists := mkdns.ClassToString[uint16(c)]
if !exists {
return strconv.Itoa(int(c))
}
return s
}
// dnsAlgorithmToString converts an algorithm value to a string. If the algorithm's
// string representation is unknown then the numeric value will be returned
// as a string.
func dnsAlgorithmToString(a uint8) string {
s, exists := mkdns.AlgorithmToString[uint8(a)]
if !exists {
return strconv.Itoa(int(a))
}
return s
}
// dnsHashToString converts a hash value to a string. If the hash's
// string representation is unknown then the numeric value will be returned
// as a string.
func dnsHashToString(h uint8) string {
s, exists := mkdns.HashToString[uint8(h)]
if !exists {
return strconv.Itoa(int(h))
}
return s
}
// dnsTypeBitsMapToString converts a map of type bits to a string. If the type's
// string representation is unknown then the numeric value will be returned
// as a string.
func dnsTypeBitsMapToString(t []uint16) string {
var s string
for i := 0; i < len(t); i++ {
s += dnsTypeToString(t[i]) + " "
}
return strings.TrimSuffix(s, " ")
}
// saltToString converts a NSECX salt to uppercase and
// returns "-" when it is empty
// func copied from miekg/dns because unexported
func dnsSaltToString(s string) string {
if len(s) == 0 {
return "-"
}
return strings.ToUpper(s)
}
// hexStringToString converts an hexadeciaml string to string. Bytes
// below 32 or above 126 are represented as an escaped base10 integer (\DDD).
// Back slashes and quotes are escaped. Tabs, carriage returns, and line feeds
// will be converted to \t, \r and \n respectively.
// Example:
func hexStringToString(hexString string) (string, error) {
bytes, err := hex.DecodeString(hexString)
if err != nil {
return hexString, err
}
var s []byte
for _, value := range bytes {
switch value {
default:
if value < 32 || value >= 127 {
// Unprintable characters are written as \\DDD (e.g. \\012).
s = append(s, []byte(fmt.Sprintf("\\%03d", int(value)))...)
} else {
s = append(s, value)
}
case '"', '\\':
s = append(s, '\\', value)
case '\t':
s = append(s, '\\', 't')
case '\r':
s = append(s, '\\', 'r')
case '\n':
s = append(s, '\\', 'n')
}
}
return string(s), nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。