more comprehensive regex

This commit is contained in:
kayos@tcp.direct 2021-02-23 05:43:33 -08:00
parent 242ecf02e3
commit bcb5811a5a
2 changed files with 14 additions and 6 deletions

View File

@ -5,6 +5,13 @@ func (c *TelnetClient) Login(login string, password string) (string, error) {
// wait for login
result := ""
out, err := c.ReadUntil(c.denialMsg)
result = out
if err == nil {
lockederr := errors.New("Locked: Denied Entry")
return result, lockederr
}
out, err := c.ReadUntil(c.loginPrompt)
result = out
if err != nil {

View File

@ -45,11 +45,12 @@ func New(tout int, login string, password string, prompt string) *TelnetClient {
}
c := TelnetClient{
Timeout: tout,
login: login,
password: password,
prompt: `(?msi:[\$%#>]$)`,
loginPrompt: `[Uu]ser(\s)?[Nn]ame(\s+)\:(\s+)?$`,
passwordPrompt: `[Pp]ass[Ww]ord(\s+)\:$`,
login: login,
password: password,
prompt: `([\$|%|#|]|(\+>)(\s+)?$)`,
loginPrompt: `([Uu]ser(\s)?|[Nn]ame(\s+)?|[Ll]ogin(\s+)?)\:(\s+)?$`,
passwordPrompt: `[Pp]ass[Ww]ord(\s+)?\:$`,
heatMsg: ``,
closed: false,
Options: make([]int,0),
}
@ -163,4 +164,4 @@ func (c *TelnetClient) RegisterCallback(pattern string, callback func()) error {
// GetBuffer returns current buffer from reader as a string
func (c *TelnetClient) GetBuffer() string {
return c.buf.String()
}
}