MCPcopy
hub / github.com/minio/minio-go / isLoopback

Function isLoopback

pkg/credentials/iam_aws.go:449–471  ·  view source on GitHub ↗

isLoopback identifies if a uri's host is on a loopback address

(uri string)

Source from the content-addressed store, hash-verified

447
448// isLoopback identifies if a uri's host is on a loopback address
449func isLoopback(uri string) (bool, error) {
450 u, err := url.Parse(uri)
451 if err != nil {
452 return false, err
453 }
454
455 host := u.Hostname()
456 if len(host) == 0 {
457 return false, fmt.Errorf("can't parse host from uri: %s", uri)
458 }
459
460 ips, err := net.LookupHost(host)
461 if err != nil {
462 return false, err
463 }
464 for _, ip := range ips {
465 if !net.ParseIP(ip).IsLoopback() {
466 return false, nil
467 }
468 }
469
470 return true, nil
471}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected