Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1967 from 2opremio/fix-insure-hosts-with-ports
Browse files Browse the repository at this point in the history
Fix insecure-host-checking for repos with an explicit port
  • Loading branch information
Alfonso Acosta authored Apr 24, 2019
2 parents e73e770 + acd39bb commit 49d6279
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions registry/client_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package registry
import (
"context"
"crypto/tls"
"net"
"net/http"
"net/url"
"sync"
Expand Down Expand Up @@ -92,11 +93,21 @@ attemptChallenge:
}

func (f *RemoteClientFactory) ClientFor(repo image.CanonicalName, creds Credentials) (Client, error) {
repoHosts := []string{repo.Domain}
// allow the insecure hosts list to contain hosts with or without the port
repoHostWithoutPort, _, err := net.SplitHostPort(repo.Domain)
if err == nil {
// parsing fails if no port is present
repoHosts = append(repoHosts, repoHostWithoutPort)
}
insecure := false
insecureCheckLoop:
for _, h := range f.InsecureHosts {
if repo.Domain == h {
insecure = true
break
for _, repoHost := range repoHosts {
if h == repoHost {
insecure = true
break insecureCheckLoop
}
}
}

Expand Down

0 comments on commit 49d6279

Please sign in to comment.