Compare commits

...

3 Commits

Author SHA1 Message Date
889c4d0b97 tmp patch to enlargen the ngc lossy custom pkg size 2023-12-13 14:03:06 +01:00
7495a50723 add hack to copy the ngc chat id 2023-12-13 14:02:31 +01:00
1cdde5170b update subs 2023-12-12 16:52:52 +01:00
7 changed files with 45 additions and 12 deletions

View File

@ -182,7 +182,11 @@ static void kill_group_friend_connection(const GC_Session *c, const GC_Chat *cha
uint16_t gc_get_wrapped_packet_size(uint16_t length, Net_Packet_Type packet_type) uint16_t gc_get_wrapped_packet_size(uint16_t length, Net_Packet_Type packet_type)
{ {
assert(length <= MAX_GC_PACKET_CHUNK_SIZE); if (packet_type == NET_PACKET_GC_LOSSY) {
assert(length <= MAX_GC_CUSTOM_LOSSY_PACKET_SIZE);
} else {
assert(length <= MAX_GC_PACKET_CHUNK_SIZE);
}
const uint16_t min_header_size = packet_type == NET_PACKET_GC_LOSSY const uint16_t min_header_size = packet_type == NET_PACKET_GC_LOSSY
? GC_MIN_LOSSY_PAYLOAD_SIZE ? GC_MIN_LOSSY_PAYLOAD_SIZE
@ -227,9 +231,13 @@ GC_Connection *get_gc_connection(const GC_Chat *chat, int peer_number)
} }
/** Returns the amount of empty padding a packet of designated length should have. */ /** Returns the amount of empty padding a packet of designated length should have. */
static uint16_t group_packet_padding_length(uint16_t length) static uint16_t group_packet_padding_length(uint16_t length, uint8_t net_packet_type)
{ {
return (MAX_GC_PACKET_CHUNK_SIZE - length) % GC_MAX_PACKET_PADDING; if (net_packet_type == NET_PACKET_GC_LOSSY) {
return (MAX_GC_CUSTOM_LOSSY_PACKET_SIZE - length) % GC_MAX_PACKET_PADDING;
} else {
return (MAX_GC_PACKET_CHUNK_SIZE - length) % GC_MAX_PACKET_PADDING;
}
} }
void gc_get_self_nick(const GC_Chat *chat, uint8_t *nick) void gc_get_self_nick(const GC_Chat *chat, uint8_t *nick)
@ -1485,7 +1493,7 @@ int group_packet_wrap(
uint16_t packet_size, const uint8_t *data, uint16_t length, uint64_t message_id, uint16_t packet_size, const uint8_t *data, uint16_t length, uint64_t message_id,
uint8_t gp_packet_type, uint8_t net_packet_type) uint8_t gp_packet_type, uint8_t net_packet_type)
{ {
const uint16_t padding_len = group_packet_padding_length(length); const uint16_t padding_len = group_packet_padding_length(length, net_packet_type);
const uint16_t min_packet_size = net_packet_type == NET_PACKET_GC_LOSSLESS const uint16_t min_packet_size = net_packet_type == NET_PACKET_GC_LOSSLESS
? length + padding_len + CRYPTO_MAC_SIZE + 1 + ENC_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + GC_MESSAGE_ID_BYTES + 1 ? length + padding_len + CRYPTO_MAC_SIZE + 1 + ENC_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + GC_MESSAGE_ID_BYTES + 1
: length + padding_len + CRYPTO_MAC_SIZE + 1 + ENC_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + 1; : length + padding_len + CRYPTO_MAC_SIZE + 1 + ENC_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + 1;
@ -1495,9 +1503,16 @@ int group_packet_wrap(
return -1; return -1;
} }
if (length > MAX_GC_PACKET_CHUNK_SIZE) { if (net_packet_type == NET_PACKET_GC_LOSSY) {
LOGGER_ERROR(log, "Packet payload size (%u) exceeds maximum (%u)", length, MAX_GC_PACKET_CHUNK_SIZE); if (length > MAX_GC_CUSTOM_LOSSY_PACKET_SIZE) {
return -1; LOGGER_ERROR(log, "Packet payload size (%u) exceeds maximum (%u)", length, MAX_GC_CUSTOM_LOSSY_PACKET_SIZE);
return -1;
}
} else {
if (length > MAX_GC_PACKET_CHUNK_SIZE) {
LOGGER_ERROR(log, "Packet payload size (%u) exceeds maximum (%u)", length, MAX_GC_PACKET_CHUNK_SIZE);
return -1;
}
} }
uint8_t *plain = (uint8_t *)malloc(packet_size); uint8_t *plain = (uint8_t *)malloc(packet_size);
@ -1563,7 +1578,7 @@ non_null()
static bool send_lossy_group_packet(const GC_Chat *chat, const GC_Connection *gconn, const uint8_t *data, static bool send_lossy_group_packet(const GC_Chat *chat, const GC_Connection *gconn, const uint8_t *data,
uint16_t length, uint8_t packet_type) uint16_t length, uint8_t packet_type)
{ {
assert(length <= MAX_GC_PACKET_CHUNK_SIZE); assert(length <= MAX_GC_CUSTOM_LOSSY_PACKET_SIZE);
if (!gconn->handshaked || gconn->pending_delete) { if (!gconn->handshaked || gconn->pending_delete) {
return false; return false;

View File

@ -34,7 +34,7 @@
#define MAX_GC_MESSAGE_SIZE GROUP_MAX_MESSAGE_LENGTH #define MAX_GC_MESSAGE_SIZE GROUP_MAX_MESSAGE_LENGTH
#define MAX_GC_MESSAGE_RAW_SIZE (MAX_GC_MESSAGE_SIZE + GC_MESSAGE_PSEUDO_ID_SIZE) #define MAX_GC_MESSAGE_RAW_SIZE (MAX_GC_MESSAGE_SIZE + GC_MESSAGE_PSEUDO_ID_SIZE)
#define MAX_GC_CUSTOM_LOSSLESS_PACKET_SIZE 1373 #define MAX_GC_CUSTOM_LOSSLESS_PACKET_SIZE 1373
#define MAX_GC_CUSTOM_LOSSY_PACKET_SIZE MAX_GC_PACKET_CHUNK_SIZE #define MAX_GC_CUSTOM_LOSSY_PACKET_SIZE 1000
#define MAX_GC_PASSWORD_SIZE 32 #define MAX_GC_PASSWORD_SIZE 32
#define MAX_GC_SAVED_INVITES 10 #define MAX_GC_SAVED_INVITES 10
#define MAX_GC_PEERS_DEFAULT 100 #define MAX_GC_PEERS_DEFAULT 100

View File

@ -3307,7 +3307,7 @@ uint32_t tox_group_max_message_length(void);
/** /**
* Maximum length of a group custom lossy packet. * Maximum length of a group custom lossy packet.
*/ */
#define TOX_GROUP_MAX_CUSTOM_LOSSY_PACKET_LENGTH 500 #define TOX_GROUP_MAX_CUSTOM_LOSSY_PACKET_LENGTH 1000
uint32_t tox_group_max_custom_lossy_packet_length(void); uint32_t tox_group_max_custom_lossy_packet_length(void);

View File

@ -6,6 +6,9 @@
#include <solanaceae/tox_messages/components.hpp> #include <solanaceae/tox_messages/components.hpp>
#include <solanaceae/contact/components.hpp> #include <solanaceae/contact/components.hpp>
// HACK: remove them
#include <solanaceae/tox_contacts/components.hpp>
#include <solanaceae/toxcore/utils.hpp>
#include <imgui/imgui.h> #include <imgui/imgui.h>
#include <imgui/misc/cpp/imgui_stdlib.h> #include <imgui/misc/cpp/imgui_stdlib.h>
@ -158,6 +161,16 @@ void ChatGui4::render(void) {
ImGui::Checkbox("show extra info", &_show_chat_extra_info); ImGui::Checkbox("show extra info", &_show_chat_extra_info);
ImGui::Checkbox("show avatar transfers", &_show_chat_avatar_tf); ImGui::Checkbox("show avatar transfers", &_show_chat_avatar_tf);
ImGui::SeparatorText("tox");
if (_cr.all_of<Contact::Components::ToxGroupPersistent>(*_selected_contact)) {
if (ImGui::MenuItem("copy ngc chatid")) {
const auto& chat_id = _cr.get<Contact::Components::ToxGroupPersistent>(*_selected_contact).chat_id.data;
const auto chat_id_str = bin2hex(std::vector<uint8_t>{chat_id.begin(), chat_id.end()});
ImGui::SetClipboardText(chat_id_str.c_str());
}
}
ImGui::EndMenu(); ImGui::EndMenu();
} }
ImGui::EndMenuBar(); ImGui::EndMenuBar();

View File

@ -3,6 +3,7 @@
#include "./image_loader_sdl_bmp.hpp" #include "./image_loader_sdl_bmp.hpp"
#include "./image_loader_stb.hpp" #include "./image_loader_stb.hpp"
#include "./image_loader_webp.hpp" #include "./image_loader_webp.hpp"
#include "./media_meta_info_loader.hpp"
#include <solanaceae/message3/components.hpp> #include <solanaceae/message3/components.hpp>
@ -22,6 +23,10 @@ std::optional<TextureEntry> MessageImageLoader::load(TextureUploaderI& tu, Messa
return std::nullopt; return std::nullopt;
} }
if (m.all_of<Message::Components::TagNotImage>()) {
return std::nullopt;
}
if (m.all_of<Message::Components::Transfer::FileInfoLocal>()) { if (m.all_of<Message::Components::Transfer::FileInfoLocal>()) {
const auto& file_list = m.get<Message::Components::Transfer::FileInfoLocal>().file_list; const auto& file_list = m.get<Message::Components::Transfer::FileInfoLocal>().file_list;
assert(!file_list.empty()); assert(!file_list.empty());