event

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunCommand

func RunCommand(ac *client.AlpaconClient, serverName, command string, username, groupname string, env map[string]string) (string, error)

func SubscribeSudoEvent added in v1.4.0

func SubscribeSudoEvent(ac *client.AlpaconClient, channelID, sessionID string) error

SubscribeSudoEvent subscribes the given channel to sudo events for a websh session.

Types

type CommandRequest

type CommandRequest struct {
	Shell       string            `json:"shell"`
	Line        string            `json:"line"`
	Env         map[string]string `json:"env"`
	Data        string            `json:"data"`
	Username    string            `json:"username"`
	Groupname   string            `json:"groupname"`
	ScheduledAt *time.Time        `json:"scheduled_at"`
	Server      string            `json:"server"`
	RunAfter    []string          `json:"run_after"`
}

type CommandResponse

type CommandResponse struct {
	ID          string              `json:"id"`
	Shell       string              `json:"shell"`
	Line        string              `json:"line"`
	Data        string              `json:"data"`
	Username    string              `json:"username"`
	Groupname   string              `json:"groupname"`
	AddedAt     time.Time           `json:"added_at"`
	ScheduledAt time.Time           `json:"scheduled_at"`
	Server      types.ServerSummary `json:"server"`
	RequestedBy types.UserSummary   `json:"requested_by"`
	RunAfter    []any               `json:"run_after"`
}

type EventAttributes

type EventAttributes struct {
	Server      string `json:"server"`
	Shell       string `json:"shell"`
	Command     string `json:"command"`
	Result      string `json:"result"`
	Status      string `json:"status"`
	Operator    string `json:"operator"`
	RequestedAt string `json:"requested_at" table:"Requested At"`
}

func GetEventList

func GetEventList(ac *client.AlpaconClient, pageSize int, serverName string, userName string) ([]EventAttributes, error)

type EventDetails

type EventDetails struct {
	ID            string              `json:"id"`
	Shell         string              `json:"shell"`
	Line          string              `json:"line"`
	Success       *bool               `json:"success"`
	Result        string              `json:"result"`
	Status        string              `json:"status"`
	Cancellable   bool                `json:"cancellable"`
	ResponseDelay float64             `json:"response_delay"`
	ElapsedTime   float64             `json:"elapsed_time"`
	AddedAt       time.Time           `json:"added_at"`
	Server        types.ServerSummary `json:"server"`
	RequestedBy   types.UserSummary   `json:"requested_by"`
}

func PollCommandExecution

func PollCommandExecution(ac *client.AlpaconClient, cmdId string) (EventDetails, error)

type EventSessionResponse added in v1.4.0

type EventSessionResponse struct {
	ID           string `json:"id"`
	WebsocketURL string `json:"websocket_url"`
	ChannelID    string `json:"channel_id"`
}

EventSessionResponse is returned when creating an event session.

func CreateEventSession added in v1.4.0

func CreateEventSession(ac *client.AlpaconClient) (*EventSessionResponse, error)

CreateEventSession creates a new event session and returns the WebSocket URL and channel ID for subscribing to events.

type EventSubscriptionRequest added in v1.4.0

type EventSubscriptionRequest struct {
	Channel   string `json:"channel"`
	EventType string `json:"event_type"`
	TargetID  string `json:"target_id"`
}

EventSubscriptionRequest is sent to subscribe to an event type.

type SudoListener added in v1.4.0

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

SudoListener listens for sudo MFA events on the event WebSocket and handles the browser-based MFA flow.

The AlpaconClient (ac) is shared with the terminal WebSocket goroutines. http.Client is concurrency-safe. Token refresh and self-approve are serialized by mfaMu so only one MFA flow runs at a time.

func NewSudoListener added in v1.4.0

func NewSudoListener(ac *client.AlpaconClient, wsURL, serverName string) *SudoListener

NewSudoListener creates a SudoListener but does not connect yet.

func (*SudoListener) Start added in v1.4.0

func (sl *SudoListener) Start()

Start begins listening for sudo MFA events in a background goroutine. It automatically reconnects on disconnection. Call Stop() to shut down.

func (*SudoListener) Stop added in v1.4.0

func (sl *SudoListener) Stop()

Stop signals the listener to shut down and closes the WebSocket connection to unblock any pending ReadMessage call.

func (*SudoListener) WaitConnected added in v1.4.0

func (sl *SudoListener) WaitConnected(timeout time.Duration) bool

WaitConnected blocks until the WebSocket connection is established or the timeout expires. Returns true if connected, false on timeout or shutdown.

Jump to

Keyboard shortcuts

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