MCPcopy Index your code
hub / github.com/screego/server / parseStatic

Function parseStatic

config/ip.go:30–56  ·  view source on GitHub ↗
(ips []string, config string)

Source from the content-addressed store, hash-verified

28}
29
30func 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
58func applyIPTo(config, ip string, static *ipdns.Static) (bool, []FutureLog) {
59 parsed := net.ParseIP(ip)

Callers 1

parseIPProviderFunction · 0.85

Calls 2

applyIPToFunction · 0.85
futureFatalFunction · 0.85

Tested by

no test coverage detected