-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Markus Blaschke <[email protected]>
- Loading branch information
Showing
16 changed files
with
140 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package types | ||
|
||
import ( | ||
"strings" | ||
) | ||
|
||
type RuleStatus int | ||
|
||
var ( | ||
RuleStatusIgnore RuleStatus = -1 | ||
RuleStatusDeny RuleStatus = 0 | ||
RuleStatusAllow RuleStatus = 1 | ||
) | ||
|
||
func StringToRuleStatus(val string) RuleStatus { | ||
val = strings.TrimSpace(val) | ||
val = strings.ToLower(val) | ||
|
||
switch strings.ToLower(val) { | ||
case "-1", "ignore": | ||
return RuleStatusIgnore | ||
case "0", "false", "deny": | ||
return RuleStatusDeny | ||
case "1", "true", "allow": | ||
return RuleStatusAllow | ||
} | ||
return RuleStatusDeny | ||
} | ||
|
||
func (s RuleStatus) String() (ret string) { | ||
ret = "unknown" | ||
switch s { | ||
case RuleStatusIgnore: | ||
ret = "ignore" | ||
case RuleStatusDeny: | ||
ret = "deny" | ||
case RuleStatusAllow: | ||
ret = "allow" | ||
} | ||
return | ||
} | ||
|
||
func (s RuleStatus) IsIgnore() bool { | ||
return s == RuleStatusIgnore | ||
} | ||
func (s RuleStatus) IsDeny() bool { | ||
return s == RuleStatusDeny | ||
} | ||
func (s RuleStatus) IsAllow() bool { | ||
return s == RuleStatusAllow | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.