processDNSValue reads DNS names from user supplied DNS value and transforms it into DNS names and IP addresses.
(dnsValue string)
| 825 | // processDNSValue reads DNS names from user supplied DNS value |
| 826 | // and transforms it into DNS names and IP addresses. |
| 827 | func processDNSValue(dnsValue string) ([]string, error) { |
| 828 | var ( |
| 829 | dnsValidator = ui.DNS() |
| 830 | dnsNames []string |
| 831 | ) |
| 832 | dnsValue = strings.ReplaceAll(dnsValue, " ", ",") |
| 833 | parts := strings.Split(dnsValue, ",") |
| 834 | if allEmpty(parts) { |
| 835 | return nil, stderrors.New("dns must not be empty") |
| 836 | } |
| 837 | for _, name := range parts { |
| 838 | if name == "" { // skip empty name |
| 839 | continue |
| 840 | } |
| 841 | if err := dnsValidator(name); err != nil { |
| 842 | return nil, err |
| 843 | } |
| 844 | dnsNames = append(dnsNames, normalize(strings.TrimSpace(name))) |
| 845 | } |
| 846 | return dnsNames, nil |
| 847 | } |
| 848 | |
| 849 | // normalize ensures an IPv6 hostname (i.e. [::1]) representation is |
| 850 | // converted to its IP representation (::1). |
searching dependent graphs…