Documentation
¶
Overview ¶
Package agent provides the main agent functionality for CipherSwarm.
Index ¶
- Variables
- func AuthenticateAgent(ctx context.Context) error
- func GetAgentConfiguration(ctx context.Context) error
- func SendAgentShutdown(ctx context.Context)
- func SendHeartBeat(ctx context.Context) (*api.State, error)
- func SetConfiguration(cfg agentConfiguration)
- func SetMetadataProvider(dm *devices.DeviceManager)
- func StartAgent()
- func UpdateAgentMetadata(ctx context.Context) error
- type RecommendedCircuitBreaker
- type RecommendedRetry
- type RecommendedTimeouts
Constants ¶
This section is empty.
Variables ¶
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.
var ErrAPITokenNotSet = errors.New("API token not set")
ErrAPITokenNotSet indicates the api_token configuration value is empty.
var ErrAPIURLNotSet = errors.New("API URL not set")
ErrAPIURLNotSet indicates the api_url configuration value is empty.
var (
ErrCouldNotValidateCredentials = stderrors.New("could not validate credentials")
)
Static errors to comply with err113 linter.
Functions ¶
func AuthenticateAgent ¶ added in v0.6.2
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
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
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
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 UpdateAgentMetadata ¶ added in v0.6.2
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).