Forward full join profiles and document canonical profile lengths

This commit is contained in:
evgeny committed 2026-10-06 12:58:00 +02:00
1 parent 6d3187db57
commit 8f83167c0f
3 files changed
+12 -7

No files matched your search

+7 -4
View File
@@ -424,7 +424,7 @@ int chat_join_forward_request(struct UTUN_INSTANCE* inst, uint64_t channel_id,
const struct join_member_data* m) {
if (!inst || !m || inviter_id == 0) return -1;
uint8_t mbuf[512]; size_t mlen = 0;
uint8_t mbuf[MS_USERINFO_MAX + 256]; size_t mlen = 0;
if (chat_join_serialize_member(m, mbuf, sizeof(mbuf), &mlen) != 0) {
DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "%s: forward serialize failed", CJ_ID);
return -1;
@@ -432,15 +432,18 @@ int chat_join_forward_request(struct UTUN_INSTANCE* inst, uint64_t channel_id,
size_t plen = 1 + 8 + mlen;
uint8_t* payload = u_malloc(plen);
if (!payload) return -1;
if (!payload) { DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "%s: forward payload allocation failed bytes=%zu", CJ_ID, plen); return -1; }
payload[0] = JOIN_SUBCMD_REQUEST_FWD;
memcpy(payload + 1, &join_key, 8);
memcpy(payload + 1 + 8, mbuf, mlen);
struct ll_entry* entry = queue_entry_new(0);
if (!entry) { u_free(payload); return -1; }
if (!entry) { DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "%s: forward entry allocation failed", CJ_ID); u_free(payload); return -1; }
entry->dgram = u_malloc(1 + plen);
if (!entry->dgram) { u_free(payload); queue_entry_free(entry); return -1; }
if (!entry->dgram) {
DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "%s: forward datagram allocation failed bytes=%zu", CJ_ID, plen + 1);
u_free(payload); queue_entry_free(entry); return -1;
}
entry->dgram[0] = ETCP_RT_ID_JOIN;
memcpy(entry->dgram + 1, payload, plen);
entry->len = 1 + (uint16_t)plen;
+3 -3
View File
@@ -32,11 +32,11 @@
SHA256 по полям:
node_id:8, x25519:32, ed25519:32, join_sig:64, join_ts:8,
update_sig:64, update_ts:8, userinfo_len:1, userinfo,
update_sig:64, update_ts:8, userinfo_len:2, userinfo,
adm_tags_len:2, adm_tags, adm_tags_sig:64, signed_by:8, signature:64.
Целые big-endian; отсутствующие подписи представлены нулями.
userinfo ограничен 255 байтами, adm_tags — 8192 байтами UTF-8 без NUL. Длина adm_tags — uint16 big-endian.
userinfo ограничен 1024 байтами, adm_tags — 8192 байтами UTF-8 без NUL. Обе длины — uint16 big-endian.
Хеш и подпись владельца покрывают весь adm_tags без обрезания. Хеш включает userinfo и дерево приглашений.
Формат сообщений, подписываемых моделью, определяется build_join_msg/build_update_msg/build_sign_msg отдельно.
@@ -45,7 +45,7 @@ userinfo ограничен 255 байтами, adm_tags — 8192 байтами
Начинается с count:2 big-endian. Далее count записей:
node_id:8, x25519:32, ed25519:32, flags:1,
при HAS_JOIN — join_sig:64 и join_ts:8,
update_sig:64, update_ts:8, userinfo_len:1, userinfo,
update_sig:64, update_ts:8, userinfo_len:2, userinfo,
adm_tags_len:2, adm_tags, adm_tags_sig:64, signed_by:8, signature:64.
Целые big-endian. Встроенные NUL и хвостовые байты запрещены.