new: implemented GET /api/events route (ref #5).

This commit is contained in:
evilsocket 2018-01-08 05:39:34 +01:00
commit 269d7d845b
14 changed files with 172 additions and 38 deletions

View file

@ -18,16 +18,18 @@ type Module interface {
}
type SessionModule struct {
Session *Session
Started bool
StatusLock *sync.Mutex
Name string `json:"name"`
Session *Session `json:"-"`
Started bool `json:"started"`
StatusLock *sync.Mutex `json:"-"`
handlers []ModuleHandler
params map[string]*ModuleParam
}
func NewSessionModule(s *Session) SessionModule {
func NewSessionModule(name string, s *Session) SessionModule {
m := SessionModule{
Name: name,
Session: s,
Started: false,
StatusLock: &sync.Mutex{},
@ -70,6 +72,12 @@ func (m *SessionModule) SetRunning(running bool) {
m.StatusLock.Lock()
defer m.StatusLock.Unlock()
m.Started = running
if running {
m.Session.Events.Add("mod.started", m.Name)
} else {
m.Session.Events.Add("mod.stopped", m.Name)
}
}
func (m *SessionModule) OnSessionStarted(s *Session) {