5 "github.com/jhalter/mobius/concat"
8 const GuestAccount = "guest" // default account used when no login is provided for a connection
11 Login string `yaml:"Login"`
12 Name string `yaml:"Name"`
13 Password string `yaml:"Password"`
14 Access *[]byte `yaml:"Access"` // 8 byte bitmap
17 // Payload marshals an account to byte slice
19 // 00 04 // fieldCount?
20 // 00 66 // 102 - fieldUserName
22 // 61 64 6d 69 6e 69 73 74 72 61 74 6f 72 // administrator
23 // 00 69 // 105 fieldUserLogin (encoded)
25 // 9e 9b 92 96 91 // encoded login name
26 // 00 6a // 106 fieldUserPassword
29 // 00 6e // fieldUserAccess
31 // ff d3 cf ef ff 80 00 00
32 func (a *Account) Payload() (out []byte) {
33 nameLen := make([]byte, 2)
34 binary.BigEndian.PutUint16(nameLen, uint16(len(a.Name)))
36 loginLen := make([]byte, 2)
37 binary.BigEndian.PutUint16(loginLen, uint16(len(a.Login)))
40 []byte{0x00, 0x3}, // param count -- always 3
42 []byte{0x00, 0x66}, // fieldUserName
46 []byte{0x00, 0x69}, // fieldUserLogin
48 []byte(NegatedUserString([]byte(a.Login))),
50 []byte{0x00, 0x6e}, // fieldUserAccess