From fd740bc499ebc6d3a381479316f74cdc736d02de Mon Sep 17 00:00:00 2001 From: Jeff Halter <868228+jhalter@users.noreply.github.com> Date: Wed, 17 Jul 2024 15:41:20 -0700 Subject: Extensive refactor, quality of life enhancements * Added ability to reload config, agreement, news, and user accounts without restarting the server by sending SIGHUP to the running process * Added ability to use modern unix or windows line breaks in Agreement.txt and MessageBoard.txt instead of classic MacOS `\r` breaks. * Extensive refactor towards swappable backends for the active server state * Extensive refactored towards making the hotline package generic and re-usable for alternate server implemenations * Fix bug where users whose accounts have been deleted would not be disconnected --- hotline/account.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'hotline/account.go') diff --git a/hotline/account.go b/hotline/account.go index 7b2aafe..7f770b1 100644 --- a/hotline/account.go +++ b/hotline/account.go @@ -14,16 +14,16 @@ type Account struct { Login string `yaml:"Login"` Name string `yaml:"Name"` Password string `yaml:"Password"` - Access accessBitmap `yaml:"Access,flow"` + Access AccessBitmap `yaml:"Access,flow"` readOffset int // Internal offset to track read progress } -func NewAccount(login, name, password string, access accessBitmap) *Account { +func NewAccount(login, name, password string, access AccessBitmap) *Account { return &Account{ Login: login, Name: name, - Password: hashAndSalt([]byte(password)), + Password: HashAndSalt([]byte(password)), Access: access, } } @@ -32,7 +32,7 @@ func NewAccount(login, name, password string, access accessBitmap) *Account { func (a *Account) Read(p []byte) (int, error) { fields := []Field{ NewField(FieldUserName, []byte(a.Name)), - NewField(FieldUserLogin, encodeString([]byte(a.Login))), + NewField(FieldUserLogin, EncodeString([]byte(a.Login))), NewField(FieldUserAccess, a.Access[:]), } @@ -63,8 +63,8 @@ func (a *Account) Read(p []byte) (int, error) { return n, nil } -// hashAndSalt generates a password hash from a users obfuscated plaintext password -func hashAndSalt(pwd []byte) string { +// HashAndSalt generates a password hash from a users obfuscated plaintext password +func HashAndSalt(pwd []byte) string { hash, _ := bcrypt.GenerateFromPassword(pwd, bcrypt.MinCost) return string(hash) -- cgit