portforwarder

package
v2.49.2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InternalPortTag      = "InternalPort"
	UserForwardedPortTag = "UserForwardedPort"
)
View Source
const (
	PrivatePortVisibility = "private"
	OrgPortVisibility     = "org"
	PublicPortVisibility  = "public"
)

Variables

This section is empty.

Functions

func AccessControlEntriesToVisibility

func AccessControlEntriesToVisibility(accessControlEntries []tunnels.TunnelAccessControlEntry) string

AccessControlEntriesToVisibility converts the access control entries used by Dev Tunnels to a friendly visibility value.

func IsInternalPort

func IsInternalPort(port *tunnels.TunnelPort) bool

IsInternalPort returns true if the port is internal.

Types

type CodespacesPortForwarder added in v2.37.0

type CodespacesPortForwarder struct {
	// contains filtered or unexported fields
}

func (*CodespacesPortForwarder) Close added in v2.39.0

func (fwd *CodespacesPortForwarder) Close() error

Close closes the port forwarder's tunnel client connection.

func (*CodespacesPortForwarder) ConnectToForwardedPort added in v2.37.0

func (fwd *CodespacesPortForwarder) ConnectToForwardedPort(ctx context.Context, conn io.ReadWriteCloser, opts ForwardPortOpts) error

ConnectToForwardedPort connects to the forwarded port via a given ReadWriteCloser. Optionally, it detects traffic over the connection and sends activity signals to the server to keep the codespace from shutting down.

func (*CodespacesPortForwarder) ForwardPort added in v2.37.0

func (fwd *CodespacesPortForwarder) ForwardPort(ctx context.Context, opts ForwardPortOpts) error

ForwardPort informs the host that we would like to forward the given port.

func (*CodespacesPortForwarder) ForwardPortToListener added in v2.37.0

func (fwd *CodespacesPortForwarder) ForwardPortToListener(ctx context.Context, opts ForwardPortOpts, listener *net.TCPListener) error

ForwardPortToListener forwards the specified port to the given TCP listener.

func (*CodespacesPortForwarder) GetKeepAliveReason added in v2.37.0

func (fwd *CodespacesPortForwarder) GetKeepAliveReason() string

GetKeepAliveReason fetches the keep alive reason from the channel and returns it.

func (*CodespacesPortForwarder) KeepAlive added in v2.37.0

func (fwd *CodespacesPortForwarder) KeepAlive(reason string)

KeepAlive accepts a reason that is retained if there is no active reason to send to the server.

func (*CodespacesPortForwarder) ListPorts added in v2.37.0

func (fwd *CodespacesPortForwarder) ListPorts(ctx context.Context) (ports []*tunnels.TunnelPort, err error)

ListPorts fetches the list of ports that are currently forwarded.

func (*CodespacesPortForwarder) UpdatePortVisibility added in v2.37.0

func (fwd *CodespacesPortForwarder) UpdatePortVisibility(ctx context.Context, remotePort int, visibility string) error

UpdatePortVisibility changes the visibility (private, org, public) of the specified port.

type ForwardPortOpts added in v2.37.0

type ForwardPortOpts struct {
	Port       int
	Internal   bool
	KeepAlive  bool
	Visibility string
}

type PortForwarder

type PortForwarder interface {
	ForwardPortToListener(ctx context.Context, opts ForwardPortOpts, listener *net.TCPListener) error
	ForwardPort(ctx context.Context, opts ForwardPortOpts) error
	ConnectToForwardedPort(ctx context.Context, conn io.ReadWriteCloser, opts ForwardPortOpts) error
	ListPorts(ctx context.Context) ([]*tunnels.TunnelPort, error)
	UpdatePortVisibility(ctx context.Context, remotePort int, visibility string) error
	KeepAlive(reason string)
	GetKeepAliveReason() string
	Close() error
}

func NewPortForwarder

func NewPortForwarder(ctx context.Context, codespaceConnection *connection.CodespaceConnection) (fwd PortForwarder, err error)

NewPortForwarder returns a new PortForwarder for the specified codespace.

Jump to

Keyboard shortcuts

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