new: the events ignore list is now exported as the events.stream state object via api.rest

This commit is contained in:
evilsocket 2019-03-21 11:59:41 +01:00
commit 80000ed737
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
2 changed files with 11 additions and 2 deletions

View file

@ -1,6 +1,7 @@
package session
import (
"encoding/json"
"errors"
"fmt"
"strings"
@ -30,6 +31,12 @@ func NewEventsIgnoreList() *EventsIgnoreList {
}
}
func (l *EventsIgnoreList) MarshalJSON() ([]byte, error) {
l.RLock()
defer l.RUnlock()
return json.Marshal(l.filters)
}
func (l *EventsIgnoreList) checkExpression(expr string) (string, error) {
expr = str.Trim(expr)
if expr == "" {
@ -88,8 +95,8 @@ func (l *EventsIgnoreList) Remove(expr string) (err error) {
}
func (l *EventsIgnoreList) Clear() {
l.RLock()
defer l.RUnlock()
l.Lock()
defer l.Unlock()
l.filters = make([]filter, 0)
}