Skip to content

Commit

Permalink
new: the events ignore list is now exported as the events.stream stat…
Browse files Browse the repository at this point in the history
…e object via api.rest
  • Loading branch information
evilsocket committed Mar 21, 2019
1 parent 2e3e4f4 commit 80000ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions modules/events_stream/events_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ func NewEventsStream(s *session.Session) *EventsStream {
triggerList: NewTriggerList(),
}

mod.State.Store("ignoring", &mod.Session.EventsIgnoreList)

mod.AddHandler(session.NewModuleHandler("events.stream on", "",
"Start events stream.",
func(args []string) error {
Expand Down
11 changes: 9 additions & 2 deletions session/events_ignore_list.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package session

import (
"encoding/json"
"errors"
"fmt"
"strings"
Expand Down Expand Up @@ -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 == "" {
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 80000ed

Please sign in to comment.