9 // User flags are stored as a 2 byte bitmap and represent various user states
11 UserFlagAway = 0 // User is away
12 UserFlagAdmin = 1 // User is admin
13 UserFlagRefusePM = 2 // User refuses private messages
14 UserFlagRefusePChat = 3 // User refuses private chat
17 // FieldOptions flags are sent from v1.5+ clients as part of TranAgreed
19 refusePM = 0 // User has "Refuse private messages" pref set
20 refuseChat = 1 // User has "Refuse private chat" pref set
21 autoResponse = 2 // User has "Automatic response" pref set
27 Flags []byte // Size 2
28 Name string // Variable length user name
31 func (u *User) Read(p []byte) (int, error) {
32 nameLen := make([]byte, 2)
33 binary.BigEndian.PutUint16(nameLen, uint16(len(u.Name)))
39 if len(u.Flags) == 4 {
43 out := append(u.ID[:2], u.Icon[:2]...)
44 out = append(out, u.Flags[:2]...)
45 out = append(out, nameLen...)
46 out = append(out, u.Name...)
48 return copy(p, slices.Concat(
57 func (u *User) Write(p []byte) (int, error) {
58 namelen := int(binary.BigEndian.Uint16(p[6:8]))
62 u.Name = string(p[8 : 8+namelen])
64 return 8 + namelen, nil
67 // encodeString takes []byte s containing cleartext and rotates by 255 into obfuscated cleartext.
68 // The Hotline protocol uses this format for sending passwords over network.
69 // Not secure, but hey, it was the 90s!
70 func encodeString(clearText []byte) []byte {
71 obfuText := make([]byte, len(clearText))
72 for i := 0; i < len(clearText); i++ {
73 obfuText[i] = 255 - clearText[i]