service_v1.go 1.1 KB

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