diff --git a/cmd/daemon/run-server.go b/cmd/daemon/run-server.go index 0be0ec8..d1a87b7 100644 --- a/cmd/daemon/run-server.go +++ b/cmd/daemon/run-server.go @@ -36,8 +36,8 @@ func runServer(config cfg.Config, reshHistoryPath, bashHistoryPath, zshHistoryPa sessionDropSubscribers = append(sessionDropSubscribers, histfileSessionsToDrop) histfileSignals := make(chan os.Signal) signalSubscribers = append(signalSubscribers, histfileSignals) - maxHistSize := 10000 // lines - minHistSizeKB := 100 // roughly lines + maxHistSize := 10000 // lines + minHistSizeKB := 2000 // roughly lines histfileBox := histfile.New(histfileRecords, histfileSessionsToDrop, reshHistoryPath, bashHistoryPath, zshHistoryPath, maxHistSize, minHistSizeKB, diff --git a/pkg/histlist/histlist.go b/pkg/histlist/histlist.go index 0f5f621..a3f4334 100644 --- a/pkg/histlist/histlist.go +++ b/pkg/histlist/histlist.go @@ -30,7 +30,7 @@ func Copy(hl Histlist) Histlist { // AddCmdLine to the histlist func (h *Histlist) AddCmdLine(cmdLine string) { - lenBefore := len(h.List) + // lenBefore := len(h.List) // lookup idx, found := h.LastIndex[cmdLine] if found { @@ -53,7 +53,7 @@ func (h *Histlist) AddCmdLine(cmdLine string) { h.LastIndex[cmdLine] = len(h.List) // append new cmdline h.List = append(h.List, cmdLine) - log.Println("histlist: Added cmdLine:", cmdLine, "; history length:", lenBefore, "->", len(h.List)) + // log.Println("histlist: Added cmdLine:", cmdLine, "; history length:", lenBefore, "->", len(h.List)) } // AddHistlist contents of another histlist to this histlist diff --git a/pkg/sesshist/sesshist.go b/pkg/sesshist/sesshist.go index 0aefa91..ac8bd92 100644 --- a/pkg/sesshist/sesshist.go +++ b/pkg/sesshist/sesshist.go @@ -58,13 +58,28 @@ func (s *Dispatch) recordAdder(recordsToAdd chan records.Record) { if record.PartOne { log.Println("sesshist: got record to add - " + record.CmdLine) s.addRecentRecord(record.SessionID, record) + } else { + // this inits session on RESH update + s.checkSession(record.SessionID, record.Shell) } // TODO: we will need to handle part2 as well eventually } } +func (s *Dispatch) checkSession(sessionID, shell string) { + s.mutex.RLock() + _, found := s.sessions[sessionID] + s.mutex.RUnlock() + if found == false { + err := s.initSession(sessionID, shell) + if err != nil { + log.Println("sesshist: Error while checking session:", err) + } + } +} + // InitSession struct -func (s *Dispatch) initSession(sessionID string, shell string) error { +func (s *Dispatch) initSession(sessionID, shell string) error { log.Println("sesshist: initializing session - " + sessionID) s.mutex.RLock() _, found := s.sessions[sessionID]