From 1d8f6e94e73c569f09a2bc8bd008d0ceb2e5b8cc Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Mon, 29 Jul 2013 20:45:53 -0400 Subject: [PATCH 01/57] Fixed formatting of some cmake files --- core/CMakeLists.txt | 14 +++++++------- other/bootstrap_serverdaemon/CMakeLists.txt | 6 ++++-- other/cmake/DHT_bootstrap.cmake | 3 ++- testing/CMakeLists.txt | 4 ++-- testing/cmake/DHT_cryptosendfiletest.cmake | 3 ++- testing/cmake/DHT_sendfiletest.cmake | 2 +- testing/cmake/DHT_test.cmake | 3 ++- testing/cmake/Lossless_UDP_testclient.cmake | 2 +- testing/cmake/Lossless_UDP_testserver.cmake | 2 +- testing/cmake/Messenger_test.cmake | 2 +- testing/cmake/nTox.cmake | 7 ++++--- .../{cmake/toxic.cmake => toxic/CMakeLists.txt} | 8 +++++--- 12 files changed, 32 insertions(+), 24 deletions(-) rename testing/{cmake/toxic.cmake => toxic/CMakeLists.txt} (62%) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 6ddd5b9b..420308d8 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -6,12 +6,12 @@ if(WIN32) endif() set(core_sources - DHT.c - network.c - Lossless_UDP.c - net_crypto.c - friend_requests.c - LAN_discovery.c - Messenger.c) + DHT.c + network.c + Lossless_UDP.c + net_crypto.c + friend_requests.c + LAN_discovery.c + Messenger.c) add_library(core ${core_sources}) diff --git a/other/bootstrap_serverdaemon/CMakeLists.txt b/other/bootstrap_serverdaemon/CMakeLists.txt index 6aa4dbee..57ba4841 100644 --- a/other/bootstrap_serverdaemon/CMakeLists.txt +++ b/other/bootstrap_serverdaemon/CMakeLists.txt @@ -4,7 +4,9 @@ project(DHT_bootstrap_daemon C) set(exe_name DHT_bootstrap_daemon) add_executable(${exe_name} - DHT_bootstrap_daemon.c) + DHT_bootstrap_daemon.c) + +target_link_libraries(${exe_name} + config) -target_link_libraries(${exe_name} config) linkCoreLibraries(${exe_name}) diff --git a/other/cmake/DHT_bootstrap.cmake b/other/cmake/DHT_bootstrap.cmake index e2b164ba..403522ab 100644 --- a/other/cmake/DHT_bootstrap.cmake +++ b/other/cmake/DHT_bootstrap.cmake @@ -4,6 +4,7 @@ project(DHT_bootstrap C) set(exe_name DHT_bootstrap) add_executable(${exe_name} - DHT_bootstrap.c ../testing/misc_tools.c) + DHT_bootstrap.c + ../testing/misc_tools.c) linkCoreLibraries(${exe_name}) diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index 3085b0c5..86f95dc8 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -8,8 +8,8 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_test.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testclient.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testserver.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Messenger_test.cmake) + if(NOT WIN32) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox.cmake) -include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/toxic.cmake) - + add_subdirectory(other) endif() diff --git a/testing/cmake/DHT_cryptosendfiletest.cmake b/testing/cmake/DHT_cryptosendfiletest.cmake index c98a2bcd..5470d02a 100644 --- a/testing/cmake/DHT_cryptosendfiletest.cmake +++ b/testing/cmake/DHT_cryptosendfiletest.cmake @@ -4,6 +4,7 @@ project(DHT_cryptosendfiletest C) set(exe_name DHT_cryptosendfiletest) add_executable(${exe_name} - DHT_cryptosendfiletest.c misc_tools.c) + DHT_cryptosendfiletest.c + misc_tools.c) linkCoreLibraries(${exe_name}) diff --git a/testing/cmake/DHT_sendfiletest.cmake b/testing/cmake/DHT_sendfiletest.cmake index 93737914..298db46c 100644 --- a/testing/cmake/DHT_sendfiletest.cmake +++ b/testing/cmake/DHT_sendfiletest.cmake @@ -4,6 +4,6 @@ project(DHT_sendfiletest C) set(exe_name DHT_sendfiletest) add_executable(${exe_name} - DHT_sendfiletest.c) + DHT_sendfiletest.c) linkCoreLibraries(${exe_name}) diff --git a/testing/cmake/DHT_test.cmake b/testing/cmake/DHT_test.cmake index 74fdf35d..bb5bf05f 100644 --- a/testing/cmake/DHT_test.cmake +++ b/testing/cmake/DHT_test.cmake @@ -4,6 +4,7 @@ project(DHT_test C) set(exe_name DHT_test) add_executable(${exe_name} - DHT_test.c misc_tools.c) + DHT_test.c + misc_tools.c) linkCoreLibraries(${exe_name}) diff --git a/testing/cmake/Lossless_UDP_testclient.cmake b/testing/cmake/Lossless_UDP_testclient.cmake index e894d228..5f651807 100644 --- a/testing/cmake/Lossless_UDP_testclient.cmake +++ b/testing/cmake/Lossless_UDP_testclient.cmake @@ -4,6 +4,6 @@ project(Lossless_UDP_testclient C) set(exe_name Lossless_UDP_testclient) add_executable(${exe_name} - Lossless_UDP_testclient.c) + Lossless_UDP_testclient.c) linkCoreLibraries(${exe_name}) diff --git a/testing/cmake/Lossless_UDP_testserver.cmake b/testing/cmake/Lossless_UDP_testserver.cmake index 04306c1a..26f9302e 100644 --- a/testing/cmake/Lossless_UDP_testserver.cmake +++ b/testing/cmake/Lossless_UDP_testserver.cmake @@ -4,6 +4,6 @@ project(Lossless_UDP_testserver C) set(exe_name Lossless_UDP_testserver) add_executable(${exe_name} - Lossless_UDP_testserver.c) + Lossless_UDP_testserver.c) linkCoreLibraries(${exe_name}) diff --git a/testing/cmake/Messenger_test.cmake b/testing/cmake/Messenger_test.cmake index b2f54d0a..15fcd77b 100644 --- a/testing/cmake/Messenger_test.cmake +++ b/testing/cmake/Messenger_test.cmake @@ -4,6 +4,6 @@ project(Messenger_test C) set(exe_name Messenger_test) add_executable(${exe_name} - Messenger_test.c misc_tools.c) + Messenger_test.c misc_tools.c) linkCoreLibraries(${exe_name}) diff --git a/testing/cmake/nTox.cmake b/testing/cmake/nTox.cmake index 4c6905e5..44476b8f 100644 --- a/testing/cmake/nTox.cmake +++ b/testing/cmake/nTox.cmake @@ -4,8 +4,9 @@ project(nTox C) set(exe_name nTox) add_executable(${exe_name} - nTox.c misc_tools.c) - -target_link_libraries(${exe_name} ncurses) + nTox.c misc_tools.c) + +target_link_libraries(${exe_name} + ncurses) linkCoreLibraries(${exe_name}) diff --git a/testing/cmake/toxic.cmake b/testing/toxic/CMakeLists.txt similarity index 62% rename from testing/cmake/toxic.cmake rename to testing/toxic/CMakeLists.txt index 1ffab788..43eb379a 100644 --- a/testing/cmake/toxic.cmake +++ b/testing/toxic/CMakeLists.txt @@ -4,8 +4,10 @@ project(toxic C) set(exe_name toxic) add_executable(${exe_name} - toxic/main.c toxic/prompt.c) - -target_link_libraries(${exe_name} curses) + toxic/main.c + toxic/prompt.c) + +target_link_libraries(${exe_name} + curses) linkCoreLibraries(${exe_name}) From 261f365e55d4711372f7053667aa368788eabea1 Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Mon, 29 Jul 2013 20:47:12 -0400 Subject: [PATCH 02/57] Fixed function signature --- core/network.c | 2 +- core/network.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/network.c b/core/network.c index aa16bda9..ced08207 100644 --- a/core/network.c +++ b/core/network.c @@ -169,7 +169,7 @@ void shutdown_networking() address should represent IPv4, IPv6 or a hostname on success returns a data in network byte order that can be used to set IP.i or IP_Port.ip.i on failure returns -1 */ -int resolve_addr(char *address) +int resolve_addr(const char *address) { struct addrinfo hints; memset(&hints, 0, sizeof(hints)); diff --git a/core/network.h b/core/network.h index aaaaa409..8af4b32f 100644 --- a/core/network.h +++ b/core/network.h @@ -125,7 +125,7 @@ void shutdown_networking(); address should represent IPv4, IPv6 or a hostname on success returns a data in network byte order that can be used to set IP.i or IP_Port.ip.i on failure returns -1 */ -int resolve_addr(char *address); +int resolve_addr(const char *address); #ifdef __cplusplus } From de7ebc55b1ee31d252160eed88d743c8ef45320b Mon Sep 17 00:00:00 2001 From: Erik Price Date: Mon, 29 Jul 2013 21:32:27 -0400 Subject: [PATCH 03/57] Replace magic value "7" with string "echo" --- core/network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/network.c b/core/network.c index aa16bda9..3cd53ef7 100644 --- a/core/network.c +++ b/core/network.c @@ -178,7 +178,7 @@ int resolve_addr(char *address) struct addrinfo *server = NULL; - int success = getaddrinfo(address, "7", &hints, &server); + int success = getaddrinfo(address, "echo", &hints, &server); if(success != 0) return -1; From 3b52624f58f4044e655920fb4e0784be3a897b03 Mon Sep 17 00:00:00 2001 From: Astonex Date: Tue, 30 Jul 2013 04:41:09 +0100 Subject: [PATCH 04/57] Update INSTALL.md Changing the libsodium link from a list of its release archives to the windows specific one - it is windows specific install instructions after all. --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 8e67d848..c3deec36 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -68,7 +68,7 @@ You have to [modify your PATH environment variable](http://www.computerhope.com/ Then you should either clone this repo by using git, or just download a [zip of current Master branch](https://github.com/irungentoo/ProjectTox-Core/archive/master.zip) and extract it somewhere. -After that you should get precompiled packages of libsodium from [here](https://download.libsodium.org/libsodium/releases/) and extract the archive into this repo's root. That is, `sodium` folder should be along with `core`, `testing` and other folders. +After that you should get precompiled package of libsodium from [here](https://download.libsodium.org/libsodium/releases/libsodium-win32-0.4.2.tar.gz) and extract the archive into this repo's root. That is, `sodium` folder should be along with `core`, `testing` and other folders. Navigate in `cmd` to this repo and run: ```cmd From 09a71f37ec3f18184364d4a6bcc93ab5c50da759 Mon Sep 17 00:00:00 2001 From: Ryan Lewon Date: Tue, 30 Jul 2013 07:19:07 +0000 Subject: [PATCH 05/57] New friend list function for nTox client. --- testing/nTox.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/testing/nTox.c b/testing/nTox.c index 960dfb27..b5fff89d 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -20,10 +20,11 @@ * along with Tox. If not, see . * */ - +#include "../core/DHT.c" #include "nTox.h" #include "misc_tools.h" + #include #include #ifdef WIN32 @@ -50,6 +51,25 @@ void new_lines(char *line) do_refresh(); } +void print_friendlist() +{ + char name[MAX_NAME_LENGTH]; + uint32_t i; + + new_lines("[i] Friend List:"); + for (i=0; i <= num_requests; i++) { + char fstring[128]; + + getname(i, (uint8_t*)name); + if (strlen(name) <= 0) { + sprintf(fstring, "[i] Friend: NULL\n\tid: %i", i); + } else { + sprintf(fstring, "[i] Friend: %s\n\tid: %i", (uint8_t*)name, i); + } + new_lines(fstring); + } +} + void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) { if (line[0] == '/') { @@ -104,6 +124,9 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) sprintf(numstring, "[i] changed nick to %s", (char*)name); new_lines(numstring); } + else if (line[1] == 'l') { + print_friendlist(); + } else if (line[1] == 's') { uint8_t status[MAX_USERSTATUS_LENGTH]; int i = 0; @@ -313,7 +336,8 @@ int main(int argc, char *argv[]) raw(); getmaxyx(stdscr,y,x); new_lines(idstring0); - new_lines("[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status), /n nick (to change nickname), /q (to quit)"); + new_lines("[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status)"); + new_lines("[i] /l list (list friends), /n nick (to change nickname), /q (to quit)"); strcpy(line, ""); IP_Port bootstrap_ip_port; bootstrap_ip_port.port = htons(atoi(argv[2])); From 20aad9c73bfad93099a2614d7be1fe8a245665c7 Mon Sep 17 00:00:00 2001 From: Ryan Lewon Date: Tue, 30 Jul 2013 07:26:58 +0000 Subject: [PATCH 06/57] Removed unneeded include. Fixed formatting and cleaned up output. --- testing/nTox.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/testing/nTox.c b/testing/nTox.c index b5fff89d..b926ebca 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -20,7 +20,6 @@ * along with Tox. If not, see . * */ -#include "../core/DHT.c" #include "nTox.h" #include "misc_tools.h" @@ -62,9 +61,9 @@ void print_friendlist() getname(i, (uint8_t*)name); if (strlen(name) <= 0) { - sprintf(fstring, "[i] Friend: NULL\n\tid: %i", i); - } else { - sprintf(fstring, "[i] Friend: %s\n\tid: %i", (uint8_t*)name, i); + sprintf(fstring, "[i] Friend: NULL\n\tid: %i", i); + } else { + sprintf(fstring, "[i] Friend: %s\n\tid: %i", (uint8_t*)name, i); } new_lines(fstring); } From 1c345e7f6bccd239398936f61eff9ff0a45577fe Mon Sep 17 00:00:00 2001 From: Emir Unluturk Date: Tue, 30 Jul 2013 12:31:02 +0300 Subject: [PATCH 07/57] Add invalid command --- testing/nTox.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/testing/nTox.c b/testing/nTox.c index 960dfb27..201f4a54 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -132,8 +132,11 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) else if (line[1] == 'q') { //exit endwin(); exit(EXIT_SUCCESS); + } else { + new_lines("[i] invalid command"); } } else { + new_lines("[i] invalid command"); //new_lines(line); } } From 5a6645709b72e932ff8d47f3141d3f7346b49a5f Mon Sep 17 00:00:00 2001 From: irungentoo Date: Tue, 30 Jul 2013 07:38:47 -0400 Subject: [PATCH 08/57] Fixed build. --- testing/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index af771085..b942e1ca 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -15,5 +15,4 @@ endif() if(NOT WIN32) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/toxic.cmake) - add_subdirectory(other) endif() From dbdeb670e467eac430789c6ec8f03ebad7a5edf1 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Tue, 30 Jul 2013 08:43:44 -0400 Subject: [PATCH 09/57] Typo in readme fixed. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b4381bc9..8f903bc0 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ With the rise of governmental monitoring programs, Tox aims to be an easy to use + Tox must use UDP simply because you can't hole punch with TCP. It's possible, but it doesn't work all the time. + Every peer is represented as a byte string (the public key of the peer [client id]) + We're using torrent-style DHT so that peers can find the IP of the other peers when they have their ID. -+ Once the client has the IP of that peer, they start initiating a secure connection with each other. (See [Crypto](https://github.com/irungentoo/ProjectTox-Core/wiki/Crypto) ++ Once the client has the IP of that peer, they start initiating a secure connection with each other. (See [Crypto](https://github.com/irungentoo/ProjectTox-Core/wiki/Crypto)) + When both peers are securely connect with the encryption, they can securely exchange messages, initiate a video chat, send files, etc.
+ Current build status: [![Build Status](https://travis-ci.org/irungentoo/ProjectTox-Core.png?branch=master)](https://travis-ci.org/irungentoo/ProjectTox-Core) From 3f85bdca15d2f0258413039978b6552965385335 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Tue, 30 Jul 2013 08:48:36 -0400 Subject: [PATCH 10/57] Fixed warning. --- testing/DHT_test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/testing/DHT_test.c b/testing/DHT_test.c index 2e9c2ac2..a215463d 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c @@ -134,7 +134,9 @@ int main(int argc, char *argv[]) char temp_id[128]; printf("\nEnter the client_id of the friend you wish to add (32 bytes HEX format):\n"); - scanf("%s", temp_id); + if(scanf("%s", temp_id) != 1) + exit(0); + DHT_addfriend(hex_string_to_bin(temp_id)); /* initialize networking */ From 1ae27fb227939dc2debb69bb02530ae183663367 Mon Sep 17 00:00:00 2001 From: dypa Date: Tue, 30 Jul 2013 06:40:16 -0700 Subject: [PATCH 11/57] replace make install to checkinstall for linux installation --- INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index c3deec36..d309cbcd 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -5,7 +5,7 @@ Build dependencies: ```bash -apt-get install build-essential libtool autotools-dev automake libconfig-dev ncurses-dev +apt-get install build-essential libtool autotools-dev automake libconfig-dev ncurses-dev checkinstall ``` You should get and install [libsodium](https://github.com/jedisct1/libsodium): @@ -15,7 +15,7 @@ cd libsodium git checkout tags/0.4.2 ./autogen.sh ./configure && make check -sudo make install +sudo checkinstall --install --pkgname libsodium --pkgversion 0.4.2 --nodoc sudo ldconfig ``` From d1a26f720f68640dad2616645d28c328ecb1cfcd Mon Sep 17 00:00:00 2001 From: Greg Date: Tue, 30 Jul 2013 11:04:59 -0400 Subject: [PATCH 12/57] Update INSTALL.md --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index c3deec36..8ab367e7 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -5,7 +5,7 @@ Build dependencies: ```bash -apt-get install build-essential libtool autotools-dev automake libconfig-dev ncurses-dev +apt-get install build-essential libtool autotools-dev automake libconfig-dev ncurses-dev cmake ``` You should get and install [libsodium](https://github.com/jedisct1/libsodium): From 12b19f691072b7cf292329953a9f8516dc6bf0a1 Mon Sep 17 00:00:00 2001 From: Peter Maatman Date: Tue, 30 Jul 2013 17:09:09 +0200 Subject: [PATCH 13/57] renamed getname to getfriendname and added a getname function to get the name of our client --- core/Messenger.c | 8 +++++++- core/Messenger.h | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/core/Messenger.c b/core/Messenger.c index f77b4491..148c3350 100644 --- a/core/Messenger.c +++ b/core/Messenger.c @@ -234,12 +234,18 @@ int setname(uint8_t * name, uint16_t length) return 0; } +int getname(uint8_t *name) +{ + memcpy(name, self_name, sizeof(self_name)); + return 0; +} + /* get name of friendnumber put it in name name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH bytes. return 0 if success return -1 if failure */ -int getname(int friendnumber, uint8_t * name) +int getfriendname(int friendnumber, uint8_t * name) { if (friendnumber >= numfriends || friendnumber < 0) return -1; diff --git a/core/Messenger.h b/core/Messenger.h index 7263901c..08f6de2a 100644 --- a/core/Messenger.h +++ b/core/Messenger.h @@ -92,12 +92,16 @@ int m_sendmessage(int friendnumber, uint8_t *message, uint32_t length); return -1 if failure */ int setname(uint8_t *name, uint16_t length); +/* Get our own nickname + Set's name to the our own nickname */ +int getname(uint8_t *name); + /* get name of friendnumber put it in name name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes. return 0 if success return -1 if failure */ -int getname(int friendnumber, uint8_t *name); +int getfriendname(int friendnumber, uint8_t *name); /* set our user status you are responsible for freeing status after From 2c756f1c53e0c4faad8716425eafdf1b6e58f5c0 Mon Sep 17 00:00:00 2001 From: Peter Maatman Date: Tue, 30 Jul 2013 17:10:20 +0200 Subject: [PATCH 14/57] changing testing clients to reflect changes made in core/Messenger.h --- testing/Messenger_test.c | 2 +- testing/nTox.c | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c index 0518d284..baecea36 100644 --- a/testing/Messenger_test.c +++ b/testing/Messenger_test.c @@ -128,7 +128,7 @@ int main(int argc, char *argv[]) while(1) { uint8_t name[128]; - getname(num, name); + getfriendname(num, name); printf("%s\n", name); m_sendmessage(num, (uint8_t*)"Test", 5); diff --git a/testing/nTox.c b/testing/nTox.c index 960dfb27..c960f761 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -88,6 +88,19 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) int num = atoi(numstring); if(m_sendmessage(num, (uint8_t*) message, sizeof(message)) != 1) { new_lines("[i] could not send message"); + } else { + char name[MAX_NAME_LENGTH]; + getname((uint8_t*)name); + char msg[100+strlen(message)+strlen(name)+1]; + time_t rawtime; + struct tm * timeinfo; + time ( &rawtime ); + timeinfo = localtime ( &rawtime ); + char* time = asctime(timeinfo); + size_t len = strlen(time); + time[len-1]='\0'; + sprintf(msg, "[%d] %s <%s> %s", num, time, name, message); // timestamp + new_lines(msg); } } else if (line[1] == 'n') { @@ -214,7 +227,7 @@ void print_request(uint8_t *public_key, uint8_t *data, uint16_t length) void print_message(int friendnumber, uint8_t * string, uint16_t length) { char name[MAX_NAME_LENGTH]; - getname(friendnumber, (uint8_t*)name); + getfriendname(friendnumber, (uint8_t*)name); char msg[100+length+strlen(name)+1]; time_t rawtime; struct tm * timeinfo; @@ -229,7 +242,7 @@ void print_message(int friendnumber, uint8_t * string, uint16_t length) void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) { char name[MAX_NAME_LENGTH]; - getname(friendnumber, (uint8_t*)name); + getfriendname(friendnumber, (uint8_t*)name); char msg[100+length]; sprintf(msg, "[i] [%d] %s is now known as %s.", friendnumber, name, string); new_lines(msg); @@ -237,7 +250,7 @@ void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) { void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) { char name[MAX_NAME_LENGTH]; - getname(friendnumber, (uint8_t*)name); + getfriendname(friendnumber, (uint8_t*)name); char msg[100+length+strlen(name)+1]; sprintf(msg, "[i] [%d] %s's status changed to %s.", friendnumber, name, string); new_lines(msg); From dc57b779d2e3d1df836698cd119a3890ffecf86d Mon Sep 17 00:00:00 2001 From: Peter Maatman Date: Tue, 30 Jul 2013 17:32:17 +0200 Subject: [PATCH 15/57] added utility function format_message --- testing/nTox.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/testing/nTox.c b/testing/nTox.c index c960f761..3d410f19 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -50,6 +50,26 @@ void new_lines(char *line) do_refresh(); } +char *format_message(char *message, int friendnum) +{ + char name[MAX_NAME_LENGTH]; + if(friendnum != -1) { + getfriendname(friendnum, (uint8_t*)name); + } else { + getname((uint8_t*)name); + } + char *msg = malloc(100+strlen(message)+strlen(name)+1); + time_t rawtime; + struct tm * timeinfo; + time ( &rawtime ); + timeinfo = localtime ( &rawtime ); + char* time = asctime(timeinfo); + size_t len = strlen(time); + time[len-1]='\0'; + sprintf(msg, "[%d] %s <%s> %s", friendnum, time, name, message); // timestamp + return msg; +} + void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) { if (line[0] == '/') { @@ -89,18 +109,7 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) if(m_sendmessage(num, (uint8_t*) message, sizeof(message)) != 1) { new_lines("[i] could not send message"); } else { - char name[MAX_NAME_LENGTH]; - getname((uint8_t*)name); - char msg[100+strlen(message)+strlen(name)+1]; - time_t rawtime; - struct tm * timeinfo; - time ( &rawtime ); - timeinfo = localtime ( &rawtime ); - char* time = asctime(timeinfo); - size_t len = strlen(time); - time[len-1]='\0'; - sprintf(msg, "[%d] %s <%s> %s", num, time, name, message); // timestamp - new_lines(msg); + new_lines(format_message(message, -1)); } } else if (line[1] == 'n') { @@ -237,7 +246,7 @@ void print_message(int friendnumber, uint8_t * string, uint16_t length) size_t len = strlen(temp); temp[len-1]='\0'; sprintf(msg, "[%d] %s <%s> %s", friendnumber, temp, name, string); // timestamp - new_lines(msg); + new_lines(format_message((char*)string, friendnumber)); } void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) { From 915ffaa8889eee6153b7507c838f77dbbd7905ae Mon Sep 17 00:00:00 2001 From: Greg Date: Tue, 30 Jul 2013 11:58:51 -0400 Subject: [PATCH 16/57] Update nTox.c Added help command to nTox.c --- testing/nTox.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/testing/nTox.c b/testing/nTox.c index f00fe200..97a39a12 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -151,6 +151,12 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) do_refresh(); } + + else if (line[1] == 'h') { //help + new_lines("[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status)"); + new_lines("[i] /l list (list friends), /h for help, /n nick (to change nickname), /q (to quit)"); + } + else if (line[1] == 'q') { //exit endwin(); exit(EXIT_SUCCESS); From 184eaacd2a0e49277367001b209f1844ea017ace Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Tue, 30 Jul 2013 11:55:46 -0400 Subject: [PATCH 17/57] Fixed cmake --- testing/CMakeLists.txt | 6 +++--- testing/cmake/toxic.cmake | 11 ----------- testing/toxic/CMakeLists.txt | 4 ++-- 3 files changed, 5 insertions(+), 16 deletions(-) delete mode 100644 testing/cmake/toxic.cmake diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index b942e1ca..abbc278e 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -9,10 +9,10 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testclient.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testserver.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Messenger_test.cmake) if(WIN32) - include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox_win32.cmake) + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox_win32.cmake) endif() if(NOT WIN32) - include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox.cmake) - include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/toxic.cmake) + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox.cmake) + add_subdirectory(toxic) endif() diff --git a/testing/cmake/toxic.cmake b/testing/cmake/toxic.cmake deleted file mode 100644 index 1ffab788..00000000 --- a/testing/cmake/toxic.cmake +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 2.6.0) -project(toxic C) - -set(exe_name toxic) - -add_executable(${exe_name} - toxic/main.c toxic/prompt.c) - -target_link_libraries(${exe_name} curses) - -linkCoreLibraries(${exe_name}) diff --git a/testing/toxic/CMakeLists.txt b/testing/toxic/CMakeLists.txt index 43eb379a..4f9785d5 100644 --- a/testing/toxic/CMakeLists.txt +++ b/testing/toxic/CMakeLists.txt @@ -4,8 +4,8 @@ project(toxic C) set(exe_name toxic) add_executable(${exe_name} - toxic/main.c - toxic/prompt.c) + main.c + prompt.c) target_link_libraries(${exe_name} curses) From 60250546ca7876cc013217d8e21716322dd76378 Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Tue, 30 Jul 2013 13:27:32 -0400 Subject: [PATCH 18/57] Added a note about libconfig --- INSTALL.md | 1 + 1 file changed, 1 insertion(+) diff --git a/INSTALL.md b/INSTALL.md index 9e89c8b3..3459a5c7 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -7,6 +7,7 @@ Build dependencies: ```bash apt-get install build-essential libtool autotools-dev automake libconfig-dev ncurses-dev cmake checkinstall ``` +Note that `libconfig-dev` should be >= 1.4. You should get and install [libsodium](https://github.com/jedisct1/libsodium): ```bash From 77fa38f597305195d50c6674150365a601c30add Mon Sep 17 00:00:00 2001 From: irungentoo Date: Tue, 30 Jul 2013 14:32:18 -0400 Subject: [PATCH 19/57] Clarification. --- core/Messenger.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/Messenger.c b/core/Messenger.c index 3a287363..272c5fa7 100644 --- a/core/Messenger.c +++ b/core/Messenger.c @@ -242,6 +242,7 @@ int setname(uint8_t * name, uint16_t length) /* get our nickname put it in name + name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH bytes. return the length of the name */ uint16_t getself_name(uint8_t *name) { From 6d0abb4132e4aa215c713ae3d0fa365957cd865c Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Tue, 30 Jul 2013 22:39:04 +0400 Subject: [PATCH 20/57] Add missing newlines at EOF in sources (missing newlines break build due to -Werror) --- core/friend_requests.h | 2 +- testing/Lossless_UDP_testclient.c | 2 +- testing/Lossless_UDP_testserver.c | 2 +- testing/misc_tools.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/friend_requests.h b/core/friend_requests.h index e38f7edc..4dfc5130 100644 --- a/core/friend_requests.h +++ b/core/friend_requests.h @@ -48,4 +48,4 @@ int friendreq_handlepacket(uint8_t *packet, uint32_t length, IP_Port source); } #endif -#endif \ No newline at end of file +#endif diff --git a/testing/Lossless_UDP_testclient.c b/testing/Lossless_UDP_testclient.c index c1eaa69d..b96756ab 100644 --- a/testing/Lossless_UDP_testclient.c +++ b/testing/Lossless_UDP_testclient.c @@ -211,4 +211,4 @@ int main(int argc, char *argv[]) } return 0; -} \ No newline at end of file +} diff --git a/testing/Lossless_UDP_testserver.c b/testing/Lossless_UDP_testserver.c index 4b437f0e..29b0ade5 100644 --- a/testing/Lossless_UDP_testserver.c +++ b/testing/Lossless_UDP_testserver.c @@ -198,4 +198,4 @@ int main(int argc, char *argv[]) } return 0; -} \ No newline at end of file +} diff --git a/testing/misc_tools.h b/testing/misc_tools.h index 29b37ce5..5079e15d 100644 --- a/testing/misc_tools.h +++ b/testing/misc_tools.h @@ -26,4 +26,4 @@ unsigned char * hex_string_to_bin(char hex_string[]); -#endif // MISC_TOOLS_H \ No newline at end of file +#endif // MISC_TOOLS_H From 5ac7f3d99084d519e7eddcf40e7d81e8b91400f0 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Tue, 30 Jul 2013 22:41:09 +0400 Subject: [PATCH 21/57] Fix "comparison is always true due to limited range of data type" warning --- testing/DHT_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/DHT_test.c b/testing/DHT_test.c index a215463d..588450e2 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c @@ -87,7 +87,7 @@ void print_friendlist() for(i = 0; i < 4; i++) { printf("ClientID: "); for(j = 0; j < 32; j++) { - if(0 <= friends_list[k].client_list[i].client_id[j] && friends_list[k].client_list[i].client_id[j] < 16) + if(friends_list[k].client_list[i].client_id[j] < 16) printf("0"); printf("%hhX", friends_list[k].client_list[i].client_id[j]); } From bd695135dcb9220e6a75e48975dd8473d3d1fcbe Mon Sep 17 00:00:00 2001 From: irungentoo Date: Tue, 30 Jul 2013 14:43:32 -0400 Subject: [PATCH 22/57] Fixed segfault. --- core/Lossless_UDP.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/Lossless_UDP.c b/core/Lossless_UDP.c index eb1314d1..6be8328f 100644 --- a/core/Lossless_UDP.c +++ b/core/Lossless_UDP.c @@ -308,12 +308,16 @@ IP_Port connection_ip(int connection_id) /* returns the number of packets in the queue waiting to be successfully sent. */ uint32_t sendqueue(int connection_id) { + if (connection_id < 0 || connection_id >= MAX_CONNECTIONS) + return 0; return connections[connection_id].sendbuff_packetnum - connections[connection_id].successful_sent; } /* returns the number of packets in the queue waiting to be successfully read with read_packet(...) */ uint32_t recvqueue(int connection_id) { + if (connection_id < 0 || connection_id >= MAX_CONNECTIONS) + return 0; return connections[connection_id].recv_packetnum - connections[connection_id].successful_read; } @@ -321,6 +325,8 @@ uint32_t recvqueue(int connection_id) return -1 if no packet in queue */ char id_packet(int connection_id) { + if (connection_id < 0 || connection_id >= MAX_CONNECTIONS) + return -1; if (recvqueue(connection_id) != 0 && connections[connection_id].status != 0) return connections[connection_id].recvbuffer[connections[connection_id].successful_read % MAX_QUEUE_NUM].data[0]; return -1; From 0fd49915f44df7e106401b41e3826f23de78b932 Mon Sep 17 00:00:00 2001 From: Shivam Bansal Date: Tue, 30 Jul 2013 12:02:16 -0700 Subject: [PATCH 23/57] Update .gitignore --- .gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 010561a2..9969b38d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,11 @@ install_manifest.txt testing/data *~ + +# Object files +*.o + +# Executables +*.exe +*.out +*.app From fd13ae24c4f88f62ef34b40358d272747820094d Mon Sep 17 00:00:00 2001 From: Rylai Date: Tue, 30 Jul 2013 14:43:31 -0400 Subject: [PATCH 24/57] travis: use apt-get -y option instead of GNU yes The Advanced Packaging Tool has an option to automatically assume Yes to all queries. We don't need to use GNU yes for this. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9de4e282..3386e678 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ before_script: # installing libconfig, needed for DHT_bootstrap_daemon - sudo sed -i 's/precise/quantal/' /etc/apt/sources.list # needed for libconfig-dev - sudo apt-get update -qq - - yes | sudo apt-get install libconfig-dev + - sudo apt-get -y install libconfig-dev script: - mkdir build && cd build From 579fa95df45c18b79507fe96a8cca74f2be70442 Mon Sep 17 00:00:00 2001 From: Rylai Date: Tue, 30 Jul 2013 15:16:17 -0400 Subject: [PATCH 25/57] travis: use -q instead of -qq to prevent travis from sometimes timing out on long apt-get updates --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3386e678..ff1732a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ before_script: - cd .. # installing libconfig, needed for DHT_bootstrap_daemon - sudo sed -i 's/precise/quantal/' /etc/apt/sources.list # needed for libconfig-dev - - sudo apt-get update -qq + - sudo apt-get update -q - sudo apt-get -y install libconfig-dev script: From 026790e181a4dd26a60bcbada3e546a1c5e50888 Mon Sep 17 00:00:00 2001 From: plutooo Date: Tue, 30 Jul 2013 12:47:40 -0700 Subject: [PATCH 26/57] Fixed a bunch of bugs in TOXIC, added friendlist and more. --- testing/toxic/CMakeLists.txt | 3 +- testing/toxic/friendlist.c | 125 +++++++++++++++++++++++++++++++++++ testing/toxic/main.c | 49 ++++++++++++-- testing/toxic/prompt.c | 107 +++++++++++++++++++----------- 4 files changed, 239 insertions(+), 45 deletions(-) create mode 100644 testing/toxic/friendlist.c diff --git a/testing/toxic/CMakeLists.txt b/testing/toxic/CMakeLists.txt index 4f9785d5..c70babb7 100644 --- a/testing/toxic/CMakeLists.txt +++ b/testing/toxic/CMakeLists.txt @@ -5,7 +5,8 @@ set(exe_name toxic) add_executable(${exe_name} main.c - prompt.c) + prompt.c + friendlist.c) target_link_libraries(${exe_name} curses) diff --git a/testing/toxic/friendlist.c b/testing/toxic/friendlist.c new file mode 100644 index 00000000..f8b8c840 --- /dev/null +++ b/testing/toxic/friendlist.c @@ -0,0 +1,125 @@ +/* + * Toxic -- Tox Curses Client + */ + +#include +#include +#include +#include + +#include "../../core/Messenger.h" +#include "../../core/network.h" + +#include "windows.h" + +#define MAX_FRIENDS_NUM 100 + +typedef struct { + uint8_t name[MAX_NAME_LENGTH]; + uint8_t status[MAX_USERSTATUS_LENGTH]; + int num; + +} friend_t; + +static friend_t friends[MAX_FRIENDS_NUM]; +static int num_friends = 0; + + +void fix_name(uint8_t* name) { + + // Remove all non alphanumeric characters. + uint8_t* p = name; + uint8_t* q = name; + + while(*p != 0) { + if(isalnum(*p)) { + *q++ = *p; + } + + p++; + } + + *q = 0; +} + +int friendlist_nickchange(int num, uint8_t* str, uint16_t len) { + + if(len >= MAX_NAME_LENGTH || num >= num_friends) + return -1; + + memcpy((char*) &friends[num].name, (char*) str, len); + friends[num].name[len] = 0; + fix_name(friends[num].name); + + return 0; +} + +int friendlist_statuschange(int num, uint8_t* str, uint16_t len) { + + if(len >= MAX_USERSTATUS_LENGTH || num >= num_friends) + return -1; + + memcpy((char*) &friends[num].status, (char*) str, len); + friends[num].status[len] = 0; + fix_name(friends[num].status); + + return 0; +} + +int friendlist_addfriend(int num) { + + if(num_friends == MAX_FRIENDS_NUM) + return -1; + + friends[num_friends].num = num; + getname(num, friends[num_friends].name); + strcpy((char*) friends[num_friends].name, "unknown"); + strcpy((char*) friends[num_friends].status, "unknown"); + + num_friends++; + return 0; +} + +static void friendlist_onKey(ToxWindow* self, int key) { + +} + +static void friendlist_onDraw(ToxWindow* self) { + size_t i; + + wclear(self->window); + + if(num_friends == 0) { + wprintw(self->window, "Empty. Add some friends! :-)\n"); + } + + wprintw(self->window, "\n"); + + for(i=0; iwindow, "[%d] ", friends[i].num); + + attron(A_BOLD); + wprintw(self->window, "%s ", friends[i].name); + attroff(A_BOLD); + + wprintw(self->window, "(%s)\n", friends[i].status); + } + + wrefresh(self->window); +} + +static void friendlist_onInit(ToxWindow* self) { + +} + + +ToxWindow new_friendlist() { + ToxWindow ret; + + ret.onKey = &friendlist_onKey; + ret.onDraw = &friendlist_onDraw; + ret.onInit = &friendlist_onInit; + strcpy(ret.title, "[friends]"); + + return ret; +} diff --git a/testing/toxic/main.c b/testing/toxic/main.c index 0aad6777..e1d1ebd0 100644 --- a/testing/toxic/main.c +++ b/testing/toxic/main.c @@ -14,6 +14,12 @@ #include "windows.h" extern ToxWindow new_prompt(); +extern ToxWindow new_friendlist(); + +extern int friendlist_addfriend(int num); +extern int friendlist_nickchange(int num, uint8_t* str, uint16_t len); +extern int friendlist_statuschange(int num, uint8_t* str, uint16_t len); + extern int add_req(uint8_t* public_key); // XXX #define TOXWINDOWS_MAX_NUM 32 @@ -35,11 +41,19 @@ void on_message(int friendnumber, uint8_t* string, uint16_t length) { } void on_nickchange(int friendnumber, uint8_t* string, uint16_t length) { - wprintw(prompt->window, "\n(nick) %d: %s!\n", friendnumber, string); + wprintw(prompt->window, "\n(nickchange) %d: %s!\n", friendnumber, string); + + friendlist_nickchange(friendnumber, string, length); } void on_statuschange(int friendnumber, uint8_t* string, uint16_t length) { - wprintw(prompt->window, "\n(status) %d: %s!\n", friendnumber, string); + wprintw(prompt->window, "\n(statuschange) %d: %s!\n", friendnumber, string); + + friendlist_statuschange(friendnumber, string, length); +} + +void on_friendadded(int friendnumber) { + friendlist_addfriend(friendnumber); } // CALLBACKS END @@ -95,7 +109,7 @@ static void init_windows() { w_num = 0; w_active = 0; - if(add_window(new_prompt()) == -1) { + if(add_window(new_prompt()) == -1 || add_window(new_friendlist()) == -1) { fprintf(stderr, "add_window() failed.\n"); endwin(); @@ -134,14 +148,18 @@ static void load_data() { if(buf == NULL) { fprintf(stderr, "malloc() failed.\n"); + fclose(fd); + endwin(); exit(1); } if(fread(buf, len, 1, fd) != 1){ fprintf(stderr, "fread() failed.\n"); + free(buf); fclose(fd); + endwin(); exit(1); } @@ -153,6 +171,7 @@ static void load_data() { if(buf == NULL) { fprintf(stderr, "malloc() failed.\n"); + endwin(); exit(1); } @@ -161,14 +180,18 @@ static void load_data() { fd = fopen("data", "w"); if(fd == NULL) { fprintf(stderr, "fopen() failed.\n"); + free(buf); + endwin(); exit(1); } if(fwrite(buf, len, 1, fd) != 1){ fprintf(stderr, "fwrite() failed.\n"); + free(buf); fclose(fd); + endwin(); exit(1); } } @@ -186,12 +209,16 @@ static void draw_bar() { move(LINES - 1, 0); + attron(COLOR_PAIR(3) | A_BOLD); + printw(" TOXIC 1.0 |"); + attroff(COLOR_PAIR(3) | A_BOLD); + for(i=0; iwindow); a->onDraw(a); draw_bar(); + // Handle input. ch = getch(); - if(ch != ERR) { + if(ch == '\t') { + w_active = (w_active + 1) % w_num; + } + else if(ch != ERR) { a->onKey(a, ch); } diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c index 4a59cc7b..22d9eb9e 100644 --- a/testing/toxic/prompt.c +++ b/testing/toxic/prompt.c @@ -15,6 +15,8 @@ uint8_t pending_requests[256][CLIENT_ID_SIZE]; // XXX uint8_t num_requests=0; // XXX +extern void on_friendadded(int friendnumber); + // XXX: int add_req(uint8_t* public_key) { memcpy(pending_requests[num_requests], public_key, CLIENT_ID_SIZE); @@ -40,7 +42,6 @@ static int prompt_buf_pos=0; static void execute(ToxWindow* self, char* cmd) { - // quit/exit: Exit program. if(!strcmp(cmd, "quit") || !strcmp(cmd, "exit")) { endwin(); exit(0); @@ -53,33 +54,32 @@ static void execute(ToxWindow* self, char* cmd) { ip = strchr(cmd, ' '); if(ip == NULL) { + wprintw(self->window, "Invalid syntax.\n"); return; } - ip++; port = strchr(ip, ' '); if(port == NULL) { + wprintw(self->window, "Invalid syntax.\n"); return; } - port[0] = 0; port++; key = strchr(port, ' '); if(key == NULL) { + wprintw(self->window, "Invalid syntax.\n"); return; } - key[0] = 0; key++; if(atoi(port) == 0) { + wprintw(self->window, "Invalid syntax.\n"); return; } - wprintw(self->window, "ip=%s, port=%s, key=%s\n", ip, port, key); - dht.port = htons(atoi(port)); int resolved_address = resolve_addr(ip); @@ -91,38 +91,62 @@ static void execute(ToxWindow* self, char* cmd) { DHT_bootstrap(dht, hex_string_to_bin(key)); } else if(!strncmp(cmd, "add ", strlen("add "))) { + uint8_t id_bin[32]; + size_t i; + char xx[3]; + uint32_t x; + char* id; char* msg; int num; id = strchr(cmd, ' '); - if(id == NULL) { + wprintw(self->window, "Invalid syntax.\n"); return; } - id++; msg = strchr(id, ' '); - if(msg == NULL) { + if(msg != NULL) { + msg[0] = 0; + msg++; + } + else msg = ""; + + if(strlen(id) != 2*32) { + wprintw(self->window, "Invalid ID length.\n"); return; } - msg[0] = 0; - msg++; + for(i=0; i<32; i++) { + xx[0] = id[2*i]; + xx[1] = id[2*i+1]; + xx[2] = '\0'; + + if(sscanf(xx, "%02x", &x) != 1) { + wprintw(self->window, "Invalid ID.\n"); + return; + } + + id_bin[i] = x; + } + + num = m_addfriend(id_bin, (uint8_t*) msg, strlen(msg)+1); - num = m_addfriend((uint8_t*) id, (uint8_t*) msg, strlen(msg)+1); wprintw(self->window, "Friend added as %d.\n", num); + on_friendadded(num); } else if(!strncmp(cmd, "status ", strlen("status "))) { char* msg; msg = strchr(cmd, ' '); if(msg == NULL) { + wprintw(self->window, "Invalid syntax.\n"); return; } - msg++; + m_set_userstatus((uint8_t*) msg, strlen(msg)+1); wprintw(self->window, "Status set to: %s.\n", msg); } @@ -133,33 +157,22 @@ static void execute(ToxWindow* self, char* cmd) { if(nick == NULL) { return; } - nick++; + setname((uint8_t*) nick, strlen(nick)+1); wprintw(self->window, "Nickname set to: %s.\n", nick); } else if(!strcmp(cmd, "myid")) { - // XXX: Clean this up - char idstring0[200]; - char idstring1[32][5]; - char idstring2[32][5]; - uint32_t i; + char id[32*2 + 1] = {0}; + size_t i; - for(i = 0; i < 32; i++) { - if(self_public_key[i] < 16) - strcpy(idstring1[i], "0"); - else - strcpy(idstring1[i], ""); - - sprintf(idstring2[i], "%hhX", self_public_key[i]); + for(i=0; i<32; i++) { + char xx[3]; + snprintf(xx, sizeof(xx), "%02x", self_public_key[i] & 0xff); + strcat(id, xx); } - for (i=0; i<32; i++) { - strcat(idstring0, idstring1[i]); - strcat(idstring0, idstring2[i]); - } - - wprintw(self->window, "%s\n", idstring0); + wprintw(self->window, "%s\n", id); } else if(!strncmp(cmd, "accept ", strlen("accept "))) { char* id; @@ -167,17 +180,26 @@ static void execute(ToxWindow* self, char* cmd) { id = strchr(cmd, ' '); if(id == NULL) { + wprintw(self->window, "Invalid syntax.\n"); return; } id++; - + num = atoi(id); if(num >= num_requests) { + wprintw(self->window, "Invalid syntax.\n"); return; } num = m_addfriend_norequest(pending_requests[num]); - wprintw(self->window, "Friend accepted as: %d.\n", num); + + if(num == -1) { + wprintw(self->window, "Failed to add friend.\n"); + } + else { + wprintw(self->window, "Friend accepted as: %d.\n", num); + on_friendadded(num); + } } else if(!strncmp(cmd, "msg ", strlen("msg "))) { char* id; @@ -186,16 +208,16 @@ static void execute(ToxWindow* self, char* cmd) { id = strchr(cmd, ' '); if(id == NULL) { + wprintw(self->window, "Invalid syntax.\n"); return; } - id++; msg = strchr(id, ' '); if(msg == NULL) { + wprintw(self->window, "Invalid syntax.\n"); return; } - msg[0] = 0; msg++; @@ -206,6 +228,9 @@ static void execute(ToxWindow* self, char* cmd) { wprintw(self->window, "Message successfully sent.\n"); } } + else { + wprintw(self->window, "Invalid syntax.\n"); + } } static void prompt_onKey(ToxWindow* self, int key) { @@ -242,9 +267,6 @@ static void prompt_onKey(ToxWindow* self, int key) { static void prompt_onDraw(ToxWindow* self) { int x, y; - mvwin(self->window,0,0); - wresize(self->window, LINES-2, COLS); - getyx(self->window, y, x); (void) x; @@ -265,11 +287,18 @@ static void print_usage(ToxWindow* self) { wprintw(self->window, " connect : Connect to DHT server\n"); wprintw(self->window, " add : Add friend\n"); + wprintw(self->window, " msg : Send message\n"); wprintw(self->window, " status : Set your status\n"); wprintw(self->window, " nick : Set your nickname\n"); wprintw(self->window, " accept : Accept friend request\n"); wprintw(self->window, " myid : Print your ID\n"); wprintw(self->window, " quit/exit : Exit program\n"); + + + wattron(self->window, A_BOLD); + wprintw(self->window, "Use the TAB key to navigate through the tabs.\n"); + wattroff(self->window, A_BOLD); + wattroff(self->window, COLOR_PAIR(2)); } From 3edb2f1f1277d9fce93d2c02e61e62a85ff0ca30 Mon Sep 17 00:00:00 2001 From: Greg Date: Tue, 30 Jul 2013 17:36:25 -0400 Subject: [PATCH 27/57] Update nTox.c Gives the user his ID. --- testing/nTox.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/testing/nTox.c b/testing/nTox.c index 9876f4ba..a12d6cf0 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -179,7 +179,29 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) new_lines("[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status)"); new_lines("[i] /l list (list friends), /h for help, /n nick (to change nickname), /q (to quit)"); } - + + else if (line[1] == 'i') { //info + char idstring0[200]; + char idstring1[32][5]; + char idstring2[32][5]; + uint32_t i; + for(i = 0; i < 32; i++) + { + if(self_public_key[i] < 16) + strcpy(idstring1[i],"0"); + else + strcpy(idstring1[i], ""); + sprintf(idstring2[i], "%hhX",self_public_key[i]); + } + // + strcpy(idstring0,"[i] ID: "); + for (i=0; i<32; i++) { + strcat(idstring0,idstring1[i]); + strcat(idstring0,idstring2[i]); + } + new_lines(idstring0); + } + else if (line[1] == 'q') { //exit endwin(); exit(EXIT_SUCCESS); From 20e4cd0a17e28dd5648bcad564e06979ac40997f Mon Sep 17 00:00:00 2001 From: Greg Date: Tue, 30 Jul 2013 17:51:16 -0400 Subject: [PATCH 28/57] Update nTox.c Edited help message. --- testing/nTox.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/nTox.c b/testing/nTox.c index a12d6cf0..5c560079 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -177,7 +177,7 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) else if (line[1] == 'h') { //help new_lines("[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status)"); - new_lines("[i] /l list (list friends), /h for help, /n nick (to change nickname), /q (to quit)"); + new_lines("[i] /l list (list friends), /h for help, /i for info, /n nick (to change nickname), /q (to quit)"); } else if (line[1] == 'i') { //info @@ -390,7 +390,7 @@ int main(int argc, char *argv[]) getmaxyx(stdscr,y,x); new_lines(idstring0); new_lines("[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status)"); - new_lines("[i] /l list (list friends), /n nick (to change nickname), /q (to quit)"); + new_lines("[i] /l list (list friends), /h for help, /i for info, /n nick (to change nickname), /q (to quit)"); strcpy(line, ""); IP_Port bootstrap_ip_port; bootstrap_ip_port.port = htons(atoi(argv[2])); From 010adbe0ac936ab5393920aa2ebcc9cd7470ca10 Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Tue, 30 Jul 2013 14:24:26 -0400 Subject: [PATCH 29/57] Modified Travis to build libconfig from sources --- .travis.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9de4e282..d295249a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,12 +11,16 @@ before_script: - ./autogen.sh - ./configure && make check -j3 - sudo make install - - sudo ldconfig - cd .. # installing libconfig, needed for DHT_bootstrap_daemon - - sudo sed -i 's/precise/quantal/' /etc/apt/sources.list # needed for libconfig-dev - - sudo apt-get update -qq - - yes | sudo apt-get install libconfig-dev + - wget http://www.hyperrealm.com/libconfig/libconfig-1.4.9.tar.gz + - tar -xvzf libconfig-1.4.9.tar.gz + - cd libconfig-1.4.9 + - ./configure && make -j3 + - sudo make install + - cd .. +# creating librarys' links and updating cache + - sudo ldconfig script: - mkdir build && cd build From 2696134363a802fd4cb510899fed469a253087d0 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Wed, 31 Jul 2013 00:25:00 +0200 Subject: [PATCH 30/57] README.md: s/Freenode/freenode/ --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f903bc0..efbfc05d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ With the rise of governmental monitoring programs, Tox aims to be an easy to use -**IRC**: #tox on Freenode, alternatively, you can use the [webchat](http://webchat.freenode.net/?channels=#tox).
+**IRC**: #tox on freenode, alternatively, you can use the [webchat](http://webchat.freenode.net/?channels=#tox).
**Website**: [http://tox.im](http://tox.im) **Website translations**: [see stal888's repository](https://github.com/stal888/ProjectTox-Website)
From 0e091f7c58ffcfce82e1384b6ed4faab6a6b6222 Mon Sep 17 00:00:00 2001 From: NemDiggers Date: Tue, 30 Jul 2013 19:03:04 -0400 Subject: [PATCH 31/57] Add tutorial videos to readme I promise they're legit<3 --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index efbfc05d..89379473 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,8 @@ With the rise of governmental monitoring programs, Tox aims to be an easy to use **Website translations**: [see stal888's repository](https://github.com/stal888/ProjectTox-Website)
**Qt GUI**: [see nurupo's repository](https://github.com/nurupo/ProjectTox-Qt-GUI) - +**How to build Tox on Linux**: [YouTube video](http://www.youtube.com/watch?v=M4WXE4VKmyg) +**How to use Tox on Windows**: [YouTube video](http://www.youtube.com/watch?v=qg_j_sDb6WQ) ## The Complex Stuff: + Tox must use UDP simply because you can't hole punch with TCP. It's possible, but it doesn't work all the time. From d169e68450bb7a5f8de65e43b46f1102e378943a Mon Sep 17 00:00:00 2001 From: NemDiggers Date: Tue, 30 Jul 2013 19:03:39 -0400 Subject: [PATCH 32/57] break line --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 89379473..e6e6fe5d 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ With the rise of governmental monitoring programs, Tox aims to be an easy to use **Website translations**: [see stal888's repository](https://github.com/stal888/ProjectTox-Website)
**Qt GUI**: [see nurupo's repository](https://github.com/nurupo/ProjectTox-Qt-GUI) -**How to build Tox on Linux**: [YouTube video](http://www.youtube.com/watch?v=M4WXE4VKmyg) +**How to build Tox on Linux**: [YouTube video](http://www.youtube.com/watch?v=M4WXE4VKmyg)
**How to use Tox on Windows**: [YouTube video](http://www.youtube.com/watch?v=qg_j_sDb6WQ) ## The Complex Stuff: From 69980e3c0cd2b384387f226c3c952ad5c99a14f6 Mon Sep 17 00:00:00 2001 From: NemDiggers Date: Tue, 30 Jul 2013 19:09:29 -0400 Subject: [PATCH 33/57] Remind users that directory isn't actually legit --- other/bootstrap_serverdaemon/server.cfg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/other/bootstrap_serverdaemon/server.cfg b/other/bootstrap_serverdaemon/server.cfg index 8ef516ca..527c2a72 100644 --- a/other/bootstrap_serverdaemon/server.cfg +++ b/other/bootstrap_serverdaemon/server.cfg @@ -6,11 +6,15 @@ port = 33445; // The key file // make sure that the user who runs the server // does have permissions to read it/write to it +// Remember to replace the provided example with +// the directory the DHT server will run in. keys_file = "/home/tom/.bootstrap_server.keys" // The PID file written to by bootstrap_server, // make sure that the user who runs the server // does have permissions to write to it +// Remember to replace the provided example with +// the directory the DHT server will run in. pid_file = "/home/tom/.bootstrap_server.pid"; // The info of the node bootstap_server will From cd0518a45c9354d06bb3eed42b5267eea27d5ca2 Mon Sep 17 00:00:00 2001 From: Astonex Date: Wed, 31 Jul 2013 00:13:31 +0100 Subject: [PATCH 34/57] Update Messenger.c Offer more meaningful returns so appropriate actions can be taken by the GUI. --- core/Messenger.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/Messenger.c b/core/Messenger.c index 272c5fa7..641dbf8e 100644 --- a/core/Messenger.c +++ b/core/Messenger.c @@ -99,16 +99,19 @@ int getclient_id(int friend_id, uint8_t *client_id) client_id is the client id of the friend data is the data and length is the length returns the friend number if success - return -1 if failure. */ + return -1 if key length is wrong. + return -2 if user's own key + return -3 if already a friend + return -4 for other*/ int m_addfriend(uint8_t *client_id, uint8_t *data, uint16_t length) { if (length == 0 || length >= (MAX_DATA_SIZE - crypto_box_PUBLICKEYBYTES - crypto_box_NONCEBYTES - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES)) return -1; if (memcmp(client_id, self_public_key, crypto_box_PUBLICKEYBYTES) == 0) - return -1; + return -2; if (getfriend_id(client_id) != -1) - return -1; + return -3; uint32_t i; for (i = 0; i <= numfriends; ++i) { if(friendlist[i].status == 0) { @@ -126,7 +129,7 @@ int m_addfriend(uint8_t *client_id, uint8_t *data, uint16_t length) return i; } } - return -1; + return -4; } int m_addfriend_norequest(uint8_t * client_id) From 1b4eea2186580bb77c2ad2a13d4263757c192c43 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Tue, 30 Jul 2013 19:38:05 -0400 Subject: [PATCH 35/57] Small fixes. --- core/Messenger.c | 10 +++++----- core/Messenger.h | 13 ++++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/core/Messenger.c b/core/Messenger.c index 641dbf8e..872d7407 100644 --- a/core/Messenger.c +++ b/core/Messenger.c @@ -113,7 +113,7 @@ int m_addfriend(uint8_t *client_id, uint8_t *data, uint16_t length) if (getfriend_id(client_id) != -1) return -3; uint32_t i; - for (i = 0; i <= numfriends; ++i) { + for (i = 0; i <= numfriends; ++i) { /*TODO: dynamic memory allocation, this will segfault if there are more than MAX_NUM_FRIENDS*/ if(friendlist[i].status == 0) { DHT_addfriend(client_id); friendlist[i].status = 1; @@ -137,7 +137,7 @@ int m_addfriend_norequest(uint8_t * client_id) if (getfriend_id(client_id) != -1) return -1; uint32_t i; - for (i = 0; i <= numfriends; ++i) { + for (i = 0; i <= numfriends; ++i) {/*TODO: dynamic memory allocation, this will segfault if there are more than MAX_NUM_FRIENDS*/ if(friendlist[i].status == 0) { DHT_addfriend(client_id); friendlist[i].status = 2; @@ -167,7 +167,7 @@ int m_delfriend(int friendnumber) memset(&friendlist[friendnumber], 0, sizeof(Friend)); uint32_t i; for (i = numfriends; i != 0; --i) { - if (friendlist[i].status != 0) + if (friendlist[i-1].status != 0) break; } numfriends = i; @@ -181,7 +181,7 @@ int m_delfriend(int friendnumber) return 0 if there is no friend with that number */ int m_friendstatus(int friendnumber) { - if (friendnumber < 0 || friendnumber >= MAX_NUM_FRIENDS) + if (friendnumber < 0 || friendnumber >= numfriends) return 0; return friendlist[friendnumber].status; } @@ -191,7 +191,7 @@ int m_friendstatus(int friendnumber) return 0 if it was not */ int m_sendmessage(int friendnumber, uint8_t *message, uint32_t length) { - if (friendnumber < 0 || friendnumber >= MAX_NUM_FRIENDS) + if (friendnumber < 0 || friendnumber >= numfriends) return 0; if (length >= MAX_DATA_SIZE || friendlist[friendnumber].status != 4) /* this does not mean the maximum message length is MAX_DATA_SIZE - 1, it is actually 17 bytes less. */ diff --git a/core/Messenger.h b/core/Messenger.h index 6ab50175..9ce96fb4 100644 --- a/core/Messenger.h +++ b/core/Messenger.h @@ -46,11 +46,14 @@ extern "C" { to an absurdly large number later */ /* add a friend - set the data that will be sent along with friend request - client_id is the client id of the friend - data is the data and length is the length - returns the friend number if success - return -1 if failure. */ + set the data that will be sent along with friend request + client_id is the client id of the friend + data is the data and length is the length + returns the friend number if success + return -1 if key length is wrong. + return -2 if user's own key + return -3 if already a friend + return -4 for other*/ int m_addfriend(uint8_t *client_id, uint8_t *data, uint16_t length); From 4faa145789853caacb8dc37d505fa20f4879ffea Mon Sep 17 00:00:00 2001 From: Teknocrat Date: Tue, 30 Jul 2013 19:09:36 -0500 Subject: [PATCH 36/57] Update CMakeLists.txt This thing requires libconfig but doesn't test for it... --- other/bootstrap_serverdaemon/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/other/bootstrap_serverdaemon/CMakeLists.txt b/other/bootstrap_serverdaemon/CMakeLists.txt index 57ba4841..f675396d 100644 --- a/other/bootstrap_serverdaemon/CMakeLists.txt +++ b/other/bootstrap_serverdaemon/CMakeLists.txt @@ -10,3 +10,6 @@ target_link_libraries(${exe_name} config) linkCoreLibraries(${exe_name}) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") +find_package(LibConfig REQUIRED) From 7803acc375c28c1fe094a1807e689959f14da468 Mon Sep 17 00:00:00 2001 From: Teknocrat Date: Tue, 30 Jul 2013 19:12:29 -0500 Subject: [PATCH 37/57] Create FindLibConfig.cmake Warning, this is a google snippet, but works fine, shouldn't be an issue --- .../cmake/Modules/FindLibConfig.cmake | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 other/bootstrap_serverdaemon/cmake/Modules/FindLibConfig.cmake diff --git a/other/bootstrap_serverdaemon/cmake/Modules/FindLibConfig.cmake b/other/bootstrap_serverdaemon/cmake/Modules/FindLibConfig.cmake new file mode 100644 index 00000000..7d6270e6 --- /dev/null +++ b/other/bootstrap_serverdaemon/cmake/Modules/FindLibConfig.cmake @@ -0,0 +1,73 @@ +#Ref: https://github.com/schnorr/pajeng/blob/master/cmake/FindLibConfig.cmake +# +# This module defines +# LIBCONFIG_INCLUDE_DIR, where to find cppunit include files, etc. +# LIBCONFIG_LIBRARIES, the libraries to link against to use CppUnit. +# LIBCONFIG_STATIC_LIBRARIY_PATH +# LIBCONFIG_FOUND, If false, do not try to use CppUnit. + +# also defined, but not for general use are +# LIBCONFIG_LIBRARY, where to find the CUnit library. + +#MESSAGE("Searching for libconfig library") + +FIND_PATH(LIBCONFIG_INCLUDE_DIR libconfig.h + /usr/local/include + /usr/include +) + +FIND_PATH(LIBCONFIGPP_INCLUDE_DIR libconfig.h++ + /usr/local/include + /usr/include +) + +FIND_LIBRARY(LIBCONFIG_LIBRARY config + /usr/local/lib + /usr/lib +) + +FIND_LIBRARY(LIBCONFIGPP_LIBRARY config++ + /usr/local/lib + /usr/lib +) + +FIND_LIBRARY(LIBCONFIG_STATIC_LIBRARY "libconfig${CMAKE_STATIC_LIBRARY_SUFFIX}" + /usr/local/lib + /usr/lib +) + +FIND_LIBRARY(LIBCONFIGPP_STATIC_LIBRARY "libconfig++${CMAKE_STATIC_LIBRARY_SUFFIX}" + /usr/local/lib + /usr/lib +) + + +IF(LIBCONFIG_INCLUDE_DIR) + IF(LIBCONFIG_LIBRARY) + SET(LIBCONFIG_FOUND TRUE) + SET(LIBCONFIG_LIBRARIES ${LIBCONFIG_LIBRARY}) + SET(LIBCONFIG_STATIC_LIBRARY_PATH ${LIBCONFIG_STATIC_LIBRARY}) + ENDIF(LIBCONFIG_LIBRARY) +ENDIF(LIBCONFIG_INCLUDE_DIR) + +IF(LIBCONFIGPP_INCLUDE_DIR) + IF(LIBCONFIGPP_LIBRARY) + SET(LIBCONFIGPP_FOUND TRUE) + SET(LIBCONFIGPP_LIBRARIES ${LIBCONFIGPP_LIBRARY}) + SET(LIBCONFIGPP_STATIC_LIBRARY_PATH ${LIBCONFIGPP_STATIC_LIBRARY}) + ENDIF(LIBCONFIGPP_LIBRARY) +ENDIF(LIBCONFIGPP_INCLUDE_DIR) + +IF (LIBCONFIG_FOUND) + IF (NOT LibConfig_FIND_QUIETLY) + MESSAGE(STATUS "Found LibConfig++: ${LIBCONFIGPP_LIBRARIES}" ) + MESSAGE(STATUS "Found LibConfig: ${LIBCONFIG_LIBRARIES}") + MESSAGE(STATUS "static LibConfig path: ${LIBCONFIG_STATIC_LIBRARY_PATH}") + ENDIF (NOT LibConfig_FIND_QUIETLY) +ELSE (LIBCONFIG_FOUND) + IF (LibConfig_FIND_REQUIRED) + MESSAGE(SEND_ERROR "Could NOT find LibConfig") + ENDIF (LibConfig_FIND_REQUIRED) +ENDIF (LIBCONFIG_FOUND) + +MARK_AS_ADVANCED(LIBCONFIG_INCLUDE_DIR LIBCONFIG_LIBRARIES) From bd8ba0bd6e4a71eab2216749d732aa40088c95b8 Mon Sep 17 00:00:00 2001 From: pyrobisqit Date: Wed, 31 Jul 2013 03:17:40 +0200 Subject: [PATCH 38/57] Update readme.md Basically, a few words tweaked here and there, to make the file more gramatically correct. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e6e6fe5d..19bbb759 100644 --- a/README.md +++ b/README.md @@ -20,14 +20,14 @@ With the rise of governmental monitoring programs, Tox aims to be an easy to use + Every peer is represented as a byte string (the public key of the peer [client id]) + We're using torrent-style DHT so that peers can find the IP of the other peers when they have their ID. + Once the client has the IP of that peer, they start initiating a secure connection with each other. (See [Crypto](https://github.com/irungentoo/ProjectTox-Core/wiki/Crypto)) -+ When both peers are securely connect with the encryption, they can securely exchange messages, initiate a video chat, send files, etc.
++ When both peers are securely connected, they can exchange messages, initiate a video chat, send files, etc, all using encrypted communications.
+ Current build status: [![Build Status](https://travis-ci.org/irungentoo/ProjectTox-Core.png?branch=master)](https://travis-ci.org/irungentoo/ProjectTox-Core) ## Roadmap: - [x] Get our DHT working perfectly.(Done, needs large scale testing though.) - [x] Reliable connection (See Lossless_UDP protocol) to other peers according to client id. (Done, see DHT_sendfiletest.c for an example) - [x] Encryption. (Done) -- [ ] Get a simple text only im client working perfectly. (This is where we are) +- [ ] Get a simple text only IM client working perfectly. (This is where we are) - [ ] Streaming media - [ ] ??? From 2d7143e850e0c22bef122beacfa9b21ff7be6805 Mon Sep 17 00:00:00 2001 From: Greg Date: Tue, 30 Jul 2013 21:36:22 -0400 Subject: [PATCH 39/57] Update nTox.c Made the help message a string type. --- testing/nTox.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testing/nTox.c b/testing/nTox.c index 5c560079..c5fc5188 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -35,6 +35,8 @@ char lines[HISTORY][STRING_LENGTH]; char line[STRING_LENGTH]; +char *help = "[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status)\n" + "[i] /l list (list friends), /h for help, /i for info, /n nick (to change nickname), /q (to quit)"; int x,y; uint8_t pending_requests[256][CLIENT_ID_SIZE]; @@ -176,8 +178,7 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) } else if (line[1] == 'h') { //help - new_lines("[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status)"); - new_lines("[i] /l list (list friends), /h for help, /i for info, /n nick (to change nickname), /q (to quit)"); + new_lines(help); } else if (line[1] == 'i') { //info @@ -389,8 +390,7 @@ int main(int argc, char *argv[]) raw(); getmaxyx(stdscr,y,x); new_lines(idstring0); - new_lines("[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status)"); - new_lines("[i] /l list (list friends), /h for help, /i for info, /n nick (to change nickname), /q (to quit)"); + new_lines(help); strcpy(line, ""); IP_Port bootstrap_ip_port; bootstrap_ip_port.port = htons(atoi(argv[2])); From 89dd7ed0111d2aebe5d362052f8582bfc17c7cbc Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Tue, 30 Jul 2013 22:41:51 +0400 Subject: [PATCH 40/57] Add detection of required libraries --- CMakeLists.txt | 8 ++++++-- cmake/FindLIBCONFIG.cmake | 15 +++++++++++++++ cmake/FindSODIUM.cmake | 15 +++++++++++++++ core/CMakeLists.txt | 2 ++ other/bootstrap_serverdaemon/CMakeLists.txt | 6 +++++- 5 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 cmake/FindLIBCONFIG.cmake create mode 100644 cmake/FindSODIUM.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index c16ce6fe..c18d41d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,14 @@ cmake_minimum_required(VERSION 2.6.0) +set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) + #MinGW prints more warnings for -Wall than gcc does, thus causing build to fail if(NOT WIN32) if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")) message(STATUS "==== ${CMAKE_C_COMPILER_ID} detected - Adding compiler flags ====") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror") endif() + find_package(SODIUM REQUIRED) endif() macro(linkCoreLibraries exe_name) @@ -16,8 +19,9 @@ macro(linkCoreLibraries exe_name) ${CMAKE_SOURCE_DIR}/sodium/lib/libsodium.a ws2_32) else() + include_directories(${SODIUM_INCLUDE_DIR}) target_link_libraries(${exe_name} core - sodium) + ${SODIUM_LIBRARY}) endif() endmacro() @@ -25,4 +29,4 @@ cmake_policy(SET CMP0011 NEW) add_subdirectory(core) add_subdirectory(testing) -add_subdirectory(other) \ No newline at end of file +add_subdirectory(other) diff --git a/cmake/FindLIBCONFIG.cmake b/cmake/FindLIBCONFIG.cmake new file mode 100644 index 00000000..d5018240 --- /dev/null +++ b/cmake/FindLIBCONFIG.cmake @@ -0,0 +1,15 @@ +# Find LIBCONFIG +# +# LIBCONFIG_INCLUDE_DIR +# LIBCONFIG_LIBRARY +# LIBCONFIG_FOUND +# + +FIND_PATH(LIBCONFIG_INCLUDE_DIR NAMES libconfig.h) + +FIND_LIBRARY(LIBCONFIG_LIBRARY NAMES config) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBCONFIG DEFAULT_MSG LIBCONFIG_LIBRARY LIBCONFIG_INCLUDE_DIR) + +MARK_AS_ADVANCED(LIBCONFIG_INCLUDE_DIR LIBCONFIG_LIBRARY) diff --git a/cmake/FindSODIUM.cmake b/cmake/FindSODIUM.cmake new file mode 100644 index 00000000..ffb6a1f7 --- /dev/null +++ b/cmake/FindSODIUM.cmake @@ -0,0 +1,15 @@ +# Find SODIUM +# +# SODIUM_INCLUDE_DIR +# SODIUM_LIBRARY +# SODIUM_FOUND +# + +FIND_PATH(SODIUM_INCLUDE_DIR NAMES sodium.h) + +FIND_LIBRARY(SODIUM_LIBRARY NAMES sodium) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SODIUM DEFAULT_MSG SODIUM_LIBRARY SODIUM_INCLUDE_DIR) + +MARK_AS_ADVANCED(SODIUM_INCLUDE_DIR SODIUM_LIBRARY) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 420308d8..44ae980c 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -3,6 +3,8 @@ project(core C) if(WIN32) include_directories(${CMAKE_HOME_DIRECTORY}/sodium/include/) +else(WIN32) + include_directories(${SODIUM_INCLUDE_DIR}) endif() set(core_sources diff --git a/other/bootstrap_serverdaemon/CMakeLists.txt b/other/bootstrap_serverdaemon/CMakeLists.txt index 57ba4841..a9cfdff7 100644 --- a/other/bootstrap_serverdaemon/CMakeLists.txt +++ b/other/bootstrap_serverdaemon/CMakeLists.txt @@ -3,10 +3,14 @@ project(DHT_bootstrap_daemon C) set(exe_name DHT_bootstrap_daemon) +find_package(LIBCONFIG REQUIRED) + +include_directories(${LIBCONFIG_INCLUDE_DIR}) + add_executable(${exe_name} DHT_bootstrap_daemon.c) target_link_libraries(${exe_name} - config) + ${LIBCONFIG_LIBRARY}) linkCoreLibraries(${exe_name}) From 207c067cf22d65cdfc08e8659fb8dd575e248053 Mon Sep 17 00:00:00 2001 From: Stuart Banks Date: Wed, 31 Jul 2013 02:15:01 -0400 Subject: [PATCH 41/57] Clean up/format code --- testing/nTox.c | 153 ++++++++++++++++++++++--------------------- testing/nTox.h | 1 + testing/nTox_win32.c | 85 ++++++++++-------------- testing/nTox_win32.h | 1 + 4 files changed, 116 insertions(+), 124 deletions(-) diff --git a/testing/nTox.c b/testing/nTox.c index 5c560079..5f184407 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -23,9 +23,9 @@ #include "nTox.h" #include "misc_tools.h" - #include #include + #ifdef WIN32 #define c_sleep(x) Sleep(1*x) #else @@ -35,7 +35,7 @@ char lines[HISTORY][STRING_LENGTH]; char line[STRING_LENGTH]; -int x,y; +int x, y; uint8_t pending_requests[256][CLIENT_ID_SIZE]; uint8_t num_requests; @@ -44,9 +44,9 @@ void new_lines(char *line) { int i; for (i = HISTORY-1; i > 0; i--) - strcpy(lines[i],lines[i-1]); + strcpy(lines[i], lines[i-1]); - strcpy(lines[0],line); + strcpy(lines[0], line); do_refresh(); } @@ -54,10 +54,9 @@ void new_lines(char *line) void print_friendlist() { char name[MAX_NAME_LENGTH]; - uint32_t i; - new_lines("[i] Friend List:"); - for (i=0; i <= num_requests; i++) { + uint32_t i; + for (i = 0; i <= num_requests; i++) { char fstring[128]; getname(i, (uint8_t*)name); @@ -73,7 +72,7 @@ void print_friendlist() char *format_message(char *message, int friendnum) { char name[MAX_NAME_LENGTH]; - if(friendnum != -1) { + if (friendnum != -1) { getname(friendnum, (uint8_t*)name); } else { getself_name((uint8_t*)name); @@ -85,7 +84,7 @@ char *format_message(char *message, int friendnum) timeinfo = localtime ( &rawtime ); char* time = asctime(timeinfo); size_t len = strlen(time); - time[len-1]='\0'; + time[len-1] = '\0'; sprintf(msg, "[%d] %s <%s> %s", friendnum, time, name, message); // timestamp return msg; } @@ -93,13 +92,14 @@ char *format_message(char *message, int friendnum) void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) { if (line[0] == '/') { - char command[STRING_LENGTH + 2] = "> "; - strcat(command, line); - new_lines(command); - if (line[1] == 'f') { // add friend command: /f ID + char inpt_command = line[1]; + char prompt[STRING_LENGTH + 2] = "> "; + strcat(prompt, line); + new_lines(prompt); + if (inpt_command == 'f') { // add friend command: /f ID int i; char temp_id[128]; - for (i=0; i<128; i++) + for (i = 0; i < 128; i++) temp_id[i] = line[i+3]; int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); char numstring[100]; @@ -107,63 +107,63 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) new_lines(numstring); do_refresh(); } - else if (line[1] == 'd') { + else if (inpt_command == 'd') { doMessenger(); } - else if (line[1] == 'm') { //message command: /m friendnumber messsage - int i; + else if (inpt_command == 'm') { //message command: /m friendnumber messsage size_t len = strlen(line); char numstring[len-3]; char message[len-3]; - for (i=0; i> "); printw(line); @@ -298,12 +297,13 @@ void print_message(int friendnumber, uint8_t * string, uint16_t length) timeinfo = localtime ( &rawtime ); char* temp = asctime(timeinfo); size_t len = strlen(temp); - temp[len-1]='\0'; + temp[len-1] = '\0'; sprintf(msg, "[%d] %s <%s> %s", friendnumber, temp, name, string); // timestamp new_lines(format_message((char*)string, friendnumber)); } -void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) { +void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) +{ char name[MAX_NAME_LENGTH]; getname(friendnumber, (uint8_t*)name); char msg[100+length]; @@ -311,7 +311,8 @@ void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) { new_lines(msg); } -void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) { +void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) +{ char name[MAX_NAME_LENGTH]; getname(friendnumber, (uint8_t*)name); char msg[100+length+strlen(name)+1]; @@ -319,15 +320,17 @@ void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) { new_lines(msg); } -void load_key(){ +void load_key() +{ FILE *data_file = NULL; - if ((data_file = fopen("data","r"))) { + data_file = fopen("data","r"); + if (data_file) { //load keys fseek(data_file, 0, SEEK_END); int size = ftell(data_file); fseek(data_file, 0, SEEK_SET); uint8_t data[size]; - if(fread(data, sizeof(uint8_t), size, data_file) != size){ + if (fread(data, sizeof(uint8_t), size, data_file) != size){ printf("[i] could not read data file\n[i] exiting\n"); exit(1); } @@ -338,7 +341,7 @@ void load_key(){ uint8_t data[size]; Messenger_save(data); data_file = fopen("data","w"); - if(fwrite(data, sizeof(uint8_t), size, data_file) != size){ + if (fwrite(data, sizeof(uint8_t), size, data_file) != size){ printf("[i] could not write data file\n[i] exiting\n"); exit(1); } @@ -368,26 +371,27 @@ int main(int argc, char *argv[]) m_callback_namechange(print_nickchange); m_callback_userstatus(print_statuschange); char idstring0[200]; - char idstring1[32][5]; - char idstring2[32][5]; - uint32_t i; - for(i = 0; i < 32; i++) + char idstring1[PUB_KEY_BYTES][5]; + char idstring2[PUB_KEY_BYTES][5]; + int i; + for(i = 0; i < PUB_KEY_BYTES; i++) { - if(self_public_key[i] < 16) + if (self_public_key[i] < (PUB_KEY_BYTES / 2)) strcpy(idstring1[i],"0"); else strcpy(idstring1[i], ""); sprintf(idstring2[i], "%hhX",self_public_key[i]); } strcpy(idstring0,"[i] your ID: "); - for (i=0; i<32; i++) { - strcat(idstring0,idstring1[i]); - strcat(idstring0,idstring2[i]); + int j; + for (j = 0; j < PUB_KEY_BYTES; j++) { + strcat(idstring0,idstring1[j]); + strcat(idstring0,idstring2[j]); } initscr(); noecho(); raw(); - getmaxyx(stdscr,y,x); + getmaxyx(stdscr, y, x); new_lines(idstring0); new_lines("[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status)"); new_lines("[i] /l list (list friends), /h for help, /i for info, /n nick (to change nickname), /q (to quit)"); @@ -413,7 +417,6 @@ int main(int argc, char *argv[]) do_refresh(); c = getch(); - if (c == ERR || c == 27) continue; @@ -422,7 +425,7 @@ int main(int argc, char *argv[]) line_eval(lines, line); strcpy(line, ""); } else if (c == 127) { - line[strlen(line) - 1] = '\0'; + line[strlen(line)-1] = '\0'; } else if (isalnum(c) || ispunct(c) || c == ' ') { strcpy(line, appender(line, (char) c)); } diff --git a/testing/nTox.h b/testing/nTox.h index 9b69d959..9d82556c 100644 --- a/testing/nTox.h +++ b/testing/nTox.h @@ -39,6 +39,7 @@ #include "../core/network.h" #define STRING_LENGTH 256 #define HISTORY 50 +#define PUB_KEY_BYTES 32 void new_lines(char *line); void line_eval(char lines[HISTORY][STRING_LENGTH], char *line); diff --git a/testing/nTox_win32.c b/testing/nTox_win32.c index 3a9caaf5..3286bb3a 100644 --- a/testing/nTox_win32.c +++ b/testing/nTox_win32.c @@ -88,14 +88,13 @@ void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) { void load_key() { FILE *data_file = NULL; - - if ((data_file = fopen("data", "r"))) { + data_file = fopen("data","r"); + if (data_file) { fseek(data_file, 0, SEEK_END); int size = ftell(data_file); fseek(data_file, 0, SEEK_SET); uint8_t data[size]; - - if(fread(data, sizeof(uint8_t), size, data_file) != size) { + if (fread(data, sizeof(uint8_t), size, data_file) != size) { printf("\n[i] Could not read the data file. Exiting."); exit(1); } @@ -107,23 +106,23 @@ void load_key() Messenger_save(data); data_file = fopen("data", "w"); - if(fwrite(data, sizeof(uint8_t), size, data_file) != size) { + if (fwrite(data, sizeof(uint8_t), size, data_file) != size) { printf("\n[i] Could not write data to file. Exiting."); exit(1); } } - fclose(data_file); } void line_eval(char* line) { if(line[0] == '/') { + char inpt_command = line[1]; /* Add friend */ - if(line[1] == 'f') { + if(inpt_command == 'f') { int i; char temp_id[128]; - for (i=0; i<128; i++) + for (i = 0; i < 128; i++) temp_id[i] = line[i+3]; int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); char numstring[100]; @@ -131,28 +130,27 @@ void line_eval(char* line) printf(numstring); } - else if (line[1] == 'r') { + else if (inpt_command == 'r') { do_header(); printf("\n\n"); } - else if (line[1] == 'l') { + else if (inpt_command == 'l') { printf("\n[i] Friend List | Total: %d\n\n", getnumfriends()); int i; - - for (i=0; i < getnumfriends(); i++) { + for (i = 0; i < getnumfriends(); i++) { char name[MAX_NAME_LENGTH]; getname(i, (uint8_t*)name); printf("[%d] %s\n\n", i, (uint8_t*)name); } } - else if (line[1] == 'd') { + else if (inpt_command == 'd') { size_t len = strlen(line); char numstring[len-3]; int i; - for (i=0; i\n", argv[0]); exit(0); } - if (initMessenger() == -1) { printf("initMessenger failed"); exit(0); } - if (argc > 4) { if(strncmp(argv[4], "nokey", 6) < 0) { } @@ -267,26 +261,25 @@ int main(int argc, char *argv[]) m_callback_friendmessage(print_message); m_callback_namechange(print_nickchange); m_callback_userstatus(print_statuschange); - - char idstring1[32][5]; - char idstring2[32][5]; - uint32_t i; - for(i = 0; i < 32; i++) + char idstring1[PUB_KEY_BYTES][5]; + char idstring2[PUB_KEY_BYTES][5]; + int i; + for(i = 0; i < PUB_KEY_BYTES; i++) { - if(self_public_key[i] < 16) + if(self_public_key[i] < (PUB_KEY_BYTES/2)) strcpy(idstring1[i],"0"); else strcpy(idstring1[i], ""); sprintf(idstring2[i], "%hhX",self_public_key[i]); } strcpy(users_id,"[i] your ID: "); - for (i=0; i<32; i++) { - strcat(users_id,idstring1[i]); - strcat(users_id,idstring2[i]); + int j; + for (j = 0; j < PUB_KEY_BYTES; j++) { + strcat(users_id,idstring1[j]); + strcat(users_id,idstring2[j]); } do_header(); - IP_Port bootstrap_ip_port; bootstrap_ip_port.port = htons(atoi(argv[2])); int resolved_address = resolve_addr(argv[1]); @@ -296,12 +289,9 @@ int main(int argc, char *argv[]) exit(1); DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); - int c; int on = 0; - _beginthread(get_input, 0, NULL); - while(1) { if (on == 1 && DHT_isconnected() == -1) { printf("\n---------------------------------"); @@ -309,15 +299,12 @@ int main(int argc, char *argv[]) printf("\n---------------------------------\n\n"); on = 0; } - if (on == 0 && DHT_isconnected()) { printf("\n[i] Connected to DHT"); printf("\n---------------------------------\n\n"); on = 1; } - doMessenger(); } - return 0; } \ No newline at end of file diff --git a/testing/nTox_win32.h b/testing/nTox_win32.h index 7861be1c..84d4a778 100644 --- a/testing/nTox_win32.h +++ b/testing/nTox_win32.h @@ -27,5 +27,6 @@ #include "../core/network.h" #define STRING_LENGTH 256 +#define PUB_KEY_BYTES 32 #endif \ No newline at end of file From fedb82e9d66fd11e87ea55bcfbd4c2fb4058a741 Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Wed, 31 Jul 2013 15:37:31 +0900 Subject: [PATCH 42/57] Adding homebrew commands to INSTALL --- INSTALL.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 3459a5c7..9efa7ee9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -42,7 +42,17 @@ make ###OSX: -Much the same as above, remember to install the latest XCode and the developer tools (Preferences -> Downloads -> Command Line Tools). +####Homebrew: +``` +brew install libtool automake autoconf libconfig libsodium +cmake . +make +sudo make install +``` + +####Non-homebrew: + +Much the same as Linux, remember to install the latest XCode and the developer tools (Preferences -> Downloads -> Command Line Tools). Users running Mountain Lion and the latest version of XCode (4.6.3) will also need to install libtool, automake and autoconf. They are easy enough to install, grab them from http://www.gnu.org/software/libtool/, http://www.gnu.org/software/autoconf/ and http://www.gnu.org/software/automake/, then follow these steps for each: From 9f6be0ce4b895eb0941e4c7063520a7d95fb7de9 Mon Sep 17 00:00:00 2001 From: Joseph Quadrino Date: Wed, 31 Jul 2013 03:07:51 -0400 Subject: [PATCH 43/57] stat file before attempting to open --- other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c b/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c index 8e278b28..4f28fb3c 100644 --- a/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c +++ b/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c @@ -123,11 +123,12 @@ void manage_keys(char *keys_file) { const uint32_t KEYS_SIZE = crypto_box_PUBLICKEYBYTES + crypto_box_SECRETKEYBYTES; uint8_t keys[KEYS_SIZE]; - - /* TODO: stat the file before trying to open it. We aren't cave people! */ - FILE *keysf = fopen(keys_file, "r"); - if (keysf != NULL) { - /* if file was opened successfully -- load keys */ + struct stat existence; + FILE *keysf; + + /* Check if file exits, proceed to open and load keys */ + if(stat(keys_file,&existence) >= 0) { + keysf = fopen(keys_file, "r"); size_t read_size = fread(keys, sizeof(uint8_t), KEYS_SIZE, keysf); if (read_size != KEYS_SIZE) { printf("Error while reading the key file\nExiting.\n"); From 11d4f18abd41cd18ee745b8db504db05c5f45217 Mon Sep 17 00:00:00 2001 From: pflo Date: Wed, 31 Jul 2013 15:27:19 +0700 Subject: [PATCH 44/57] Create start_guide.de.md Translated the original small documentation to german. --- start_guide.de.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 start_guide.de.md diff --git a/start_guide.de.md b/start_guide.de.md new file mode 100644 index 00000000..7dfd52ca --- /dev/null +++ b/start_guide.de.md @@ -0,0 +1,40 @@ +# Tox nutzen +1. Tox erstellen +2. Fehler korrigieren +3. Im IRC nach Hilfe fragen +4. Auf Debug-Reise für Entwickler +5. Tox wirklich erstellen +6. ??? + +Trotz der ganzen Arbeit, die wir bisher in Tox +gesteckt haben, gibt es noch keine richtige +Anleitung, wie man Tox _benutzt_. +Dies ist ein anwenderfreundlicher Versuch. + +1. Verbinde dich zum Netzwerk! + + Du musst dich zu einem Bootstrap-Server verbinden, um einen öffentlichen Schlüssel zu erhalten. + + Wo finde ich einen öffentlichen Server? Zur Zeit hier: + (die Hilfe-Nachricht von nTox ohne Kommandos hilft auch) + + 198.46.136.167 33445 728925473812C7AAC482BE7250BCCAD0B8CB9F737BF3D42ABD34459C1768F854 + + 192.81.133.111 33445 8CD5A9BF0A6CE358BA36F7A653F99FA6B258FF756E490F52C1F98CC420F78858 + + 66.175.223.88 33445 AC4112C975240CAD260BB2FCD134266521FAAF0A5D159C5FD3201196191E4F5D + + 192.184.81.118 33445 5CD7EB176C19A2FD840406CD56177BB8E75587BB366F7BB3004B19E3EDC04143 +2. Finde einen Freund! + + Jetzt, da du im Netzwerk bist, brauchst du einen Freund. Um einen zu bekommen, + musst du eine Anfrage senden oder erhalten. Was eine Anfrage ist? + Es ist wie eine Freundschaftsanfrage, jedoch benutzen wir unglaublich schaurige + und kryptische Nummern anstatt Namen. When nTox startet, erscheint _deine_ lange, + schaurige Nummer, auch *öffentlicher Schlüssel* genannt. Diesen kannst du an + andere Personen weitergeben und sie können dich als "Freund" hinzufügen. Oder du + fügst andere Personen mit dem */f*-Befehl hinzu, wenn du möchtest. +3. Chatte drauf los! + + Benutze nun den */m*-Befehl, um eine Nachricht an jemanden zu senden. Wow, du chattest! +4. Mach etwas kaputt! + + Jep, pre-alpha-alpha-Software stürzt manchmal ab. Wir arbeiten daran. + + Bitte melde alle Abstürze entweder an die GitHub-Seite oder #tox-dev im freenode-IRC. +5. Nichts ist kaputt, aber was bedeutet */f*? + + nTox liest einen Text als Befehl, wenn das erste Zeichen ein Schrägstrich ist ('/'). + Du kannst alle Befehle in commands.md nachlesen. +6. Benutze und unterstütze Tox! + + Programmiere, debugge, dokumentiere, übersetze für uns, oder sprich einfach über uns! + + Je mehr Interesse wir erhalten, desto mehr Arbeit wird getan und desto besser wird Tox. From c4a5dabe05dcd2eef842408960e4d46c5236dc81 Mon Sep 17 00:00:00 2001 From: pflo Date: Wed, 31 Jul 2013 15:28:36 +0700 Subject: [PATCH 45/57] Create start_guide.md Written by charmlesscoin. --- start_guide.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 start_guide.md diff --git a/start_guide.md b/start_guide.md new file mode 100644 index 00000000..b4f4310d --- /dev/null +++ b/start_guide.md @@ -0,0 +1,38 @@ +# Using Tox +1. Build Tox +2. Fix errors +3. Consult IRC for help +4. Go on debugging journy for devs +5. Build Tox for real +6. ??? + +For all the work we've put into Tox so far, +there isn't yet a decent guide for how you _use_ +Tox. Here's a user-friendly attempt at it. + +1. Connect to the network! + + You need to connect to a bootstrapping server, to give you a public key. + + Where can I find a public server? Right here, as of now: + (the help message from running nTox with no args will help) + + 198.46.136.167 33445 728925473812C7AAC482BE7250BCCAD0B8CB9F737BF3D42ABD34459C1768F854 + + 192.81.133.111 33445 8CD5A9BF0A6CE358BA36F7A653F99FA6B258FF756E490F52C1F98CC420F78858 + + 66.175.223.88 33445 AC4112C975240CAD260BB2FCD134266521FAAF0A5D159C5FD3201196191E4F5D + + 192.184.81.118 33445 5CD7EB176C19A2FD840406CD56177BB8E75587BB366F7BB3004B19E3EDC04143 +2. Find a friend! + + Now that you're on the network, you need a friend. To get one of those, + you need to to send or receive a request. What's a request, you ask? + It's like a friend request, but we use really scary and cryptic numbers + instead of names. When nTox starts, it shows your _your_ long, scary number, + called your *public key*. Give that to people, and they can add you as + as "friend". Or, you can add someone else, with the */f* command, if you like. +3. Chat it up! + + Now use the */m* command to send a message to someone. Wow, you're chatting! +4. But something broke! + + Yeah, pre-alpha-alpha software tends to do that. We're working on it. + + Please report all crashes to either the github page, or #tox-dev on freenode. +5. Nothing broke, but what does */f* mean? + + nTox parses text as a command if the first character is a forward-slash ('/'). + You can check all commands in commands.md. +6. Use and support Tox! + + Code for us, debug for us, document for us, translate for us, even just talk about us! + + The more interest we get, the more work gets done, the better Tox is. From 439de6fa3ab50bcb4c401d9175b643b6188786d3 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Wed, 31 Jul 2013 10:36:02 +0200 Subject: [PATCH 46/57] Fix space/tab indentation --- testing/DHT_cryptosendfiletest.c | 4 ++-- testing/nTox.c | 16 ++++++++-------- testing/toxic/prompt.c | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/testing/DHT_cryptosendfiletest.c b/testing/DHT_cryptosendfiletest.c index c7c33531..888dac0f 100644 --- a/testing/DHT_cryptosendfiletest.c +++ b/testing/DHT_cryptosendfiletest.c @@ -186,7 +186,7 @@ int main(int argc, char *argv[]) fclose(file2); } } - /* if buffer is empty and the connection timed out. */ + /* if buffer is empty and the connection timed out. */ else if(is_cryptoconnected(inconnection) == 4) { crypto_kill(inconnection); } @@ -209,7 +209,7 @@ int main(int argc, char *argv[]) fclose(file2); } } - /* if buffer is empty and the connection timed out. */ + /* if buffer is empty and the connection timed out. */ else if(is_cryptoconnected(connection) == 4) { crypto_kill(connection); } diff --git a/testing/nTox.c b/testing/nTox.c index 5c560079..04ae55cd 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -72,13 +72,13 @@ void print_friendlist() char *format_message(char *message, int friendnum) { - char name[MAX_NAME_LENGTH]; - if(friendnum != -1) { - getname(friendnum, (uint8_t*)name); - } else { - getself_name((uint8_t*)name); - } - char *msg = malloc(100+strlen(message)+strlen(name)+1); + char name[MAX_NAME_LENGTH]; + if(friendnum != -1) { + getname(friendnum, (uint8_t*)name); + } else { + getself_name((uint8_t*)name); + } + char *msg = malloc(100+strlen(message)+strlen(name)+1); time_t rawtime; struct tm * timeinfo; time ( &rawtime ); @@ -129,7 +129,7 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) if(m_sendmessage(num, (uint8_t*) message, sizeof(message)) != 1) { new_lines("[i] could not send message"); } else { - new_lines(format_message(message, -1)); + new_lines(format_message(message, -1)); } } else if (line[1] == 'n') { diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c index 22d9eb9e..0cd10730 100644 --- a/testing/toxic/prompt.c +++ b/testing/toxic/prompt.c @@ -125,8 +125,8 @@ static void execute(ToxWindow* self, char* cmd) { xx[2] = '\0'; if(sscanf(xx, "%02x", &x) != 1) { - wprintw(self->window, "Invalid ID.\n"); - return; + wprintw(self->window, "Invalid ID.\n"); + return; } id_bin[i] = x; From f77fe65d5435290368bb2ccad6d5aa6cc5fbc234 Mon Sep 17 00:00:00 2001 From: xzfcpw Date: Tue, 30 Jul 2013 21:00:55 +0700 Subject: [PATCH 47/57] NaCl compiling option --- CMakeLists.txt | 21 +++++++++++++++++++-- cmake/FindNaCl.cmake | 17 +++++++++++++++++ core/network.h | 6 +----- 3 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 cmake/FindNaCl.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index c16ce6fe..4db6985d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,22 @@ cmake_minimum_required(VERSION 2.6.0) +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") + +if(NOT WIN32) + option(USE_NACL "Use NaCl library instead of libsodium") +endif() + +if(NOT USE_NACL) + set(LINK_CRYPTO_LIBRARY "sodium") +else() + find_package(NaCl REQUIRED) + + include_directories(${NACL_INCLUDE_DIR}) + add_definitions(-DVANILLA_NACL) + + set(LINK_CRYPTO_LIBRARY ${NACL_LIBRARIES}) +endif() + #MinGW prints more warnings for -Wall than gcc does, thus causing build to fail if(NOT WIN32) if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")) @@ -17,7 +34,7 @@ macro(linkCoreLibraries exe_name) ws2_32) else() target_link_libraries(${exe_name} core - sodium) + ${LINK_CRYPTO_LIBRARY}) endif() endmacro() @@ -25,4 +42,4 @@ cmake_policy(SET CMP0011 NEW) add_subdirectory(core) add_subdirectory(testing) -add_subdirectory(other) \ No newline at end of file +add_subdirectory(other) diff --git a/cmake/FindNaCl.cmake b/cmake/FindNaCl.cmake new file mode 100644 index 00000000..cdd6248a --- /dev/null +++ b/cmake/FindNaCl.cmake @@ -0,0 +1,17 @@ +find_path(NACL_INCLUDE_DIR crypto_box.h + $ENV{NACL_INCLUDE_DIR} /usr/include/nacl/ + DOC "Directory which contain NaCl headers") + +find_path(NACL_LIBRARY_DIR libnacl.a + $ENV{NACL_LIBRARY_DIR} /usr/lib/nacl + DOC "Directory which contain libnacl.a, cpucycles.o, and randombytes.o") + +if(NACL_LIBRARY_DIR) + set(NACL_LIBRARIES + "${NACL_LIBRARY_DIR}/cpucycles.o" + "${NACL_LIBRARY_DIR}/libnacl.a" + "${NACL_LIBRARY_DIR}/randombytes.o") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(NaCl DEFAULT_MSG NACL_INCLUDE_DIR NACL_LIBRARY_DIR NACL_LIBRARIES) diff --git a/core/network.h b/core/network.h index 8af4b32f..3277070c 100644 --- a/core/network.h +++ b/core/network.h @@ -56,11 +56,7 @@ /* we use libsodium by default */ #include #else - -/* TODO: Including stuff like this is bad. This needs fixing. - We keep support for the original NaCl for now. */ -#include "../nacl/build/Linux/include/amd64/crypto_box.h" - +#include #endif #ifdef __cplusplus From e52db5b8b7c96c9fcedd018213a0a0b8cdc0a3ef Mon Sep 17 00:00:00 2001 From: charmlesscoin Date: Wed, 31 Jul 2013 05:00:40 -0400 Subject: [PATCH 48/57] Wrote the commands down and a 'start up' guide. --- docs/commands.md | 25 +++++++++++++++++++++++++ docs/using_tox.md | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 docs/commands.md create mode 100644 docs/using_tox.md diff --git a/docs/commands.md b/docs/commands.md new file mode 100644 index 00000000..8669bb9b --- /dev/null +++ b/docs/commands.md @@ -0,0 +1,25 @@ +# Tox User Commands +Here's a list of commands that nTox accepts, +which can all be used by starting your line with +a */*. Currently there can be no spaces before this. + +* */f* [ID] + + Add a friend with ID [ID]. +* */d* + + Call doMessenger() which does...something? +* */m* \[FRIEND\_NUM\] \[MESSAGE\] + + Message \[FRIEND\_NUM\] \[MESSAGE\]. +* */n* \[NAME\] + + Change your username to \[NAME\]. +* */l* + + Print your list of friends. (like you have any) +* */s* \[STATUS\] + + Set your status to \[STATUS\]. +* */a* \[ID\] + + Accept friend request from \[ID\]. +* */i* + + Print useful info about your client. +* */h* + + Print some help. +* */q/* + + Quit Tox. (why ;_;) diff --git a/docs/using_tox.md b/docs/using_tox.md new file mode 100644 index 00000000..b4f4310d --- /dev/null +++ b/docs/using_tox.md @@ -0,0 +1,38 @@ +# Using Tox +1. Build Tox +2. Fix errors +3. Consult IRC for help +4. Go on debugging journy for devs +5. Build Tox for real +6. ??? + +For all the work we've put into Tox so far, +there isn't yet a decent guide for how you _use_ +Tox. Here's a user-friendly attempt at it. + +1. Connect to the network! + + You need to connect to a bootstrapping server, to give you a public key. + + Where can I find a public server? Right here, as of now: + (the help message from running nTox with no args will help) + + 198.46.136.167 33445 728925473812C7AAC482BE7250BCCAD0B8CB9F737BF3D42ABD34459C1768F854 + + 192.81.133.111 33445 8CD5A9BF0A6CE358BA36F7A653F99FA6B258FF756E490F52C1F98CC420F78858 + + 66.175.223.88 33445 AC4112C975240CAD260BB2FCD134266521FAAF0A5D159C5FD3201196191E4F5D + + 192.184.81.118 33445 5CD7EB176C19A2FD840406CD56177BB8E75587BB366F7BB3004B19E3EDC04143 +2. Find a friend! + + Now that you're on the network, you need a friend. To get one of those, + you need to to send or receive a request. What's a request, you ask? + It's like a friend request, but we use really scary and cryptic numbers + instead of names. When nTox starts, it shows your _your_ long, scary number, + called your *public key*. Give that to people, and they can add you as + as "friend". Or, you can add someone else, with the */f* command, if you like. +3. Chat it up! + + Now use the */m* command to send a message to someone. Wow, you're chatting! +4. But something broke! + + Yeah, pre-alpha-alpha software tends to do that. We're working on it. + + Please report all crashes to either the github page, or #tox-dev on freenode. +5. Nothing broke, but what does */f* mean? + + nTox parses text as a command if the first character is a forward-slash ('/'). + You can check all commands in commands.md. +6. Use and support Tox! + + Code for us, debug for us, document for us, translate for us, even just talk about us! + + The more interest we get, the more work gets done, the better Tox is. From 17e64b3ee50605cbc15f195f770dacf31039e121 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Wed, 31 Jul 2013 05:52:08 -0400 Subject: [PATCH 49/57] initialize num_requests --- testing/nTox.c | 3 ++- testing/nTox_win32.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/testing/nTox.c b/testing/nTox.c index 5f184407..54f973d0 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -38,7 +38,7 @@ char line[STRING_LENGTH]; int x, y; uint8_t pending_requests[256][CLIENT_ID_SIZE]; -uint8_t num_requests; +uint8_t num_requests = 0; void new_lines(char *line) { @@ -57,6 +57,7 @@ void print_friendlist() new_lines("[i] Friend List:"); uint32_t i; for (i = 0; i <= num_requests; i++) { + printf ("num_resusts: %d\n", num_requests); char fstring[128]; getname(i, (uint8_t*)name); diff --git a/testing/nTox_win32.c b/testing/nTox_win32.c index 3286bb3a..27ab6a77 100644 --- a/testing/nTox_win32.c +++ b/testing/nTox_win32.c @@ -27,7 +27,7 @@ #include uint8_t pending_requests[256][CLIENT_ID_SIZE]; -uint8_t num_requests; +uint8_t num_requests = 0; char line[STRING_LENGTH]; char users_id[200]; From 55a2e59a64d879440667b9d672a3878fa7fe5d2e Mon Sep 17 00:00:00 2001 From: irungentoo Date: Wed, 31 Jul 2013 08:35:06 -0400 Subject: [PATCH 50/57] Fixed build. --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) mode change 100644 => 100755 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index 9a79b74e..9b7db143 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,9 +6,7 @@ if(NOT WIN32) option(USE_NACL "Use NaCl library instead of libsodium") endif() -if(NOT USE_NACL) - set(LINK_CRYPTO_LIBRARY ${SODIUM_LIBRARY}) -else() +if(USE_NACL) find_package(NaCl REQUIRED) include_directories(${NACL_INCLUDE_DIR}) @@ -26,6 +24,10 @@ if(NOT WIN32) find_package(SODIUM REQUIRED) endif() +if(NOT USE_NACL) + set(LINK_CRYPTO_LIBRARY ${SODIUM_LIBRARY}) +endif() + macro(linkCoreLibraries exe_name) add_dependencies(${exe_name} core) if(WIN32) From d9f88fd89ea37119cbfc64551251e33b20e507b0 Mon Sep 17 00:00:00 2001 From: pyrobisqit Date: Wed, 31 Jul 2013 16:46:49 +0200 Subject: [PATCH 51/57] more tweaks to README.md Simplified a few blocks and made it easier to read, corrected punctuation and bits here and there. --- README.md | 62 +++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 19bbb759..db0f551c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ ![Project Tox](https://rbt.asia/boards/g/img/0352/79/1373823047559.png "Project Tox") -Project Tox, _also known as Tox_, is a FOSS instant messaging application aimed to replace Skype.
- -With the rise of governmental monitoring programs, Tox aims to be an easy to use application that allows people to connect with friends and loved ones without the worry of privacy.

+Project Tox, _also known as Tox_, is a FOSS (Free and Open Source Software) instant messaging application aimed to replace Skype.
+With the rise of governmental monitoring programs, Tox aims to be an easy to use, all-in-one communication platform (including audio, and videochats in the future) that ensures their users full privacy and secure message delivery.

@@ -15,41 +14,40 @@ With the rise of governmental monitoring programs, Tox aims to be an easy to use **How to build Tox on Linux**: [YouTube video](http://www.youtube.com/watch?v=M4WXE4VKmyg)
**How to use Tox on Windows**: [YouTube video](http://www.youtube.com/watch?v=qg_j_sDb6WQ) -## The Complex Stuff: -+ Tox must use UDP simply because you can't hole punch with TCP. It's possible, but it doesn't work all the time. -+ Every peer is represented as a byte string (the public key of the peer [client id]) -+ We're using torrent-style DHT so that peers can find the IP of the other peers when they have their ID. -+ Once the client has the IP of that peer, they start initiating a secure connection with each other. (See [Crypto](https://github.com/irungentoo/ProjectTox-Core/wiki/Crypto)) -+ When both peers are securely connected, they can exchange messages, initiate a video chat, send files, etc, all using encrypted communications.
-+ Current build status: [![Build Status](https://travis-ci.org/irungentoo/ProjectTox-Core.png?branch=master)](https://travis-ci.org/irungentoo/ProjectTox-Core) +### Objectives: -## Roadmap: -- [x] Get our DHT working perfectly.(Done, needs large scale testing though.) -- [x] Reliable connection (See Lossless_UDP protocol) to other peers according to client id. (Done, see DHT_sendfiletest.c for an example) -- [x] Encryption. (Done) -- [ ] Get a simple text only IM client working perfectly. (This is where we are) -- [ ] Streaming media -- [ ] ??? - -For further information, check our [To-do list](https://github.com/irungentoo/ProjectTox-Core/wiki/TODO) - - -### Important-stuff: - -Use the same UDP socket for everything +Use the same UDP socket for everything. Keep everything really simple. -### Details and Documents: +## The Complex Stuff: ++ Tox must use UDP simply because [hole punching](http://en.wikipedia.org/wiki/UDP_hole_punching) with TCP is not as reliable. ++ Every peer is represented as a [byte string](https://en.wikipedia.org/wiki/String_(computer_science)) (the public key of the peer [client ID]). ++ We're using torrent-style DHT so that peers can find the IP of the other peers when they have their ID. ++ Once the client has the IP of that peer, they start initiating a secure connection with each other. (See [Crypto](https://github.com/irungentoo/ProjectTox-Core/wiki/Crypto)) ++ When both peers are securely connected, they can exchange messages, initiate a video chat, send files, etc, all using encrypted communications. ++ Current build status: [![Build Status](https://travis-ci.org/irungentoo/ProjectTox-Core.png?branch=master)](https://travis-ci.org/irungentoo/ProjectTox-Core) + +## Roadmap: +- [x] Get our DHT working perfectly. (Done, needs large scale testing though) +- [x] Reliable connection (See Lossless UDP protocol) to other peers according to client ID. (Done, see DHT_sendfiletest.c for an example) +- [x] Encryption. (Done) +- [ ] Get a simple text only IM client working perfectly. (This is where we are) +- [ ] Streaming media +- [ ] ??? + +For further information, check our [To-do list](https://github.com/irungentoo/ProjectTox-Core/wiki/TODO) + +### Why are you doing this? There are already a bunch of free skype alternatives. +The goal of this project is to create a configuration-free P2P skype +replacement. Configuration-free means that the user will simply have to open the program and +without any account configuration will be capable of adding people to his +friends list and start conversing with them. There are many so called skype replacements and all of them are either hard to +configure for the normal user or suffer from being way too centralized. + +### Documentation: [DHT Protocol](https://github.com/irungentoo/ProjectTox-Core/wiki/DHT)
[Lossless UDP Protocol](https://github.com/irungentoo/ProjectTox-Core/wiki/Lossless-UDP)
[Crypto](https://github.com/irungentoo/ProjectTox-Core/wiki/Crypto)
[Ideas](https://github.com/irungentoo/ProjectTox-Core/wiki/Ideas) - -### Why are you doing this? There are already a bunch of free skype alternatives. -The goal of this project is to create a configuration-free p2p skype -replacement. Configuration-free means that the user will simply have to open the program and -without any account configuration will be capable of adding people to his -friends list and start conversing with them. There are many so called skype replacements and all of them are either hard to -configure for the normal user or suffer from being much too centralized. From ccbe4c67996b4732a167449dfe288c65281b5d2d Mon Sep 17 00:00:00 2001 From: Nick ODell Date: Wed, 31 Jul 2013 10:38:13 -0600 Subject: [PATCH 52/57] Show error message instead of "added friendnumber -1" --- testing/nTox.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/testing/nTox.c b/testing/nTox.c index 29726a3a..ff8f8caf 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -172,13 +172,17 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) else if (inpt_command == 'a') { uint8_t numf = atoi(line + 3); char numchar[100]; - sprintf(numchar, "[i] friend request %u accepted", numf); - new_lines(numchar); int num = m_addfriend_norequest(pending_requests[numf]); - sprintf(numchar, "[i] added friendnumber %d", num); - new_lines(numchar); + if (num != -1) { + sprintf(numchar, "[i] friend request %u accepted", numf); + new_lines(numchar); + sprintf(numchar, "[i] added friendnumber %d", num); + new_lines(numchar); + } else { + sprintf(numchar, "[i] failed to add friend"); + new_lines(numchar); + } do_refresh(); - } else if (inpt_command == 'h') { //help new_lines("[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status)"); From d0888f750c59433eb46828f24274da3cd9bd4b76 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Wed, 31 Jul 2013 12:44:03 -0400 Subject: [PATCH 53/57] Fixed something in readme. --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index db0f551c..499d8202 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,6 @@ With the rise of governmental monitoring programs, Tox aims to be an easy to use ### Objectives: -Use the same UDP socket for everything. - Keep everything really simple. ## The Complex Stuff: From 2247b7fad552d75eb0e0f4407970aa76f64b8942 Mon Sep 17 00:00:00 2001 From: plutooo Date: Wed, 31 Jul 2013 10:20:03 -0700 Subject: [PATCH 54/57] Added chat windows, and some clean up. --- testing/toxic/CMakeLists.txt | 3 +- testing/toxic/chat.c | 134 +++++++++++++++++++++++++++++++++++ testing/toxic/friendlist.c | 48 ++++++++++--- testing/toxic/main.c | 45 +++++++++--- testing/toxic/prompt.c | 4 +- testing/toxic/windows.h | 6 ++ 6 files changed, 222 insertions(+), 18 deletions(-) create mode 100644 testing/toxic/chat.c diff --git a/testing/toxic/CMakeLists.txt b/testing/toxic/CMakeLists.txt index c70babb7..f30d8e9e 100644 --- a/testing/toxic/CMakeLists.txt +++ b/testing/toxic/CMakeLists.txt @@ -6,7 +6,8 @@ set(exe_name toxic) add_executable(${exe_name} main.c prompt.c - friendlist.c) + friendlist.c + chat.c) target_link_libraries(${exe_name} curses) diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c new file mode 100644 index 00000000..53cf3319 --- /dev/null +++ b/testing/toxic/chat.c @@ -0,0 +1,134 @@ +#include +#include +#include +#include +#include + +#include "../../core/Messenger.h" +#include "../../core/network.h" + +#include "windows.h" + +typedef struct { + int friendnum; + + char line[256]; + size_t pos; + + WINDOW* history; + WINDOW* linewin; + +} ChatContext; + +extern void fix_name(uint8_t* name); + + +static void chat_onMessage(ToxWindow* self, int num, uint8_t* msg, uint16_t len) { + ChatContext* ctx = (ChatContext*) self->x; + uint8_t nick[MAX_NAME_LENGTH] = {0}; + + if(ctx->friendnum != num) + return; + + getname(num, (uint8_t*) &nick); + + msg[len-1] = '\0'; + nick[MAX_NAME_LENGTH-1] = '\0'; + + fix_name(msg); + fix_name(nick); + + wprintw(ctx->history, "%s: %s\n", nick, msg); +} + +static void chat_onNickChange(ToxWindow* self, int num, uint8_t* nick, uint16_t len) { + ChatContext* ctx = (ChatContext*) self->x; + + if(ctx->friendnum != num) + return; + + nick[len-1] = '\0'; + fix_name(nick); + + wattron(ctx->history, COLOR_PAIR(3)); + wprintw(ctx->history, " * Your partner changed nick to '%s'\n", nick); + wattroff(ctx->history, COLOR_PAIR(3)); +} + +static void chat_onStatusChange(ToxWindow* self, int num, uint8_t* status, uint16_t len) { + +} + +static void chat_onKey(ToxWindow* self, int key) { + ChatContext* ctx = (ChatContext*) self->x; + + if(isprint(key)) { + + if(ctx->pos != sizeof(ctx->line)-1) { + ctx->line[ctx->pos++] = key; + ctx->line[ctx->pos] = '\0'; + } + } + else if(key == '\n') { + wprintw(ctx->history, "you: %s\n", ctx->line); + + if(m_sendmessage(ctx->friendnum, (uint8_t*) ctx->line, strlen(ctx->line)+1) < 0) { + wprintw(ctx->history, " * Failed to send message.\n"); + } + + ctx->line[0] = '\0'; + ctx->pos = 0; + } +} + +static void chat_onDraw(ToxWindow* self) { + int x, y; + ChatContext* ctx = (ChatContext*) self->x; + + getmaxyx(self->window, y, x); + + (void) x; + if(y < 3) + return; + + wclear(ctx->linewin); + mvwhline(ctx->linewin, 0, 0, '_', COLS); + mvwprintw(ctx->linewin, 1, 0, "%s\n", ctx->line); + + wrefresh(self->window); +} + +static void chat_onInit(ToxWindow* self) { + int x, y; + ChatContext* ctx = (ChatContext*) self->x; + + getmaxyx(self->window, y, x); + + ctx->history = subwin(self->window, y - 4, x, 0, 0); + wprintw(ctx->history, "Here goes chat\n"); + scrollok(ctx->history, 1); + + ctx->linewin = subwin(self->window, 2, x, y - 3, 0); +} + +ToxWindow new_chat(int friendnum) { + ToxWindow ret; + + memset(&ret, 0, sizeof(ret)); + + ret.onKey = &chat_onKey; + ret.onDraw = &chat_onDraw; + ret.onInit = &chat_onInit; + ret.onMessage = &chat_onMessage; + ret.onNickChange = &chat_onNickChange; + ret.onStatusChange = &chat_onStatusChange; + + snprintf(ret.title, sizeof(ret.title), "[chat %d]", friendnum); + + ChatContext* x = calloc(1, sizeof(ChatContext)); + x->friendnum = friendnum; + + ret.x = (void*) x; + + return ret; +} diff --git a/testing/toxic/friendlist.c b/testing/toxic/friendlist.c index f8b8c840..629adaff 100644 --- a/testing/toxic/friendlist.c +++ b/testing/toxic/friendlist.c @@ -12,6 +12,10 @@ #include "windows.h" +extern int add_window(ToxWindow w); +extern int focus_window(int num); +extern ToxWindow new_chat(int friendnum); + #define MAX_FRIENDS_NUM 100 typedef struct { @@ -23,6 +27,7 @@ typedef struct { static friend_t friends[MAX_FRIENDS_NUM]; static int num_friends = 0; +static int num_selected = 0; void fix_name(uint8_t* name) { @@ -42,31 +47,31 @@ void fix_name(uint8_t* name) { *q = 0; } -int friendlist_nickchange(int num, uint8_t* str, uint16_t len) { +void friendlist_onNickChange(ToxWindow* self, int num, uint8_t* str, uint16_t len) { if(len >= MAX_NAME_LENGTH || num >= num_friends) - return -1; + return; memcpy((char*) &friends[num].name, (char*) str, len); friends[num].name[len] = 0; fix_name(friends[num].name); - return 0; + return; } -int friendlist_statuschange(int num, uint8_t* str, uint16_t len) { +void friendlist_onStatusChange(ToxWindow* self, int num, uint8_t* str, uint16_t len) { if(len >= MAX_USERSTATUS_LENGTH || num >= num_friends) - return -1; + return; memcpy((char*) &friends[num].status, (char*) str, len); friends[num].status[len] = 0; fix_name(friends[num].status); - return 0; + return; } -int friendlist_addfriend(int num) { +int friendlist_onFriendAdded(int num) { if(num_friends == MAX_FRIENDS_NUM) return -1; @@ -82,6 +87,17 @@ int friendlist_addfriend(int num) { static void friendlist_onKey(ToxWindow* self, int key) { + if(key == KEY_UP) { + if(num_selected != 0) + num_selected--; + } + else if(key == KEY_DOWN) { + if(num_friends != 0) + num_selected = (num_selected+1) % num_friends; + } + else if(key == '\n') { + focus_window(add_window(new_chat(num_selected))); + } } static void friendlist_onDraw(ToxWindow* self) { @@ -92,11 +108,23 @@ static void friendlist_onDraw(ToxWindow* self) { if(num_friends == 0) { wprintw(self->window, "Empty. Add some friends! :-)\n"); } + else { + wattron(self->window, COLOR_PAIR(2) | A_BOLD); + wprintw(self->window, "Friend list:\n"); + wattroff(self->window, A_BOLD); + + wprintw(self->window, " ENTER: start a chat\n"); + wprintw(self->window, " UP/DOWN: navigate list\n"); + wattroff(self->window, COLOR_PAIR(2)); + } wprintw(self->window, "\n"); for(i=0; iwindow, "[%d] ", friends[i].num); + + if(i == num_selected) wattron(self->window, COLOR_PAIR(3)); + wprintw(self->window, " [%d] ", friends[i].num); + if(i == num_selected) wattroff(self->window, COLOR_PAIR(3)); attron(A_BOLD); wprintw(self->window, "%s ", friends[i].name); @@ -116,9 +144,13 @@ static void friendlist_onInit(ToxWindow* self) { ToxWindow new_friendlist() { ToxWindow ret; + memset(&ret, 0, sizeof(ret)); + ret.onKey = &friendlist_onKey; ret.onDraw = &friendlist_onDraw; ret.onInit = &friendlist_onInit; + ret.onNickChange = &friendlist_onNickChange; + ret.onStatusChange = &friendlist_onStatusChange; strcpy(ret.title, "[friends]"); return ret; diff --git a/testing/toxic/main.c b/testing/toxic/main.c index e1d1ebd0..1c095c54 100644 --- a/testing/toxic/main.c +++ b/testing/toxic/main.c @@ -16,9 +16,7 @@ extern ToxWindow new_prompt(); extern ToxWindow new_friendlist(); -extern int friendlist_addfriend(int num); -extern int friendlist_nickchange(int num, uint8_t* str, uint16_t len); -extern int friendlist_statuschange(int num, uint8_t* str, uint16_t len); +extern int friendlist_onFriendAdded(int num); extern int add_req(uint8_t* public_key); // XXX @@ -31,29 +29,52 @@ static ToxWindow* prompt; // CALLBACKS START void on_request(uint8_t* public_key, uint8_t* data, uint16_t length) { + size_t i; int n = add_req(public_key); wprintw(prompt->window, "\nFriend request.\nUse \"accept %d\" to accept it.\n", n); + + for(i=0; iwindow, "\n(message) %d: %s!\n", friendnumber, string); + + for(i=0; iwindow, "\n(nickchange) %d: %s!\n", friendnumber, string); - friendlist_nickchange(friendnumber, string, length); + for(i=0; iwindow, "\n(statuschange) %d: %s!\n", friendnumber, string); - friendlist_statuschange(friendnumber, string, length); + for(i=0; i= w_num || num < 0) + return -1; + + w_active = num; + return 0; } static void init_windows() { diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c index 22d9eb9e..52e9bde0 100644 --- a/testing/toxic/prompt.c +++ b/testing/toxic/prompt.c @@ -221,7 +221,7 @@ static void execute(ToxWindow* self, char* cmd) { msg[0] = 0; msg++; - if(m_sendmessage(atoi(id), (uint8_t*) msg, strlen(msg)+1) != 1) { + if(m_sendmessage(atoi(id), (uint8_t*) msg, strlen(msg)+1) < 0) { wprintw(self->window, "Error occurred while sending message.\n"); } else { @@ -312,6 +312,8 @@ static void prompt_onInit(ToxWindow* self) { ToxWindow new_prompt() { ToxWindow ret; + memset(&ret, 0, sizeof(ret)); + ret.onKey = &prompt_onKey; ret.onDraw = &prompt_onDraw; ret.onInit = &prompt_onInit; diff --git a/testing/toxic/windows.h b/testing/toxic/windows.h index 2e082ca9..480fd658 100644 --- a/testing/toxic/windows.h +++ b/testing/toxic/windows.h @@ -4,7 +4,13 @@ struct ToxWindow_ { void(*onKey)(ToxWindow*, int); void(*onDraw)(ToxWindow*); void(*onInit)(ToxWindow*); + void(*onFriendRequest)(ToxWindow*, uint8_t*, uint8_t*, uint16_t); + void(*onMessage)(ToxWindow*, int, uint8_t*, uint16_t); + void(*onNickChange)(ToxWindow*, int, uint8_t*, uint16_t); + void(*onStatusChange)(ToxWindow*, int, uint8_t*, uint16_t); char title[256]; + void* x; + WINDOW* window; }; From 0815d1110d452f174bc523c11291b8da41e01d4a Mon Sep 17 00:00:00 2001 From: plutooo Date: Wed, 31 Jul 2013 11:20:16 -0700 Subject: [PATCH 55/57] toxic: Made everything 1000x more userfriendly. --- testing/toxic/chat.c | 27 ++++++++++++++++++++++++--- testing/toxic/friendlist.c | 37 +++++++++++++++++++++++-------------- testing/toxic/main.c | 25 ++++++++++++++++++++++--- testing/toxic/prompt.c | 7 +++---- testing/toxic/windows.h | 7 +++++++ 5 files changed, 79 insertions(+), 24 deletions(-) diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c index 53cf3319..da9ad025 100644 --- a/testing/toxic/chat.c +++ b/testing/toxic/chat.c @@ -1,3 +1,7 @@ +/* + * Toxic -- Tox Curses Client + */ + #include #include #include @@ -38,7 +42,13 @@ static void chat_onMessage(ToxWindow* self, int num, uint8_t* msg, uint16_t len) fix_name(msg); fix_name(nick); - wprintw(ctx->history, "%s: %s\n", nick, msg); + wattron(ctx->history, COLOR_PAIR(4)); + wprintw(ctx->history, "%s: ", nick); + wattroff(ctx->history, COLOR_PAIR(4)); + + wprintw(ctx->history, "%s\n", msg); + + self->blink = true; } static void chat_onNickChange(ToxWindow* self, int num, uint8_t* nick, uint16_t len) { @@ -70,15 +80,27 @@ static void chat_onKey(ToxWindow* self, int key) { } } else if(key == '\n') { - wprintw(ctx->history, "you: %s\n", ctx->line); + wattron(ctx->history, COLOR_PAIR(1)); + wprintw(ctx->history, "you: ", ctx->line); + wattroff(ctx->history, COLOR_PAIR(1)); + + wprintw(ctx->history, "%s\n", ctx->line); if(m_sendmessage(ctx->friendnum, (uint8_t*) ctx->line, strlen(ctx->line)+1) < 0) { + wattron(ctx->history, COLOR_PAIR(3)); wprintw(ctx->history, " * Failed to send message.\n"); + wattroff(ctx->history, COLOR_PAIR(3)); } ctx->line[0] = '\0'; ctx->pos = 0; } + else if(key == 0x107) { + if(ctx->pos != 0) { + ctx->line[--ctx->pos] = '\0'; + } + } + } static void chat_onDraw(ToxWindow* self) { @@ -105,7 +127,6 @@ static void chat_onInit(ToxWindow* self) { getmaxyx(self->window, y, x); ctx->history = subwin(self->window, y - 4, x, 0, 0); - wprintw(ctx->history, "Here goes chat\n"); scrollok(ctx->history, 1); ctx->linewin = subwin(self->window, 2, x, y - 3, 0); diff --git a/testing/toxic/friendlist.c b/testing/toxic/friendlist.c index 629adaff..f9a413f9 100644 --- a/testing/toxic/friendlist.c +++ b/testing/toxic/friendlist.c @@ -22,7 +22,7 @@ typedef struct { uint8_t name[MAX_NAME_LENGTH]; uint8_t status[MAX_USERSTATUS_LENGTH]; int num; - + int chatwin; } friend_t; static friend_t friends[MAX_FRIENDS_NUM]; @@ -37,7 +37,7 @@ void fix_name(uint8_t* name) { uint8_t* q = name; while(*p != 0) { - if(isalnum(*p)) { + if(isprint(*p)) { *q++ = *p; } @@ -47,6 +47,16 @@ void fix_name(uint8_t* name) { *q = 0; } +void friendlist_onMessage(ToxWindow* self, int num, uint8_t* str, uint16_t len) { + + if(num >= num_friends) + return; + + if(friends[num].chatwin == -1) { + friends[num].chatwin = add_window(new_chat(num)); + } +} + void friendlist_onNickChange(ToxWindow* self, int num, uint8_t* str, uint16_t len) { if(len >= MAX_NAME_LENGTH || num >= num_friends) @@ -55,8 +65,6 @@ void friendlist_onNickChange(ToxWindow* self, int num, uint8_t* str, uint16_t le memcpy((char*) &friends[num].name, (char*) str, len); friends[num].name[len] = 0; fix_name(friends[num].name); - - return; } void friendlist_onStatusChange(ToxWindow* self, int num, uint8_t* str, uint16_t len) { @@ -67,8 +75,6 @@ void friendlist_onStatusChange(ToxWindow* self, int num, uint8_t* str, uint16_t memcpy((char*) &friends[num].status, (char*) str, len); friends[num].status[len] = 0; fix_name(friends[num].status); - - return; } int friendlist_onFriendAdded(int num) { @@ -80,6 +86,7 @@ int friendlist_onFriendAdded(int num) { getname(num, friends[num_friends].name); strcpy((char*) friends[num_friends].name, "unknown"); strcpy((char*) friends[num_friends].status, "unknown"); + friends[num_friends].chatwin = -1; num_friends++; return 0; @@ -96,7 +103,12 @@ static void friendlist_onKey(ToxWindow* self, int key) { num_selected = (num_selected+1) % num_friends; } else if(key == '\n') { - focus_window(add_window(new_chat(num_selected))); + + if(friends[num_selected].chatwin != -1) + return; + + friends[num_selected].chatwin = add_window(new_chat(num_selected)); + focus_window(friends[num_selected].chatwin); } } @@ -110,12 +122,8 @@ static void friendlist_onDraw(ToxWindow* self) { } else { wattron(self->window, COLOR_PAIR(2) | A_BOLD); - wprintw(self->window, "Friend list:\n"); - wattroff(self->window, A_BOLD); - - wprintw(self->window, " ENTER: start a chat\n"); - wprintw(self->window, " UP/DOWN: navigate list\n"); - wattroff(self->window, COLOR_PAIR(2)); + wprintw(self->window, "Open chat with.. (up/down keys, enter)\n"); + wattroff(self->window, COLOR_PAIR(2) | A_BOLD); } wprintw(self->window, "\n"); @@ -123,7 +131,7 @@ static void friendlist_onDraw(ToxWindow* self) { for(i=0; iwindow, COLOR_PAIR(3)); - wprintw(self->window, " [%d] ", friends[i].num); + wprintw(self->window, " [#%d] ", friends[i].num); if(i == num_selected) wattroff(self->window, COLOR_PAIR(3)); attron(A_BOLD); @@ -149,6 +157,7 @@ ToxWindow new_friendlist() { ret.onKey = &friendlist_onKey; ret.onDraw = &friendlist_onDraw; ret.onInit = &friendlist_onInit; + ret.onMessage = &friendlist_onMessage; ret.onNickChange = &friendlist_onNickChange; ret.onStatusChange = &friendlist_onStatusChange; strcpy(ret.title, "[friends]"); diff --git a/testing/toxic/main.c b/testing/toxic/main.c index 1c095c54..fffc3f84 100644 --- a/testing/toxic/main.c +++ b/testing/toxic/main.c @@ -32,7 +32,14 @@ void on_request(uint8_t* public_key, uint8_t* data, uint16_t length) { size_t i; int n = add_req(public_key); - wprintw(prompt->window, "\nFriend request.\nUse \"accept %d\" to accept it.\n", n); + wprintw(prompt->window, "\nFriend request from:\n"); + + for(i=0; i<32; i++) { + wprintw(prompt->window, "%02x", public_key[i] & 0xff); + } + wprintw(prompt->window, "\n"); + + wprintw(prompt->window, "Use \"accept %d\" to accept it.\n", n); for(i=0; iwindow); + a->blink = false; a->onDraw(a); draw_bar(); diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c index 52e9bde0..cd9ef219 100644 --- a/testing/toxic/prompt.c +++ b/testing/toxic/prompt.c @@ -42,7 +42,7 @@ static int prompt_buf_pos=0; static void execute(ToxWindow* self, char* cmd) { - if(!strcmp(cmd, "quit") || !strcmp(cmd, "exit")) { + if(!strcmp(cmd, "quit") || !strcmp(cmd, "exit") || !strcmp(cmd, "q")) { endwin(); exit(0); } @@ -282,12 +282,11 @@ static void prompt_onDraw(ToxWindow* self) { static void print_usage(ToxWindow* self) { wattron(self->window, COLOR_PAIR(2) | A_BOLD); - wprintw(self->window, "Usage:\n"); + wprintw(self->window, "Commands:\n"); wattroff(self->window, A_BOLD); wprintw(self->window, " connect : Connect to DHT server\n"); wprintw(self->window, " add : Add friend\n"); - wprintw(self->window, " msg : Send message\n"); wprintw(self->window, " status : Set your status\n"); wprintw(self->window, " nick : Set your nickname\n"); wprintw(self->window, " accept : Accept friend request\n"); @@ -296,7 +295,7 @@ static void print_usage(ToxWindow* self) { wattron(self->window, A_BOLD); - wprintw(self->window, "Use the TAB key to navigate through the tabs.\n"); + wprintw(self->window, "TIP: Use the TAB key to navigate through the tabs.\n\n"); wattroff(self->window, A_BOLD); wattroff(self->window, COLOR_PAIR(2)); diff --git a/testing/toxic/windows.h b/testing/toxic/windows.h index 480fd658..dde1430f 100644 --- a/testing/toxic/windows.h +++ b/testing/toxic/windows.h @@ -1,3 +1,9 @@ +/* + * Toxic -- Tox Curses Client + */ + +#include + typedef struct ToxWindow_ ToxWindow; struct ToxWindow_ { @@ -11,6 +17,7 @@ struct ToxWindow_ { char title[256]; void* x; + bool blink; WINDOW* window; }; From 0d5eef4b43f6d936d3e34a2329b7d819e870953c Mon Sep 17 00:00:00 2001 From: irungentoo Date: Wed, 31 Jul 2013 15:22:43 -0400 Subject: [PATCH 56/57] Backspace key should now work on more terminals in toxic. --- testing/toxic/chat.c | 2 +- testing/toxic/prompt.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c index da9ad025..dceb1d7b 100644 --- a/testing/toxic/chat.c +++ b/testing/toxic/chat.c @@ -95,7 +95,7 @@ static void chat_onKey(ToxWindow* self, int key) { ctx->line[0] = '\0'; ctx->pos = 0; } - else if(key == 0x107) { + else if(key == 0x107 || key == 0x8 || key == 0x7f) { if(ctx->pos != 0) { ctx->line[--ctx->pos] = '\0'; } diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c index 62470a23..f1b6e689 100644 --- a/testing/toxic/prompt.c +++ b/testing/toxic/prompt.c @@ -256,7 +256,7 @@ static void prompt_onKey(ToxWindow* self, int key) { } // BACKSPACE key: Remove one character from line. - else if(key == 0x107) { + else if(key == 0x107 || key == 0x8 || key == 0x7f) { if(prompt_buf_pos != 0) { prompt_buf[--prompt_buf_pos] = 0; From 3eafbc900e0547041aae299461e59f3dfd31c8d8 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Wed, 31 Jul 2013 15:34:34 -0400 Subject: [PATCH 57/57] remove debugging printf statement --- testing/nTox.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/testing/nTox.c b/testing/nTox.c index ff8f8caf..7c84871f 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -61,9 +61,7 @@ void print_friendlist() new_lines("[i] Friend List:"); uint32_t i; for (i = 0; i <= num_requests; i++) { - printf ("num_resusts: %d\n", num_requests); char fstring[128]; - getname(i, (uint8_t*)name); if (strlen(name) <= 0) { sprintf(fstring, "[i] Friend: NULL\n\tid: %i", i);