Documentation ¶
Overview ¶
Package dnet contains alternative net.Conn implementations.
Index ¶
- func FreePortsTCP(count int) ([]*net.TCPAddr, error)
- func NewLoopbackListener() (net.Listener, func(net.Conn) error)
- type Conn
- func AcceptFromAmbassadorCloud(systema manager.ManagerProxy_HandleConnectionServer, closeFn func()) (interceptID string, conn Conn, err error)
- func DialFromAmbassadorCloud(ctx context.Context, managerClient manager.ManagerProxyClient, ...) (Conn, error)
- func WrapAmbassadorCloudTunnelClient(impl systema.SystemAProxy_ReverseConnectionClient) Conn
- func WrapAmbassadorCloudTunnelServer(impl systema.SystemAProxy_ReverseConnectionServer, closeFn func()) Conn
- type DialerFunc
- type PortForwardDialer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FreePortsTCP ¶ added in v2.12.0
FreePortsTCP uses net.Listen repeatedly to choose free TCP ports for the localhost. It then immediately closes the listeners and returns the addresses that were allocated.
NOTE: Since the listeners are closed, there's a chance that someone else might allocate the returned addresses before they are actually used. The chances are slim though, since tests show that in most cases (at least on macOS and Linux), the same address isn't allocated for a while even if the allocation is made from different processes.
Types ¶
type Conn ¶
type Conn interface { net.Conn // Wait until either the connection is Close()d, or one of Read() or Write() encounters an // error (*not* counting errors caused by deadlines). If this returns because Close() was // called, nil is returned; otherwise the triggering error is returned. // // Essentially: Wait until the connection is finished. Wait() error }
Conn is a net.Conn, plus a Wait() method.
func AcceptFromAmbassadorCloud ¶
func AcceptFromAmbassadorCloud(systema manager.ManagerProxy_HandleConnectionServer, closeFn func()) (interceptID string, conn Conn, err error)
AcceptFromAmbassadorCloud is used by a Telepresence manger to accept a connection to an intercept for a preview URL from Ambassador Cloud.
It is the counterpart to DialFromAmbassadorCloud.
func DialFromAmbassadorCloud ¶
func DialFromAmbassadorCloud(ctx context.Context, managerClient manager.ManagerProxyClient, interceptID string, opts ...grpc.CallOption) (Conn, error)
DialFromAmbassadorCloud is used by Ambassador Cloud to dial to the manager, initiating a connection to an intercept for a preview URL.
It is the counterpart to AcceptFromAmbassadorCloud.
func WrapAmbassadorCloudTunnelClient ¶ added in v2.4.8
func WrapAmbassadorCloudTunnelClient(impl systema.SystemAProxy_ReverseConnectionClient) Conn
WrapAmbassadorCloudTunnelClient takes a systema.SystemAProxy_ReverseConnectionClient and wraps it so that it can be used as a net.Conn.
It is important to call `.Close()` when you are done with the connection, in order to release resources associated with it. The GC will not be able to collect it if you do not call `.Close()`.
func WrapAmbassadorCloudTunnelServer ¶ added in v2.4.8
func WrapAmbassadorCloudTunnelServer(impl systema.SystemAProxy_ReverseConnectionServer, closeFn func()) Conn
WrapAmbassadorCloudTunnel takes a systema.SystemAProxy_ReverseConnectionServer and wraps it so that it can be used as a net.Conn.
It is important to call `.Close()` when you are done with the connection, in order to release resources associated with it. The GC will not be able to collect it if you do not call `.Close()`.
type PortForwardDialer ¶ added in v2.9.4
type PortForwardDialer interface { io.Closer Dial(ctx context.Context, addr string) (net.Conn, error) }
func NewK8sPortForwardDialer ¶
func NewK8sPortForwardDialer(logCtx context.Context, kubeConfig *rest.Config, k8sInterface kubernetes.Interface) (PortForwardDialer, error)
NewK8sPortForwardDialer returns a dialer function (matching the signature required by grpc.WithContextDialer) that dials to a port on a Kubernetes Pod, in the manor of `kubectl port-forward`. It returns the direct connection to the apiserver; it does not establish a local port being forwarded from or otherwise pump data over the connection.