Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RandomLocalPort ¶
func RandomLocalPort() string
func RestoreSavedForwards ¶ added in v0.1.56
func RestoreSavedForwards( ctx context.Context, client *api.Client, playID string, out labcli.Outputer, ) (<-chan error, error)
RestoreSavedForwards starts port forwarding for all saved port forwards in the background. It returns a channel that will receive the result (nil on success, error on failure). The caller can choose to wait on the channel or let it run in the background.
Types ¶
type ForwardingSpec ¶
type ForwardingSpec struct {
Kind string // "local" or "remote"
LocalHost string // Defaults to "127.0.0.1" if not specified
LocalPort string // Empty if a random port is to be used
RemoteHost string // Defaults to ""
RemotePort string // Required, no default
}
func ParseLocal ¶
func ParseLocal(s string) (ForwardingSpec, error)
func ParseRemote ¶ added in v0.1.69
func ParseRemote(s string) (ForwardingSpec, error)
ParseRemote parses a -R port forwarding spec, following SSH-like semantics where the BIND address (on the playground) comes first and the TARGET address (on the labctl side) comes second. Accepted forms:
REMOTE_PORT:LOCAL_PORT # bind 0.0.0.0:REMOTE_PORT on playground,
# dial 127.0.0.1:LOCAL_PORT on labctl
REMOTE_PORT:LOCAL_HOST:LOCAL_PORT # same, but dial LOCAL_HOST:LOCAL_PORT
REMOTE_HOST:REMOTE_PORT:LOCAL_PORT # bind REMOTE_HOST:REMOTE_PORT
REMOTE_HOST:REMOTE_PORT:LOCAL_HOST:LOCAL_PORT # most explicit form
func PortForwardToSpec ¶ added in v0.1.56
func PortForwardToSpec(pf *api.PortForward) ForwardingSpec
PortForwardToSpec converts an API PortForward to a ForwardingSpec.
func (ForwardingSpec) LocalAddr ¶
func (f ForwardingSpec) LocalAddr() string
func (ForwardingSpec) RemoteAddr ¶
func (f ForwardingSpec) RemoteAddr() string
func (ForwardingSpec) ToPortForward ¶ added in v0.1.56
func (f ForwardingSpec) ToPortForward(machine string) (*api.PortForward, error)
type Tunnel ¶
type Tunnel struct {
// contains filtered or unexported fields
}
func StartTunnel ¶
func (*Tunnel) StartForwarding ¶ added in v0.1.62
func (t *Tunnel) StartForwarding(ctx context.Context, spec ForwardingSpec) <-chan error
StartForwarding starts port forwarding in the background and logs transient errors. It returns a channel that receives the final result (nil or error) when the forwarding stops.