M5: moderation, permissions, channel CRUD, in-app account management
- Server-side moderation & permissions (kick/ban/move/server-mute, channel CRUD). - Database schema v2: channels, bans; BLAKE2b channel passwords, Argon2id accounts. - C ABI additions and client-side handling (vc_kick_user, vc_ban_user, vc_set_permission, vc_set_server_mute, vc_move_user, vc_create/edit/delete_channel, vc_create/reset/delete/list_account). - vccli flags for all M5 operations plus --username/--password auth. - Four new tests covering permissions, kick/ban/move/mute, admin accounts, channel CRUD. - Docs: protocol.md envelope updates, security.md channel-password hashing, PROGRESS.md.
This commit is contained in:
@@ -127,7 +127,7 @@ typedef enum vc_event_type {
|
||||
VC_EVENT_TALK_STATE = 9, /* user_id, stream_id, u32a = talking(0/1) */
|
||||
VC_EVENT_ERROR = 10, /* result, text */
|
||||
VC_EVENT_DISCONNECTED = 11, /* result, text = reason */
|
||||
/* M4 additions — appended, not inserted, to keep existing values stable. */
|
||||
/* M4 additions — appended, not inserted, to keep existing enum values stable. */
|
||||
VC_EVENT_JOIN_RESULT = 12, /* result (VC_OK/VC_ERR_*), channel_id, text = error on
|
||||
failure. Reply to vc_join_channel(). */
|
||||
VC_EVENT_SERVER_IDENTITY = 13, /* u32a = vc_tofu_status, text = hex-encoded TLS leaf-cert
|
||||
@@ -136,6 +136,13 @@ typedef enum vc_event_type {
|
||||
attempt, right after the TLS handshake succeeds. The
|
||||
connection is held open until vc_confirm_server_identity()
|
||||
is called. */
|
||||
/* M5 additions — appended, not inserted. */
|
||||
VC_EVENT_GENERIC_RESULT = 14, /* result, u32a = server error code, text = message. Reply
|
||||
to vc_kick_user/vc_ban_user/vc_set_permission/
|
||||
vc_move_user/vc_create_channel/vc_edit_channel/
|
||||
vc_delete_channel/vc_create_account/vc_reset_password/
|
||||
vc_delete_account. */
|
||||
VC_EVENT_ACCOUNT_LIST = 15, /* Reply to vc_list_accounts. */
|
||||
} vc_event_type;
|
||||
|
||||
/* TOFU server-identity classification (M4) — see VC_EVENT_SERVER_IDENTITY and
|
||||
@@ -216,6 +223,30 @@ typedef struct vc_audio_config {
|
||||
uint32_t complexity; /* 0..10 */
|
||||
} vc_audio_config;
|
||||
|
||||
/* M5: permission bitset (mirrors protocol Permissions). */
|
||||
typedef struct vc_permissions {
|
||||
int can_create_temp_channel; /* bool */
|
||||
int can_kick; /* bool */
|
||||
int can_ban; /* bool */
|
||||
int can_move_users; /* bool */
|
||||
int can_admin_accounts; /* bool */
|
||||
int is_admin; /* bool */
|
||||
} vc_permissions;
|
||||
|
||||
/* M5: channel creation/edition descriptor. */
|
||||
typedef struct vc_channel_info {
|
||||
uint32_t id; /* 0 = new channel for create */
|
||||
uint32_t parent_id; /* 0 = root */
|
||||
const char* name;
|
||||
const char* topic;
|
||||
int password_protected; /* bool */
|
||||
const char* password; /* nullable; ignored if password_protected == 0 */
|
||||
uint32_t max_users; /* 0 = unlimited */
|
||||
uint32_t sort_order;
|
||||
/* Audio config — 0/NULL fields use server defaults. */
|
||||
vc_audio_config audio;
|
||||
} vc_channel_info;
|
||||
|
||||
typedef struct vc_device {
|
||||
const char* id;
|
||||
const char* name;
|
||||
@@ -370,6 +401,32 @@ VC_API vc_result vc_confirm_server_identity(vc_client* c, int accept /* bool */)
|
||||
VC_API vc_result vc_get_server_identity_display(vc_client* c, char* out_buf, size_t buf_cap,
|
||||
size_t* out_len);
|
||||
|
||||
/* ── M5: Moderation & admin ─────────────────────────────────────────────────
|
||||
* All calls are async; the result arrives as VC_EVENT_GENERIC_RESULT (or
|
||||
* VC_EVENT_ACCOUNT_LIST for vc_list_accounts). They require VC_STATE_CONNECTED and,
|
||||
* on the server side, the appropriate permission. */
|
||||
|
||||
VC_API vc_result vc_kick_user(vc_client* c, uint32_t user_id, const char* reason);
|
||||
VC_API vc_result vc_ban_user(vc_client* c, uint32_t user_id, const char* reason,
|
||||
uint64_t expires_unix_ms);
|
||||
VC_API vc_result vc_set_permission(vc_client* c, uint32_t user_id,
|
||||
const vc_permissions* perms);
|
||||
VC_API vc_result vc_set_server_mute(vc_client* c, uint32_t user_id, int muted, int deafened);
|
||||
VC_API vc_result vc_move_user(vc_client* c, uint32_t user_id, uint32_t channel_id);
|
||||
|
||||
VC_API vc_result vc_create_channel(vc_client* c, const vc_channel_info* info);
|
||||
VC_API vc_result vc_edit_channel(vc_client* c, const vc_channel_info* info);
|
||||
VC_API vc_result vc_delete_channel(vc_client* c, uint32_t channel_id);
|
||||
|
||||
VC_API vc_result vc_create_account(vc_client* c, const char* username, const char* password);
|
||||
VC_API vc_result vc_reset_password(vc_client* c, const char* username,
|
||||
const char* new_password);
|
||||
VC_API vc_result vc_delete_account(vc_client* c, const char* username);
|
||||
VC_API vc_result vc_list_accounts(vc_client* c);
|
||||
|
||||
/* Pull the caller's own permissions (from the last AuthResult). */
|
||||
VC_API vc_result vc_get_permissions(vc_client* c, vc_permissions* out);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user