]> git.r.bdr.sh - rbdr/mobius/blob - access.go
Initial squashed commit
[rbdr/mobius] / 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 func authorize(access *[]byte, accessBit int) bool {
53 if accessBit == accessAlwaysAllow {
54 return true
55 }
56 accessBitmap := big.NewInt(int64(binary.BigEndian.Uint64(*access)))
57
58 return accessBitmap.Bit(63-accessBit) == 1
59 }