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)
PSK authentication 8d4dd7660af8cd3856d0d54d92386ce3ef1bc333 GDR! 2015-06-19 19:54:59
Command line switch for shared secret 8f9376b7ab3f9fca1514eb63c7ae7d545042b168 GDR! 2015-06-19 19:12:33
The program now compiles with new toxcore (67df1ab7ce) 97b9fd40dbba9b94144862f719a2a4ca8f12af22 GDR! 2015-06-19 18:25:14
Fixed 100% CPU usage in server mode 114911b46f221912e25589d746dc1f9f905413bd GDR! 2015-01-30 18:31:43
credits 0b461fdbbe611a553c16e6081fee9a7891c1f36e GDR! 2015-01-12 22:25:23
Typo 91c407badf6392619f187b03ea4b42ab98bedbef GDR! 2015-01-12 22:24:07
Readme VPN 0285ddb7b7c2740775bce4d7a1c41534208202d4 GDR! 2015-01-12 22:21:29
md formatting 9426b96c040e3bc897583c3d90565a3f4678f761 GDR! 2015-01-12 22:20:19
Document on making a point-to-point VPN 32d3ec0ee95c1a8516ee3bb730ffaf5eeb854911 GDR! 2015-01-12 22:19:05
Allow using @ instead of : in port forward definitions 4350dabf2f524daabb03f26928742296310b456f GDR! 2015-01-12 21:57:20
Got rid of the memory leak 4e3d5e48fe25648a182dc7f67f4f49e4d8471ebf GDR! 2014-12-30 13:38:43
Removed old comments 870624e91fa526f5eeb0d699f8a33a43ff7af4a1 GDR! 2014-12-28 14:35:41
Debian init script added 86e70ffe9f835b12667d296f2df9c307ba1aff06 GDR! 2014-12-24 16:26:51
Forking/setuid/pidfile working e98c42e6712f16b60ade4f2f996b25001394da4d GDR! 2014-12-24 16:07:35
Added syslog capability 53bfa010d3ee7a0c79e4c9155e189431eeafb208 GDR! 2014-12-24 14:59:40
Clean target 4280af5e82fad6296d3581a5f62700da34ccd3ea GDR! 2014-12-24 14:35:07
Version string 325ae4c314482d10fe46c5c16c2b581959af2f41 GDR! 2014-12-24 14:28:13
Fixed callbacks on raspbian 7324419faf44b59072633a76db24a8e612460c8f GDR! 2014-12-22 02:23:21
Logging framework and command line options b8c1f1cf062ff681daf160411ad6c35ed7a49d42 GDR! 2014-12-22 02:22:38
Fixed warning on implicit function declaration 575ea150208b7ca61a639d0c9a20df656d2b178f GDR! 2014-12-22 00:52:53
Commit 8d4dd7660af8cd3856d0d54d92386ce3ef1bc333 - PSK authentication
Author: GDR!
Author date (UTC): 2015-06-19 19:54
Committer name: GDR!
Committer date (UTC): 2015-06-19 19:54
Parent(s): 8f9376b7ab3f9fca1514eb63c7ae7d545042b168
Signer:
Signing key:
Signing status: N
Tree: daad5c239d82553a876359087d9e62be60952eab
File Lines added Lines deleted
client.c 21 3
main.c 37 3
main.h 3 0
util.c 1 1
File client.c changed (mode: 100644) (index d2ef837..929e2f5)
1 #include <time.h>
1 2 #include "log.h" #include "log.h"
2 3 #include "main.h" #include "main.h"
3 4 #include "client.h" #include "client.h"
 
... ... int do_client_loop(char *tox_id_str)
220 221 uint32_t friendnumber; uint32_t friendnumber;
221 222 struct timeval tv; struct timeval tv;
222 223 fd_set fds; fd_set fds;
224 static time_t invitation_sent_time = 0;
223 225 TOX_ERR_FRIEND_QUERY friend_query_error; TOX_ERR_FRIEND_QUERY friend_query_error;
224 226 TOX_ERR_FRIEND_CUSTOM_PACKET custom_packet_error; TOX_ERR_FRIEND_CUSTOM_PACKET custom_packet_error;
225 227
 
