status

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SecurityLevelOff uint8 = 0

	SecurityLevelNormal  uint8 = 1
	SecurityLevelHigh    uint8 = 2
	SecurityLevelExtreme uint8 = 4

	SecurityLevelsNormalAndHigh    uint8 = SecurityLevelNormal | SecurityLevelHigh
	SecurityLevelsNormalAndExtreme uint8 = SecurityLevelNormal | SecurityLevelExtreme
	SecurityLevelsHighAndExtreme   uint8 = SecurityLevelHigh | SecurityLevelExtreme
	SecurityLevelsAll              uint8 = SecurityLevelNormal | SecurityLevelHigh | SecurityLevelExtreme

	StatusOff     uint8 = 0
	StatusError   uint8 = 1
	StatusWarning uint8 = 2
	StatusOk      uint8 = 3
)

Definitions of Security and Status Levels

View Source
const (
	UpdateStatusCurrentStable = "stable"
	UpdateStatusCurrentBeta   = "beta"
	UpdateStatusAvailable     = "available" // restart or reboot required
	UpdateStatusFailed        = "failed"    // check logs
)

Update status options

Variables

This section is empty.

Functions

func ActiveSecurityLevel

func ActiveSecurityLevel() uint8

ActiveSecurityLevel returns the current security level.

func AddOrUpdateThreat

func AddOrUpdateThreat(new *Threat)

AddOrUpdateThreat adds or updates a new threat in the system status.

func DeleteThreat

func DeleteThreat(id string)

DeleteThreat deletes a threat from the system status.

func FmtActiveSecurityLevel

func FmtActiveSecurityLevel() string

FmtActiveSecurityLevel returns the current security level as a string.

func FmtSecurityLevel

func FmtSecurityLevel(level uint8) string

FmtSecurityLevel returns the given security level as a string.

func Gate17Status

func Gate17Status() uint8

Gate17Status returns the current Gate17 status.

func PortmasterStatus

func PortmasterStatus() uint8

PortmasterStatus returns the current Portmaster status.

func SelectedSecurityLevel

func SelectedSecurityLevel() uint8

SelectedSecurityLevel returns the selected security level.

func SetGate17Status

func SetGate17Status(g17Status uint8, msg string)

SetGate17Status sets the current Gate17 status.

func SetPortmasterStatus

func SetPortmasterStatus(pmStatus uint8, msg string)

SetPortmasterStatus sets the current Portmaster status.

func SetUpdateStatus

func SetUpdateStatus(newStatus string)

SetUpdateStatus updates the system status with a new update status.

Types

type SecurityLevelOption

type SecurityLevelOption func(minSecurityLevel uint8) bool

SecurityLevelOption defines the returned function by ConfigIsActive.

func ConfigIsActive

func ConfigIsActive(name string) SecurityLevelOption

ConfigIsActive returns whether the given security level dependent config option is on or off.

func ConfigIsActiveConcurrent

func ConfigIsActiveConcurrent(name string) SecurityLevelOption

ConfigIsActiveConcurrent returns whether the given security level dependent config option is on or off and is concurrency safe.

type SystemStatus

type SystemStatus struct {
	record.Base
	sync.Mutex

	ActiveSecurityLevel   uint8
	SelectedSecurityLevel uint8

	PortmasterStatus    uint8
	PortmasterStatusMsg string

	Gate17Status    uint8
	Gate17StatusMsg string

	ThreatMitigationLevel uint8
	Threats               map[string]*Threat

	UpdateStatus string
}

SystemStatus saves basic information about the current system status.

func EnsureSystemStatus

func EnsureSystemStatus(r record.Record) (*SystemStatus, error)

EnsureSystemStatus ensures that the given record is of type SystemStatus and unwraps it, if needed.

func (*SystemStatus) Save

func (s *SystemStatus) Save()

Save saves the SystemStatus to the database

type Threat

type Threat struct {
	ID              string      // A unique ID chosen by reporting module (eg. modulePrefix-incident) to periodically check threat existence
	Name            string      // Descriptive (human readable) name for detected threat
	Description     string      // Simple description
	AdditionalData  interface{} // Additional data a module wants to make available for the user
	MitigationLevel uint8       // Recommended Security Level to switch to for mitigation
	Started         int64
	Ended           int64
}

Threat describes a detected threat.

func GetThreats

func GetThreats(idPrefix string) ([]*Threat, sync.Locker)

GetThreats returns all threats who's IDs are prefixed by the given string, and also a locker for editing them.

Jump to

Keyboard shortcuts

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