Squashed 'external/toxcore/c-toxcore/' changes from f1df709b87..8f0d505f9a
8f0d505f9a feat: add ngc events 9b8216e70c refactor: Make event dispatch ordered by receive time. 814c12a6f4 cleanup: Add dynamically derived array sizes to the API. 226b23be12 cleanup: Add explicit array sizes to toxencryptsave. ef33cb4de0 cleanup: Add Toxav alias for ToxAV. 1da723b34d cleanup: Make Tox_Options a typedef. b148a2afff chore: Simplify msvc build using vcpkg. 5cac6d7eb1 cleanup: Move `tox_get_system` out of the public API. c9ca4007e3 refactor: Align group message sending with other send functions. 6c6c0b1b1b cleanup: Make setters take non-const `Tox *`. a76f758d70 cleanup: Mark arrays in the tox API as `[]` instead of `*`. baf6d1f6cf cleanup: Make array params in toxav `[]` instead of `*`. 79f55bd06a cleanup: Put the size of fixed arrays into the API types. 1e73698db2 cleanup: Add typedefs for public API int identifiers. cac074c57f chore: Add fetch-sha256 script to update bootstrap node hash. 32576656bb Make the comment capitalization uniform aff4dda17c Spellcheck tox-bootstrapd 40b5fbbe9d chore: Remove settings.yml in favour of hs-github-tools. ebafd51be7 chore: Use GPL license with https. 0e42752f0f cleanup: Move all vptr-to-ptr casts to the beginning of a function. 5407384211 cleanup: Use github actions matrix to simplify CI. 82d8265688 fix: Use QueryPerformanceCounter on windows for monotonic time. 1224e656e3 chore: Add `net_(new|kill)_strerror` to cppcheck's allocators. 6a90ddfe4e cleanup: Run clang-tidy on headers, as well. bd930cc80a cleanup: Make TCP connection failures a warning instead of error. fad6e4e173 cleanup: Make all .c files include the headers they need. ef4897a898 cleanup: Upgrade to clang-tidy-17 and fix some warnings. REVERT: f1df709b87 feat: add ngc events REVERT: 1b6c907235 refactor: Make event dispatch ordered by receive time. git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: 8f0d505f9a598cc41c682178e1589bcc01efe9cb
This commit is contained in:
@ -16,12 +16,17 @@
|
||||
#include "../toxcore/DHT.h"
|
||||
#include "../toxcore/LAN_discovery.h"
|
||||
#include "../toxcore/ccompat.h"
|
||||
#include "../toxcore/friend_requests.h"
|
||||
#include "../toxcore/crypto_core.h"
|
||||
#include "../toxcore/forwarding.h"
|
||||
#include "../toxcore/group_announce.h"
|
||||
#include "../toxcore/group_onion_announce.h"
|
||||
#include "../toxcore/logger.h"
|
||||
#include "../toxcore/mem.h"
|
||||
#include "../toxcore/mono_time.h"
|
||||
#include "../toxcore/network.h"
|
||||
#include "../toxcore/onion.h"
|
||||
#include "../toxcore/onion_announce.h"
|
||||
#include "../toxcore/tox.h"
|
||||
#include "../toxcore/util.h"
|
||||
|
||||
#define TCP_RELAY_ENABLED
|
||||
|
||||
@ -46,7 +51,7 @@ static const char *motd_str = ""; //Change this to anything within 256 bytes(but
|
||||
#define PORT 33445
|
||||
|
||||
|
||||
static void manage_keys(DHT *dht)
|
||||
static bool manage_keys(DHT *dht)
|
||||
{
|
||||
enum { KEYS_SIZE = CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_SECRET_KEY_SIZE };
|
||||
uint8_t keys[KEYS_SIZE];
|
||||
@ -60,7 +65,8 @@ static void manage_keys(DHT *dht)
|
||||
|
||||
if (read_size != KEYS_SIZE) {
|
||||
printf("Error while reading the key file\nExiting.\n");
|
||||
exit(1);
|
||||
fclose(keys_file);
|
||||
return false;
|
||||
}
|
||||
|
||||
dht_set_self_public_key(dht, keys);
|
||||
@ -73,18 +79,20 @@ static void manage_keys(DHT *dht)
|
||||
|
||||
if (keys_file == nullptr) {
|
||||
printf("Error opening key file in write mode.\nKeys will not be saved.\n");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fwrite(keys, sizeof(uint8_t), KEYS_SIZE, keys_file) != KEYS_SIZE) {
|
||||
printf("Error while writing the key file.\nExiting.\n");
|
||||
exit(1);
|
||||
fclose(keys_file);
|
||||
return false;
|
||||
}
|
||||
|
||||
printf("Keys saved successfully.\n");
|
||||
}
|
||||
|
||||
fclose(keys_file);
|
||||
return true;
|
||||
}
|
||||
|
||||
static const char *strlevel(Logger_Level level)
|
||||
@ -121,7 +129,7 @@ int main(int argc, char *argv[])
|
||||
if (argc == 2 && !tox_strncasecmp(argv[1], "-h", 3)) {
|
||||
printf("Usage (connected) : %s [--ipv4|--ipv6] IP PORT KEY\n", argv[0]);
|
||||
printf("Usage (unconnected): %s [--ipv4|--ipv6]\n", argv[0]);
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* let user override default by cmdline */
|
||||
@ -129,7 +137,7 @@ int main(int argc, char *argv[])
|
||||
int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled);
|
||||
|
||||
if (argvoffset < 0) {
|
||||
exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Initialize networking -
|
||||
@ -162,14 +170,16 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (!(onion && forwarding && onion_a)) {
|
||||
printf("Something failed to initialize.\n");
|
||||
exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
gca_onion_init(gc_announces_list, onion_a);
|
||||
|
||||
perror("Initialization");
|
||||
|
||||
manage_keys(dht);
|
||||
if (!manage_keys(dht)) {
|
||||
return 1;
|
||||
}
|
||||
printf("Public key: ");
|
||||
|
||||
#ifdef TCP_RELAY_ENABLED
|
||||
@ -179,7 +189,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (tcp_s == nullptr) {
|
||||
printf("TCP server failed to initialize.\n");
|
||||
exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -189,7 +199,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (file == nullptr) {
|
||||
printf("Could not open file \"%s\" for writing. Exiting...\n", public_id_filename);
|
||||
exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < 32; ++i) {
|
||||
@ -210,7 +220,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (port_conv <= 0 || port_conv > UINT16_MAX) {
|
||||
printf("Failed to convert \"%s\" into a valid port. Exiting...\n", argv[argvoffset + 2]);
|
||||
exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const uint16_t port = net_htons((uint16_t)port_conv);
|
||||
@ -222,7 +232,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (!res) {
|
||||
printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]);
|
||||
exit(1);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user