Better tracking of SFTP events

This commit is contained in:
DaneEveritt
2022-07-10 14:30:32 -04:00
parent 59fbd2bcea
commit f28e06267c
9 changed files with 331 additions and 60 deletions

View File

@@ -82,6 +82,10 @@ func (ra RequestActivity) IP() string {
return ra.ip
}
func (ra *RequestActivity) User() string {
return ra.user
}
// SetUser clones the RequestActivity struct and sets a new user value on the copy
// before returning it.
func (ra RequestActivity) SetUser(u string) RequestActivity {

View File

@@ -52,6 +52,24 @@ func (m *Manager) Client() remote.Client {
return m.client
}
// Len returns the count of servers stored in the manager instance.
func (m *Manager) Len() int {
m.mu.RLock()
defer m.mu.RUnlock()
return len(m.servers)
}
// Keys returns all of the server UUIDs stored in the manager set.
func (m *Manager) Keys() []string {
m.mu.RLock()
defer m.mu.RUnlock()
keys := make([]string, len(m.servers))
for i, s := range m.servers {
keys[i] = s.ID()
}
return keys
}
// Put replaces all the current values in the collection with the value that
// is passed through.
func (m *Manager) Put(s []*Server) {