]> git.r.bdr.sh - rbdr/mobius/blob - hotline/account.go
minor: v0.3.0
[rbdr/mobius] / hotline / account.go
1 package hotline
2
3 import (
4 "github.com/jhalter/mobius/concat"
5 )
6
7 const GuestAccount = "guest" // default account used when no login is provided for a connection
8
9 type Account struct {
10 Login string `yaml:"Login"`
11 Name string `yaml:"Name"`
12 Password string `yaml:"Password"`
13 Access *[]byte `yaml:"Access"` // 8 byte bitmap
14 }
15
16 // MarshalBinary marshals an Account to byte slice
17 func (a *Account) MarshalBinary() (out []byte) {
18 return concat.Slices(
19 []byte{0x00, 0x3}, // param count -- always 3
20 NewField(fieldUserName, []byte(a.Name)).Payload(),
21 NewField(fieldUserLogin, negateString([]byte(a.Login))).Payload(),
22 NewField(fieldUserAccess, *a.Access).Payload(),
23 )
24 }