Compare commits

..

No commits in common. "4248d1d9ab3969b5a4a5429fc21f4855b4d86f46" and "fd9d14d00c1ca053d16c44a434f2cb447891bfd2" have entirely different histories.

9 changed files with 21 additions and 58 deletions

View File

@ -16,7 +16,6 @@ cc_binary(
testonly = 1,
srcs = ["DHT_bootstrap.c"],
deps = [
":bootstrap_node_packets",
"//c-toxcore/testing:misc_tools",
"//c-toxcore/toxcore:DHT",
"//c-toxcore/toxcore:LAN_discovery",

View File

@ -31,16 +31,11 @@
#include "../testing/misc_tools.h"
#define DHT_NODE_EXTRA_PACKETS
#ifdef DHT_NODE_EXTRA_PACKETS
#include "./bootstrap_node_packets.h"
#ifndef DAEMON_VERSION_NUMBER
#define DAEMON_VERSION_NUMBER (1000000000UL + TOX_VERSION_MAJOR*1000000UL + TOX_VERSION_MINOR*1000UL + TOX_VERSION_PATCH*1UL)
#endif
static const char *motd_str = ""; //Change this to anything within 256 bytes(but 96 bytes maximum prefered)
#define DHT_VERSION_NUMBER 1
#define DHT_MOTD "This is a test motd"
#endif
#define PORT 33445
@ -157,7 +152,7 @@ int main(int argc, char *argv[])
Onion_Announce *onion_a = new_onion_announce(logger, mem, rng, mono_time, dht);
#ifdef DHT_NODE_EXTRA_PACKETS
bootstrap_set_callbacks(dht_get_net(dht), (uint32_t)DAEMON_VERSION_NUMBER, (const uint8_t *) motd_str, strlen(motd_str)+1);
bootstrap_set_callbacks(dht_get_net(dht), DHT_VERSION_NUMBER, DHT_MOTD, sizeof(DHT_MOTD));
#endif
if (!(onion && forwarding && onion_a)) {

View File

@ -1 +1 @@
b2996d73cab7c7453dc10ccf7ad733622558de3b1ad0db824a379cf96f500379 /usr/local/bin/tox-bootstrapd
9bec65f2a3093ebb49c3751dfad267482bc80d4b29ef9171f11d5ba53058d713 /usr/local/bin/tox-bootstrapd

View File

@ -108,19 +108,10 @@ static_assert(GCC_BUFFER_SIZE <= UINT16_MAX,
static_assert(MAX_GC_PACKET_CHUNK_SIZE < MAX_GC_PACKET_SIZE,
"MAX_GC_PACKET_CHUNK_SIZE must be < MAX_GC_PACKET_SIZE");
static_assert(MAX_GC_PACKET_INCOMING_CHUNK_SIZE < MAX_GC_PACKET_SIZE,
"MAX_GC_PACKET_INCOMING_CHUNK_SIZE must be < MAX_GC_PACKET_SIZE");
static_assert(MAX_GC_PACKET_INCOMING_CHUNK_SIZE >= MAX_GC_PACKET_CHUNK_SIZE,
"MAX_GC_PACKET_INCOMING_CHUNK_SIZE must be >= MAX_GC_PACKET_CHUNK_SIZE");
// size of a lossless handshake packet - lossless packets can't/shouldn't be split up
static_assert(MAX_GC_PACKET_CHUNK_SIZE >= 171,
"MAX_GC_PACKET_CHUNK_SIZE must be >= 171");
static_assert(MAX_GC_PACKET_INCOMING_CHUNK_SIZE >= 171,
"MAX_GC_PACKET_INCOMING_CHUNK_SIZE must be >= 171");
// group_moderation constants assume this is the max packet size.
static_assert(MAX_GC_PACKET_SIZE >= 50000,
"MAX_GC_PACKET_SIZE doesn't match constants in group_moderation.h");
@ -128,9 +119,6 @@ static_assert(MAX_GC_PACKET_SIZE >= 50000,
static_assert(MAX_GC_PACKET_SIZE <= UINT16_MAX - MAX_GC_PACKET_CHUNK_SIZE,
"MAX_GC_PACKET_SIZE must be <= UINT16_MAX - MAX_GC_PACKET_CHUNK_SIZE");
static_assert(MAX_GC_PACKET_SIZE <= UINT16_MAX - MAX_GC_PACKET_INCOMING_CHUNK_SIZE,
"MAX_GC_PACKET_SIZE must be <= UINT16_MAX - MAX_GC_PACKET_INCOMING_CHUNK_SIZE");
/** Types of broadcast messages. */
typedef enum Group_Message_Type {
GC_MESSAGE_TYPE_NORMAL = 0x00,
@ -6267,13 +6255,13 @@ static int handle_gc_tcp_packet(void *object, int id, const uint8_t *packet, uin
if (length <= MIN_TCP_PACKET_SIZE) {
LOGGER_WARNING(m->log, "Got tcp packet with invalid length: %u (expected %u to %u)", length,
MIN_TCP_PACKET_SIZE, MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
MIN_TCP_PACKET_SIZE, MAX_GC_PACKET_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
return -1;
}
if (length > MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE) {
if (length > MAX_GC_PACKET_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE) {
LOGGER_WARNING(m->log, "Got tcp packet with invalid length: %u (expected %u to %u)", length,
MIN_TCP_PACKET_SIZE, MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
MIN_TCP_PACKET_SIZE, MAX_GC_PACKET_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
return -1;
}
@ -6348,13 +6336,13 @@ static int handle_gc_tcp_oob_packet(void *object, const uint8_t *public_key, uns
if (length <= GC_MIN_HS_PACKET_PAYLOAD_SIZE) {
LOGGER_WARNING(m->log, "Got tcp oob packet with invalid length: %u (expected %u to %u)", length,
GC_MIN_HS_PACKET_PAYLOAD_SIZE, MAX_GC_PACKET_INCOMING_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE);
GC_MIN_HS_PACKET_PAYLOAD_SIZE, MAX_GC_PACKET_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE);
return -1;
}
if (length > MAX_GC_PACKET_INCOMING_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE) {
if (length > MAX_GC_PACKET_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE) {
LOGGER_WARNING(m->log, "Got tcp oob packet with invalid length: %u (expected %u to %u)", length,
GC_MIN_HS_PACKET_PAYLOAD_SIZE, MAX_GC_PACKET_INCOMING_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE);
GC_MIN_HS_PACKET_PAYLOAD_SIZE, MAX_GC_PACKET_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE);
return -1;
}
@ -6404,13 +6392,13 @@ static int handle_gc_udp_packet(void *object, const IP_Port *ipp, const uint8_t
if (length <= MIN_UDP_PACKET_SIZE) {
LOGGER_WARNING(m->log, "Got UDP packet with invalid length: %u (expected %u to %u)", length,
MIN_UDP_PACKET_SIZE, MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
MIN_UDP_PACKET_SIZE, MAX_GC_PACKET_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
return -1;
}
if (length > MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE) {
if (length > MAX_GC_PACKET_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE) {
LOGGER_WARNING(m->log, "Got UDP packet with invalid length: %u (expected %u to %u)", length,
MIN_UDP_PACKET_SIZE, MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
MIN_UDP_PACKET_SIZE, MAX_GC_PACKET_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
return -1;
}

View File

@ -28,8 +28,6 @@
* For an explanation on why this value was chosen, see the following link: https://archive.ph/vsCOG
*/
#define MAX_GC_PACKET_CHUNK_SIZE 500
/* Max size of an incoming packet chunk that is allowed */
#define MAX_GC_PACKET_INCOMING_CHUNK_SIZE 1372
#define MAX_GC_MESSAGE_SIZE GROUP_MAX_MESSAGE_LENGTH
#define MAX_GC_MESSAGE_RAW_SIZE (MAX_GC_MESSAGE_SIZE + GC_MESSAGE_PSEUDO_ID_SIZE)

View File

@ -366,7 +366,7 @@ static uint16_t reassemble_packet(const Logger *log, GC_Connection *gconn, uint8
// search backwards in recv array until we find an empty slot or a non-fragment packet type
while (!array_entry_is_empty(entry) && entry->packet_type == GP_FRAGMENT) {
assert(entry->data != nullptr);
assert(entry->data_length <= MAX_GC_PACKET_INCOMING_CHUNK_SIZE);
assert(entry->data_length <= MAX_GC_PACKET_CHUNK_SIZE);
const uint16_t diff = packet_length + entry->data_length;

View File

@ -858,26 +858,12 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error)
if (load_savedata_tox
&& tox_load(tox, tox_options_get_savedata_data(opts), tox_options_get_savedata_length(opts)) == -1) {
kill_groupchats(tox->m->conferences_object);
kill_messenger(tox->m);
mono_time_free(tox->sys.mem, tox->mono_time);
tox_options_free(default_options);
tox_unlock(tox);
if (tox->mutex != nullptr) {
pthread_mutex_destroy(tox->mutex);
}
mem_delete(sys->mem, tox->mutex);
mem_delete(sys->mem, tox);
SET_ERROR_PARAMETER(error, TOX_ERR_NEW_LOAD_BAD_FORMAT);
return nullptr;
}
if (load_savedata_sk) {
} else if (load_savedata_sk) {
load_secret_key(tox->m->net_crypto, tox_options_get_savedata_data(opts));
SET_ERROR_PARAMETER(error, TOX_ERR_NEW_OK);
} else {
SET_ERROR_PARAMETER(error, TOX_ERR_NEW_OK);
}
m_callback_namechange(tox->m, tox_friend_name_handler);
@ -927,9 +913,6 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error)
tox_options_free(default_options);
tox_unlock(tox);
SET_ERROR_PARAMETER(error, TOX_ERR_NEW_OK);
return tox;
}

View File

@ -890,6 +890,9 @@ typedef enum Tox_Err_New {
* This function will bring the instance into a valid state. Running the event
* loop with a new instance will operate correctly.
*
* If loading failed or succeeded only partially, the new or partially loaded
* instance is returned and an error code is set.
*
* @param options An options object as described above. If this parameter is
* NULL, the default options are used.
*

View File

@ -171,8 +171,6 @@ void ChatGui4::render(void) {
if (const auto* unread_storage = mm.storage<Message::Components::TagUnread>(); unread_storage != nullptr && !unread_storage->empty()) {
//assert(unread_storage->size() == 0);
//assert(unread_storage.cbegin() == unread_storage.cend());
#if 0
std::cout << "UNREAD ";
Message3 prev_ent = entt::null;
for (const Message3 e : mm.view<Message::Components::TagUnread>()) {
@ -183,7 +181,6 @@ void ChatGui4::render(void) {
prev_ent = e;
}
std::cout << "\n";
#endif
}
}