Documentation ¶
Index ¶
- Constants
- func SendFile(dir, fpath string, ID int, chunkSize int64, send func(m *Message) error) error
- func Trunk(remote io.ReadCloser, uuid string, fn func(*Message) error)
- type Client
- type Command
- type ConnTest
- type File
- type Filter
- type Message
- type Process
- type Response
- type Server
- func (s *Server) ClearCommands()
- func (s *Server) ClearResponses() error
- func (s *Server) Clients() int
- func (s *Server) CloseUnix(path string) error
- func (s *Server) DeleteCommand(id int) error
- func (s *Server) DeleteCommands(prefix string) error
- func (s *Server) DeleteResponse(id int) error
- func (s *Server) DeleteResponses(prefix string) error
- func (s *Server) Destroy()
- func (s *Server) DialSerial(path, uuid string) error
- func (s *Server) DisconnectUFS(uuid string) error
- func (s *Server) Forward(uuid string, source int, host string, dest int) error
- func (s *Server) GetClients() map[string]*Client
- func (s *Server) GetCommand(id int) *Command
- func (s *Server) GetCommands() map[int]*Command
- func (s *Server) GetProcesses(uuid string) ([]*Process, error)
- func (s *Server) GetResponse(id int, raw bool) (string, error)
- func (s *Server) GetResponses(raw bool) (string, error)
- func (s *Server) HasClient(c string) bool
- func (s *Server) Listen(port int) error
- func (s *Server) ListenUFS(uuid string) (int, error)
- func (s *Server) ListenUnix(path string) error
- func (s *Server) NewCommand(c *Command) int
- func (s *Server) NewFilesSendCommand(files []string) (*Command, error)
- func (s *Server) RegisterVM(vm VM)
- func (s *Server) Reverse(filter *Filter, source int, host string, dest int) error
- func (s *Server) UnregisterVM(vm VM)
- type Type
- type VM
Constants ¶
const ( PIPE_NEW_READER = iota PIPE_NEW_WRITER PIPE_CLOSE_READER PIPE_CLOSE_WRITER PIPE_DATA )
Pipe modes
const ( UFS_OPEN = iota UFS_CLOSE UFS_DATA )
UFS modes
const ( HEARTBEAT_RATE = 5 REAPER_RATE = 30 CLIENT_RECONNECT_RATE = 5 CLIENT_EXPIRED = 30 RESPONSE_PATH = "miniccc_responses" )
const (
BUFFER_SIZE = 32768
)
const PART_SIZE = 1024 * 100
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct { UUID string Arch string OS string Version string Hostname string IPs []string MACs []string // Processes that are running in the background Processes map[int]*Process // Tags set via the command socket since the last heartbeat. Also used by // the server to determine whether the client matches a given filter. Tags map[string]string // Responses for commands processed since the last heartbeat Responses []*Response // LastCommandID is the last command ID that the client processed. LastCommandID int }
type Command ¶
type Command struct { ID int // run command in the background and return immediately Background bool // The command is a slice of strings with the first element being the // command, and any other elements as the arguments Command []string // Files to transfer to the client. Any path given in a file specified // here will be rooted at <BASE>/files FilesSend []string // Files to transfer back to the master FilesRecv []string // Connectivity test to execute ConnTest *ConnTest // PID of the process to signal, -1 signals all processes PID int // KillAll kills all processes by name KillAll string // Level adjusts the minilog level Level *log.Level // Filter for clients to process commands. Not all fields in a client // must be set (wildcards), but all set fields must match for a command // to be processed. Filter *Filter // clients that have responded to this command CheckedIn []string // Prefix is an optional field that can be used to track commands. It is // not used by the server or client. Prefix string // plumber connections Stdin string Stdout string Stderr string }
type File ¶
type File struct { ID int // command that requested the file Name string // name of the file Perm os.FileMode // permissions Data []byte // data chunk Offset int64 // offset for this chunk EOF bool // final chunk in file }
File sent from server to client or client to server. The ID and name uniquely identify the transfer. Perm is only used for the first chunk. EOF signals that this is the last data chunk.
type Filter ¶
type Server ¶
type Server struct { // UseVMs controls whether ron uses VM callbacks or not (see ron.VM) UseVMs bool // contains filtered or unexported fields }
func NewServer ¶
func NewServer(path, subpath string, plumber *miniplumber.Plumber) (*Server, error)
NewServer creates a ron server. Must call Listen* to actually allow ron to start accepting connections from clients.
func (*Server) ClearCommands ¶
func (s *Server) ClearCommands()
ClearCommands deletes all commands and sets the command ID counter back to zero. As with DeleteCommand, any in-flight responses may still be returned.
func (*Server) ClearResponses ¶
ClearResponses deletes all responses received so far. It may not affect responses that are still in-flight.
func (*Server) DeleteCommand ¶
DeleteCommand removes a command from the active command list. Any in-flight messages held by any clients may still return a response to the deleted command.
func (*Server) DeleteCommands ¶
DeleteCommands removes all commands with the specified prefix.
func (*Server) DeleteResponse ¶
DeleteResponse removes all responses for the given ID. Any in-flight responses will not be deleted.
func (*Server) DeleteResponses ¶
DeleteResponses removes all commands with the specified prefix.
func (*Server) DialSerial ¶
Dial a client serial port. The server will maintain this connection until a client connects and then disconnects.
func (*Server) DisconnectUFS ¶
func (*Server) Forward ¶
Forward creates a tunnel from host->guest, based on UUID, source, host, and destination port. This is similar to the ssh -L command.
func (*Server) GetClients ¶
GetClients returns a list of every active client
func (*Server) GetCommand ¶
GetCommand returns copy of a command by ID or nil if it doesn't exist
func (*Server) GetCommands ¶
GetCommands returns a deep copy of the current command list
func (*Server) Listen ¶
Listen starts accepting TCP connections on the specified port, accepting connections in a goroutine. Returns an error if the server is already listening on that port or if there was another error.
func (*Server) ListenUFS ¶
ListenUFS starts a listener to connect to UFS running on the VM specified by the UUID. Returns the TCP port or an error.
func (*Server) ListenUnix ¶
ListenUnix creates a unix domain socket at the given path and listens for incoming connections. ListenUnix returns on the successful creation of the socket, and accepts connections in a goroutine. Returns an error if the server is already listening on that path or if there was another error.
func (*Server) NewCommand ¶
NewCommand posts a new command to the active command list. The command ID is returned.
func (*Server) NewFilesSendCommand ¶
NewFilesSendCommand creates a command to send to clients to read the listed files, expanding globs.
func (*Server) RegisterVM ¶
func (*Server) Reverse ¶
Reverse creates a reverse tunnel from guest->host. It is possible to have multiple clients create a reverse tunnel simultaneously. filter allows specifying which clients to have create the tunnel.