Add additional functions to the status package
This commit is contained in:
@@ -2,8 +2,6 @@ package status
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/Safing/portbase/config"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -30,35 +28,27 @@ func init() {
|
||||
gate17Status = &gate17StatusValue
|
||||
}
|
||||
|
||||
// GetCurrentSecurityLevel returns the current security level.
|
||||
func GetCurrentSecurityLevel() uint8 {
|
||||
// CurrentSecurityLevel returns the current security level.
|
||||
func CurrentSecurityLevel() uint8 {
|
||||
return uint8(atomic.LoadUint32(currentSecurityLevel))
|
||||
}
|
||||
|
||||
// GetSelectedSecurityLevel returns the selected security level.
|
||||
func GetSelectedSecurityLevel() uint8 {
|
||||
// SelectedSecurityLevel returns the selected security level.
|
||||
func SelectedSecurityLevel() uint8 {
|
||||
return uint8(atomic.LoadUint32(selectedSecurityLevel))
|
||||
}
|
||||
|
||||
// GetThreatLevel returns the current threat level.
|
||||
func GetThreatLevel() uint8 {
|
||||
// ThreatLevel returns the current threat level.
|
||||
func ThreatLevel() uint8 {
|
||||
return uint8(atomic.LoadUint32(threatLevel))
|
||||
}
|
||||
|
||||
// GetPortmasterStatus returns the current Portmaster status.
|
||||
func GetPortmasterStatus() uint8 {
|
||||
// PortmasterStatus returns the current Portmaster status.
|
||||
func PortmasterStatus() uint8 {
|
||||
return uint8(atomic.LoadUint32(portmasterStatus))
|
||||
}
|
||||
|
||||
// GetGate17Status returns the current Gate17 status.
|
||||
func GetGate17Status() uint8 {
|
||||
// Gate17Status returns the current Gate17 status.
|
||||
func Gate17Status() uint8 {
|
||||
return uint8(atomic.LoadUint32(gate17Status))
|
||||
}
|
||||
|
||||
// GetConfigByLevel returns whether the given security level dependent config option is on or off.
|
||||
func GetConfigByLevel(name string) func() bool {
|
||||
activatedLevel := config.GetAsInt(name, int64(SecurityLevelDynamic))
|
||||
return func() bool {
|
||||
return uint8(activatedLevel()) <= GetCurrentSecurityLevel()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user