|
|
@ -12,17 +12,20 @@ const (
|
|
|
|
|
|
|
|
|
|
|
|
//RuleAction is the action to apply to a rule
|
|
|
|
//RuleAction is the action to apply to a rule
|
|
|
|
type RuleAction uint16
|
|
|
|
type RuleAction uint16
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
const (
|
|
|
|
RULE_ACTION_DENY RuleAction = iota
|
|
|
|
RULE_ACTION_DENY RuleAction = iota
|
|
|
|
RULE_ACTION_ALLOW
|
|
|
|
RULE_ACTION_ALLOW
|
|
|
|
RULE_ACTION_ALLOW_TLSONLY
|
|
|
|
RULE_ACTION_ALLOW_TLSONLY
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// RuleActionString is used to get a string from an action id
|
|
|
|
// RuleActionString is used to get a string from an action id
|
|
|
|
var RuleActionString = map[RuleAction]string{
|
|
|
|
var RuleActionString = map[RuleAction]string{
|
|
|
|
RULE_ACTION_DENY: "DENY",
|
|
|
|
RULE_ACTION_DENY: "DENY",
|
|
|
|
RULE_ACTION_ALLOW: "ALLOW",
|
|
|
|
RULE_ACTION_ALLOW: "ALLOW",
|
|
|
|
RULE_ACTION_ALLOW_TLSONLY: "ALLOW_TLSONLY",
|
|
|
|
RULE_ACTION_ALLOW_TLSONLY: "ALLOW_TLSONLY",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// RuleActionValue is used to get an action id using the action string
|
|
|
|
// RuleActionValue is used to get an action id using the action string
|
|
|
|
var RuleActionValue = map[string]RuleAction{
|
|
|
|
var RuleActionValue = map[string]RuleAction{
|
|
|
|
RuleActionString[RULE_ACTION_DENY]: RULE_ACTION_DENY,
|
|
|
|
RuleActionString[RULE_ACTION_DENY]: RULE_ACTION_DENY,
|
|
|
@ -32,12 +35,14 @@ var RuleActionValue = map[string]RuleAction{
|
|
|
|
|
|
|
|
|
|
|
|
//RuleMode contains the time scope of a rule
|
|
|
|
//RuleMode contains the time scope of a rule
|
|
|
|
type RuleMode uint16
|
|
|
|
type RuleMode uint16
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
const (
|
|
|
|
RULE_MODE_SESSION RuleMode = iota
|
|
|
|
RULE_MODE_SESSION RuleMode = iota
|
|
|
|
RULE_MODE_PROCESS
|
|
|
|
RULE_MODE_PROCESS
|
|
|
|
RULE_MODE_PERMANENT
|
|
|
|
RULE_MODE_PERMANENT
|
|
|
|
RULE_MODE_SYSTEM
|
|
|
|
RULE_MODE_SYSTEM
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// RuleModeString is used to get a rule mode string from its id
|
|
|
|
// RuleModeString is used to get a rule mode string from its id
|
|
|
|
var RuleModeString = map[RuleMode]string{
|
|
|
|
var RuleModeString = map[RuleMode]string{
|
|
|
|
RULE_MODE_SESSION: "SESSION",
|
|
|
|
RULE_MODE_SESSION: "SESSION",
|
|
|
@ -45,6 +50,7 @@ var RuleModeString = map[RuleMode]string{
|
|
|
|
RULE_MODE_PERMANENT: "PERMANENT",
|
|
|
|
RULE_MODE_PERMANENT: "PERMANENT",
|
|
|
|
RULE_MODE_SYSTEM: "SYSTEM",
|
|
|
|
RULE_MODE_SYSTEM: "SYSTEM",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// RuleModeValue converts a mode string to its id
|
|
|
|
// RuleModeValue converts a mode string to its id
|
|
|
|
var RuleModeValue = map[string]RuleMode{
|
|
|
|
var RuleModeValue = map[string]RuleMode{
|
|
|
|
RuleModeString[RULE_MODE_SESSION]: RULE_MODE_SESSION,
|
|
|
|
RuleModeString[RULE_MODE_SESSION]: RULE_MODE_SESSION,
|
|
|
@ -55,12 +61,14 @@ var RuleModeValue = map[string]RuleMode{
|
|
|
|
|
|
|
|
|
|
|
|
//FilterScope contains a filter's time scope
|
|
|
|
//FilterScope contains a filter's time scope
|
|
|
|
type FilterScope uint16
|
|
|
|
type FilterScope uint16
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
const (
|
|
|
|
APPLY_ONCE FilterScope = iota
|
|
|
|
APPLY_ONCE FilterScope = iota
|
|
|
|
APPLY_SESSION
|
|
|
|
APPLY_SESSION
|
|
|
|
APPLY_PROCESS
|
|
|
|
APPLY_PROCESS
|
|
|
|
APPLY_FOREVER
|
|
|
|
APPLY_FOREVER
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// FilterScopeString converts a filter scope ID to its string
|
|
|
|
// FilterScopeString converts a filter scope ID to its string
|
|
|
|
var FilterScopeString = map[FilterScope]string{
|
|
|
|
var FilterScopeString = map[FilterScope]string{
|
|
|
|
APPLY_ONCE: "ONCE",
|
|
|
|
APPLY_ONCE: "ONCE",
|
|
|
@ -68,6 +76,7 @@ var FilterScopeString = map[FilterScope]string{
|
|
|
|
APPLY_PROCESS: "PROCESS",
|
|
|
|
APPLY_PROCESS: "PROCESS",
|
|
|
|
APPLY_FOREVER: "FOREVER",
|
|
|
|
APPLY_FOREVER: "FOREVER",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// FilterScopeString converts a filter scope string to its ID
|
|
|
|
// FilterScopeString converts a filter scope string to its ID
|
|
|
|
var FilterScopeValue = map[string]FilterScope{
|
|
|
|
var FilterScopeValue = map[string]FilterScope{
|
|
|
|
FilterScopeString[APPLY_ONCE]: APPLY_ONCE,
|
|
|
|
FilterScopeString[APPLY_ONCE]: APPLY_ONCE,
|
|
|
@ -75,6 +84,7 @@ var FilterScopeValue = map[string]FilterScope{
|
|
|
|
FilterScopeString[APPLY_PROCESS]: APPLY_PROCESS,
|
|
|
|
FilterScopeString[APPLY_PROCESS]: APPLY_PROCESS,
|
|
|
|
FilterScopeString[APPLY_FOREVER]: APPLY_FOREVER,
|
|
|
|
FilterScopeString[APPLY_FOREVER]: APPLY_FOREVER,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// GetFilterScopeString is used to safely return a filter scope string
|
|
|
|
// GetFilterScopeString is used to safely return a filter scope string
|
|
|
|
func GetFilterScopeString(scope FilterScope) string {
|
|
|
|
func GetFilterScopeString(scope FilterScope) string {
|
|
|
|
if val, ok := FilterScopeString[scope]; ok {
|
|
|
|
if val, ok := FilterScopeString[scope]; ok {
|
|
|
@ -82,6 +92,7 @@ func GetFilterScopeString(scope FilterScope) string {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FilterScopeString[APPLY_SESSION]
|
|
|
|
return FilterScopeString[APPLY_SESSION]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// GetFilterScopeValue is used to safely return a filter scope ID
|
|
|
|
// GetFilterScopeValue is used to safely return a filter scope ID
|
|
|
|
func GetFilterScopeValue(scope string) FilterScope {
|
|
|
|
func GetFilterScopeValue(scope string) FilterScope {
|
|
|
|
scope = strings.ToUpper(scope)
|
|
|
|
scope = strings.ToUpper(scope)
|
|
|
@ -93,12 +104,14 @@ func GetFilterScopeValue(scope string) FilterScope {
|
|
|
|
|
|
|
|
|
|
|
|
//FilterResult contains the filtering resulting action
|
|
|
|
//FilterResult contains the filtering resulting action
|
|
|
|
type FilterResult uint16
|
|
|
|
type FilterResult uint16
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
const (
|
|
|
|
FILTER_DENY FilterResult = iota
|
|
|
|
FILTER_DENY FilterResult = iota
|
|
|
|
FILTER_ALLOW
|
|
|
|
FILTER_ALLOW
|
|
|
|
FILTER_PROMPT
|
|
|
|
FILTER_PROMPT
|
|
|
|
FILTER_ALLOW_TLSONLY
|
|
|
|
FILTER_ALLOW_TLSONLY
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// FilterResultString converts a filter value ID to its string
|
|
|
|
// FilterResultString converts a filter value ID to its string
|
|
|
|
var FilterResultString = map[FilterResult]string{
|
|
|
|
var FilterResultString = map[FilterResult]string{
|
|
|
|
FILTER_DENY: "DENY",
|
|
|
|
FILTER_DENY: "DENY",
|
|
|
@ -106,6 +119,7 @@ var FilterResultString = map[FilterResult]string{
|
|
|
|
FILTER_PROMPT: "PROMPT",
|
|
|
|
FILTER_PROMPT: "PROMPT",
|
|
|
|
FILTER_ALLOW_TLSONLY: "ALLOW_TLSONLY",
|
|
|
|
FILTER_ALLOW_TLSONLY: "ALLOW_TLSONLY",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// FilterResultValue converts a filter value string to its ID
|
|
|
|
// FilterResultValue converts a filter value string to its ID
|
|
|
|
var FilterResultValue = map[string]FilterResult{
|
|
|
|
var FilterResultValue = map[string]FilterResult{
|
|
|
|
FilterResultString[FILTER_DENY]: FILTER_DENY,
|
|
|
|
FilterResultString[FILTER_DENY]: FILTER_DENY,
|
|
|
|