aboutsummaryrefslogtreecommitdiff
path: root/hotline/account.go
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2024-07-17 15:41:20 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2024-07-17 15:42:37 -0700
commitfd740bc499ebc6d3a381479316f74cdc736d02de (patch)
treee77563ce0997e51debaec75c9f7a053759ca3a0a /hotline/account.go
parent80aed6b19ff0b0927670e459ce5cc7a16ef047ec (diff)
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
Diffstat (limited to 'hotline/account.go')
-rw-r--r--hotline/account.go12
1 files changed, 6 insertions, 6 deletions
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)