gdr / tuntox (public) (License: GPLv3) (since 2017-01-24) (hash sha1)
Tunnel TCP connections over the Tox protocol
List of commits:
Subject Hash Author Date (UTC)
"Whitelist clients by pubkeys" mode, re-request friends 1013b2aaeafa9112849df4e08bcced23cbd91fdf GDR! 2016-06-07 19:52:48
Remove FDs of closed tunnels from fdset 816245f429145052b8908d500c64d372fc8c2972 GDR! 2016-06-07 18:42:45
Mention toxvpn c2a78f48bd44613162a6e3c1d02cb53266611936 GDR! 2016-05-05 17:55:59
ProxyCommand explained c17be222aa46a4cf1a9d19c0ae767697ad585fd3 GDR! 2016-05-05 17:50:05
Visible ToxID 4f38371fd72ba889e39805b76a1a2402194b5398 GDR! 2016-05-05 17:46:06
Tuntox does fork! 0d1230def56597b25bcd731346794058c66d3e7c GDR! 2016-05-05 17:45:25
Tox.chat 2 90990f49bda18d06c89fca0495b39726bd55a076 GDR! 2016-05-05 17:43:58
Tox.chat 5b921bc92cf04773f8e5b08120e5850156fbb580 GDR! 2016-05-05 17:43:11
Possible fix for Issue #16 cc633e9ad431850d298638dbcdcbf1e8a4dfdeb1 GDR! 2016-05-05 17:39:42
Fix build on non-mac platforms 981501cf1e19d07a11e28cff99b9cd7c7b1d0b1d GDR! 2015-09-17 08:30:57
* fix: Possibility to compile on Mac OS platform 199787953243d91449ac5f4a5ac16edc2497e438 Dawid 'nCore' Opis 2015-09-16 18:14:03
remove tox.im because it's evil b57ae8b86109e6fe6f626d03ddeca79539d07822 GrayHatter 2015-08-08 00:45:31
Update README.md 9226aa00b30e7af7a0122b0772cc3e20ae5b49d0 GDR! 2015-07-14 12:57:55
CID 122512 (#1 of 1): Resource leak (RESOURCE_LEAK)11. leaked_storage: 5d9e9c5d9078d8d1987375e972282220d50b9328 GDR! 2015-07-08 10:04:52
off_by_one: Testing whether handle sockfd is strictly greater than zero a6d788c45764afb4d172dd3c75dfe593b85b5dab GDR! 2015-07-08 10:02:12
Remaining coverity bugs 5d387074214a9b9f7437bed4dcc02aab1f9abd7f GDR! 2015-07-07 17:39:47
CID 122498 (#1 of 1): Unchecked return value from library 8ae485719161a1b1d33c5d777b2b2d4035c9ff06 GDR! 2015-07-07 17:35:36
CID 122499 (#1 of 1): Unchecked return value from library 7262fd7141bdae8ae15c3f625988a7f26463cdb5 GDR! 2015-07-07 17:30:50
CID 122500 (#1 of 1): Missing return statement (MISSING_RETURN)6. f1826d2061908883fb654059f0675f79396edad0 GDR! 2015-07-07 17:25:53
CID 122503 (#1 of 1): Missing return statement (MISSING_RETURN)1. 25c3d4cc3bd800d5866a54fc0c6bc4f792971a11 GDR! 2015-07-07 17:22:40
Commit 1013b2aaeafa9112849df4e08bcced23cbd91fdf - "Whitelist clients by pubkeys" mode, re-request friends
See #14
Author: GDR!
Author date (UTC): 2016-06-07 19:52
Committer name: GDR!
Committer date (UTC): 2016-06-07 19:52
Parent(s): 816245f429145052b8908d500c64d372fc8c2972
Signer:
Signing key:
Signing status: N
Tree: 101e51c47c70ac1a9a70c4db3633983939de95aa
File Lines added Lines deleted
client.c 23 2
main.c 50 5
main.h 6 0
File client.c changed (mode: 100644) (index 9dc1b03..0634702)
... ... int do_client_loop(char *tox_id_str)
266 266 struct timeval tv; struct timeval tv;
267 267 fd_set fds; fd_set fds;
268 268 static time_t invitation_sent_time = 0; static time_t invitation_sent_time = 0;
269 uint32_t invitations_sent = 0;
269 270 TOX_ERR_FRIEND_QUERY friend_query_error; TOX_ERR_FRIEND_QUERY friend_query_error;
270 271 TOX_ERR_FRIEND_CUSTOM_PACKET custom_packet_error; TOX_ERR_FRIEND_CUSTOM_PACKET custom_packet_error;
271 272
 
... ... int do_client_loop(char *tox_id_str)
318 319 log_printf(L_DEBUG, "Sent shared secret of length %u\n", length); log_printf(L_DEBUG, "Sent shared secret of length %u\n", length);
319 320 } }
320 321
321 log_printf(L_INFO, "Connected. Sending friend request.\n");
322 if(invitations_sent == 0)
323 {
324 log_printf(L_INFO, "Connected. Sending friend request.\n");
325 }
326 else
327 {
328 log_printf(L_INFO, "Sending another friend request.\n");
329 }
322 330
323 331 friendnumber = tox_friend_add( friendnumber = tox_friend_add(
324 332 tox, tox,
 
... ... int do_client_loop(char *tox_id_str)
337 345 } }
338 346
339 347 invitation_sent_time = time(NULL); invitation_sent_time = time(NULL);
348 invitations_sent++;
340 349 state = CLIENT_STATE_SENTREQUEST; state = CLIENT_STATE_SENTREQUEST;
341 350 log_printf(L_INFO, "Waiting for friend to accept us...\n"); log_printf(L_INFO, "Waiting for friend to accept us...\n");
342 351 } }
 
... ... int do_client_loop(char *tox_id_str)
359 368 } }
360 369 else else
361 370 { {
362 if(0 && (time(NULL) - invitation_sent_time > 60))
371 if(1 && (time(NULL) - invitation_sent_time > 45))
363 372 { {
373 TOX_ERR_FRIEND_DELETE error = 0;
374
364 375 log_printf(L_INFO, "Sending another friend request..."); log_printf(L_INFO, "Sending another friend request...");
376 tox_friend_delete(
377 tox,
378 friendnumber,
379 &error);
380 if(error != TOX_ERR_FRIEND_DELETE_OK)
381 {
382 log_printf(L_ERROR, "Error %u deleting friend before reconnection\n", error);
383 exit(-1);
384 }
385
365 386 state = CLIENT_STATE_CONNECTED; state = CLIENT_STATE_CONNECTED;
366 387 } }
367 388 } }
File main.c changed (mode: 100644) (index b87172c..94f0396)
... ... char *daemon_username = NULL;
47 47 int use_shared_secret = 0; int use_shared_secret = 0;
48 48 char shared_secret[TOX_MAX_FRIEND_REQUEST_LENGTH]; char shared_secret[TOX_MAX_FRIEND_REQUEST_LENGTH];
49 49
50 /* Only let in a whitelisted client */
51 int server_whitelist_mode = 1;
52 allowed_toxid *allowed_toxids = NULL;
53
54 int load_saved_toxid_in_client_mode = 0;
55
50 56 fd_set master_server_fds; fd_set master_server_fds;
51 57
52 58 /* We keep two hash tables: one indexed by sockfd and another by "connection id" */ /* We keep two hash tables: one indexed by sockfd and another by "connection id" */
 
