Skip to content

Commit

Permalink
update: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeEirc committed Dec 7, 2020
1 parent 3255b14 commit 48af8b6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion _example/telnet_client/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.15

require (
github.com/LeeEirc/tclientlib v0.0.0
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
)

replace github.com/LeeEirc/tclientlib v0.0.0 => ../../
8 changes: 4 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ func (conf *Config) SetDefaults() {
}
}
if conf.UsernameRegex == nil {
conf.UsernameRegex = usernamePattern
conf.UsernameRegex = DefaultUsernamePattern
}

if conf.PasswordRegex == nil {
conf.PasswordRegex = passwordPattern
conf.PasswordRegex = DefaultPasswordPattern
}

if conf.LoginSuccessRegex == nil {
conf.LoginSuccessRegex = defaultLoginSuccessPattern
conf.LoginSuccessRegex = DefaultLoginSuccessPattern
}
if conf.LoginFailureRegex == nil {
conf.LoginFailureRegex = defaultLoginFailedPattern
conf.LoginFailureRegex = DefaultLoginFailedPattern
}
}

Expand Down
16 changes: 8 additions & 8 deletions const.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ var CodeTOASCII = map[byte]string{
}

const (
loginRegs = "(?i)login:?\\s*$|username:?\\s*$|name:?\\s*$|用户名:?\\s*$|账\\s*号:?\\s*$|user:?\\s*$"
passwordRegs = "(?i)Password:?\\s*$|ssword:?\\s*$|passwd:?\\s*$|密\\s*码:?\\s*$"
FailedRegs = "(?i)incorrect|failed|失败|错误"
DefaultSuccessRegs = "(?i)Last\\s*login|success|成功|#|>|\\$"
usernameRegs = "(?i)login:?\\s*$|username:?\\s*$|name:?\\s*$|用户名:?\\s*$|账\\s*号:?\\s*$|user:?\\s*$"
passwordRegs = "(?i)Password:?\\s*$|ssword:?\\s*$|passwd:?\\s*$|密\\s*码:?\\s*$"
loginFailedRegs = "(?i)incorrect|failed|失败|错误"
loginSuccessRegs = "(?i)Last\\s*login|success|成功|#|>|\\$"
)

var (
usernamePattern, _ = regexp.Compile(loginRegs)
passwordPattern, _ = regexp.Compile(passwordRegs)
defaultLoginFailedPattern, _ = regexp.Compile(FailedRegs)
defaultLoginSuccessPattern, _ = regexp.Compile(DefaultSuccessRegs)
DefaultUsernamePattern = regexp.MustCompile(usernameRegs)
DefaultPasswordPattern = regexp.MustCompile(passwordRegs)
DefaultLoginFailedPattern = regexp.MustCompile(loginFailedRegs)
DefaultLoginSuccessPattern = regexp.MustCompile(loginSuccessRegs)
)

type AuthStatus int
Expand Down

0 comments on commit 48af8b6

Please sign in to comment.