remove recall

pull/179/head
Simon Let 4 years ago
parent 5c57697850
commit d72fa1d200
No known key found for this signature in database
GPG Key ID: D650C65DD46D431D
  1. 36
      .goreleaser.yml
  2. 2
      Makefile
  3. 151
      cmd/collect/main.go
  4. 35
      pkg/collect/collect.go
  5. 2
      roadmap.md

@ -75,33 +75,6 @@ builds:
- amd64
- arm
- arm64
-
id: "evaluate"
main: ./cmd/evaluate
binary: bin/resh-evaluate
goarch:
- 386
- amd64
- arm
- arm64
-
id: "event"
main: ./cmd/event
binary: bin/resh-event
goarch:
- 386
- amd64
- arm
- arm64
-
id: "inspect"
main: ./cmd/inspect
binary: bin/resh-inspect
goarch:
- 386
- amd64
- arm
- arm64
-
id: "postcollect"
main: ./cmd/postcollect
@ -111,15 +84,6 @@ builds:
- amd64
- arm
- arm64
-
id: "sanitize"
main: ./cmd/sanitize
binary: bin/resh-sanitize
goarch:
- 386
- amd64
- arm
- arm64
-
id: "session-init"
main: ./cmd/session-init

@ -6,7 +6,7 @@ GOFLAGS=-ldflags "-X main.version=${VERSION} -X main.commit=${REVISION}"
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 bin/resh-cli
bin/resh-control bin/resh-config bin/resh-cli
install: build
scripts/install.sh

