protobuf migration: replace JSON with prost-generated wire format
- Expanded protocol/lnex.proto with full message set for all packet types - Added prost + prost-build to gateway build pipeline - Refactored all handlers and framing to use prost encode/decode - Removed serde payload structs (now generated from .proto) - Server starts and admin endpoint responds
This commit is contained in:
parent
5534cd01f7
commit
9821814240
31 changed files with 719 additions and 661 deletions
|
|
@ -3,129 +3,359 @@ package lnex;
|
|||
|
||||
// ─── HANDSHAKE ──────────────────────────────────────────────────────────────
|
||||
|
||||
// Server → Client on TCP connect (packet_id = 0x0001)
|
||||
message Hello {
|
||||
string lnex_version = 1; // "v1"
|
||||
bytes server_pubkey = 2; // 32-byte Ed25519 public key
|
||||
bytes challenge_nonce = 3; // 32-byte random challenge
|
||||
string node_name = 4;
|
||||
string lnex_version = 1;
|
||||
bytes server_pubkey = 2;
|
||||
bytes challenge_nonce = 3;
|
||||
string node_name = 4;
|
||||
bytes server_eph_pubkey = 5;
|
||||
bool private_mode = 6;
|
||||
}
|
||||
|
||||
// Client → Server (packet_id = 0x0002)
|
||||
message Auth {
|
||||
bytes client_pubkey = 1; // 32-byte Ed25519 public key
|
||||
string nickname = 2;
|
||||
string lnex_version = 3;
|
||||
bytes signature = 4; // Ed25519 sig over challenge_nonce
|
||||
bytes client_pubkey = 1;
|
||||
string nickname = 2;
|
||||
string lnex_version = 3;
|
||||
bytes signature = 4;
|
||||
bytes client_eph_pubkey = 5;
|
||||
}
|
||||
|
||||
// Server → Client on success (packet_id = 0x0003)
|
||||
message Session {
|
||||
string session_id = 1;
|
||||
string token = 2;
|
||||
int64 expires_at = 3; // Unix ms, 0 = no expiry
|
||||
string session_id = 1;
|
||||
string token = 2;
|
||||
int64 expires_at = 3;
|
||||
}
|
||||
|
||||
// ─── KEEPALIVE ──────────────────────────────────────────────────────────────
|
||||
|
||||
// Either direction (0x0004 / 0x0005)
|
||||
message Ping {
|
||||
int64 timestamp = 1; // Unix ms
|
||||
}
|
||||
message Ping { int64 timestamp = 1; }
|
||||
message Pong { int64 timestamp = 1; }
|
||||
|
||||
message Pong {
|
||||
int64 timestamp = 1; // Echo of Ping.timestamp
|
||||
}
|
||||
// ─── ERROR / DISCONNECT ─────────────────────────────────────────────────────
|
||||
|
||||
message Error { uint32 code = 1; string message = 2; }
|
||||
message Disconnect { string reason = 1; }
|
||||
|
||||
// ─── CHANNELS ───────────────────────────────────────────────────────────────
|
||||
|
||||
// Client → Gateway (0x0030)
|
||||
message JoinChannel {
|
||||
string channel_id = 1;
|
||||
}
|
||||
message JoinChannel { string channel_id = 1; }
|
||||
message LeaveChannel { string channel_id = 1; }
|
||||
|
||||
// Client → Gateway (0x0031)
|
||||
message LeaveChannel {
|
||||
string channel_id = 1;
|
||||
}
|
||||
|
||||
// Gateway → Client (0x0032) — full channel snapshot on join
|
||||
message ChannelState {
|
||||
string channel_id = 1;
|
||||
string channel_name = 2;
|
||||
ChannelKind kind = 3;
|
||||
repeated Member members = 4;
|
||||
string voice_endpoint = 5; // host:port of voice-node UDP
|
||||
|
||||
enum ChannelKind {
|
||||
TEXT = 0;
|
||||
VOICE = 1;
|
||||
}
|
||||
|
||||
message Member {
|
||||
string user_id = 1;
|
||||
string nickname = 2;
|
||||
bool in_voice = 3;
|
||||
}
|
||||
string kind = 3;
|
||||
repeated MemberInfo members = 4;
|
||||
string voice_endpoint = 5;
|
||||
}
|
||||
|
||||
// Broadcast → all channel members (0x0040 / 0x0041)
|
||||
message UserJoin {
|
||||
string channel_id = 1;
|
||||
string user_id = 2;
|
||||
string nickname = 3;
|
||||
message MemberInfo {
|
||||
string user_id = 1;
|
||||
string nickname = 2;
|
||||
bool in_voice = 3;
|
||||
}
|
||||
|
||||
message UserLeave {
|
||||
string channel_id = 1;
|
||||
string user_id = 2;
|
||||
message ChannelCreate {
|
||||
string channel_id = 1;
|
||||
string channel_name = 2;
|
||||
string kind = 3;
|
||||
optional string guild_id = 4;
|
||||
}
|
||||
|
||||
// ─── CHAT ───────────────────────────────────────────────────────────────────
|
||||
message ChannelDelete { string channel_id = 1; }
|
||||
|
||||
message ChannelList { repeated ChannelListItem channels = 1; }
|
||||
|
||||
message ChannelListItem {
|
||||
string channel_id = 1;
|
||||
string channel_name = 2;
|
||||
string kind = 3;
|
||||
}
|
||||
|
||||
message UserJoin { string channel_id = 1; string user_id = 2; string nickname = 3; }
|
||||
message UserLeave { string channel_id = 1; string user_id = 2; }
|
||||
|
||||
// ─── CHAT ────────────────────────────────────────────────────────────────────
|
||||
|
||||
// Client → Gateway, broadcast to channel (0x0020)
|
||||
message ChatMessage {
|
||||
string message_id = 1; // UUID v4, generated by client
|
||||
string channel_id = 2;
|
||||
string sender_id = 3; // sender pubkey short form
|
||||
string content = 4;
|
||||
int64 timestamp = 5; // Unix ms
|
||||
string message_id = 1;
|
||||
string channel_id = 2;
|
||||
string sender_id = 3;
|
||||
string content = 4;
|
||||
int64 timestamp = 5;
|
||||
bool edited = 6;
|
||||
optional string reply_to = 7;
|
||||
}
|
||||
|
||||
// Gateway → Client on join (0x0021) — recent history
|
||||
message ChatHistory {
|
||||
string channel_id = 1;
|
||||
repeated ChatMessage messages = 2;
|
||||
string channel_id = 1;
|
||||
repeated ChatMessage messages = 2;
|
||||
}
|
||||
|
||||
// ─── VOICE STATE ────────────────────────────────────────────────────────────
|
||||
message ReactionPayload {
|
||||
string message_id = 1;
|
||||
string channel_id = 2;
|
||||
string emoji = 3;
|
||||
string user_id = 4;
|
||||
}
|
||||
|
||||
message MessageEdit {
|
||||
string message_id = 1;
|
||||
string channel_id = 2;
|
||||
string content = 3;
|
||||
}
|
||||
|
||||
message MessageDelete {
|
||||
string message_id = 1;
|
||||
string channel_id = 2;
|
||||
}
|
||||
|
||||
// ─── VOICE ──────────────────────────────────────────────────────────────────
|
||||
|
||||
// Broadcast on voice state change (0x0011)
|
||||
message VoiceState {
|
||||
string user_id = 1;
|
||||
string channel_id = 2;
|
||||
|
||||
enum State {
|
||||
SILENT = 0;
|
||||
SPEAKING = 1;
|
||||
MUTED = 2;
|
||||
DEAFENED = 3;
|
||||
}
|
||||
|
||||
State state = 3;
|
||||
string state = 3;
|
||||
}
|
||||
|
||||
// ─── ERRORS ─────────────────────────────────────────────────────────────────
|
||||
// ─── GUILDS ─────────────────────────────────────────────────────────────────
|
||||
|
||||
// Any direction (0x00F0)
|
||||
message Error {
|
||||
uint32 code = 1; // ErrorCode enum value
|
||||
string message = 2;
|
||||
message GuildCreate { string name = 1; }
|
||||
|
||||
message GuildInfo {
|
||||
string id = 1;
|
||||
string owner_id = 2;
|
||||
string name = 3;
|
||||
int64 member_count = 4;
|
||||
int64 created_at = 5;
|
||||
}
|
||||
|
||||
// ─── DISCONNECT ─────────────────────────────────────────────────────────────
|
||||
message GuildDelete { string guild_id = 1; }
|
||||
message GuildList { repeated GuildInfo guilds = 1; }
|
||||
|
||||
// Any direction (0x00FF) — graceful close
|
||||
message Disconnect {
|
||||
string reason = 1; // optional human-readable reason
|
||||
message GuildMemberJoin { string guild_id = 1; }
|
||||
message GuildMemberLeave { string guild_id = 1; string user_id = 2; }
|
||||
message GuildMemberKick { string guild_id = 1; string user_id = 2; }
|
||||
|
||||
message RoleCreate {
|
||||
string guild_id = 1;
|
||||
string name = 2;
|
||||
optional string color = 3;
|
||||
optional uint64 permissions = 4;
|
||||
string id = 5;
|
||||
}
|
||||
|
||||
message RoleDelete {
|
||||
string guild_id = 1;
|
||||
string role_id = 2;
|
||||
}
|
||||
|
||||
message InviteCreate {
|
||||
string guild_id = 1;
|
||||
optional int64 max_uses = 2;
|
||||
optional int64 expires_in_seconds = 3;
|
||||
}
|
||||
|
||||
message InviteInfo {
|
||||
string id = 1;
|
||||
string guild_id = 2;
|
||||
string guild_name = 3;
|
||||
string code = 4;
|
||||
string creator_id = 5;
|
||||
optional int64 max_uses = 6;
|
||||
int64 uses = 7;
|
||||
optional int64 expires_at = 8;
|
||||
int64 created_at = 9;
|
||||
}
|
||||
|
||||
message InviteAccept {
|
||||
string code = 1;
|
||||
string guild_id = 2;
|
||||
string guild_name = 3;
|
||||
}
|
||||
|
||||
message InviteDelete {
|
||||
string guild_id = 1;
|
||||
string invite_id = 2;
|
||||
}
|
||||
|
||||
message GuildAuditLogFetch {
|
||||
string guild_id = 1;
|
||||
int64 limit = 2;
|
||||
}
|
||||
|
||||
message AuditLogEntry {
|
||||
string id = 1;
|
||||
string guild_id = 2;
|
||||
string actor_id = 3;
|
||||
string action = 4;
|
||||
optional string target_id = 5;
|
||||
optional string target_type = 6;
|
||||
optional string reason = 7;
|
||||
int64 created_at = 8;
|
||||
}
|
||||
|
||||
message GuildAuditLog {
|
||||
string guild_id = 1;
|
||||
repeated AuditLogEntry entries = 2;
|
||||
}
|
||||
|
||||
message GuildMemberListFetch { string guild_id = 1; }
|
||||
|
||||
message GuildMemberInfo {
|
||||
string user_id = 1;
|
||||
string nickname = 2;
|
||||
int64 joined_at = 3;
|
||||
string role_color = 4;
|
||||
string role_name = 5;
|
||||
bool is_owner = 6;
|
||||
}
|
||||
|
||||
message GuildMemberList {
|
||||
string guild_id = 1;
|
||||
repeated GuildMemberInfo members = 2;
|
||||
}
|
||||
|
||||
message RoleAssign {
|
||||
string guild_id = 1;
|
||||
string user_id = 2;
|
||||
string role_id = 3;
|
||||
}
|
||||
|
||||
message GuildRoleListFetch { string guild_id = 1; }
|
||||
|
||||
message GuildRoleInfo {
|
||||
string id = 1;
|
||||
string guild_id = 2;
|
||||
string name = 3;
|
||||
string color = 4;
|
||||
uint64 permissions = 5;
|
||||
int32 position = 6;
|
||||
}
|
||||
|
||||
message GuildRoleList {
|
||||
string guild_id = 1;
|
||||
repeated GuildRoleInfo roles = 2;
|
||||
}
|
||||
|
||||
// ─── DIRECT MESSAGES ────────────────────────────────────────────────────────
|
||||
|
||||
message DmStart {
|
||||
string target_user_id = 1;
|
||||
}
|
||||
|
||||
message DmStartResponse {
|
||||
string dm_id = 1;
|
||||
string other_user_id = 2;
|
||||
string other_nickname = 3;
|
||||
repeated DmMessage messages = 4;
|
||||
uint32 unread_count = 5;
|
||||
}
|
||||
|
||||
message DmMessage {
|
||||
string dm_id = 1;
|
||||
string sender_id = 2;
|
||||
string content = 3;
|
||||
int64 timestamp = 4;
|
||||
}
|
||||
|
||||
message DmHistory {
|
||||
string dm_id = 1;
|
||||
repeated DmMessage messages = 2;
|
||||
optional string search_query = 3;
|
||||
optional int64 limit = 4;
|
||||
}
|
||||
|
||||
message DmReadAck {
|
||||
string dm_id = 1;
|
||||
}
|
||||
|
||||
// ─── FRIENDS ────────────────────────────────────────────────────────────────
|
||||
|
||||
message FriendRequest { string to_user_id = 1; }
|
||||
message FriendAccept { string from_user_id = 1; }
|
||||
message FriendDecline { string from_user_id = 1; }
|
||||
message FriendRemove { string user_id = 1; }
|
||||
|
||||
message FriendInfo {
|
||||
string user_id = 1;
|
||||
string nickname = 2;
|
||||
string status = 3;
|
||||
int64 since = 4;
|
||||
}
|
||||
|
||||
message FriendList { repeated FriendInfo friends = 1; }
|
||||
|
||||
message BlockUser { string user_id = 1; }
|
||||
message UnblockUser { string user_id = 1; }
|
||||
message BlockList { repeated string blocked = 1; }
|
||||
|
||||
message FriendEvent {
|
||||
string event = 1;
|
||||
string user_id = 2;
|
||||
optional string nickname = 3;
|
||||
}
|
||||
|
||||
// ─── PRESENCE ──────────────────────────────────────────────────────────────
|
||||
|
||||
message PresenceUpdate {
|
||||
string status = 1;
|
||||
optional string activity_type = 2;
|
||||
optional string activity_text = 3;
|
||||
}
|
||||
|
||||
message PresenceInfo {
|
||||
string user_id = 1;
|
||||
string nickname = 2;
|
||||
string status = 3;
|
||||
optional string activity_type = 4;
|
||||
optional string activity_text = 5;
|
||||
}
|
||||
|
||||
message PresenceSync { repeated PresenceInfo presences = 1; }
|
||||
|
||||
message PresenceEvent {
|
||||
string user_id = 1;
|
||||
string nickname = 2;
|
||||
string status = 3;
|
||||
optional string activity_type = 4;
|
||||
optional string activity_text = 5;
|
||||
}
|
||||
|
||||
// ─── READ RECEIPT & TYPING ─────────────────────────────────────────────────
|
||||
|
||||
message ReadReceipt {
|
||||
string channel_id = 1;
|
||||
string last_read_message_id = 2;
|
||||
string user_id = 3;
|
||||
}
|
||||
|
||||
message TypingStart {
|
||||
string channel_id = 1;
|
||||
}
|
||||
|
||||
// ─── AD-HOC RESPONSE / BROADCAST TYPES ──────────────────────────────────────
|
||||
|
||||
message ReadReceiptBroadcast {
|
||||
string channel_id = 1;
|
||||
string user_id = 2;
|
||||
string last_read_message_id = 3;
|
||||
}
|
||||
|
||||
message UserRoleUpdate {
|
||||
string user_id = 1;
|
||||
string guild_id = 2;
|
||||
string color = 3;
|
||||
}
|
||||
|
||||
message TypingBroadcast {
|
||||
string user_id = 1;
|
||||
string nickname = 2;
|
||||
string channel_id = 3;
|
||||
}
|
||||
|
||||
message SimpleResponse {
|
||||
bool ok = 1;
|
||||
optional string user_id = 2;
|
||||
optional string role_id = 3;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue