(ips []string, config string)
| 28 | } |
| 29 | |
| 30 | func parseStatic(ips []string, config string) (*ipdns.Static, []FutureLog) { |
| 31 | var static ipdns.Static |
| 32 | |
| 33 | firstV4, errs := applyIPTo(config, ips[0], &static) |
| 34 | if errs != nil { |
| 35 | return nil, errs |
| 36 | } |
| 37 | |
| 38 | if len(ips) == 1 { |
| 39 | return &static, nil |
| 40 | } |
| 41 | |
| 42 | secondV4, errs := applyIPTo(config, ips[1], &static) |
| 43 | if errs != nil { |
| 44 | return nil, errs |
| 45 | } |
| 46 | |
| 47 | if firstV4 == secondV4 { |
| 48 | return nil, []FutureLog{futureFatal(fmt.Sprintf("invalid %s: the ips must be of different type ipv4/ipv6", config))} |
| 49 | } |
| 50 | |
| 51 | if len(ips) > 2 { |
| 52 | return nil, []FutureLog{futureFatal(fmt.Sprintf("invalid %s: too many ips supplied", config))} |
| 53 | } |
| 54 | |
| 55 | return &static, nil |
| 56 | } |
| 57 | |
| 58 | func applyIPTo(config, ip string, static *ipdns.Static) (bool, []FutureLog) { |
| 59 | parsed := net.ParseIP(ip) |
no test coverage detected