You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
fw-daemon/sgfw/const.go

112 lines
1.9 KiB

8 years ago
package sgfw
import (
"strings"
)
const (
STR_REDACTED = "[redacted]"
8 years ago
STR_UNKNOWN = "[uknown]"
8 years ago
)
type RuleAction uint16
const (
RULE_ACTION_DENY RuleAction = iota
RULE_ACTION_ALLOW
)
8 years ago
var RuleActionString = map[RuleAction]string{
RULE_ACTION_DENY: "DENY",
8 years ago
RULE_ACTION_ALLOW: "ALLOW",
}
8 years ago
var RuleActionValue = map[string]RuleAction{
"DENY": RULE_ACTION_DENY,
"ALLOW": RULE_ACTION_ALLOW,
8 years ago
}
type RuleMode uint16
const (
RULE_MODE_SESSION RuleMode = iota
RULE_MODE_PERMANENT
RULE_MODE_SYSTEM
)
8 years ago
var RuleModeString = map[RuleMode]string{
RULE_MODE_SESSION: "SESSION",
8 years ago
RULE_MODE_PERMANENT: "PERMANENT",
8 years ago
RULE_MODE_SYSTEM: "SYSTEM",
8 years ago
}
8 years ago
var RuleModeValue = map[string]RuleMode{
"SESSION": RULE_MODE_SESSION,
8 years ago
"PERMANENT": RULE_MODE_PERMANENT,
8 years ago
"SYSTEM": RULE_MODE_SYSTEM,
8 years ago
}
type FilterScope uint16
8 years ago
8 years ago
const (
APPLY_ONCE FilterScope = iota
APPLY_SESSION
APPLY_FOREVER
)
8 years ago
var FilterScopeString = map[FilterScope]string{
APPLY_ONCE: "ONCE",
8 years ago
APPLY_SESSION: "SESSION",
APPLY_FOREVER: "FOREVER",
}
8 years ago
var FilterScopeValue = map[string]FilterScope{
"ONCE": APPLY_ONCE,
8 years ago
"SESSION": APPLY_SESSION,
"FOREVER": APPLY_FOREVER,
}
func GetFilterScopeString(scope FilterScope) string {
if val, ok := FilterScopeString[scope]; ok {
return val
}
return FilterScopeString[APPLY_SESSION]
}
func GetFilterScopeValue(scope string) FilterScope {
scope = strings.ToUpper(scope)
if val, ok := FilterScopeValue[scope]; ok {
return val
}
return APPLY_SESSION
}
type FilterResult uint16
const (
FILTER_DENY FilterResult = iota
FILTER_ALLOW
FILTER_PROMPT
)
var FilterResultString = map[FilterResult]string{
8 years ago
FILTER_DENY: "DENY",
FILTER_ALLOW: "ALLOW",
8 years ago
FILTER_PROMPT: "PROMPT",
}
8 years ago
var FilterResultValue = map[string]FilterResult{
"DENY": FILTER_DENY,
"ALLOW": FILTER_ALLOW,
8 years ago
"PROMPT": FILTER_PROMPT,
}
type DbusRule struct {
Id uint32
App string
Path string
Verb uint16
Target string
Mode uint16
}