1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-06-29 15:06:45 +02:00

Compare commits

...

4 Commits

Author SHA1 Message Date
398aecdd92 Fix group whispering for duplicate nicks
If a group has numerous peers with the same nick we now require
their public key in order to send a private message. Previously
we would greedily send the message to the first peer
in the list.
2022-10-06 14:16:16 -04:00
57a439c9b4 Remove testnet specific code
Preparing for ngc merge
2022-09-22 14:05:23 -04:00
0aea5d7fbe Remove testnet specific code
Preparing for ngc merge
2022-09-22 13:51:00 -04:00
e56edd556f Remove error code that no longer exists 2022-07-14 00:17:39 -04:00
3 changed files with 37 additions and 65 deletions

View File

@ -136,15 +136,20 @@ mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR" cd "$BUILD_DIR"
# The git hash of the c-toxcore version we're using # The git hash of the c-toxcore version we're using
TOXCORE_VERSION="02996f06850fb565fa5520cb4e1daa8c616b41c1" TOXCORE_VERSION="0a277b52ea22fe297a8487ac05a0c507a74c6480"
TOXCORE_FILENAME="toxcore-$TOXCORE_VERSION.tar.gz" # The sha256sum of the c-toxcore tarball for TOXCORE_VERSION
TOXCORE_HASH="a63f3d8c9ee8bf51dd40fd0035914a73b4214e8d314c06f38a366c79c20278fb"
TOXCORE_FILENAME="c-toxcore-$TOXCORE_VERSION.tar.gz"
wget --timeout=10 -O "$TOXCORE_FILENAME" "https://github.com/TokTok/c-toxcore/archive/$TOXCORE_VERSION.tar.gz"
check_sha256 "$TOXCORE_HASH" "$TOXCORE_FILENAME"
wget --timeout=10 -O "$TOXCORE_FILENAME" "https://github.com/JFreegman/toxcore/archive/$TOXCORE_VERSION.tar.gz"
tar -o -xf "$TOXCORE_FILENAME" tar -o -xf "$TOXCORE_FILENAME"
rm "$TOXCORE_FILENAME" rm "$TOXCORE_FILENAME"
cd toxcore* cd c-toxcore*
mkdir -p "third_party" && cd "third_party" mkdir -p "third_party" && cd "third_party"
CMP_VERSION="074e0df43e8a61ea938c4f77f65d1fbccc0c3bf9" CMP_VERSION="074e0df43e8a61ea938c4f77f65d1fbccc0c3bf9"
@ -156,7 +161,7 @@ mv cmp\-*/* "cmp/"
cd .. cd ..
cmake -B_build -H. \ cmake -B_build -H. \
-DUSE_TEST_NETWORK=ON \ -DUSE_TEST_NETWORK=OFF \
-DENABLE_STATIC=ON \ -DENABLE_STATIC=ON \
-DENABLE_SHARED=OFF \ -DENABLE_SHARED=OFF \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \

View File

@ -42,7 +42,7 @@
extern struct user_settings *user_settings; extern struct user_settings *user_settings;
/* URL that we get the JSON encoded nodes list from. */ /* URL that we get the JSON encoded nodes list from. */
#define NODES_LIST_URL 0 // This should be empty until NGC merges with mainnet #define NODES_LIST_URL "https://nodes.tox.chat/json"
#define DEFAULT_NODES_FILENAME "DHTnodes.json" #define DEFAULT_NODES_FILENAME "DHTnodes.json"
@ -79,29 +79,6 @@ extern struct user_settings *user_settings;
/* Maximum allowable size of the nodes list */ /* Maximum allowable size of the nodes list */
#define MAX_NODELIST_SIZE (MAX_RECV_CURL_DATA_SIZE) #define MAX_NODELIST_SIZE (MAX_RECV_CURL_DATA_SIZE)
// TODO(Jfreegman): Remove this before production
static uint8_t const TESTNET_KEY[] = {
0x79, 0xCA, 0xDA, 0x49, 0x74, 0xB0, 0x92, 0x6F,
0x28, 0x6F, 0x02, 0x5C, 0xD5, 0xFF, 0xDF, 0x3E,
0x65, 0x4A, 0x37, 0x58, 0xC5, 0x3E, 0x02, 0x73,
0xEC, 0xFC, 0x4D, 0x12, 0xC2, 0x1D, 0xCA, 0x48,
};
// TODO(Jfreegman): Remove this before production
#define TESTNET_PORT 33445
#define TESTNET_IP "172.93.52.70"
static uint8_t const TESTNET_KEY2[] = {
0x5E, 0x47, 0xBA, 0x1D, 0xC3, 0x91, 0x3E, 0xB2,
0xCB, 0xF2, 0xD6, 0x4C, 0xE4, 0xF2, 0x3D, 0x8B,
0xFE, 0x53, 0x91, 0xBF, 0xAB, 0xE5, 0xC4, 0x3C,
0x5B, 0xAD, 0x13, 0xF0, 0xA4, 0x14, 0xCD, 0x77,
};
#define TESTNET_PORT2 38445
#define TESTNET_IP2 "tox.plastiras.org"
static struct Thread_Data { static struct Thread_Data {
pthread_t tid; pthread_t tid;
pthread_attr_t attr; pthread_attr_t attr;
@ -298,11 +275,6 @@ on_exit:
*/ */
static int update_DHT_nodeslist(const char *nodes_path) static int update_DHT_nodeslist(const char *nodes_path)
{ {
if (NODES_LIST_URL == 0) { // TODO: Remove this when NGC merges with mainnet
fprintf(stderr, "Skipping DHT Nodes list fetching (remove before production)\n");
return 0;
}
if (!nodeslist_needs_update(nodes_path)) { if (!nodeslist_needs_update(nodes_path)) {
return 0; return 0;
} }
@ -583,25 +555,6 @@ on_exit:
*/ */
int load_DHT_nodeslist(void) int load_DHT_nodeslist(void)
{ {
// TODO(Jfreegman): Remove this before production
fprintf(stderr, "Adding NGC testnet node - remove this before production\n");
struct Node *node = &Nodes.list[0];
node->have_ip4 = true;
node->port = TESTNET_PORT;
memcpy(node->key, TESTNET_KEY, sizeof(TESTNET_KEY));
memcpy(node->ip4, TESTNET_IP, sizeof(TESTNET_IP));
struct Node *node2 = &Nodes.list[1];
node2->have_ip4 = true;
node2->port = TESTNET_PORT2;
memcpy(node2->key, TESTNET_KEY2, sizeof(TESTNET_KEY2));
memcpy(node2->ip4, TESTNET_IP2, sizeof(TESTNET_IP2));
Nodes.count = 2;
#if 0
if (thread_data.active) { if (thread_data.active) {
return -1; return -1;
} }
@ -625,8 +578,6 @@ int load_DHT_nodeslist(void)
return -5; return -5;
} }
#endif
return 0; return 0;
} }

View File

@ -385,11 +385,6 @@ void set_nick_all_groups(Tox *m, const char *new_nick, size_t length)
break; break;
} }
case TOX_ERR_GROUP_SELF_NAME_SET_TAKEN: {
line_info_add(self, false, NULL, 0, SYS_MSG, 0, RED, "-!- That nick is already in use.");
break;
}
default: { default: {
if (groupchats[i].time_connected > 0) { if (groupchats[i].time_connected > 0) {
line_info_add(self, false, NULL, 0, SYS_MSG, 0, RED, "-!- Failed to set nick (error %d).", err); line_info_add(self, false, NULL, 0, SYS_MSG, 0, RED, "-!- Failed to set nick (error %d).", err);
@ -480,6 +475,10 @@ static int group_get_nick_peer_id(uint32_t groupnumber, const char *nick, uint32
return -1; return -1;
} }
if (nick == NULL) {
return -1;
}
size_t count = 0; size_t count = 0;
for (uint32_t i = 0; i < chat->max_idx; ++i) { for (uint32_t i = 0; i < chat->max_idx; ++i) {
@ -498,7 +497,7 @@ static int group_get_nick_peer_id(uint32_t groupnumber, const char *nick, uint32
} }
} }
return 0; return count > 0 ? 0 : -1;
} }
/* Gets the peer_id associated with `public_key`. /* Gets the peer_id associated with `public_key`.
@ -514,9 +513,17 @@ int group_get_public_key_peer_id(uint32_t groupnumber, const char *public_key, u
return -1; return -1;
} }
if (public_key == NULL) {
return -1;
}
if (strlen(public_key) < TOX_GROUP_PEER_PUBLIC_KEY_SIZE * 2) {
return -1;
}
char key_bin[TOX_GROUP_PEER_PUBLIC_KEY_SIZE]; char key_bin[TOX_GROUP_PEER_PUBLIC_KEY_SIZE];
if (tox_pk_string_to_bytes(public_key, strlen(public_key), key_bin, sizeof(key_bin)) == -1) { if (tox_pk_string_to_bytes(public_key, TOX_GROUP_PEER_PUBLIC_KEY_SIZE * 2, key_bin, sizeof(key_bin)) == -1) {
return -1; return -1;
} }
@ -1420,7 +1427,6 @@ static void send_group_prvt_message(ToxWindow *self, Tox *m, uint32_t groupnumbe
return; return;
} }
uint32_t peer_id = 0;
uint32_t name_length = 0; uint32_t name_length = 0;
const char *nick = NULL; const char *nick = NULL;
@ -1438,13 +1444,23 @@ static void send_group_prvt_message(ToxWindow *self, Tox *m, uint32_t groupnumbe
if (chat->peer_list[i].name_length > name_length) { if (chat->peer_list[i].name_length > name_length) {
name_length = chat->peer_list[i].name_length; name_length = chat->peer_list[i].name_length;
nick = chat->peer_list[i].name; nick = chat->peer_list[i].name;
peer_id = chat->peer_list[i].peer_id;
} }
} }
} }
if (nick == NULL) { if (nick == NULL) {
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Invalid peer name."); if (data_len < TOX_GROUP_PEER_PUBLIC_KEY_SIZE * 2) {
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Invalid nick.");
return;
}
nick = data;
name_length = TOX_GROUP_PEER_PUBLIC_KEY_SIZE * 2;
}
uint32_t peer_id;
if (group_get_peer_id_of_identifier(self, nick, &peer_id) != 0) {
return; return;
} }