agent

package
v2.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package agent is the service for interacting with Agent objects

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithMemoryAgentRepository

func WithMemoryAgentRepository() agents.Repository

WithMemoryAgentRepository retrieves an in-memory Agent repository interface used to manage Agent object

func WithMemoryGroupRepository

func WithMemoryGroupRepository() group.Repository

WithMemoryGroupRepository retrieves an in-memory Group repository interface used to manage Agent Group object

Types

type Service

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

Service holds references to repositories to manage Agent objects or Group objects

func NewAgentService

func NewAgentService() *Service

NewAgentService is a factory to create an Agent service to be used by other packages or services

func (*Service) Add

func (s *Service) Add(agent agents.Agent) (err error)

Add stores and Agent object in the database

func (*Service) AddAgentToGroup

func (s *Service) AddAgentToGroup(group string, id uuid.UUID) error

AddAgentToGroup adds the Agent to a group

func (*Service) Agent

func (s *Service) Agent(id uuid.UUID) (agents.Agent, error)

Agent returns a single Agent object for the provided id

func (*Service) Agents

func (s *Service) Agents() []agents.Agent

Agents returns a list of all Agent objects known to the server

func (*Service) Authenticated

func (s *Service) Authenticated(id uuid.UUID) bool

Authenticated determines if the Agent is authenticated or not

func (*Service) Exist

func (s *Service) Exist(id uuid.UUID) bool

Exist determines if the Agent is known to the server or not

func (*Service) GroupMembers

func (s *Service) GroupMembers() map[string][]uuid.UUID

GroupMembers returns a list of lists that contain all groups and their members

func (*Service) Groups

func (s *Service) Groups() []string

Groups returns a list of all created groups

func (*Service) IsChild

func (s *Service) IsChild(id uuid.UUID) bool

IsChild checks to see if the Agent id is a peer-to-peer child to any other Agent

func (*Service) Lifetime

func (s *Service) Lifetime(id uuid.UUID) (time.Duration, error)

Lifetime returns the amount an agent could live without successfully communicating with the server

func (s *Service) Link(id, link uuid.UUID) error

Link adds a child relationship link to the Agent id

func (*Service) Linked

func (s *Service) Linked(id, link uuid.UUID) (bool, error)

Linked determines if the link is associated with the parent agent id

func (s *Service) Links(id uuid.UUID) ([]uuid.UUID, error)

Links returns a list of child Agent IDs

func (*Service) Log

func (s *Service) Log(id uuid.UUID, message string) error

Log writes a message to an existing Agent's log file

func (*Service) Remove

func (s *Service) Remove(id uuid.UUID) (err error)

Remove deletes an existing Agent from the database

func (*Service) RemoveAgentFromGroup

func (s *Service) RemoveAgentFromGroup(group string, id uuid.UUID) error

RemoveAgentFromGroup removes an Agent ID from a group

func (*Service) ResetAuthentication

func (s *Service) ResetAuthentication(id uuid.UUID) (err error)

ResetAuthentication sets the Agent's authentication status to false and its secret back to empty

func (*Service) Status

func (s *Service) Status(id uuid.UUID) (status string, err error)

Status determines if the agent is active, delayed, or dead based on its last checkin time and retry settings

func (s *Service) Unlink(id, link uuid.UUID) error

Unlink removes a child Agent link from the parent Agent id

func (*Service) Update

func (s *Service) Update(agent agents.Agent) error

Update replaces an Agent object in the database with the one provided

func (*Service) UpdateAgentInfo

func (s *Service) UpdateAgentInfo(id uuid.UUID, info messages.AgentInfo) (err error)

UpdateAgentInfo replaces an existing Agent's embedded Build, Comms, Host, and Process structures This is typically used after initial checkin or when the Agent has a configuration change

func (*Service) UpdateAlive

func (s *Service) UpdateAlive(id uuid.UUID, alive bool) error

UpdateAlive set's the Agent's alive status to the provided value

func (*Service) UpdateAuthenticated

func (s *Service) UpdateAuthenticated(id uuid.UUID, authenticated bool) error

UpdateAuthenticated set's the Agent's authenticated field value

func (*Service) UpdateComms

func (s *Service) UpdateComms(id uuid.UUID, comms agents.Comms) error

UpdateComms replaces an existing Agent's embedded Comms structure

func (*Service) UpdateInitial

func (s *Service) UpdateInitial(id uuid.UUID, t time.Time) error

UpdateInitial set's that Agent's initial checkin time field

func (*Service) UpdateListener

func (s *Service) UpdateListener(id, listener uuid.UUID) error

func (*Service) UpdateNote

func (s *Service) UpdateNote(id uuid.UUID, note string) (err error)

UpdateNote replaces an existing Agent's note

func (*Service) UpdateStatusCheckin

func (s *Service) UpdateStatusCheckin(id uuid.UUID, t time.Time) error

UpdateStatusCheckin sets an existing Agent's timestamp for the last checkin field

Jump to

Keyboard shortcuts

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