dnet

package
v2.13.0-rc.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package dnet contains alternative net.Conn implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FreePortsTCP added in v2.12.0

func FreePortsTCP(count int) ([]*net.TCPAddr, error)

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.

func NewLoopbackListener added in v2.3.7

func NewLoopbackListener() (net.Listener, func(net.Conn) error)

NewLoopbackListener returns a net.Listener that rather than listening on a real network interface, waits for you to add new connections to it with the returned AddConn function.

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 DialerFunc added in v2.9.3

type DialerFunc func(context.Context, string) (net.Conn, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL