mirror of
https://github.com/Tha14/toxic.git
synced 2025-06-26 20:16:44 +02:00
Compare commits
12 Commits
fix_log_on
...
efbfa2c95c
Author | SHA1 | Date | |
---|---|---|---|
efbfa2c95c | |||
3f3e848b6f | |||
8d125d5e6b | |||
fbdc20dfa5 | |||
e8388bf20c | |||
398aecdd92 | |||
57a439c9b4 | |||
0aea5d7fbe | |||
e56edd556f | |||
7ed031b9bf | |||
6ef2c784c5 | |||
058057c64d |
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -28,7 +28,7 @@ jobs:
|
||||
libx11-dev
|
||||
python3-dev
|
||||
pkg-config &&
|
||||
git clone --depth=1 https://github.com/TokTok/c-toxcore &&
|
||||
git clone --depth=1 --recursive https://github.com/TokTok/c-toxcore &&
|
||||
cd c-toxcore &&
|
||||
cmake . -B_build -DBOOTSTRAP_DAEMON=OFF &&
|
||||
cd _build &&
|
||||
@ -85,7 +85,7 @@ jobs:
|
||||
make
|
||||
python3-dev
|
||||
pkg-config &&
|
||||
git clone --depth=1 https://github.com/TokTok/c-toxcore &&
|
||||
git clone --depth=1 --recursive https://github.com/TokTok/c-toxcore &&
|
||||
cd c-toxcore &&
|
||||
cmake . -B_build -DBOOTSTRAP_DAEMON=OFF &&
|
||||
cd _build &&
|
||||
|
@ -1 +0,0 @@
|
||||
toxme.io 1A39E7A5D5FA9CF155C751570A32E625698A60A55F6D88028F949F66144F4F25
|
||||
|
@ -114,7 +114,6 @@ apk add \
|
||||
libsodium-dev \
|
||||
libsodium-static \
|
||||
linux-headers \
|
||||
msgpack-c-dev \
|
||||
ncurses-dev \
|
||||
ncurses-static \
|
||||
ncurses-terminfo \
|
||||
@ -137,20 +136,32 @@ mkdir -p "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
# The git hash of the c-toxcore version we're using
|
||||
TOXCORE_VERSION="v0.2.16"
|
||||
TOXCORE_VERSION="0a277b52ea22fe297a8487ac05a0c507a74c6480"
|
||||
|
||||
# The sha256sum of the c-toxcore tarball for TOXCORE_VERSION
|
||||
TOXCORE_HASH="653aa42654b607f0940cecfac873e9ce55605119a90d1dc454d1090ff6ca29c0"
|
||||
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"
|
||||
|
||||
tar -o -xf "$TOXCORE_FILENAME"
|
||||
rm "$TOXCORE_FILENAME"
|
||||
|
||||
cd c-toxcore*
|
||||
mkdir -p "third_party" && cd "third_party"
|
||||
|
||||
CMP_VERSION="074e0df43e8a61ea938c4f77f65d1fbccc0c3bf9"
|
||||
CMP_FILENAME="cmp-$CMP_VERSION.tar.gz"
|
||||
wget --timeout=10 -O "$CMP_FILENAME" "https://github.com/TokTok/cmp/archive/$CMP_VERSION.tar.gz"
|
||||
tar -o -xf "$CMP_FILENAME"
|
||||
|
||||
mv cmp\-*/* "cmp/"
|
||||
cd ..
|
||||
|
||||
cmake -B_build -H. \
|
||||
-DUSE_TEST_NETWORK=OFF \
|
||||
-DENABLE_STATIC=ON \
|
||||
-DENABLE_SHARED=OFF \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
|
@ -42,7 +42,7 @@
|
||||
extern struct user_settings *user_settings;
|
||||
|
||||
/* 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"
|
||||
|
||||
@ -79,29 +79,6 @@ extern struct user_settings *user_settings;
|
||||
/* Maximum allowable size of the nodes list */
|
||||
#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 {
|
||||
pthread_t tid;
|
||||
pthread_attr_t attr;
|
||||
@ -298,11 +275,6 @@ on_exit:
|
||||
*/
|
||||
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)) {
|
||||
return 0;
|
||||
}
|
||||
@ -583,24 +555,6 @@ on_exit:
|
||||
*/
|
||||
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) {
|
||||
return -1;
|
||||
}
|
||||
@ -623,7 +577,6 @@ int load_DHT_nodeslist(void)
|
||||
thread_data.active = false;
|
||||
return -5;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -385,11 +385,6 @@ void set_nick_all_groups(Tox *m, const char *new_nick, size_t length)
|
||||
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: {
|
||||
if (groupchats[i].time_connected > 0) {
|
||||
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;
|
||||
}
|
||||
|
||||
if (nick == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
size_t count = 0;
|
||||
|
||||
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`.
|
||||
@ -514,9 +513,17 @@ int group_get_public_key_peer_id(uint32_t groupnumber, const char *public_key, u
|
||||
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];
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -991,7 +998,9 @@ static void groupchat_onGroupPeerJoin(ToxWindow *self, Tox *m, uint32_t groupnum
|
||||
++chat->max_idx;
|
||||
}
|
||||
|
||||
if (timed_out(chat->time_connected, 60) && user_settings->show_group_connection_msg == SHOW_GROUP_CONNECTION_MSG_ON) { /* ignore join messages when we first connect to the group */
|
||||
if (timed_out(chat->time_connected, 60)
|
||||
&& user_settings->show_group_connection_msg ==
|
||||
SHOW_GROUP_CONNECTION_MSG_ON) { /* ignore join messages when we first connect to the group */
|
||||
line_info_add(self, true, peer->name, NULL, CONNECTION, 0, GREEN, "has joined the room");
|
||||
|
||||
write_to_log("has joined the room", peer->name, self->chatwin->log, true);
|
||||
@ -1027,17 +1036,16 @@ void groupchat_onGroupPeerExit(ToxWindow *self, Tox *m, uint32_t groupnumber, ui
|
||||
if (length > 0) {
|
||||
line_info_add(self, true, name, NULL, DISCONNECTION, 0, RED, "[Quit]: %s", part_message);
|
||||
snprintf(log_str, sizeof(log_str), "has left the room (%s)", part_message);
|
||||
write_to_log(log_str, name, self->chatwin->log, true);
|
||||
sound_notify(self, silent, NT_WNDALERT_2, NULL);
|
||||
} else if (user_settings->show_group_connection_msg == SHOW_GROUP_CONNECTION_MSG_ON) {
|
||||
const char *exit_string = get_group_exit_string(exit_type);
|
||||
line_info_add(self, true, name, NULL, DISCONNECTION, 0, RED, "[%s]", exit_string);
|
||||
snprintf(log_str, sizeof(log_str), "[%s]", exit_string);
|
||||
write_to_log(log_str, name, self->chatwin->log, true);
|
||||
sound_notify(self, silent, NT_WNDALERT_2, NULL);
|
||||
}
|
||||
|
||||
if (user_settings->show_group_connection_msg == SHOW_GROUP_CONNECTION_MSG_ON) {
|
||||
write_to_log(log_str, name, self->chatwin->log, true);
|
||||
}
|
||||
|
||||
sound_notify(self, silent, NT_WNDALERT_2, NULL);
|
||||
}
|
||||
|
||||
int peer_index = get_peer_index(groupnumber, peer_id);
|
||||
@ -1419,7 +1427,6 @@ static void send_group_prvt_message(ToxWindow *self, Tox *m, uint32_t groupnumbe
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t peer_id = 0;
|
||||
uint32_t name_length = 0;
|
||||
const char *nick = NULL;
|
||||
|
||||
@ -1437,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) {
|
||||
name_length = chat->peer_list[i].name_length;
|
||||
nick = chat->peer_list[i].name;
|
||||
peer_id = chat->peer_list[i].peer_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1662,7 +1679,15 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m)
|
||||
wattron(ctx->sidebar, A_BOLD);
|
||||
|
||||
pthread_mutex_lock(&Winthread.lock);
|
||||
wprintw(ctx->sidebar, "Peers: %d\n", chat->num_peers);
|
||||
|
||||
if (chat->num_peers > 1) {
|
||||
wprintw(ctx->sidebar, "Peers: %d\n", chat->num_peers);
|
||||
} else if (tox_group_is_connected(m, self->num, NULL)) {
|
||||
wprintw(ctx->sidebar, "Connecting...\n");
|
||||
} else {
|
||||
wprintw(ctx->sidebar, "Disconnected\n");
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&Winthread.lock);
|
||||
|
||||
wattroff(ctx->sidebar, A_BOLD);
|
||||
|
11
src/help.c
11
src/help.c
@ -188,6 +188,7 @@ static void help_draw_global(ToxWindow *self)
|
||||
wprintw(win, " /log <on> or <off> : Enable/disable logging\n");
|
||||
wprintw(win, " /myid : Print your Tox ID\n");
|
||||
wprintw(win, " /group <name> : Create a new group chat\n");
|
||||
wprintw(win, " /join <chatid> : Join a groupchat using a Chat ID\n");
|
||||
#ifdef GAMES
|
||||
wprintw(win, " /game : Play a game\n");
|
||||
#endif /* GAMES */
|
||||
@ -245,8 +246,10 @@ static void help_draw_chat(ToxWindow *self)
|
||||
wprintw(win, "Chat Commands:\n");
|
||||
wattroff(win, A_BOLD | COLOR_PAIR(RED));
|
||||
|
||||
wprintw(win, " /invite <n> : Invite contact to a conference \n");
|
||||
wprintw(win, " /join : Join a pending conference\n");
|
||||
wprintw(win, " /cinvite <n> : Invite contact to a conference \n");
|
||||
wprintw(win, " /cjoin : Join a pending conference\n");
|
||||
wprintw(win, " /invite <n> : Invite contact to a groupchat \n");
|
||||
wprintw(win, " /gaccept <password> : Accept a pending groupchat invite\n");
|
||||
wprintw(win, " /sendfile <path> : Send a file\n");
|
||||
wprintw(win, " /savefile <id> : Receive a file\n");
|
||||
wprintw(win, " /cancel <type> <id> : Cancel file transfer where type: in|out\n");
|
||||
@ -435,13 +438,13 @@ void help_onKey(ToxWindow *self, wint_t key)
|
||||
#elif AUDIO
|
||||
help_init_window(self, 21, 80);
|
||||
#else
|
||||
help_init_window(self, 11, 80);
|
||||
help_init_window(self, 13, 80);
|
||||
#endif
|
||||
self->help->type = HELP_CHAT;
|
||||
break;
|
||||
|
||||
case L'g':
|
||||
height = 22;
|
||||
height = 23;
|
||||
#ifdef VIDEO
|
||||
height += 8;
|
||||
#elif AUDIO
|
||||
|
@ -365,7 +365,7 @@ on_exit:
|
||||
void name_lookup(ToxWindow *self, Tox *m, const char *id_bin, const char *addr, const char *message)
|
||||
{
|
||||
if (t_data.disabled) {
|
||||
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "name lookups are disabled.");
|
||||
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "nameservers list is empty or does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
13
src/toxic.c
13
src/toxic.c
@ -258,10 +258,6 @@ void cb_toxcore_logger(Tox *m, TOX_LOG_LEVEL level, const char *file, uint32_t l
|
||||
{
|
||||
UNUSED_VAR(m);
|
||||
|
||||
if (level == TOX_LOG_LEVEL_TRACE) {
|
||||
return;
|
||||
}
|
||||
|
||||
FILE *fp = (FILE *)user_data;
|
||||
|
||||
if (!fp) {
|
||||
@ -269,13 +265,20 @@ void cb_toxcore_logger(Tox *m, TOX_LOG_LEVEL level, const char *file, uint32_t l
|
||||
}
|
||||
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
|
||||
struct tm tmp;
|
||||
|
||||
gmtime_r(&tv.tv_sec, &tmp);
|
||||
|
||||
char timestamp[200];
|
||||
|
||||
strftime(timestamp, sizeof(timestamp), "%F %T", &tmp);
|
||||
|
||||
fprintf(fp, "%c %s.%06ld %s:%u(%s) - %s\n", tox_log_level_show(level)[0], timestamp, tv.tv_usec, file, line, func, message);
|
||||
fprintf(fp, "%c %s.%06ld %s:%u(%s) - %s\n", tox_log_level_show(level)[0], timestamp, tv.tv_usec, file, line, func,
|
||||
message);
|
||||
|
||||
fflush(fp);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user