From 32d50b16095a7c1c5bc792078d29828ecc0f48b3 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Mon, 22 Aug 2022 12:51:36 +0800 Subject: [PATCH] fix: enable proxy in auth Signed-off-by: Billy Zha --- cmd/oras/internal/option/remote.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cmd/oras/internal/option/remote.go b/cmd/oras/internal/option/remote.go index 11be9579b..d15d478ee 100644 --- a/cmd/oras/internal/option/remote.go +++ b/cmd/oras/internal/option/remote.go @@ -24,6 +24,7 @@ import ( "net/http" "os" "strings" + "time" "github.com/spf13/pflag" "oras.land/oras-go/v2/registry/remote" @@ -116,8 +117,19 @@ func (opts *Remote) authClient(debug bool) (client *auth.Client, err error) { } client = &auth.Client{ Client: &http.Client{ + // default value are derived from http.DefaultTransport Transport: &http.Transport{ - TLSClientConfig: config, + Proxy: http.ProxyFromEnvironment, + DialContext: (&net.Dialer{ + Timeout: 30 * time.Second, + KeepAlive: 30 * time.Second, + }).DialContext, + ForceAttemptHTTP2: true, + MaxIdleConns: 100, + IdleConnTimeout: 90 * time.Second, + TLSHandshakeTimeout: 10 * time.Second, + ExpectContinueTimeout: 1 * time.Second, + TLSClientConfig: config, }, }, Cache: auth.NewCache(),