wsl

package
v0.9.2-beta.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Status_Init         = "init"
	Status_Connecting   = "connecting"
	Status_Connected    = "connected"
	Status_Disconnected = "disconnected"
	Status_Error        = "error"
)
View Source
const DefaultConnectionTimeout = 60 * time.Second

Variables

This section is empty.

Functions

func CpHostToRemote

func CpHostToRemote(ctx context.Context, client *Distro, sourcePath string, destPath string) error

func DetectShell

func DetectShell(ctx context.Context, client *Distro) (string, error)

func DisconnectClient

func DisconnectClient(connName string) error

func EnsureConnection

func EnsureConnection(ctx context.Context, connName string) error

Convenience function for ensuring a connection is established

func GetAllConnStatus

func GetAllConnStatus() []wshrpc.ConnStatus

func GetClientArch

func GetClientArch(ctx context.Context, client *Distro) (string, error)

func GetClientOs

func GetClientOs(ctx context.Context, client *Distro) (string, error)

func GetHomeDir

func GetHomeDir(ctx context.Context, client *Distro) string

func GetWshPath

func GetWshPath(ctx context.Context, client *Distro) string

func GetWshVersion

func GetWshVersion(ctx context.Context, client *Distro) (string, error)

func InstallClientRcFiles

func InstallClientRcFiles(ctx context.Context, client *Distro) error

func IsPowershell

func IsPowershell(shellPath string) bool

Types

type CancellableCmd

type CancellableCmd struct {
	Cmd    *WslCmd
	Cancel func()
}

type Distro

type Distro struct{}

func DefaultDistro

func DefaultDistro(ctx context.Context) (d Distro, ok bool, err error)

func GetDistro

func GetDistro(ctx context.Context, wslDistroName WslName) (*Distro, error)

func RegisteredDistros

func RegisteredDistros(ctx context.Context) (distros []Distro, err error)

func (*Distro) Name

func (d *Distro) Name() string

func (*Distro) WslCommand

func (d *Distro) WslCommand(ctx context.Context, cmd string) *WslCmd

type WshInstallOpts

type WshInstallOpts struct {
	Force        bool
	NoUserPrompt bool
}

type WslCmd

type WslCmd struct {
	exec.Cmd
}

just use the regular cmd since it's similar enough to not cause issues type WslCmd = exec.Cmd

func GetDistroCmd

func GetDistroCmd(ctx context.Context, wslDistroName string, cmd string) (*WslCmd, error)

func (*WslCmd) GetProcess

func (wc *WslCmd) GetProcess() *os.Process

func (*WslCmd) GetProcessState

func (wc *WslCmd) GetProcessState() *os.ProcessState

func (*WslCmd) SetStderr

func (c *WslCmd) SetStderr(stderr io.Writer)

func (*WslCmd) SetStdin

func (c *WslCmd) SetStdin(stdin io.Reader)

func (*WslCmd) SetStdout

func (c *WslCmd) SetStdout(stdout io.Writer)

type WslConn

type WslConn struct {
	Lock               *sync.Mutex
	Status             string
	Name               WslName
	Client             *Distro
	SockName           string
	DomainSockListener net.Listener
	ConnController     *WslCmd
	Error              string
	HasWaiter          *atomic.Bool
	LastConnectTime    int64
	ActiveConnNum      int
	Context            context.Context
	// contains filtered or unexported fields
}

func GetWslConn

func GetWslConn(ctx context.Context, name string, shouldConnect bool) *WslConn

func (*WslConn) CheckAndInstallWsh

func (conn *WslConn) CheckAndInstallWsh(ctx context.Context, clientDisplayName string, opts *WshInstallOpts) error

func (*WslConn) Close

func (conn *WslConn) Close() error

func (*WslConn) Connect

func (conn *WslConn) Connect(ctx context.Context) error

does not return an error since that error is stored inside of WslConn

func (*WslConn) DeriveConnStatus

func (conn *WslConn) DeriveConnStatus() wshrpc.ConnStatus

func (*WslConn) FireConnChangeEvent

func (conn *WslConn) FireConnChangeEvent()

func (*WslConn) GetClient

func (conn *WslConn) GetClient() *Distro

func (*WslConn) GetDomainSocketName

func (conn *WslConn) GetDomainSocketName() string

func (*WslConn) GetName

func (conn *WslConn) GetName() string

func (*WslConn) GetStatus

func (conn *WslConn) GetStatus() string

func (*WslConn) OpenDomainSocketListener

func (conn *WslConn) OpenDomainSocketListener() error

*

  • This function is does not set a listener for WslConn
  • It is still required in order to set SockName

*

func (*WslConn) Reconnect

func (conn *WslConn) Reconnect(ctx context.Context) error

func (*WslConn) StartConnServer

func (conn *WslConn) StartConnServer() error

func (*WslConn) WaitForConnect

func (conn *WslConn) WaitForConnect(ctx context.Context) error

func (*WslConn) WithLock

func (conn *WslConn) WithLock(fn func())

type WslName

type WslName struct {
	Distro string `json:"distro"`
}

Jump to

Keyboard shortcuts

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