MCPcopy
hub / github.com/bettercap/bettercap / getEvents

Method getEvents

modules/api_rest/api_rest_controller.go:247–264  ·  view source on GitHub ↗
(limit int)

Source from the content-addressed store, hash-verified

245}
246
247func (mod *RestAPI) getEvents(limit int) []session.Event {
248 events := make([]session.Event, 0)
249 for _, e := range mod.Session.Events.Sorted() {
250 if mod.Session.EventsIgnoreList.Ignored(e) == false {
251 events = append(events, e)
252 }
253 }
254
255 nevents := len(events)
256 nmax := nevents
257 n := nmax
258
259 if limit > 0 && limit < nmax {
260 n = limit
261 }
262
263 return events[nevents-n:]
264}
265
266func (mod *RestAPI) showEvents(w http.ResponseWriter, r *http.Request) {
267 q := r.URL.Query()

Callers 5

showEventsMethod · 0.95
recordStateMethod · 0.95
TestGetEventsEmptyFunction · 0.95
TestGetEventsWithLimitFunction · 0.95
main.jsFile · 0.80

Calls 2

IgnoredMethod · 0.80
SortedMethod · 0.45

Tested by 2

TestGetEventsEmptyFunction · 0.76
TestGetEventsWithLimitFunction · 0.76