X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/1632959187e9c7d8946126914af99270fc14d40a..f85c2d086919ca24cea8608538594a2f8cc25fd8:/hotline/access.go diff --git a/hotline/access.go b/hotline/access.go index ae72780..90740fc 100644 --- a/hotline/access.go +++ b/hotline/access.go @@ -1,31 +1,25 @@ package hotline -import ( - "encoding/binary" - "math/big" -) - const ( - accessDeleteFile = 0 // File System Maintenance: Can Delete Files - accessUploadFile = 1 // File System Maintenance: Can Upload Files - accessDownloadFile = 2 // File System Maintenance: Can Download Files - accessRenameFile = 3 // File System Maintenance: Can Rename Files - accessMoveFile = 4 // File System Maintenance: Can Move Files - accessCreateFolder = 5 // File System Maintenance: Can Create Folders - accessDeleteFolder = 6 // File System Maintenance: Can Delete Folders - accessRenameFolder = 7 // File System Maintenance: Can Rename Folders - accessMoveFolder = 8 // File System Maintenance: Can Move Folders - accessReadChat = 9 // Chat: Can Read Chat - accessSendChat = 10 // Chat: Can Send Chat - accessOpenChat = 11 // Chat: Can Initial Private Chat - accessCloseChat = 12 // Present in the Hotline 1.9 protocol documentation, but seemingly unused - accessShowInList = 13 // Present in the Hotline 1.9 protocol documentation, but seemingly unused - accessCreateUser = 14 // User Maintenance: Can Create Accounts - accessDeleteUser = 15 // User Maintenance: Can Delete Accounts - accessOpenUser = 16 // User Maintenance: Can Read Accounts - accessModifyUser = 17 // User Maintenance: Can Modify Accounts - accessChangeOwnPass = 18 // Present in the Hotline 1.9 protocol documentation, but seemingly unused - accessSendPrivMsg = 19 // Messaging: Can Send Messages + accessDeleteFile = 0 // File System Maintenance: Can Delete Files + accessUploadFile = 1 // File System Maintenance: Can Upload Files + accessDownloadFile = 2 // File System Maintenance: Can Download Files + accessRenameFile = 3 // File System Maintenance: Can Rename Files + accessMoveFile = 4 // File System Maintenance: Can Move Files + accessCreateFolder = 5 // File System Maintenance: Can Create Folders + accessDeleteFolder = 6 // File System Maintenance: Can Delete Folders + accessRenameFolder = 7 // File System Maintenance: Can Rename Folders + accessMoveFolder = 8 // File System Maintenance: Can Move Folders + accessReadChat = 9 // Chat: Can Read Chat + accessSendChat = 10 // Chat: Can Send Chat + accessOpenChat = 11 // Chat: Can Initial Private Chat + // accessCloseChat = 12 // Present in the Hotline 1.9 protocol documentation, but seemingly unused + // accessShowInList = 13 // Present in the Hotline 1.9 protocol documentation, but seemingly unused + accessCreateUser = 14 // User Maintenance: Can Create Accounts + accessDeleteUser = 15 // User Maintenance: Can Delete Accounts + accessOpenUser = 16 // User Maintenance: Can Read Accounts + accessModifyUser = 17 // User Maintenance: Can Modify Accounts + // accessChangeOwnPass = 18 // Present in the Hotline 1.9 protocol documentation, but seemingly unused accessNewsReadArt = 20 // News: Can Read Articles accessNewsPostArt = 21 // News: Can Post Articles accessDisconUser = 22 // User Maintenance: Can Disconnect Users (Note: Turns username red in user list) @@ -44,6 +38,7 @@ const ( accessNewsDeleteCat = 35 // News: Can Delete Categories accessNewsCreateFldr = 36 // News: Can Create News Bundles accessNewsDeleteFldr = 37 // News: Can Delete News Bundles + accessSendPrivMsg = 40 // Messaging: Can Send Messages (Note: 1.9 protocol doc incorrectly says this is bit 19) ) type accessBitmap [8]byte @@ -52,10 +47,6 @@ 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 { - bits := big.NewInt(int64(binary.BigEndian.Uint64(*access))) - - return bits.Bit(63-accessBit) == 1 +func (bits *accessBitmap) IsSet(i int) bool { + return bits[i/8]&(1<