... ... uint16_t get_random_tunnel_id()
76 82 } }
77 83 } }
78 84
85 /* Comparison function for allowed_toxid objects */
86 int allowed_toxid_cmp(allowed_toxid *a, allowed_toxid *b)
87 {
88 return memcmp(a->toxid, b->toxid, TOX_PUBLIC_KEY_SIZE);
89 }
90
79 91 void update_select_nfds(int fd) void update_select_nfds(int fd)
80 92 { {
81 93 /* TODO maybe replace with a scan every time to make select() more efficient in the long run? */ /* TODO maybe replace with a scan every time to make select() more efficient in the long run? */
 
... ... void accept_friend_request(Tox *tox, const uint8_t *public_key, const uint8_t *m
723 735 } }
724 736 } }
725 737
738 memset(tox_printable_id, '\0', sizeof(tox_printable_id));
739 id_to_string(tox_printable_id, public_key);
740
741 if(server_whitelist_mode)
742 {
743 allowed_toxid etmp, *found = NULL;
744 memcpy(etmp.toxid, public_key, TOX_PUBLIC_KEY_SIZE);
745 LL_SEARCH(allowed_toxids, found, &etmp, allowed_toxid_cmp);
746 if(!found)
747 {
748 log_printf(L_WARNING, "Rejected friend request from non-whitelisted friend %s", tox_printable_id);
749 return;
750 }
751 log_printf(L_DEBUG, "Friend %s passed whitelist check", tox_printable_id);
752 }
726 753
727 754 friendnumber = tox_friend_add_norequest(tox, public_key, &friend_add_error); friendnumber = tox_friend_add_norequest(tox, public_key, &friend_add_error);
728 755 if(friend_add_error != TOX_ERR_FRIEND_ADD_OK) if(friend_add_error != TOX_ERR_FRIEND_ADD_OK)
 
... ... void accept_friend_request(Tox *tox, const uint8_t *public_key, const uint8_t *m
731 758 return; return;
732 759 } }
733 760
734 memset(tox_printable_id, '\0', sizeof(tox_printable_id));
735 id_to_string(tox_printable_id, public_key);
736 761 log_printf(L_INFO, "Accepted friend request from %s as %d\n", tox_printable_id, friendnumber); log_printf(L_INFO, "Accepted friend request from %s as %d\n", tox_printable_id, friendnumber);
737 762 } }
738 763
 
