registry: always treat 127.0.0.1 as insecure for all cases anytime anywhere

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
This commit is contained in:
Erik Hollensbe 2014-11-12 09:08:45 -08:00
parent 8582d04393
commit 524aa8b1a6
2 changed files with 19 additions and 25 deletions

View file

@ -152,19 +152,25 @@ func (e Endpoint) Ping() (RegistryInfo, error) {
// IsSecure returns false if the provided hostname is part of the list of insecure registries.
// Insecure registries accept HTTP and/or accept HTTPS with certificates from unknown CAs.
func IsSecure(hostname string, insecureRegistries []string) bool {
if hostname == IndexServerAddress() {
return true
}
host, _, err := net.SplitHostPort(hostname)
if err != nil {
host = hostname
}
if host == "127.0.0.1" || host == "localhost" {
return false
}
if len(insecureRegistries) == 0 {
host, _, err := net.SplitHostPort(hostname)
if err != nil {
host = hostname
}
if host == "127.0.0.1" || host == "localhost" {
return false
}
return true
}
for _, h := range insecureRegistries {
if hostname == h {
return false