From 0d4f34f6d529f3b53f3223db9deea8b4ea153bde Mon Sep 17 00:00:00 2001 From: Urko Date: Fri, 7 Jul 2023 23:36:05 +0200 Subject: [PATCH] fix unmarshal panic --- internal/services/fail2ban/fail.go | 2 +- internal/services/prosody/account.go | 6 +++--- internal/services/prosody/change_password.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/services/fail2ban/fail.go b/internal/services/fail2ban/fail.go index 9279714..6ccb626 100644 --- a/internal/services/fail2ban/fail.go +++ b/internal/services/fail2ban/fail.go @@ -33,7 +33,7 @@ func (f *Fail2Ban) FailedAttempt(ip string) { } client.FailedAttempts++ - if client.FailedAttempts >= 3 { + if client.FailedAttempts >= 2 { client.BlockedUntil = time.Now().Add(10 * time.Minute) client.FailedAttempts = 0 diff --git a/internal/services/prosody/account.go b/internal/services/prosody/account.go index b0cc325..531f87d 100644 --- a/internal/services/prosody/account.go +++ b/internal/services/prosody/account.go @@ -8,9 +8,9 @@ import ( ) type account struct { - salt string `prosody:"salt"` - storedKey string `prosody:"stored_key"` - iterationCount int `prosody:"iteration_count"` + Salt string `prosody:"salt"` + StoredKey string `prosody:"stored_key"` + IterationCount int `prosody:"iteration_count"` } func (acc *account) unmarshal(data map[string]interface{}) { diff --git a/internal/services/prosody/change_password.go b/internal/services/prosody/change_password.go index d2a6d2b..72afe9e 100644 --- a/internal/services/prosody/change_password.go +++ b/internal/services/prosody/change_password.go @@ -18,13 +18,13 @@ func (p *Prosody) ChangePassword(user string, currentPwd string, newPwd string) return fmt.Errorf("p.loadAccount %w", err) } - storedKey, err := hashPassword(currentPwd, acc.salt, acc.iterationCount) + storedKey, err := hashPassword(currentPwd, acc.Salt, acc.IterationCount) if err != nil { return fmt.Errorf("hashPassword: %w", err) } // Compare the hashes - if storedKey != acc.storedKey { + if storedKey != acc.StoredKey { return errors.New("password is incorrect") }