package toolbox

import "github.com/vmware/govmomi/toolbox"

Index

Variables

var (
	ErrNotVirtualWorld = errors.New("not in a virtual world")
)
var (
	Trace = false
)

Functions

func DecodeXDR

func DecodeXDR(buf []byte, val interface{}) error

func DefaultIP

func DefaultIP() string

DefaultIP is used by default when responding to a Set_Option broadcastIP request It can be overridden with the Service.PrimaryIP field

func DefaultStartCommand

func DefaultStartCommand(m *process.Manager, r *vix.StartProgramRequest) (int64, error)

func EncodeXDR

func EncodeXDR(val interface{}) ([]byte, error)

func GuestInfoCommand

func GuestInfoCommand(kind int, req []byte) []byte

func GuestInfoNicInfoRequest

func GuestInfoNicInfoRequest() ([]byte, error)

func Halt

func Halt() error

func Reboot

func Reboot() error

Types

type Channel

type Channel interface {
	Start() error
	Stop() error
	Send([]byte) error
	Receive() ([]byte, error)
}

Channel abstracts the guest<->vmx RPC transport

func NewBackdoorChannelIn

func NewBackdoorChannelIn() Channel

NewBackdoorChannelIn creates a Channel for use with the TCLO protocol

func NewBackdoorChannelOut

func NewBackdoorChannelOut() Channel

NewBackdoorChannelOut creates a Channel for use with the RPCI protocol

func NewTraceChannel

func NewTraceChannel(c Channel) Channel

type ChannelOut

type ChannelOut struct {
	Channel
}

ChannelOut extends Channel to provide RPCI protocol helpers

func (*ChannelOut) Request

func (c *ChannelOut) Request(request []byte) ([]byte, error)

Request sends an RPC command to the vmx and checks the return code for success or error

type CommandHandler

type CommandHandler func(vix.CommandRequestHeader, []byte) ([]byte, error)

type CommandServer

type CommandServer struct {
	Out *ChannelOut

	ProcessManager *process.Manager

	Authenticate func(vix.CommandRequestHeader, []byte) error

	ProcessStartCommand func(*process.Manager, *vix.StartProgramRequest) (int64, error)

	FileServer *hgfs.Server
	// contains filtered or unexported fields
}

func (*CommandServer) CreateDirectory

func (c *CommandServer) CreateDirectory(header vix.CommandRequestHeader, data []byte) ([]byte, error)

func (*CommandServer) CreateTemporaryDirectory

func (c *CommandServer) CreateTemporaryDirectory(header vix.CommandRequestHeader, data []byte) ([]byte, error)

func (*CommandServer) CreateTemporaryFile

func (c *CommandServer) CreateTemporaryFile(header vix.CommandRequestHeader, data []byte) ([]byte, error)

func (*CommandServer) DeleteDirectory

func (c *CommandServer) DeleteDirectory(header vix.CommandRequestHeader, data []byte) ([]byte, error)

func (*CommandServer) DeleteFile

func (c *CommandServer) DeleteFile(header vix.CommandRequestHeader, data []byte) ([]byte, error)

func (*CommandServer) Dispatch

func (c *CommandServer) Dispatch(data []byte) ([]byte, error)

func (*CommandServer) GetToolsState

func (c *CommandServer) GetToolsState(_ vix.CommandRequestHeader, _ []byte) ([]byte, error)

func (*CommandServer) InitiateFileTransferFromGuest

func (c *CommandServer) InitiateFileTransferFromGuest(header vix.CommandRequestHeader, data []byte) ([]byte, error)

func (*CommandServer) InitiateFileTransferToGuest

func (c *CommandServer) InitiateFileTransferToGuest(header vix.CommandRequestHeader, data []byte) ([]byte, error)

func (*CommandServer) KillProcess

func (c *CommandServer) KillProcess(header vix.CommandRequestHeader, data []byte) ([]byte, error)

func (*CommandServer) ListFiles

func (c *CommandServer) ListFiles(header vix.CommandRequestHeader, data []byte) ([]byte, error)

func (*CommandServer) ListProcesses

func (c *CommandServer) ListProcesses(header vix.CommandRequestHeader, data []byte) ([]byte, error)

func (*CommandServer) MoveDirectory

func (c *CommandServer) MoveDirectory(header vix.CommandRequestHeader, data []byte) ([]byte, error)

func (*CommandServer) MoveFile

func (c *CommandServer) MoveFile(header vix.CommandRequestHeader, data []byte) ([]byte, error)

func (*CommandServer) ProcessHgfsPacket

func (c *CommandServer) ProcessHgfsPacket(header vix.CommandRequestHeader, data []byte) ([]byte, error)

func (*CommandServer) ReadEnvironmentVariables

func (c *CommandServer) ReadEnvironmentVariables(header vix.CommandRequestHeader, data []byte) ([]byte, error)

func (*CommandServer) RegisterHandler

func (c *CommandServer) RegisterHandler(op uint32, handler CommandHandler)

func (*CommandServer) SetGuestFileAttributes

func (c *CommandServer) SetGuestFileAttributes(header vix.CommandRequestHeader, data []byte) ([]byte, error)

func (*CommandServer) StartCommand

func (c *CommandServer) StartCommand(header vix.CommandRequestHeader, data []byte) ([]byte, error)

type DNSConfigInfo

