add debug conf, fix minor sesshist request issue, fixes

pull/58/head
Simon Let 6 years ago
parent 9a35e44d42
commit 75f46957f0
  1. 4
      Makefile
  2. 4
      cmd/daemon/main.go
  3. 10
      cmd/daemon/recall.go
  4. 2
      cmd/postcollect/main.go
  5. 6
      conf/config-dev.toml
  6. 5
      scripts/hooks.sh

@ -42,8 +42,10 @@ sanitize:
build: submodules bin/resh-session-init bin/resh-collect bin/resh-postcollect bin/resh-daemon\
bin/resh-evaluate bin/resh-sanitize bin/resh-control bin/resh-config bin/resh-inspect
install: build
install: build conf/config-dev.toml
scripts/install.sh
# Dev config
cp -f conf/config-dev.toml ~/.config/
test_go:
# Running tests

@ -23,6 +23,9 @@ var version string
// commit from git set during build
var commit string
// Debug switch
var Debug = false
func main() {
log.Println("Daemon starting... \n" +
"version: " + version +
@ -51,6 +54,7 @@ func main() {
return
}
if config.Debug {
Debug = true
log.SetFlags(log.LstdFlags | log.Lmicroseconds)
}

@ -17,8 +17,10 @@ type recallHandler struct {
}
func (h *recallHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if Debug {
log.Println("/recall START")
log.Println("/recall reading body ...")
}
jsn, err := ioutil.ReadAll(r.Body)
if err != nil {
log.Println("Error reading the body", err)
@ -26,14 +28,18 @@ func (h *recallHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
rec := records.SlimRecord{}
if Debug {
log.Println("/recall unmarshaling record ...")
}
err = json.Unmarshal(jsn, &rec)
if err != nil {
log.Println("Decoding error:", err)
log.Println("Payload:", jsn)
return
}
if Debug {
log.Println("/recall recalling ...")
}
found := true
cmd, err := h.sesshistDispatch.Recall(rec.SessionID, rec.RecallHistno, rec.RecallPrefix)
if err != nil {
@ -43,15 +49,19 @@ func (h *recallHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
cmd = ""
}
resp := collect.SingleResponse{CmdLine: cmd, Found: found}
if Debug {
log.Println("/recall marshaling response ...")
}
jsn, err = json.Marshal(&resp)
if err != nil {
log.Println("Encoding error:", err)
log.Println("Response:", resp)
return
}
if Debug {
log.Println(string(jsn))
log.Println("/recall writing response ...")
}
w.Write(jsn)
log.Println("/recall END - sess id:", rec.SessionID, " - histno:", rec.RecallHistno, " -> ", cmd, " (found:", found, ")")
}

@ -45,6 +45,7 @@ func main() {
exitCode := flag.Int("exitCode", -1, "exit code")
sessionID := flag.String("sessionId", "", "resh generated session id")
shlvl := flag.Int("shlvl", -1, "$SHLVL")
shell := flag.String("shell", "", "actual shell")
// posix variables
pwdAfter := flag.String("pwdAfter", "", "$PWD after command")
@ -118,6 +119,7 @@ func main() {
ExitCode: *exitCode,
SessionID: *sessionID,
Shlvl: *shlvl,
Shell: *shell,
PwdAfter: *pwdAfter,

@ -0,0 +1,6 @@
port = 2627
sesswatchPeriodSeconds = 120
sesshistInitHistorySize = 1000
debug = true
bindArrowKeysBash = false
bindArrowKeysZsh = true

@ -3,7 +3,9 @@ __resh_reset_variables() {
__RESH_HISTNO=0
__RESH_HISTNO_MAX=""
__RESH_HISTNO_ZERO_LINE=""
__RESH_HIST_PREV_LINE=""
__RESH_HIST_PREV_LINE="" # deprecated
__RESH_HIST_PREV_CURSOR="" # deprecated
__RESH_HIST_PREV_PREFIX=""
__RESH_HIST_RECALL_ACTIONS=""
__RESH_HIST_NO_PREFIX_MODE=0
__RESH_HIST_RECALL_STRATEGY=""
@ -148,6 +150,7 @@ __resh_precmd() {
-realtimeBefore "$__RESH_RT_BEFORE" \
-exitCode "$__RESH_EXIT_CODE" \
-sessionId "$__RESH_SESSION_ID" \
-shell "$__RESH_SHELL" \
-shlvl "$__RESH_SHLVL" \
-pwdAfter "$__RESH_PWD_AFTER" \
-gitCdupAfter "$__RESH_GIT_CDUP_AFTER" \

Loading…
Cancel
Save