]> git.r.bdr.sh - rbdr/mobius/blob - hotline/access.go
Implement handling of special case Dropbox and Upload folders
[rbdr/mobius] / hotline / access.go
1 package hotline
2
3 import (
4 "encoding/binary"
5 "math/big"
6 )
7
8 const (
9 accessAlwaysAllow = -1 // Some transactions are always allowed
10
11 // File System Maintenance
12 accessDeleteFile = 0
13 accessUploadFile = 1
14 accessDownloadFile = 2 // Can Download Files
15 accessRenameFile = 3
16 accessMoveFile = 4
17 accessCreateFolder = 5
18 accessDeleteFolder = 6
19 accessRenameFolder = 7
20 accessMoveFolder = 8
21 accessReadChat = 9
22 accessSendChat = 10
23 accessOpenChat = 11
24 // accessCloseChat = 12 // Documented but unused?
25 // accessShowInList = 13 // Documented but unused?
26 accessCreateUser = 14
27 accessDeleteUser = 15
28 accessOpenUser = 16
29 accessModifyUser = 17
30 // accessChangeOwnPass = 18 // Documented but unused?
31 // accessSendPrivMsg = 19 // This doesn't do what it seems like it should do. TODO: Investigate
32 accessNewsReadArt = 20
33 accessNewsPostArt = 21
34 accessDisconUser = 22 // Toggles red user name in user list
35 accessCannotBeDiscon = 23
36 accessGetClientInfo = 24
37 accessUploadAnywhere = 25
38 // accessAnyName = 26
39 // accessNoAgreement = 27
40 // accessSetFileComment = 28
41 // accessSetFolderComment = 29
42 accessViewDropBoxes = 30
43 accessMakeAlias = 31
44 accessBroadcast = 32
45 accessNewsDeleteArt = 33
46 accessNewsCreateCat = 34
47 // accessNewsDeleteCat = 35
48 accessNewsCreateFldr = 36
49 // accessNewsDeleteFldr = 37
50 )
51
52 type accessBitmap [8]byte
53
54 func (bits *accessBitmap) Set(i int) {
55 bits[i/8] |= 1 << uint(7-i%8)
56 }
57
58 // authorize checks if 64 bit access slice contain has accessBit set
59 // TODO: refactor to use accessBitmap type
60 func authorize(access *[]byte, accessBit int) bool {
61 if accessBit == accessAlwaysAllow {
62 return true
63 }
64 bits := big.NewInt(int64(binary.BigEndian.Uint64(*access)))
65
66 return bits.Bit(63-accessBit) == 1
67 }