agent

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package agent provides the main agent functionality for CipherSwarm.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAuthenticationFailed = errors.New("failed to authenticate with the CipherSwarm API")
	ErrConfigurationFailed  = errors.New("failed to get agent configuration")
	ErrBadResponse          = errors.New("bad response from server")
)

Define static errors.

View Source
var ErrAPITokenNotSet = errors.New("API token not set")

ErrAPITokenNotSet indicates the api_token configuration value is empty.

View Source
var ErrAPIURLNotSet = errors.New("API URL not set")

ErrAPIURLNotSet indicates the api_url configuration value is empty.

View Source
var (
	ErrCouldNotValidateCredentials = stderrors.New("could not validate credentials")
)

Static errors to comply with err113 linter.

Functions

func AuthenticateAgent added in v0.6.2

func AuthenticateAgent(ctx context.Context) error

AuthenticateAgent authenticates the agent with the CipherSwarm API using the API client interface. It sends an authentication request to the API, processes the response, and updates the shared state. On error, it logs the error and returns it. If the response is nil or indicates a failed authentication, an error is logged and returned.

func GetAgentConfiguration added in v0.6.2

func GetAgentConfiguration(ctx context.Context) error

GetAgentConfiguration retrieves the agent configuration from the CipherSwarm API and handles errors. It updates the global Configuration variable with the fetched configuration. If UseNativeHashcat is true in the configuration, it sets the native Hashcat path.

func SendAgentShutdown added in v0.6.2

func SendAgentShutdown(ctx context.Context)

SendAgentShutdown notifies the server of the agent shutdown and handles any errors during the API call. Callers control context: pass context.Background() for shutdown notifications that must complete.

func SendHeartBeat added in v0.6.2

func SendHeartBeat(ctx context.Context) (*api.State, error)

SendHeartBeat sends a heartbeat signal to the server and processes the server's response. It handles different response status codes and logs relevant messages. It returns the agent's state object (or nil for no state change) and an error if the heartbeat failed.

func SetConfiguration added in v0.6.2

func SetConfiguration(cfg agentConfiguration)

SetConfiguration atomically replaces the entire agent configuration.

func SetMetadataProvider added in v0.6.2

func SetMetadataProvider(dm *devices.DeviceManager)

SetMetadataProvider wires the enumerated DeviceManager into the metadata provider used by UpdateAgentMetadata. Called by StartAgent and handleReload after device enumeration completes.

func StartAgent

func StartAgent()

StartAgent initializes and starts the CipherSwarm agent.

func UpdateAgentMetadata added in v0.6.2

func UpdateAgentMetadata(ctx context.Context) error

UpdateAgentMetadata updates the agent's metadata and sends it to the CipherSwarm API. It retrieves host information, device list, constructs the agent update request body, and sends the updated metadata to the API. Logs relevant information and handles any API errors.

Types

type RecommendedCircuitBreaker added in v0.6.2

type RecommendedCircuitBreaker struct {
	FailureThreshold int `json:"failure_threshold" yaml:"failure_threshold"`
	Timeout          int `json:"timeout"           yaml:"timeout"`
}

RecommendedCircuitBreaker holds server-recommended circuit breaker settings.

type RecommendedRetry added in v0.6.2

type RecommendedRetry struct {
	MaxAttempts  int `json:"max_attempts"  yaml:"max_attempts"`
	InitialDelay int `json:"initial_delay" yaml:"initial_delay"`
	MaxDelay     int `json:"max_delay"     yaml:"max_delay"`
}

RecommendedRetry holds server-recommended retry settings.

type RecommendedTimeouts added in v0.6.2

type RecommendedTimeouts struct {
	ConnectTimeout int `json:"connect_timeout" yaml:"connect_timeout"`
	ReadTimeout    int `json:"read_timeout"    yaml:"read_timeout"`
	WriteTimeout   int `json:"write_timeout"   yaml:"write_timeout"`
	RequestTimeout int `json:"request_timeout" yaml:"request_timeout"`
}

RecommendedTimeouts holds server-recommended timeout settings (values in seconds).

Jump to

Keyboard shortcuts

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