]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/account.go
Update goreleaser config
[rbdr/mobius] / hotline / account.go
index c51162d3c8b70c0388367db9ddbdc4c42c49ce43..4c5a9b98a608810047a8830b01495973be172bda 100644 (file)
@@ -3,7 +3,9 @@ package hotline
 import (
        "encoding/binary"
        "golang.org/x/crypto/bcrypt"
 import (
        "encoding/binary"
        "golang.org/x/crypto/bcrypt"
+       "io"
        "log"
        "log"
+       "slices"
 )
 
 const GuestAccount = "guest" // default account used when no login is provided for a connection
 )
 
 const GuestAccount = "guest" // default account used when no login is provided for a connection
@@ -19,7 +21,7 @@ type Account struct {
 func (a *Account) Read(p []byte) (n int, err error) {
        fields := []Field{
                NewField(FieldUserName, []byte(a.Name)),
 func (a *Account) Read(p []byte) (n int, err error) {
        fields := []Field{
                NewField(FieldUserName, []byte(a.Name)),
-               NewField(FieldUserLogin, negateString([]byte(a.Login))),
+               NewField(FieldUserLogin, encodeString([]byte(a.Login))),
                NewField(FieldUserAccess, a.Access[:]),
        }
 
                NewField(FieldUserAccess, a.Access[:]),
        }
 
@@ -30,13 +32,12 @@ func (a *Account) Read(p []byte) (n int, err error) {
        fieldCount := make([]byte, 2)
        binary.BigEndian.PutUint16(fieldCount, uint16(len(fields)))
 
        fieldCount := make([]byte, 2)
        binary.BigEndian.PutUint16(fieldCount, uint16(len(fields)))
 
-       p = append(p, fieldCount...)
-
+       var fieldBytes []byte
        for _, field := range fields {
        for _, field := range fields {
-               p = append(p, field.Payload()...)
+               fieldBytes = append(fieldBytes, field.Payload()...)
        }
 
        }
 
-       return len(p), nil
+       return copy(p, slices.Concat(fieldCount, fieldBytes)), io.EOF
 }
 
 // hashAndSalt generates a password hash from a users obfuscated plaintext password
 }
 
 // hashAndSalt generates a password hash from a users obfuscated plaintext password