... ... int do_server_loop()
788 813 tox_do_interval_ms = tox_iteration_interval(tox); tox_do_interval_ms = tox_iteration_interval(tox);
789 814 tv.tv_usec = (tox_do_interval_ms % 1000) * 1000; tv.tv_usec = (tox_do_interval_ms % 1000) * 1000;
790 815 tv.tv_sec = tox_do_interval_ms / 1000; tv.tv_sec = tox_do_interval_ms / 1000;
791 log_printf(L_DEBUG, "Iteration interval: %dms\n", tox_do_interval_ms);
816 log_printf(L_DEBUG2, "Iteration interval: %dms\n", tox_do_interval_ms);
792 817 gettimeofday(&tv_start, NULL); gettimeofday(&tv_start, NULL);
793 818
794 819 /* Check change in connection state */ /* Check change in connection state */
 
... ... int main(int argc, char *argv[])
1051 1076 int oc; int oc;
1052 1077 size_t save_size = 0; size_t save_size = 0;
1053 1078 uint8_t *save_data = NULL; uint8_t *save_data = NULL;
1079 allowed_toxid *allowed_toxid_obj = NULL;
1054 1080
1055 1081 log_init(); log_init();
1056 1082
 
... ... int main(int argc, char *argv[])
1099 1125 break; break;
1100 1126 case 'i': case 'i':
1101 1127 /* Tox ID */ /* Tox ID */
1128 allowed_toxid_obj = (allowed_toxid *)calloc(sizeof(allowed_toxid), 1);
1129 if(!allowed_toxid_obj)
1130 {
1131 log_printf(L_ERROR, "Could not allocate memory for allowed_toxid");
1132 exit(1);
1133 }
1102 1134 remote_tox_id = optarg; remote_tox_id = optarg;
1135 if(!string_to_id(allowed_toxid_obj->toxid, optarg))
1136 {
1137 log_printf(L_ERROR, "Invalid Tox ID");
1138 exit(1);
1139 }
1140 LL_APPEND(allowed_toxids, allowed_toxid_obj);
1103 1141 break; break;
1104 1142 case 'C': case 'C':
1105 1143 /* Config directory */ /* Config directory */
 
... ... int main(int argc, char *argv[])
1111 1149 config_path[optarg_len] = '/'; config_path[optarg_len] = '/';
1112 1150 config_path[optarg_len + 1] = '\0'; config_path[optarg_len + 1] = '\0';
1113 1151 } }
1152 load_saved_toxid_in_client_mode = 1;
1114 1153 break; break;
1115 1154 case 's': case 's':
1116 1155 /* Shared secret */ /* Shared secret */
 
... ... int main(int argc, char *argv[])
1148 1187
1149 1188 if(!client_mode && min_log_level == L_UNSET) if(!client_mode && min_log_level == L_UNSET)
1150 1189 { {
1151 min_log_level = L_INFO;
1190 min_log_level = L_INFO;
1191 }
1192
1193 if(!client_mode && remote_tox_id)
1194 {
1195 server_whitelist_mode = 1;
1196 log_printf(L_INFO, "Server in ToxID whitelisting mode - only clients listed with -i can connect");
1152 1197 } }
1153 1198
1154 1199 if(daemonize) if(daemonize)
 
... ... int main(int argc, char *argv[])
1162 1207
1163 1208 /* Bootstrap tox */ /* Bootstrap tox */
1164 1209 tox_options_default(&tox_options); tox_options_default(&tox_options);
1165 if(!client_mode)
1210 if((!client_mode) || load_saved_toxid_in_client_mode)
1166 1211 { {
1167 1212 uint8_t *save_data = NULL; uint8_t *save_data = NULL;
1168 1213 save_size = load_save(&save_data); save_size = load_save(&save_data);
File main.h changed (mode: 100644) (index 41a7995..65494ef)
22 22
23 23 #include "util.h" #include "util.h"
24 24 #include "uthash.h" #include "uthash.h"
25 #include "utlist.h"
25 26
26 27
27 28 #define PROTOCOL_MAGIC_V1 0xa26a #define PROTOCOL_MAGIC_V1 0xa26a
 
... ... typedef struct tunnel_t {
56 57 UT_hash_handle hh; UT_hash_handle hh;
57 58 } tunnel; } tunnel;
58 59
60 typedef struct allowed_toxid {
61 char toxid[TOX_ADDRESS_SIZE];
62 struct allowed_toxid *next;
63 } allowed_toxid;
64
59 65 typedef struct protocol_frame_t { typedef struct protocol_frame_t {
60 66 uint32_t friendnumber; uint32_t friendnumber;
61 67
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/gdr/tuntox

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/gdr/tuntox

Clone this repository using git:
git clone git://git.rocketgit.com/user/gdr/tuntox

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main