mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 13:09:49 -07:00
new: the events ignore list is now exported as the events.stream state object via api.rest
This commit is contained in:
parent
2e3e4f453b
commit
80000ed737
2 changed files with 11 additions and 2 deletions
|
@ -49,6 +49,8 @@ func NewEventsStream(s *session.Session) *EventsStream {
|
||||||
triggerList: NewTriggerList(),
|
triggerList: NewTriggerList(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod.State.Store("ignoring", &mod.Session.EventsIgnoreList)
|
||||||
|
|
||||||
mod.AddHandler(session.NewModuleHandler("events.stream on", "",
|
mod.AddHandler(session.NewModuleHandler("events.stream on", "",
|
||||||
"Start events stream.",
|
"Start events stream.",
|
||||||
func(args []string) error {
|
func(args []string) error {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package session
|
package session
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"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) {
|
func (l *EventsIgnoreList) checkExpression(expr string) (string, error) {
|
||||||
expr = str.Trim(expr)
|
expr = str.Trim(expr)
|
||||||
if expr == "" {
|
if expr == "" {
|
||||||
|
@ -88,8 +95,8 @@ func (l *EventsIgnoreList) Remove(expr string) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *EventsIgnoreList) Clear() {
|
func (l *EventsIgnoreList) Clear() {
|
||||||
l.RLock()
|
l.Lock()
|
||||||
defer l.RUnlock()
|
defer l.Unlock()
|
||||||
l.filters = make([]filter, 0)
|
l.filters = make([]filter, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue