mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-05-14 21:15:14 +00:00
* simple_sensor: redesigned permissions
* companion: PUSH_CODE_LOGIN_SUCCESS now has extra byte in frame for ACL permissions
This commit is contained in:
@@ -23,22 +23,29 @@
|
||||
#include <RTClib.h>
|
||||
#include <target.h>
|
||||
|
||||
#define PERM_IS_ADMIN 0x8000
|
||||
#define PERM_GET_TELEMETRY 0x0001
|
||||
#define PERM_GET_MIN_MAX_AVG 0x0002
|
||||
#define PERM_RECV_ALERTS_LO 0x0100 // low priority alerts
|
||||
#define PERM_RECV_ALERTS_HI 0x0200 // high priority alerts
|
||||
#define PERM_ACL_ROLE_MASK 3 // lower 2 bits
|
||||
#define PERM_ACL_GUEST 0
|
||||
#define PERM_ACL_LEVEL1 1
|
||||
#define PERM_ACL_LEVEL2 2
|
||||
#define PERM_ACL_LEVEL3 3 // admin
|
||||
|
||||
#define PERM_GET_TELEMETRY (1 << 2)
|
||||
#define PERM_GET_OTHER_STATS (1 << 3)
|
||||
#define PERM_RESERVED1 (1 << 4)
|
||||
#define PERM_RESERVED2 (1 << 5)
|
||||
#define PERM_RECV_ALERTS_LO (1 << 6) // low priority alerts
|
||||
#define PERM_RECV_ALERTS_HI (1 << 7) // high priority alerts
|
||||
|
||||
struct ContactInfo {
|
||||
mesh::Identity id;
|
||||
uint16_t permissions;
|
||||
uint8_t permissions;
|
||||
int8_t out_path_len;
|
||||
uint8_t out_path[MAX_PATH_SIZE];
|
||||
uint8_t shared_secret[PUB_KEY_SIZE];
|
||||
uint32_t last_timestamp; // by THEIR clock (transient)
|
||||
uint32_t last_activity; // by OUR clock (transient)
|
||||
|
||||
bool isAdmin() const { return (permissions & PERM_IS_ADMIN) != 0; }
|
||||
bool isAdmin() const { return (permissions & PERM_ACL_ROLE_MASK) == PERM_ACL_LEVEL3; }
|
||||
};
|
||||
|
||||
#ifndef FIRMWARE_BUILD_DATE
|
||||
@@ -151,10 +158,10 @@ private:
|
||||
void loadContacts();
|
||||
void saveContacts();
|
||||
uint8_t handleLoginReq(const mesh::Identity& sender, const uint8_t* secret, uint32_t sender_timestamp, const uint8_t* data);
|
||||
uint8_t handleRequest(uint16_t perms, uint32_t sender_timestamp, uint8_t req_type, uint8_t* payload, size_t payload_len);
|
||||
uint8_t handleRequest(uint8_t perms, uint32_t sender_timestamp, uint8_t req_type, uint8_t* payload, size_t payload_len);
|
||||
mesh::Packet* createSelfAdvert();
|
||||
ContactInfo* putContact(const mesh::Identity& id);
|
||||
void applyContactPermissions(const uint8_t* pubkey, uint16_t perms);
|
||||
void applyContactPermissions(const uint8_t* pubkey, uint8_t perms);
|
||||
|
||||
void sendAlert(ContactInfo* c, Trigger* t);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user