... ... int do_client_loop(char *tox_id_str)
260 262 break; break;
261 263 case CLIENT_STATE_CONNECTED: case CLIENT_STATE_CONNECTED:
262 264 { {
263 uint8_t data[] = "Hi, fellow tuntox instance!";
265 uint8_t* data = "Hi, fellow tuntox instance!";
264 266 uint16_t length = sizeof(data); uint16_t length = sizeof(data);
265 267 TOX_ERR_FRIEND_ADD add_error; TOX_ERR_FRIEND_ADD add_error;
266 268
269 if(use_shared_secret)
270 {
271 data = shared_secret;
272 data[TOX_MAX_FRIEND_REQUEST_LENGTH-1] = '\0';
273 length = strlen(data)+1;
274 log_printf(L_DEBUG, "Sent shared secret of length %u\n", length);
275 }
276
267 277 log_printf(L_INFO, "Connected. Sending friend request.\n"); log_printf(L_INFO, "Connected. Sending friend request.\n");
268 278
269 279 friendnumber = tox_friend_add( friendnumber = tox_friend_add(
 
... ... int do_client_loop(char *tox_id_str)
274 284 &add_error &add_error
275 285 ); );
276 286
277 if(friendnumber == UINT32_MAX)
287 if(add_error != TOX_ERR_FRIEND_ADD_OK)
278 288 { {
279 log_printf(L_ERROR, "Error %u adding friend %s\n", add_error, tox_id);
289 unsigned char tox_printable_id[TOX_ADDRESS_SIZE * 2 + 1];
290 id_to_string(tox_printable_id, tox_id);
291 log_printf(L_ERROR, "Error %u adding friend %s\n", add_error, tox_printable_id);
280 292 exit(-1); exit(-1);
281 293 } }
282 294
295 invitation_sent_time = time(NULL);
283 296 state = CLIENT_STATE_SENTREQUEST; state = CLIENT_STATE_SENTREQUEST;
284 297 log_printf(L_INFO, "Waiting for friend to accept us...\n"); log_printf(L_INFO, "Waiting for friend to accept us...\n");
285 298 } }
 
... ... int do_client_loop(char *tox_id_str)
302 315 } }
303 316 else else
304 317 { {
318 if(0 && (time(NULL) - invitation_sent_time > 60))
319 {
320 log_printf(L_INFO, "Sending another friend request...");
321 state = CLIENT_STATE_CONNECTED;
322 }
305 323 } }
306 324 } }
307 325 break; break;
File main.c changed (mode: 100644) (index bdfe201..ed653ef)
... ... char *pidfile = NULL;
40 40 char *daemon_username = NULL; char *daemon_username = NULL;
41 41
42 42 /* Shared secret used for authentication */ /* Shared secret used for authentication */
43 char *shared_secret = NULL;
43 int use_shared_secret = 0;
44 char shared_secret[TOX_MAX_FRIEND_REQUEST_LENGTH];
44 45
45 46 fd_set master_server_fds; fd_set master_server_fds;
46 47
 
