Enforce admission on local messages and feedback exchange
This commit is contained in:
1 parent
635a03bbd8
commit
45f6e4807f
3 files changed
+8
-2
No files matched your search
@@ -305,7 +305,7 @@ int chat_feedback_set(struct UTUN_INSTANCE* inst, const char* channel, const uin
|
||||
memcpy(r.message_id, message_id, 32); if (len) memcpy(r.data, data, len);
|
||||
uint8_t author_key[32];
|
||||
enum ms_author_status status = member_sync_author_key(inst, channel, inst->node_id, author_key);
|
||||
if (status != MS_AUTHOR_ACTIVE) {
|
||||
if (status != MS_AUTHOR_ACTIVE || !topo_node_sqlite_member_allowed(inst->topo_sqlite_db, channel, inst->node_id)) {
|
||||
DEBUG_WARN(DEBUG_CATEGORY_CHAT_SYNC, "feedback: local action denied ch=%s node=%016llx status=%d",
|
||||
channel, (unsigned long long)inst->node_id, status); goto finish;
|
||||
}
|
||||
@@ -455,7 +455,9 @@ static int fb_apply_page(void* ctx, const char* channel, uint64_t peer, const ui
|
||||
|
||||
static int fb_peer(void* ctx, const char* channel, uint64_t peer) {
|
||||
struct UTUN_INSTANCE* inst = ctx; uint8_t key[32];
|
||||
return member_sync_verified_ed25519(inst, channel, peer, key) == 0;
|
||||
return topo_node_sqlite_member_allowed(inst->topo_sqlite_db, channel, inst->node_id) &&
|
||||
topo_node_sqlite_member_allowed(inst->topo_sqlite_db, channel, peer) &&
|
||||
member_sync_verified_ed25519(inst, channel, peer, key) == 0;
|
||||
}
|
||||
|
||||
static const struct merkle_sync_data_ops fb_ops = {
|
||||
|
||||
@@ -129,6 +129,9 @@ int chat_core_submit_message(struct UTUN_INSTANCE* inst, struct chat_msg_submit*
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "%s: invalid message submission", CC_ID); return -1;
|
||||
}
|
||||
memset(req->message_id, 0, sizeof(req->message_id));
|
||||
if (!topo_node_sqlite_member_allowed(cc->db, req->channel_id, inst->node_id)) {
|
||||
DEBUG_WARN(DEBUG_CATEGORY_CHAT, "message denied: local member excluded ch=%s", req->channel_id); return -1;
|
||||
}
|
||||
struct DB_SYNC_INSTANCE* si = si_find(inst, req->channel_id);
|
||||
if (!si) { DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "%s: no history for ch=%s", CC_ID, req->channel_id); return -1; }
|
||||
|
||||
|
||||
@@ -229,6 +229,7 @@ int group_policy_refresh(struct UTUN_INSTANCE* inst, const char* channel) {
|
||||
if (g && conn && m[i].allowed && conn->links_up && !conn->close_requested) topo_group_new_conn(g, conn);
|
||||
}
|
||||
if (changes) {
|
||||
merkle_sync_revalidate_peers(inst, MT_DATA_FEEDBACK, channel);
|
||||
db_sync_members_changed(inst, channel);
|
||||
uint8_t evt[21]; evt[0] = (uint8_t)strlen(channel); memcpy(evt + 1, channel, evt[0]);
|
||||
chat_event_post(inst, CHAT_EVT_MEMBERS_CHANGED, evt, evt[0] + 1);
|
||||
|
||||
Reference in new issue
Block a user