type DNSConfigInfo struct {
	HostName   *string `xdr:"optional"`
	DomainName *string `xdr:"optional"`
	Servers    []TypedIPAddress
	Search     *string `xdr:"optional"`
}

type DhcpConfigInfo

type DhcpConfigInfo struct {
	Enabled  bool
	Settings string
}

type GuestNicInfo

type GuestNicInfo struct {
	Version int32
	V3      *NicInfoV3 `xdr:"optional"`
}

func DefaultGuestNicInfo

func DefaultGuestNicInfo() *GuestNicInfo

func NewGuestNicInfo

func NewGuestNicInfo() *GuestNicInfo

type GuestNicV3

type GuestNicV3 struct {
	MacAddress       string
	IPs              []IPAddressEntry
	DNSConfigInfo    *DNSConfigInfo  `xdr:"optional"`
	WinsConfigInfo   *WinsConfigInfo `xdr:"optional"`
	DhcpConfigInfov4 *DhcpConfigInfo `xdr:"optional"`
	DhcpConfigInfov6 *DhcpConfigInfo `xdr:"optional"`
}

func (*GuestNicV3) AddIP

func (nic *GuestNicV3) AddIP(addr net.Addr)

type Handler

type Handler func([]byte) ([]byte, error)

Handler is given the raw argument portion of an RPC request and returns a response

type IPAddressEntry

type IPAddressEntry struct {
	Address      TypedIPAddress
	PrefixLength uint32
	Origin       *int32 `xdr:"optional"`
	Status       *int32 `xdr:"optional"`
}

type InetCidrRouteEntry

type InetCidrRouteEntry struct {
	Dest         TypedIPAddress
	PrefixLength uint32
	NextHop      *TypedIPAddress `xdr:"optional"`
	IfIndex      uint32
	Type         int32
	Metric       uint32
}

type NicInfoV3

type NicInfoV3 struct {
	Nics             []GuestNicV3
	Routes           []InetCidrRouteEntry
	DNSConfigInfo    *DNSConfigInfo  `xdr:"optional"`
	WinsConfigInfo   *WinsConfigInfo `xdr:"optional"`
	DhcpConfigInfov4 *DhcpConfigInfo `xdr:"optional"`
	DhcpConfigInfov6 *DhcpConfigInfo `xdr:"optional"`
}

type PowerCommand

type PowerCommand struct {
	Handler func() error
	// contains filtered or unexported fields
}

func (*PowerCommand) Dispatch

func (c *PowerCommand) Dispatch([]byte) ([]byte, error)

type PowerCommandHandler

type PowerCommandHandler struct {
	Halt    PowerCommand
	Reboot  PowerCommand
	PowerOn PowerCommand
	Resume  PowerCommand
	Suspend PowerCommand
}

type Service

type Service struct {
	Command *CommandServer
	Power   *PowerCommandHandler

	PrimaryIP func() string
	// contains filtered or unexported fields
}

Service receives and dispatches incoming RPC requests from the vmx

func NewService

func NewService(rpcIn Channel, rpcOut Channel) *Service

NewService initializes a Service instance

func (*Service) CapabilitiesRegister

func (s *Service) CapabilitiesRegister([]byte) ([]byte, error)

func (*Service) Dispatch

func (s *Service) Dispatch(request []byte) []byte

Dispatch an incoming RPC request to a Handler

func (*Service) Ping

func (s *Service) Ping([]byte) ([]byte, error)

Ping is the default Handler for ping requests

func (*Service) RegisterHandler

func (s *Service) RegisterHandler(name string, handler Handler)

RegisterHandler for the given RPC name

func (*Service) Reset

func (s *Service) Reset([]byte) ([]byte, error)

Reset is the default Handler for reset requests

func (*Service) SendGuestInfo

func (s *Service) SendGuestInfo()

func (*Service) SetOption

func (s *Service) SetOption(args []byte) ([]byte, error)

SetOption is the default Handler for Set_Option requests

func (*Service) Start

func (s *Service) Start() error

Start initializes the RPC channels and starts a goroutine to listen for incoming RPC requests

func (*Service) Stop

func (s *Service) Stop()

Stop cancels the RPC listener routine created via Start

func (*Service) Wait

func (s *Service) Wait()

Wait blocks until Start returns, allowing any current RPC in progress to complete.

type TraceChannel

type TraceChannel struct {
	Channel
	// contains filtered or unexported fields
}

func (*TraceChannel) Receive

func (d *TraceChannel) Receive() ([]byte, error)

func (*TraceChannel) Send

func (d *TraceChannel) Send(buf []byte) error

func (*TraceChannel) Start

func (d *TraceChannel) Start() error

func (*TraceChannel) Stop

func (d *TraceChannel) Stop() error

type TypedIPAddress

type TypedIPAddress struct {
	Type    int32
	Address []byte
}

type WinsConfigInfo

type WinsConfigInfo struct {
	Primary   TypedIPAddress
	Secondary TypedIPAddress
}

Source Files

backdoor.go channel.go command.go guest_info.go power.go service.go toolbox_linux.go trace_channel.go

Directories

PathSynopsis
toolbox/hgfs
toolbox/process
toolbox/toolbox
toolbox/vix
Version
v0.48.1 (latest)
Published
Feb 11, 2025
Platform
linux/amd64
Imports
24 packages
Last checked
2 months ago

Tools for package owners.