fix unmarshal panic

This commit is contained in:
Urko 2023-07-07 23:36:05 +02:00
parent dff505037f
commit 0d4f34f6d5
3 changed files with 6 additions and 6 deletions

View File

@ -33,7 +33,7 @@ func (f *Fail2Ban) FailedAttempt(ip string) {
} }
client.FailedAttempts++ client.FailedAttempts++
if client.FailedAttempts >= 3 { if client.FailedAttempts >= 2 {
client.BlockedUntil = time.Now().Add(10 * time.Minute) client.BlockedUntil = time.Now().Add(10 * time.Minute)
client.FailedAttempts = 0 client.FailedAttempts = 0

View File

@ -8,9 +8,9 @@ import (
) )
type account struct { type account struct {
salt string `prosody:"salt"` Salt string `prosody:"salt"`
storedKey string `prosody:"stored_key"` StoredKey string `prosody:"stored_key"`
iterationCount int `prosody:"iteration_count"` IterationCount int `prosody:"iteration_count"`
} }
func (acc *account) unmarshal(data map[string]interface{}) { func (acc *account) unmarshal(data map[string]interface{}) {

View File

@ -18,13 +18,13 @@ func (p *Prosody) ChangePassword(user string, currentPwd string, newPwd string)
return fmt.Errorf("p.loadAccount %w", err) 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 { if err != nil {
return fmt.Errorf("hashPassword: %w", err) return fmt.Errorf("hashPassword: %w", err)
} }
// Compare the hashes // Compare the hashes
if storedKey != acc.storedKey { if storedKey != acc.StoredKey {
return errors.New("password is incorrect") return errors.New("password is incorrect")
} }