mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
Goal of this commit is to add some missing features when the Kubernetes API is accessed through a SOCKS5 proxy. That's for example the case when port-forwarding is used (`kubectl port-forward`) or when exec'ing inside a container (`kubectl exec`), with this commit it'll now be possible to use both. Signed-off-by: Romain Aviolat <romain.aviolat@kudelskisecurity.com> Signed-off-by: Romain Jufer <romain.jufer@kudelskisecurity.com>
24 lines
530 B
Go
24 lines
530 B
Go
package socks5
|
|
|
|
import (
|
|
"net"
|
|
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
// NameResolver is used to implement custom name resolution
|
|
type NameResolver interface {
|
|
Resolve(ctx context.Context, name string) (context.Context, net.IP, error)
|
|
}
|
|
|
|
// DNSResolver uses the system DNS to resolve host names
|
|
type DNSResolver struct{}
|
|
|
|
func (d DNSResolver) Resolve(ctx context.Context, name string) (context.Context, net.IP, error) {
|
|
addr, err := net.ResolveIPAddr("ip", name)
|
|
if err != nil {
|
|
return ctx, nil, err
|
|
}
|
|
return ctx, addr.IP, err
|
|
}
|