Len returns the length of the RData field, based on its type
()
| 74 | |
| 75 | // Len returns the length of the RData field, based on its type |
| 76 | func (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 | |
| 99 | var invalidHostMatcher = regexp.MustCompile(invalidHostLabel) |
| 100 |
no outgoing calls