diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | INSTALL.md | 2 | ||||
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | core/LAN_discovery.c | 58 | ||||
-rw-r--r-- | core/LAN_discovery.h | 8 | ||||
-rw-r--r-- | docs/start_guide.md | 8 | ||||
-rw-r--r-- | testing/toxic/chat.c | 8 | ||||
-rw-r--r-- | testing/toxic/prompt.c | 20 |
8 files changed, 81 insertions, 27 deletions
@@ -3,6 +3,7 @@ | |||
3 | //nacl build | 3 | //nacl build |
4 | nacl/build/ | 4 | nacl/build/ |
5 | build | 5 | build |
6 | sodium | ||
6 | 7 | ||
7 | CMakeCache.txt | 8 | CMakeCache.txt |
8 | CMakeFiles | 9 | CMakeFiles |
@@ -58,7 +58,7 @@ make | |||
58 | <a name="homebrew" /> | 58 | <a name="homebrew" /> |
59 | ####Homebrew: | 59 | ####Homebrew: |
60 | ``` | 60 | ``` |
61 | brew install libtool automake autoconf libconfig libsodium | 61 | brew install libtool automake autoconf libconfig libsodium cmake |
62 | cmake . | 62 | cmake . |
63 | make | 63 | make |
64 | sudo make install | 64 | sudo make install |
@@ -12,7 +12,8 @@ With the rise of governmental monitoring programs, Tox aims to be an easy to use | |||
12 | **Qt GUI**: [see nurupo's repository](https://github.com/nurupo/ProjectTox-Qt-GUI) | 12 | **Qt GUI**: [see nurupo's repository](https://github.com/nurupo/ProjectTox-Qt-GUI) |
13 | 13 | ||
14 | **How to build Tox on Linux**: [YouTube video](http://www.youtube.com/watch?v=M4WXE4VKmyg)<br /> | 14 | **How to build Tox on Linux**: [YouTube video](http://www.youtube.com/watch?v=M4WXE4VKmyg)<br /> |
15 | **How to use Tox on Windows**: [YouTube video](http://www.youtube.com/watch?v=qg_j_sDb6WQ) | 15 | **How to use Tox on Windows**: [YouTube video](http://www.youtube.com/watch?v=qg_j_sDb6WQ)<br /> |
16 | **For Mac OSX read INSTALL.md** | ||
16 | 17 | ||
17 | ### Objectives: | 18 | ### Objectives: |
18 | 19 | ||
diff --git a/core/LAN_discovery.c b/core/LAN_discovery.c index 0a23914d..6170f2fb 100644 --- a/core/LAN_discovery.c +++ b/core/LAN_discovery.c | |||
@@ -23,13 +23,67 @@ | |||
23 | 23 | ||
24 | #include "LAN_discovery.h" | 24 | #include "LAN_discovery.h" |
25 | 25 | ||
26 | #define MAX_INTERFACES 16 | ||
27 | #define ERR_INTERFACES 0 | ||
28 | #define ERR_IOCTL 1 | ||
26 | 29 | ||
27 | /*Return the broadcast ip | 30 | #ifdef __linux |
28 | TODO: make it return the real one, not the 255.255.255.255 one.*/ | 31 | /* get the first running interface's broadcast IP, |
32 | * return is higher than 0 on success | ||
33 | * ERR_IOCTL on an ioctl error | ||
34 | * ERR_INTERFACES on general error */ | ||
35 | uint32_t get_broadcast(void) | ||
36 | { | ||
37 | /* not sure how many platforms this will | ||
38 | * run on, so it's wrapped in __linux for now */ | ||
39 | struct ifconf ifconf; | ||
40 | struct ifreq i_faces[MAX_INTERFACES]; | ||
41 | int count = 0; | ||
42 | int sock = 0; | ||
43 | int i = 0; | ||
44 | struct sockaddr_in *sock_holder = NULL; | ||
45 | |||
46 | /* configure ifconf for the ioctl call */ | ||
47 | sock = socket(AF_INET, SOCK_STREAM, 0); | ||
48 | ifconf.ifc_buf = (char *)i_faces; | ||
49 | ifconf.ifc_len = sizeof(i_faces); | ||
50 | count = ifconf.ifc_len / sizeof(i_faces[0]); | ||
51 | |||
52 | for(i = 0; i < count; i++) { | ||
53 | /* skip the loopback interface, as it's useless */ | ||
54 | if(strcmp(i_faces[i].ifr_name, "lo") != 0) { | ||
55 | if(ioctl(sock, SIOCGIFBRDADDR, &i_faces[i]) < 0) { | ||
56 | perror("[!] get_broadcast: ioctl error"); | ||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | /* just to clarify where we're getting the values from */ | ||
61 | sock_holder = (struct sockaddr_in *)&i_faces[i].ifr_broadaddr; | ||
62 | break; | ||
63 | } | ||
64 | } | ||
65 | close(sock); | ||
66 | |||
67 | if(sock_holder == NULL) | ||
68 | return ERR_INTERFACES; | ||
69 | |||
70 | return sock_holder->sin_addr.s_addr; | ||
71 | } | ||
72 | #endif | ||
73 | |||
74 | /* Return the broadcast ip */ | ||
29 | IP broadcast_ip() | 75 | IP broadcast_ip() |
30 | { | 76 | { |
31 | IP ip; | 77 | IP ip; |
78 | #ifdef __linux | ||
79 | ip.i = get_broadcast(); | ||
80 | if(ip.i == ERR_INTERFACES) | ||
81 | ip.i = ~0; | ||
82 | else if(ip.i == ERR_IOCTL) | ||
83 | ip.i = 0; | ||
84 | #else | ||
32 | ip.i = ~0; | 85 | ip.i = ~0; |
86 | #endif | ||
33 | return ip; | 87 | return ip; |
34 | } | 88 | } |
35 | 89 | ||
diff --git a/core/LAN_discovery.h b/core/LAN_discovery.h index 4ca65c03..23391b90 100644 --- a/core/LAN_discovery.h +++ b/core/LAN_discovery.h | |||
@@ -28,6 +28,14 @@ | |||
28 | 28 | ||
29 | #include "DHT.h" | 29 | #include "DHT.h" |
30 | 30 | ||
31 | /* used for get_broadcast() */ | ||
32 | #ifdef __linux | ||
33 | #include <sys/ioctl.h> | ||
34 | #include <arpa/inet.h> | ||
35 | #include <linux/netdevice.h> | ||
36 | #endif | ||
37 | |||
38 | |||
31 | #ifdef __cplusplus | 39 | #ifdef __cplusplus |
32 | extern "C" { | 40 | extern "C" { |
33 | #endif | 41 | #endif |
diff --git a/docs/start_guide.md b/docs/start_guide.md index b7eec3f0..9ced4078 100644 --- a/docs/start_guide.md +++ b/docs/start_guide.md | |||
@@ -2,7 +2,7 @@ | |||
2 | 1. [Build Tox](../INSTALL.md) | 2 | 1. [Build Tox](../INSTALL.md) |
3 | 2. Fix errors | 3 | 2. Fix errors |
4 | 3. Consult IRC for help | 4 | 3. Consult IRC for help |
5 | 4. Go on debugging journy for devs | 5 | 4. Go on debugging journey for devs |
6 | 5. Build Tox for real | 6 | 5. Build Tox for real |
7 | 6. ??? | 7 | 6. ??? |
8 | 8 | ||
@@ -22,9 +22,9 @@ Tox. Here's a user-friendly attempt at it. | |||
22 | + Now that you're on the network, you need a friend. To get one of those, | 22 | + Now that you're on the network, you need a friend. To get one of those, |
23 | you need to to send or receive a request. What's a request, you ask? | 23 | you need to to send or receive a request. What's a request, you ask? |
24 | It's like a friend request, but we use really scary and cryptic numbers | 24 | It's like a friend request, but we use really scary and cryptic numbers |
25 | instead of names. When `nTox` starts, it shows your _your_ long, scary number, | 25 | instead of names. When `nTox` starts, it shows _your_ long, scary number, |
26 | called your *public key*. Give that to people, and they can add you as | 26 | called your *public key*. Give that to people, and they can add you as |
27 | as "friend". Or, you can add someone else, with the `/f` command, if you like. | 27 | a "friend". Or, you can add someone else, with the `/f` command, if you like. |
28 | 3. Chat it up! | 28 | 3. Chat it up! |
29 | + Now use the `/m` command to send a message to someone. Wow, you're chatting! | 29 | + Now use the `/m` command to send a message to someone. Wow, you're chatting! |
30 | 4. But something broke! | 30 | 4. But something broke! |
@@ -35,4 +35,4 @@ Tox. Here's a user-friendly attempt at it. | |||
35 | You can check all commands in commands.md. | 35 | You can check all commands in commands.md. |
36 | 6. Use and support Tox! | 36 | 6. Use and support Tox! |
37 | + Code for us, debug for us, document for us, translate for us, even just talk about us! | 37 | + Code for us, debug for us, document for us, translate for us, even just talk about us! |
38 | + The more interest we get, the more work gets done, the better Tox is. \ No newline at end of file | 38 | + The more interest we get, the more work gets done, the better Tox is. |
diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c index dceb1d7b..854d3817 100644 --- a/testing/toxic/chat.c +++ b/testing/toxic/chat.c | |||
@@ -60,6 +60,8 @@ static void chat_onNickChange(ToxWindow* self, int num, uint8_t* nick, uint16_t | |||
60 | nick[len-1] = '\0'; | 60 | nick[len-1] = '\0'; |
61 | fix_name(nick); | 61 | fix_name(nick); |
62 | 62 | ||
63 | snprintf(self->title, sizeof(self->title), "[%s (%d)]", nick, num); | ||
64 | |||
63 | wattron(ctx->history, COLOR_PAIR(3)); | 65 | wattron(ctx->history, COLOR_PAIR(3)); |
64 | wprintw(ctx->history, " * Your partner changed nick to '%s'\n", nick); | 66 | wprintw(ctx->history, " * Your partner changed nick to '%s'\n", nick); |
65 | wattroff(ctx->history, COLOR_PAIR(3)); | 67 | wattroff(ctx->history, COLOR_PAIR(3)); |
@@ -144,7 +146,11 @@ ToxWindow new_chat(int friendnum) { | |||
144 | ret.onNickChange = &chat_onNickChange; | 146 | ret.onNickChange = &chat_onNickChange; |
145 | ret.onStatusChange = &chat_onStatusChange; | 147 | ret.onStatusChange = &chat_onStatusChange; |
146 | 148 | ||
147 | snprintf(ret.title, sizeof(ret.title), "[chat %d]", friendnum); | 149 | uint8_t nick[MAX_NAME_LENGTH] = {0}; |
150 | getname(friendnum, (uint8_t*) &nick); | ||
151 | fix_name(nick); | ||
152 | |||
153 | snprintf(ret.title, sizeof(ret.title), "[%s (%d)]", nick, friendnum); | ||
148 | 154 | ||
149 | ChatContext* x = calloc(1, sizeof(ChatContext)); | 155 | ChatContext* x = calloc(1, sizeof(ChatContext)); |
150 | x->friendnum = friendnum; | 156 | x->friendnum = friendnum; |
diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c index e18bdff0..3c4a27dd 100644 --- a/testing/toxic/prompt.c +++ b/testing/toxic/prompt.c | |||
@@ -16,6 +16,7 @@ uint8_t pending_requests[256][CLIENT_ID_SIZE]; // XXX | |||
16 | uint8_t num_requests=0; // XXX | 16 | uint8_t num_requests=0; // XXX |
17 | 17 | ||
18 | extern void on_friendadded(int friendnumber); | 18 | extern void on_friendadded(int friendnumber); |
19 | static void print_usage(ToxWindow* self); | ||
19 | 20 | ||
20 | // XXX: | 21 | // XXX: |
21 | int add_req(uint8_t* public_key) { | 22 | int add_req(uint8_t* public_key) { |
@@ -138,24 +139,7 @@ static void execute(ToxWindow* self, char* cmd) { | |||
138 | on_friendadded(num); | 139 | on_friendadded(num); |
139 | } | 140 | } |
140 | else if(!strcmp(cmd, "help")) { | 141 | else if(!strcmp(cmd, "help")) { |
141 | wattron(self->window, COLOR_PAIR(2) | A_BOLD); | 142 | print_usage(self); |
142 | wprintw(self->window, "Commands:\n"); | ||
143 | wattroff(self->window, A_BOLD); | ||
144 | |||
145 | wprintw(self->window, " connect <ip> <port> <key> : Connect to DHT server\n"); | ||
146 | wprintw(self->window, " add <id> <message> : Add friend\n"); | ||
147 | wprintw(self->window, " status <message> : Set your status\n"); | ||
148 | wprintw(self->window, " nick <nickname> : Set your nickname\n"); | ||
149 | wprintw(self->window, " accept <number> : Accept friend request\n"); | ||
150 | wprintw(self->window, " myid : Print your ID\n"); | ||
151 | wprintw(self->window, " quit/exit : Exit program\n"); | ||
152 | |||
153 | |||
154 | wattron(self->window, A_BOLD); | ||
155 | wprintw(self->window, "TIP: Use the TAB key to navigate through the tabs.\n\n"); | ||
156 | wattroff(self->window, A_BOLD); | ||
157 | |||
158 | wattroff(self->window, COLOR_PAIR(2)); | ||
159 | } | 143 | } |
160 | else if(!strncmp(cmd, "status ", strlen("status "))) { | 144 | else if(!strncmp(cmd, "status ", strlen("status "))) { |
161 | char* msg; | 145 | char* msg; |