github.com/kobeld/docker@v1.12.0-rc1/registry/service_v1.go (about)

     1  package registry
     2  
     3  import (
     4  	"net/url"
     5  
     6  	"github.com/docker/go-connections/tlsconfig"
     7  )
     8  
     9  func (s *DefaultService) lookupV1Endpoints(hostname string) (endpoints []APIEndpoint, err error) {
    10  	var cfg = tlsconfig.ServerDefault
    11  	tlsConfig := &cfg
    12  	if hostname == DefaultNamespace {
    13  		endpoints = append(endpoints, APIEndpoint{
    14  			URL:          DefaultV1Registry,
    15  			Version:      APIVersion1,
    16  			Official:     true,
    17  			TrimHostname: true,
    18  			TLSConfig:    tlsConfig,
    19  		})
    20  		return endpoints, nil
    21  	}
    22  
    23  	tlsConfig, err = s.TLSConfig(hostname)
    24  	if err != nil {
    25  		return nil, err
    26  	}
    27  
    28  	endpoints = []APIEndpoint{
    29  		{
    30  			URL: &url.URL{
    31  				Scheme: "https",
    32  				Host:   hostname,
    33  			},
    34  			Version:      APIVersion1,
    35  			TrimHostname: true,
    36  			TLSConfig:    tlsConfig,
    37  		},
    38  	}
    39  
    40  	if tlsConfig.InsecureSkipVerify {
    41  		endpoints = append(endpoints, APIEndpoint{ // or this
    42  			URL: &url.URL{
    43  				Scheme: "http",
    44  				Host:   hostname,
    45  			},
    46  			Version:      APIVersion1,
    47  			TrimHostname: true,
    48  			// used to check if supposed to be secure via InsecureSkipVerify
    49  			TLSConfig: tlsConfig,
    50  		})
    51  	}
    52  	return endpoints, nil
    53  }