metrics: reduce complexity for AddLoginResult method
fix a gocyclo warning
This commit is contained in:
parent
a6e36e7cad
commit
901cafc6da
1 changed files with 42 additions and 34 deletions
|
@ -830,44 +830,52 @@ func AddLoginAttempt(authMethod string) {
|
|||
}
|
||||
}
|
||||
|
||||
func incLoginOK(authMethod string) {
|
||||
totalLoginOK.Inc()
|
||||
switch authMethod {
|
||||
case loginMethodPublicKey:
|
||||
totalKeyLoginOK.Inc()
|
||||
case loginMethodKeyboardInteractive:
|
||||
totalInteractiveLoginOK.Inc()
|
||||
case loginMethodKeyAndPassword:
|
||||
totalKeyAndPasswordLoginOK.Inc()
|
||||
case loginMethodKeyAndKeyboardInt:
|
||||
totalKeyAndKeyIntLoginOK.Inc()
|
||||
case loginMethodTLSCertificate:
|
||||
totalTLSCertLoginOK.Inc()
|
||||
case loginMethodTLSCertificateAndPwd:
|
||||
totalTLSCertAndPwdLoginOK.Inc()
|
||||
default:
|
||||
totalPasswordLoginOK.Inc()
|
||||
}
|
||||
}
|
||||
|
||||
func incLoginFailed(authMethod string) {
|
||||
totalLoginFailed.Inc()
|
||||
switch authMethod {
|
||||
case loginMethodPublicKey:
|
||||
totalKeyLoginFailed.Inc()
|
||||
case loginMethodKeyboardInteractive:
|
||||
totalInteractiveLoginFailed.Inc()
|
||||
case loginMethodKeyAndPassword:
|
||||
totalKeyAndPasswordLoginFailed.Inc()
|
||||
case loginMethodKeyAndKeyboardInt:
|
||||
totalKeyAndKeyIntLoginFailed.Inc()
|
||||
case loginMethodTLSCertificate:
|
||||
totalTLSCertLoginFailed.Inc()
|
||||
case loginMethodTLSCertificateAndPwd:
|
||||
totalTLSCertAndPwdLoginFailed.Inc()
|
||||
default:
|
||||
totalPasswordLoginFailed.Inc()
|
||||
}
|
||||
}
|
||||
|
||||
// AddLoginResult increments the metrics for login results
|
||||
func AddLoginResult(authMethod string, err error) {
|
||||
if err == nil {
|
||||
totalLoginOK.Inc()
|
||||
switch authMethod {
|
||||
case loginMethodPublicKey:
|
||||
totalKeyLoginOK.Inc()
|
||||
case loginMethodKeyboardInteractive:
|
||||
totalInteractiveLoginOK.Inc()
|
||||
case loginMethodKeyAndPassword:
|
||||
totalKeyAndPasswordLoginOK.Inc()
|
||||
case loginMethodKeyAndKeyboardInt:
|
||||
totalKeyAndKeyIntLoginOK.Inc()
|
||||
case loginMethodTLSCertificate:
|
||||
totalTLSCertLoginOK.Inc()
|
||||
case loginMethodTLSCertificateAndPwd:
|
||||
totalTLSCertAndPwdLoginOK.Inc()
|
||||
default:
|
||||
totalPasswordLoginOK.Inc()
|
||||
}
|
||||
incLoginOK(authMethod)
|
||||
} else {
|
||||
totalLoginFailed.Inc()
|
||||
switch authMethod {
|
||||
case loginMethodPublicKey:
|
||||
totalKeyLoginFailed.Inc()
|
||||
case loginMethodKeyboardInteractive:
|
||||
totalInteractiveLoginFailed.Inc()
|
||||
case loginMethodKeyAndPassword:
|
||||
totalKeyAndPasswordLoginFailed.Inc()
|
||||
case loginMethodKeyAndKeyboardInt:
|
||||
totalKeyAndKeyIntLoginFailed.Inc()
|
||||
case loginMethodTLSCertificate:
|
||||
totalTLSCertLoginFailed.Inc()
|
||||
case loginMethodTLSCertificateAndPwd:
|
||||
totalTLSCertAndPwdLoginFailed.Inc()
|
||||
default:
|
||||
totalPasswordLoginFailed.Inc()
|
||||
}
|
||||
incLoginFailed(authMethod)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue