Merge pull request #6303 from crosbymichael/bump_v1.0.0
Bump version to v1.0.0
This commit is contained in:
commit
80199dceb9
@ -766,7 +766,7 @@ func trustedLocation(req *http.Request) bool {
|
||||
}
|
||||
|
||||
for _, trusted := range trusteds {
|
||||
if strings.HasSuffix(hostname, trusted) {
|
||||
if hostname == trusted || strings.HasSuffix(hostname, "."+trusted) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -790,8 +790,13 @@ func AddRequiredHeadersToRedirectedRequests(req *http.Request, via []*http.Reque
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewRegistry(authConfig *AuthConfig, factory *utils.HTTPRequestFactory, indexEndpoint string) (r *Registry, err error) {
|
||||
httpDial := func(proto string, addr string) (net.Conn, error) {
|
||||
func NewRegistry(authConfig *AuthConfig, factory *utils.HTTPRequestFactory, indexEndpoint string, timeout bool) (r *Registry, err error) {
|
||||
httpTransport := &http.Transport{
|
||||
DisableKeepAlives: true,
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
}
|
||||
if timeout {
|
||||
httpTransport.Dial = func(proto string, addr string) (net.Conn, error) {
|
||||
conn, err := net.Dial(proto, addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -799,13 +804,7 @@ func NewRegistry(authConfig *AuthConfig, factory *utils.HTTPRequestFactory, inde
|
||||
conn = utils.NewTimeoutConn(conn, time.Duration(1)*time.Minute)
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
httpTransport := &http.Transport{
|
||||
Dial: httpDial,
|
||||
DisableKeepAlives: true,
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
}
|
||||
|
||||
r = &Registry{
|
||||
authConfig: authConfig,
|
||||
client: &http.Client{
|
||||
|
@ -18,7 +18,7 @@ var (
|
||||
|
||||
func spawnTestRegistry(t *testing.T) *Registry {
|
||||
authConfig := &AuthConfig{}
|
||||
r, err := NewRegistry(authConfig, utils.NewHTTPRequestFactory(), makeURL("/v1/"))
|
||||
r, err := NewRegistry(authConfig, utils.NewHTTPRequestFactory(), makeURL("/v1/"), true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -235,7 +235,7 @@ func TestValidRepositoryName(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTrustedLocation(t *testing.T) {
|
||||
for _, url := range []string{"http://example.com", "https://example.com:7777", "http://docker.io", "http://test.docker.io"} {
|
||||
for _, url := range []string{"http://example.com", "https://example.com:7777", "http://docker.io", "http://test.docker.io", "https://fakedocker.com"} {
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
if trustedLocation(req) == true {
|
||||
t.Fatalf("'%s' shouldn't be detected as a trusted location", url)
|
||||
|
@ -82,7 +82,7 @@ func (s *Service) Search(job *engine.Job) engine.Status {
|
||||
job.GetenvJson("authConfig", authConfig)
|
||||
job.GetenvJson("metaHeaders", metaHeaders)
|
||||
|
||||
r, err := NewRegistry(authConfig, HTTPRequestFactory(metaHeaders), IndexServerAddress())
|
||||
r, err := NewRegistry(authConfig, HTTPRequestFactory(metaHeaders), IndexServerAddress(), true)
|
||||
if err != nil {
|
||||
return job.Error(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user