more comprehensive regex
This commit is contained in:
parent
242ecf02e3
commit
bcb5811a5a
7
login.go
7
login.go
|
@ -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 {
|
||||
|
|
13
telnet.go
13
telnet.go
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue