MCPcopy
hub / github.com/netbirdio/netbird / Len

Method Len

dns/dns.go:76–97  ·  view source on GitHub ↗

Len returns the length of the RData field, based on its type

()

Source from the content-addressed store, hash-verified

74
75// Len returns the length of the RData field, based on its type
76func (s SimpleRecord) Len() uint16 {
77 emptyString := s.RData == ""
78 switch s.Type {
79 case int(dns.TypeA):
80 if emptyString {
81 return 0
82 }
83 return net.IPv4len
84 case int(dns.TypeCNAME):
85 if emptyString || s.RData == "." {
86 return 1
87 }
88 return uint16(len(s.RData) + 1)
89 case int(dns.TypeAAAA):
90 if emptyString {
91 return 0
92 }
93 return net.IPv6len
94 default:
95 return 0
96 }
97}
98
99var invalidHostMatcher = regexp.MustCompile(invalidHostLabel)
100

Calls

no outgoing calls