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