mirror of
https://github.com/kubevirt/containerized-data-importer.git
synced 2025-06-03 06:30:22 +00:00

* Updated dependencies Signed-off-by: Tomasz Baranski <tbaransk@redhat.com> * Replace skopeo with containers API. This commit removes dependence on skopeo (binary) and uses containers API. By doing that we're able to opimize the use of storage (scratch) space, storage I/O and download bandwith. Signed-off-by: Tomasz Baranski <tbaransk@redhat.com> * Fixing rebase - dependencies kerfuffle. Signed-off-by: Tomasz Baranski <tbaransk@redhat.com> * Handling docker-format images as well as OCI. Signed-off-by: Tomasz Baranski <tbaransk@redhat.com> * Fix for missing code-generator module. Signed-off-by: Tomasz Baranski <tbaransk@redhat.com> * Remove regex, image file in registry images are matched by a path prefix. Signed-off-by: Tomasz Baranski <tbaransk@redhat.com> * Added nginx proxy in front of docker registry for a rate-limited access. Signed-off-by: Tomasz Baranski <tbaransk@redhat.com>
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
// Copyright 2011 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package proxy
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
|
|
"golang.org/x/net/internal/socks"
|
|
)
|
|
|
|
// SOCKS5 returns a Dialer that makes SOCKSv5 connections to the given
|
|
// address with an optional username and password.
|
|
// See RFC 1928 and RFC 1929.
|
|
func SOCKS5(network, address string, auth *Auth, forward Dialer) (Dialer, error) {
|
|
d := socks.NewDialer(network, address)
|
|
if forward != nil {
|
|
if f, ok := forward.(ContextDialer); ok {
|
|
d.ProxyDial = func(ctx context.Context, network string, address string) (net.Conn, error) {
|
|
return f.DialContext(ctx, network, address)
|
|
}
|
|
} else {
|
|
d.ProxyDial = func(ctx context.Context, network string, address string) (net.Conn, error) {
|
|
return dialContext(ctx, forward, network, address)
|
|
}
|
|
}
|
|
}
|
|
if auth != nil {
|
|
up := socks.UsernamePassword{
|
|
Username: auth.User,
|
|
Password: auth.Password,
|
|
}
|
|
d.AuthMethods = []socks.AuthMethod{
|
|
socks.AuthMethodNotRequired,
|
|
socks.AuthMethodUsernamePassword,
|
|
}
|
|
d.Authenticate = up.Authenticate
|
|
}
|
|
return d, nil
|
|
}
|