notifier plugin: add support for login succeeded events

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2024-04-10 18:39:08 +02:00
parent e8140d7310
commit 456517af87
15 changed files with 58 additions and 24 deletions

View File

@@ -331,18 +331,28 @@ func (m *Manager) NotifyLogEvent(event notifier.LogEventType, protocol, username
m.notifLock.RLock()
defer m.notifLock.RUnlock()
e := &notifier.LogEvent{
Timestamp: time.Now().UnixNano(),
Event: event,
Protocol: protocol,
Username: username,
IP: ip,
Message: err.Error(),
Role: role,
}
var e *notifier.LogEvent
for _, n := range m.notifiers {
n.notifyLogEvent(e)
if util.Contains(n.config.NotifierOptions.LogEvents, int(event)) {
if e == nil {
message := ""
if err != nil {
message = err.Error()
}
e = &notifier.LogEvent{
Timestamp: time.Now().UnixNano(),
Event: event,
Protocol: protocol,
Username: username,
IP: ip,
Message: message,
Role: role,
}
}
n.notifyLogEvent(e)
}
}
}