7 // User flags are stored as a 2 byte bitmap with the following values:
9 userFlagAway = 0 // User is away
10 userFlagAdmin = 1 // User is admin
11 userFlagRefusePM = 2 // User refuses private messages
12 userFLagRefusePChat = 3 // User refuses private chat
18 Flags []byte // Size 2
19 Name string // Variable length user name
22 func (u User) Payload() []byte {
23 nameLen := make([]byte, 2)
24 binary.BigEndian.PutUint16(nameLen, uint16(len(u.Name)))
30 if len(u.Flags) == 4 {
34 out := append(u.ID[:2], u.Icon[:2]...)
35 out = append(out, u.Flags[:2]...)
36 out = append(out, nameLen...)
37 out = append(out, u.Name...)
42 func ReadUser(b []byte) (*User, error) {
52 // DecodeUserString decodes an obfuscated user string from a client
53 // e.g. 98 8a 9a 8c 8b => "guest"
54 func DecodeUserString(obfuText []byte) (clearText string) {
55 for _, char := range obfuText {
56 clearText += string(rune(255 - uint(char)))
61 // negateString takes []byte s containing cleartext and rotates by 255 into obfuscated cleartext.
62 // The Hotline protocol uses this format for sending passwords over network.
63 // Not secure, but hey, it was the 90s!
64 func negateString(clearText []byte) []byte {
65 obfuText := make([]byte, len(clearText))
66 for i := 0; i < len(clearText); i++ {
67 obfuText[i] = 255 - clearText[i]