1.Change base.Dial to base.DailContext.
2.Remove proxyDialer that was previously used to configure a
net.Dialer to route proxy.Dialer which will route the connections
through the proxy using the connections through a SOCKS proxy.
SOCKS proxies are now supported by configuring only http.Transport.Proxy,
and no longer require changing http.Transport.Dial.
Signed-off-by: HuanHuan Ye <logindaveye@gmail.com>
| ... | ... |
@@ -16,7 +16,6 @@ import ( |
| 16 | 16 |
"github.com/docker/docker/api/types" |
| 17 | 17 |
"github.com/docker/docker/dockerversion" |
| 18 | 18 |
"github.com/docker/docker/registry" |
| 19 |
- "github.com/docker/go-connections/sockets" |
|
| 20 | 19 |
ocispec "github.com/opencontainers/image-spec/specs-go/v1" |
| 21 | 20 |
) |
| 22 | 21 |
|
| ... | ... |
@@ -56,7 +55,10 @@ func init() {
|
| 56 | 56 |
// NewV2Repository returns a repository (v2 only). It creates an HTTP transport |
| 57 | 57 |
// providing timeout settings and authentication support, and also verifies the |
| 58 | 58 |
// remote API version. |
| 59 |
-func NewV2Repository(ctx context.Context, repoInfo *registry.RepositoryInfo, endpoint registry.APIEndpoint, metaHeaders http.Header, authConfig *types.AuthConfig, actions ...string) (repo distribution.Repository, foundVersion bool, err error) {
|
|
| 59 |
+func NewV2Repository( |
|
| 60 |
+ ctx context.Context, repoInfo *registry.RepositoryInfo, endpoint registry.APIEndpoint, |
|
| 61 |
+ metaHeaders http.Header, authConfig *types.AuthConfig, actions ...string, |
|
| 62 |
+) (repo distribution.Repository, foundVersion bool, err error) {
|
|
| 60 | 63 |
repoName := repoInfo.Name.Name() |
| 61 | 64 |
// If endpoint does not support CanonicalName, use the RemoteName instead |
| 62 | 65 |
if endpoint.TrimHostname {
|
| ... | ... |
@@ -72,18 +74,13 @@ func NewV2Repository(ctx context.Context, repoInfo *registry.RepositoryInfo, end |
| 72 | 72 |
// TODO(dmcgowan): Call close idle connections when complete, use keep alive |
| 73 | 73 |
base := &http.Transport{
|
| 74 | 74 |
Proxy: http.ProxyFromEnvironment, |
| 75 |
- Dial: direct.Dial, |
|
| 75 |
+ DialContext: direct.DialContext, |
|
| 76 | 76 |
TLSHandshakeTimeout: 10 * time.Second, |
| 77 | 77 |
TLSClientConfig: endpoint.TLSConfig, |
| 78 | 78 |
// TODO(dmcgowan): Call close idle connections when complete and use keep alive |
| 79 | 79 |
DisableKeepAlives: true, |
| 80 | 80 |
} |
| 81 | 81 |
|
| 82 |
- proxyDialer, err := sockets.DialerFromEnvironment(direct) |
|
| 83 |
- if err == nil {
|
|
| 84 |
- base.Dial = proxyDialer.Dial |
|
| 85 |
- } |
|
| 86 |
- |
|
| 87 | 82 |
modifiers := registry.Headers(dockerversion.DockerUserAgent(ctx), metaHeaders) |
| 88 | 83 |
authTransport := transport.NewTransport(base, modifiers...) |
| 89 | 84 |
|
| ... | ... |
@@ -46,10 +46,6 @@ issues: |
| 46 | 46 |
- text: "G202: SQL string concatenation" |
| 47 | 47 |
linters: |
| 48 | 48 |
- gosec |
| 49 |
- # FIXME temporarily suppress these. See #39925 |
|
| 50 |
- - text: "SA1019: base.Dial is deprecated" |
|
| 51 |
- linters: |
|
| 52 |
- - staticcheck |
|
| 53 | 49 |
# FIXME temporarily suppress these. See #39928 |
| 54 | 50 |
- text: "SA1019: grpc.WithDialer is deprecated" |
| 55 | 51 |
linters: |
| ... | ... |
@@ -14,7 +14,6 @@ import ( |
| 14 | 14 |
"time" |
| 15 | 15 |
|
| 16 | 16 |
"github.com/docker/distribution/registry/client/transport" |
| 17 |
- "github.com/docker/go-connections/sockets" |
|
| 18 | 17 |
"github.com/docker/go-connections/tlsconfig" |
| 19 | 18 |
"github.com/sirupsen/logrus" |
| 20 | 19 |
) |
| ... | ... |
@@ -176,16 +175,12 @@ func NewTransport(tlsConfig *tls.Config) *http.Transport {
|
| 176 | 176 |
|
| 177 | 177 |
base := &http.Transport{
|
| 178 | 178 |
Proxy: http.ProxyFromEnvironment, |
| 179 |
- Dial: direct.Dial, |
|
| 179 |
+ DialContext: direct.DialContext, |
|
| 180 | 180 |
TLSHandshakeTimeout: 10 * time.Second, |
| 181 | 181 |
TLSClientConfig: tlsConfig, |
| 182 | 182 |
// TODO(dmcgowan): Call close idle connections when complete and use keep alive |
| 183 | 183 |
DisableKeepAlives: true, |
| 184 | 184 |
} |
| 185 | 185 |
|
| 186 |
- proxyDialer, err := sockets.DialerFromEnvironment(direct) |
|
| 187 |
- if err == nil {
|
|
| 188 |
- base.Dial = proxyDialer.Dial |
|
| 189 |
- } |
|
| 190 | 186 |
return base |
| 191 | 187 |
} |