ssh: fix shell regex

* from ssh videos I found on youtube, the @ symbol might not be present in prompt, so make it optional
* fix typo of 0-0 instead of 0-9 (all numbers are possible in the prompt)
This commit is contained in:
Greg T. Wallace 2024-06-18 21:30:40 -04:00
parent 7bf70c4d71
commit 208827f636

View file

@ -11,8 +11,8 @@ func scanAPCShell(data []byte, atEOF bool) (advance int, token []byte, err error
return 0, nil, nil return 0, nil, nil
} }
// regex for shell prompt (e.g., `apc@apc>`) // regex for shell prompt (e.g., `apc@apc>`, `apc>`, `some@dev>`, `other123>`, etc.)
re := regexp.MustCompile(`(\r\n|\r|\n)[A-Za-z0-0.]+@[A-Za-z0-0.]+>`) re := regexp.MustCompile(`(\r\n|\r|\n)([A-Za-z0-9.]+@?)?[A-Za-z0-9.]+>`)
// find match for prompt // find match for prompt
if index := re.FindStringIndex(string(data)); index != nil { if index := re.FindStringIndex(string(data)); index != nil {