MCPcopy Create free account
hub / github.com/CPChain/chain / resolveDomain

Function resolveDomain

configs/general.go:262–277  ·  view source on GitHub ↗
(hostname string)

Source from the content-addressed store, hash-verified

260}
261
262func resolveDomain(hostname string) (string, error) {
263 ipAddress := net.ParseIP(hostname)
264 log.Debug("parse ip", "hostname", hostname, "ipAddress", ipAddress)
265 if ipAddress != nil {
266 return ipAddress.String(), nil
267 }
268 addr, err := net.LookupHost(hostname)
269 if err != nil {
270 log.Error("lookup host error", "hostname", hostname, "err", err)
271 return "", err
272 }
273 if len(addr) > 0 {
274 return addr[0], nil
275 }
276 return "", fmt.Errorf("invalid host: %v", err)
277}
278
279func ResolveUrl(url string) (string, error) {
280 host, port, err := net.SplitHostPort(url[7:])

Callers 4

convertDomainNodeFunction · 0.85
ResolveUrlFunction · 0.85
TestResolveDomainFunction · 0.85
TestResolveDomain1Function · 0.85

Calls 3

DebugMethod · 0.80
ErrorMethod · 0.65
StringMethod · 0.45

Tested by 2

TestResolveDomainFunction · 0.68
TestResolveDomain1Function · 0.68