service

package
v0.0.0-...-9ac8f15 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SpeedtestHistoryLimit = 25
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationService

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

Service for managing authentication requests.

func (*AuthenticationService) Authenticate

func (s *AuthenticationService) Authenticate(
	username string,
	password string,
) (Token, error)

func (*AuthenticationService) NeedsAdminRegistration

func (s *AuthenticationService) NeedsAdminRegistration() bool

func (*AuthenticationService) RegisterAdmin

func (s *AuthenticationService) RegisterAdmin(
	username string,
	password string,
) (Token, error)

type AuthorizationService

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

Service for managing authorization requests.

func NewAuthorizationService

func NewAuthorizationService(
	tokens *TokenBucket,
) *AuthorizationService

func (*AuthorizationService) HasAdminRights

func (s *AuthorizationService) HasAdminRights(token string) bool

type MasterConfigurationService

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

Service that acts as a facade for configuration requests.

func NewMasterConfigurationService

func NewMasterConfigurationService(
	cfg *config.Config,
) *MasterConfigurationService

func (MasterConfigurationService) Current

func (MasterConfigurationService) Save

func (MasterConfigurationService) Stream

func (s MasterConfigurationService) Stream() chan (config.Config)

func (MasterConfigurationService) UpdateConfigurable

func (s MasterConfigurationService) UpdateConfigurable(
	nodeStatsPolling int,
	nodeLastSeenTimeout int,
	autoSavePeriod int,
)

Updates all configurable values present in the current configuration instance.

func (MasterConfigurationService) UpdateTrustedNetwork

func (s MasterConfigurationService) UpdateTrustedNetwork(
	nodes []models.Node,
)

Updates the trusted network present in the current configuration instance.

type NetworkService

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

Service for managing network nodes.

func NewNetworkService

func NewNetworkService(
	subscriber event.EventSubscriber,
) *NetworkService

func (*NetworkService) Address

func (s *NetworkService) Address() models.Address

todo: cache address

func (*NetworkService) PublicKey

func (s *NetworkService) PublicKey() ([]byte, error)

todo: cache public key

type NetworkingService

type NetworkingService struct {
}

Service for networking operations.

func NewNetworkingService

func NewNetworkingService() *NetworkingService

func (NetworkingService) PrivateIP

func (s NetworkingService) PrivateIP() (net.IP, error)

func (NetworkingService) PublicIP

func (s NetworkingService) PublicIP() (net.IP, error)

type NodeCommanderService

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

Service for executing commands in nodes.

func NewNodeCommanderService

func NewNodeCommanderService(
	publisher event.EventPublisher,
	subscriber event.EventSubscriber,
) *NodeCommanderService

func (NodeCommanderService) Connections

func (s NodeCommanderService) Connections(id string) ([]models.Connection, error)

func (NodeCommanderService) Disconnect

func (s NodeCommanderService) Disconnect(id string) error

func (NodeCommanderService) KillProcess

func (s NodeCommanderService) KillProcess(id string, pid int32) error

func (NodeCommanderService) Packages

func (s NodeCommanderService) Packages(id string) ([]models.Package, error)

func (NodeCommanderService) Processes

func (s NodeCommanderService) Processes(id string) ([]models.Process, error)

type NodeManagerService

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

Service for managing nodes that report to master.

func NewNodeManagerService

func NewNodeManagerService(nodes ...models.Node) *NodeManagerService

Creates a service for managing network nodes. Allows passing previously saved nodes as varadiac param.

func (*NodeManagerService) Authenticate

func (s *NodeManagerService) Authenticate(node models.Node, code string) error

func (*NodeManagerService) Code

func (*NodeManagerService) IsAuthenticated

func (s *NodeManagerService) IsAuthenticated(node models.Node) bool

func (*NodeManagerService) Join

func (s *NodeManagerService) Join(node models.Node) error

Joins master node.

func (NodeManagerService) Network

func (s NodeManagerService) Network() []models.Node

func (NodeManagerService) Node

func (s NodeManagerService) Node(id string) (models.Node, bool)

func (*NodeManagerService) Release

func (s *NodeManagerService) Release(stream chan ([]models.Node))

Notifies the manager that a stream should be released.

func (*NodeManagerService) Remove

func (s *NodeManagerService) Remove(node models.Node) error

Removes a node from the network.

func (*NodeManagerService) Stream

func (s *NodeManagerService) Stream() chan ([]models.Node)

func (*NodeManagerService) Update

func (s *NodeManagerService) Update(node models.Node) error

Updates the state of a node.

func (*NodeManagerService) Valid

func (s *NodeManagerService) Valid(code string) bool

type NodeReporterService

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

Service for reporting node information to master.

func (NodeReporterService) Connections

func (s NodeReporterService) Connections() ([]models.Connection, error)

func (NodeReporterService) KillProcess

func (s NodeReporterService) KillProcess(pid int32) error

func (NodeReporterService) Node

func (s NodeReporterService) Node() models.Node

func (NodeReporterService) Packages

func (s NodeReporterService) Packages() ([]models.Package, error)

func (NodeReporterService) Processes

func (s NodeReporterService) Processes() ([]models.Process, error)

func (NodeReporterService) Speedtest

func (s NodeReporterService) Speedtest() (chan (models.Speedtest), error)

func (*NodeReporterService) Start

func (s *NodeReporterService) Start(pollDuration time.Duration) chan (models.Stats)

Starts reporting node stats through a channel. The channel is unbuffered.

func (*NodeReporterService) Update

func (s *NodeReporterService) Update(
	d time.Duration,
)

type NodeSchedulerService

type NodeSchedulerService struct{}

func NewNodeSchedulerService

func NewNodeSchedulerService(
	cfg func() config.Config,
	cfgStream func() chan (config.Config),
	saveCfg func() error,
	updateTrustedNetwork func([]models.Node),
	updateNetwork func(models.Node) error,
	network func() []models.Node,
	networkStream func() chan ([]models.Node),
) *NodeSchedulerService

Creates a new service that schedules routines that interact with the nodes network. All routines are initialized when calling this function.

This is a dumb service and shouldn't interact with no injected instance. Instead instances should be retrieved by callbacks.

type NodeSpeedtestService

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

Service for managing nodes speedtests.

func (NodeSpeedtestService) History

func (s NodeSpeedtestService) History(nodeid string) ([]models.Speedtest, bool)

func (NodeSpeedtestService) Speedtest

func (s NodeSpeedtestService) Speedtest(id string) (models.Speedtest, bool)

func (NodeSpeedtestService) Start

func (s NodeSpeedtestService) Start(nodeid string) (models.Speedtest, error)

func (NodeSpeedtestService) Updates

func (s NodeSpeedtestService) Updates(id string) (chan (models.Speedtest), bool)

type Token

type Token struct {
	Value  string
	User   models.User
	Expiry time.Time
}

type TokenBucket

type TokenBucket map[string]Token

func (TokenBucket) New

func (b TokenBucket) New(user models.User) Token

func (TokenBucket) Token

func (b TokenBucket) Token(token string) (Token, bool)

Jump to

Keyboard shortcuts

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