@ -35,10 +35,6 @@ func main() {
if _, err := toml.DecodeFile(configPath, &config); err != nil {
log.Fatal("Error reading config:", err)
}
// recall command
recall := flag.Bool("recall", false, "Recall command on position --histno")
recallHistno := flag.Int("histno", 0, "Recall command on position --histno")
recallPrefix := flag.String("prefix-search", "", "Recall command based on prefix --prefix-search")
// version
showVersion := flag.Bool("version", false, "Show version and exit")
@ -55,11 +51,6 @@ func main() {
sessionID := flag.String("sessionId", "", "resh generated session id")
recordID := flag.String("recordId", "", "resh generated record id")
// recall metadata
recallActions := flag.String("recall-actions", "", "recall actions that took place before executing the command")
recallStrategy := flag.String("recall-strategy", "", "recall strategy used during recall actions")
recallLastCmdLine := flag.String("recall-last-cmdline", "", "last recalled cmdline")
// posix variables
cols := flag.String("cols", "-1", "$COLUMNS")
lines := flag.String("lines", "-1", "$LINES")
@ -127,10 +118,6 @@ func main() {
")")
os.Exit(3)
}
if *recallPrefix != "" && *recall == false {
log.Println("Option '--prefix-search' only works with '--recall' option - exiting!")
os.Exit(4)
}
realtimeBefore, err := strconv.ParseFloat(*rtb, 64)
if err != nil {
@ -171,85 +158,65 @@ func main() {
// *osReleasePrettyName = "Linux"
// }
if *recall {
rec := records.SlimRecord{
SessionID: *sessionID,
RecallHistno: *recallHistno,
RecallPrefix: *recallPrefix,
}
str, found := collect.SendRecallRequest(rec, strconv.Itoa(config.Port))
if found == false {
os.Exit(1)
}
fmt.Println(str)
} else {
rec := records.Record{
rec := records.Record{
// posix
Cols: *cols,
Lines: *lines,
// core
BaseRecord: records.BaseRecord{
CmdLine: *cmdLine,
ExitCode: *exitCode,
Shell: *shell,
Uname: *uname,
SessionID: *sessionID,
RecordID: *recordID,
// posix
Cols: *cols,
Lines: *lines,
// core
BaseRecord: records.BaseRecord{
RecallHistno: *recallHistno,
CmdLine: *cmdLine,
ExitCode: *exitCode,
Shell: *shell,
Uname: *uname,
SessionID: *sessionID,
RecordID: *recordID,
// posix
Home: *home,
Lang: *lang,
LcAll: *lcAll,
Login: *login,
// Path: *path,
Pwd: *pwd,
ShellEnv: *shellEnv,
Term: *term,
// non-posix
RealPwd: realPwd,
Pid: *pid,
SessionPID: *sessionPid,
Host: *host,
Hosttype: *hosttype,
Ostype: *ostype,
Machtype: *machtype,
Shlvl: *shlvl,
// before after
TimezoneBefore: *timezoneBefore,
RealtimeBefore: realtimeBefore,
RealtimeBeforeLocal: realtimeBeforeLocal,
RealtimeSinceSessionStart: realtimeSinceSessionStart,
RealtimeSinceBoot: realtimeSinceBoot,
GitDir: gitDir,
GitRealDir: gitRealDir,
GitOriginRemote: *gitRemote,
MachineID: collect.ReadFileContent(machineIDPath),
OsReleaseID: *osReleaseID,
OsReleaseVersionID: *osReleaseVersionID,
OsReleaseIDLike: *osReleaseIDLike,
OsReleaseName: *osReleaseName,
OsReleasePrettyName: *osReleasePrettyName,
PartOne: true,
ReshUUID: collect.ReadFileContent(reshUUIDPath),
ReshVersion: version,
ReshRevision: commit,
RecallActionsRaw: *recallActions,
RecallPrefix: *recallPrefix,
RecallStrategy: *recallStrategy,
RecallLastCmdLine: *recallLastCmdLine,
},
}
collect.SendRecord(rec, strconv.Itoa(config.Port), "/record")
Home: *home,
Lang: *lang,
LcAll: *lcAll,
Login: *login,
// Path: *path,
Pwd: *pwd,
ShellEnv: *shellEnv,
Term: *term,
// non-posix
RealPwd: realPwd,
Pid: *pid,
SessionPID: *sessionPid,
Host: *host,
Hosttype: *hosttype,
Ostype: *ostype,
Machtype: *machtype,
Shlvl: *shlvl,
// before after
TimezoneBefore: *timezoneBefore,
RealtimeBefore: realtimeBefore,
RealtimeBeforeLocal: realtimeBeforeLocal,
RealtimeSinceSessionStart: realtimeSinceSessionStart,
RealtimeSinceBoot: realtimeSinceBoot,
GitDir: gitDir,
GitRealDir: gitRealDir,
GitOriginRemote: *gitRemote,
MachineID: collect.ReadFileContent(machineIDPath),
OsReleaseID: *osReleaseID,
OsReleaseVersionID: *osReleaseVersionID,
OsReleaseIDLike: *osReleaseIDLike,
OsReleaseName: *osReleaseName,
OsReleasePrettyName: *osReleasePrettyName,
PartOne: true,
ReshUUID: collect.ReadFileContent(reshUUIDPath),
ReshVersion: version,
ReshRevision: commit,
},
}
collect.SendRecord(rec, strconv.Itoa(config.Port), "/record")
}

@ -20,41 +20,6 @@ type SingleResponse struct {
CmdLine string `json:"cmdline"`
}
// SendRecallRequest to daemon
func SendRecallRequest(r records.SlimRecord, port string) (string, bool) {
recJSON, err := json.Marshal(r)
if err != nil {
log.Fatal("send err 1", err)
}
req, err := http.NewRequest("POST", "http://localhost:"+port+"/recall",
bytes.NewBuffer(recJSON))
if err != nil {
log.Fatal("send err 2", err)
}
req.Header.Set("Content-Type", "application/json")
client := httpclient.New()
resp, err := client.Do(req)
if err != nil {
log.Fatal("resh-daemon is not running - try restarting this terminal")
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal("read response error")
}
log.Println(string(body))
response := SingleResponse{}
err = json.Unmarshal(body, &response)
if err != nil {
log.Fatal("unmarshal resp error: ", err)
}
log.Println(response)
return response.CmdLine, response.Found
}
// SendRecord to daemon
func SendRecord(r records.Record, port, path string) {
recJSON, err := json.Marshal(r)

@ -41,5 +41,3 @@
- :heavy_check_mark: Linux
- :white_check_mark: MacOS *(requires coreutils - `brew install coreutils`)*
- :heavy_check_mark: Provide a tool to sanitize the recorded history

Loading…
Cancel
Save