mirror of
https://github.com/eosswedenorg/thalos
synced 2026-07-02 11:43:40 +02:00
internal/types/blacklist.go: add BlacklistWildcard constant
This commit is contained in:
parent
eb2032e233
commit
2006da6a19
1 changed files with 4 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
package types
|
package types
|
||||||
|
|
||||||
|
const BlacklistWildcard = "*"
|
||||||
|
|
||||||
type Blacklist struct {
|
type Blacklist struct {
|
||||||
table map[string][]string
|
table map[string][]string
|
||||||
isWhitelist bool
|
isWhitelist bool
|
||||||
|
|
@ -42,9 +44,9 @@ func (bl Blacklist) list(contracts ...string) [][]string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bl Blacklist) IsAllowed(contract string, action string) bool {
|
func (bl Blacklist) IsAllowed(contract string, action string) bool {
|
||||||
for _, v := range bl.list(contract, "*") {
|
for _, v := range bl.list(contract, BlacklistWildcard) {
|
||||||
for _, act := range v {
|
for _, act := range v {
|
||||||
if act == action || act == "*" {
|
if act == action || act == BlacklistWildcard {
|
||||||
return bl.isWhitelist == true
|
return bl.isWhitelist == true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue