fix: Filters from list and regex both match (#2)

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2023-01-20 11:17:44 +01:00
commit 9cff851021
No known key found for this signature in database
GPG key ID: A2EB1F2CA8E3F677
6 changed files with 254 additions and 41 deletions

View file

@ -60,3 +60,21 @@ func (s *Session) IsIdle() bool {
}
return false
}
// Equal returns true when two sessions share the same process id
func (s *Session) Equal(session *Session) bool {
if s.Pid == 0 {
return s.User == session.User && s.Db == session.Db && s.Client == session.Client
}
return s.Pid == session.Pid
}
// InSlice returns true when this sessions in present in the slice
func (s *Session) InSlice(sessions []*Session) bool {
for _, session := range sessions {
if s.Equal(session) {
return true
}
}
return false
}