... ... void accept_friend_request(Tox *tox, const uint8_t *public_key, const uint8_t *m
676 677
677 678 log_printf(L_DEBUG, "Got friend request\n"); log_printf(L_DEBUG, "Got friend request\n");
678 679
680 if(use_shared_secret)
681 {
682 if(!message)
683 {
684 log_printf(L_WARNING, "Friend sent NULL message - not accepting request");
685 return;
686 }
687
688 if(message[length - 1] != '\0')
689 {
690 log_printf(L_WARNING, "Message of size %u is not NULL terminated - not accepting request", length);
691 return;
692 }
693
694 if(strncmp(message, shared_secret, TOX_MAX_FRIEND_REQUEST_LENGTH-1))
695 {
696 log_printf(L_WARNING, "Received shared secret \"%s\" differs from our shared secret - not accepting request", message);
697 return;
698 }
699 }
700
701
679 702 friendnumber = tox_friend_add_norequest(tox, public_key, &friend_add_error); friendnumber = tox_friend_add_norequest(tox, public_key, &friend_add_error);
680 703 if(friend_add_error != TOX_ERR_FRIEND_ADD_OK) if(friend_add_error != TOX_ERR_FRIEND_ADD_OK)
681 704 { {
 
... ... void help()
948 971 fprintf(stderr, "-P <remotehostname>:<remoteport> - forward <remotehostname>:<remoteport> to stdin/stdout (SSH ProxyCommand mode)\n"); fprintf(stderr, "-P <remotehostname>:<remoteport> - forward <remotehostname>:<remoteport> to stdin/stdout (SSH ProxyCommand mode)\n");
949 972 fprintf(stderr, "-p - ping the server from -i and exit\n"); fprintf(stderr, "-p - ping the server from -i and exit\n");
950 973 fprintf(stderr, "-C <dir> - save private key in <dir> instead of /etc/tuntox in server mode\n"); fprintf(stderr, "-C <dir> - save private key in <dir> instead of /etc/tuntox in server mode\n");
951 fprintf(stderr, "-s <secret> - shared secret used for connection authentication\n");
974 fprintf(stderr, "-s <secret> - shared secret used for connection authentication (max %u characters)\n", TOX_MAX_FRIEND_REQUEST_LENGTH-1);
952 975 fprintf(stderr, "-d - debug mode\n"); fprintf(stderr, "-d - debug mode\n");
953 976 fprintf(stderr, "-q - quiet mode\n"); fprintf(stderr, "-q - quiet mode\n");
954 977 fprintf(stderr, "-S - send output to syslog instead of stderr\n"); fprintf(stderr, "-S - send output to syslog instead of stderr\n");
 
... ... int main(int argc, char *argv[])
969 992
970 993 log_init(); log_init();
971 994
972 while ((oc = getopt(argc, argv, "L:pi:C:P:dqhSF:DU:")) != -1)
995 while ((oc = getopt(argc, argv, "L:pi:C:s:P:dqhSF:DU:")) != -1)
973 996 { {
974 997 switch(oc) switch(oc)
975 998 { {
 
... ... int main(int argc, char *argv[])
1027 1050 config_path[optarg_len + 1] = '\0'; config_path[optarg_len + 1] = '\0';
1028 1051 } }
1029 1052 break; break;
1053 case 's':
1054 /* Shared secret */
1055 use_shared_secret = 1;
1056 memset(shared_secret, 0, TOX_MAX_FRIEND_REQUEST_LENGTH);
1057 strncpy(shared_secret, optarg, TOX_MAX_FRIEND_REQUEST_LENGTH-1);
1058 break;
1030 1059 case 'd': case 'd':
1031 1060 min_log_level = L_DEBUG; min_log_level = L_DEBUG;
1032 1061 break; break;
 
... ... int main(int argc, char *argv[])
1130 1159 { {
1131 1160 write_save(tox); write_save(tox);
1132 1161
1162 if(!use_shared_secret)
1163 {
1164 log_printf(L_WARNING, "Shared secret authentication is not used - skilled attackers may connect to your tuntox server");
1165 }
1166
1133 1167 tox_self_get_address(tox, tox_id); tox_self_get_address(tox, tox_id);
1134 1168 memset(tox_printable_id, '\0', sizeof(tox_printable_id)); memset(tox_printable_id, '\0', sizeof(tox_printable_id));
1135 1169 id_to_string(tox_printable_id, tox_id); id_to_string(tox_printable_id, tox_id);
File main.h changed (mode: 100644) (index aad191a..41a7995)
... ... extern char *remote_tox_id;
86 86 extern int remote_port; extern int remote_port;
87 87 extern char *remote_host; extern char *remote_host;
88 88 extern int local_port; extern int local_port;
89 /* Shared secret used for authentication */
90 extern int use_shared_secret;
91 extern char shared_secret[TOX_MAX_FRIEND_REQUEST_LENGTH];
89 92
90 93 extern int select_nfds; extern int select_nfds;
91 94 extern tunnel *by_id; extern tunnel *by_id;
File util.c changed (mode: 100644) (index 0d88f8d..5d3fefe)
... ... const char *readable_connection_status(TOX_CONNECTION status)
191 191 case TOX_CONNECTION_TCP: case TOX_CONNECTION_TCP:
192 192 return "A TCP connection has been established (via TCP relay)"; return "A TCP connection has been established (via TCP relay)";
193 193 case TOX_CONNECTION_UDP: case TOX_CONNECTION_UDP:
194 return "A UDP connection has been established with DHT nodes";
194 return "An UDP connection has been established";
195 195 default: default:
196 196 return "Unknown connection status"; return "Unknown connection status";
197 197 } }
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