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)
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
Trying to make the calling convention problem go away 1fb0fae11b2d129dd380b6413e5e81d461c8806d GDR! 2014-12-22 00:52:27
Increased number of send retries - helpful on flaky links 3f86c8bb935408fdfb056a412da23b6b181d0755 GDR! 2014-12-13 18:13:12
Tokssh formatted 489cad267d4537cbe20f4c539f49a2d96ed6d0bb GDR! 2014-12-13 17:50:07
Added tokssh wrapper script 967a260e4fb84659424e9b81cc7f6318380ae02d GDR! 2014-12-13 17:49:14
More robust connection algorithm 4f28d0b194fdd9607955f2e32de44f8fbf5d7d31 GDR! 2014-12-13 17:24:39
Added -lrt for old glibc versions like raspbian 9f66ecc193b1bca4eac19f178123215340c9cb14 GDR! 2014-12-13 17:24:10
Pipe mode working, yay! 99a66836911b804dce1455580cbf75dc99f23538 GDR! 2014-12-11 22:27:26
Added MSG_NOSIGNAL to send() in client c9f51df320380a537843145ebbf4ceff7ef1c561 GDR! 2014-12-11 21:33:27
Fixed a warning and printing garbage 925a7c2bdf93c3a0209552285b77e2e585a799c4 GDR! 2014-12-11 21:31:49
Fixed a warning and printing garbage f7f5170d00ee10affcacf569842207120a7ab16d GDR! 2014-12-11 21:30:51
Fixed server-side SIGPIPE 946e3fa1907217a0717978ac98b32ce1ee7c23ac GDR! 2014-12-11 21:24:16
Added handle_server_tcp_fin_frame 169a478762d6863782395acff8c9f53b733048f5 GDR! 2014-12-11 21:19:32
Added systemd and supervisord config files ea3d59d854108f28c2d2d10a5af60fe3d66e1f6f GDR! 2014-12-11 20:33:54
Removed the const qualifier from frame->data d81429c916e41958483256556dea861cb97487c4 GDR! 2014-12-11 19:57:32
Commit 53bfa010d3ee7a0c79e4c9155e189431eeafb208 - Added syslog capability
Closes #2
Author: GDR!
Author date (UTC): 2014-12-24 14:59
Committer name: GDR!
Committer date (UTC): 2014-12-24 14:59
Parent(s): 898e5bf826e78c22ac27c2f476e1e746aadebe9a
Signer:
Signing key:
Signing status: N
Tree: f2984a9d6c67417dddfa3adf80e9efc5ba0be237
File Lines added Lines deleted
gitversion.c 1 1
log.c 45 12
log.h 3 0
main.c 9 1
File gitversion.c changed (mode: 100644) (index 4eb4c15..52f9d71)
... ... const char *gitversion = GITVERSION;
5 5
6 6 void print_version() void print_version()
7 7 { {
8 log_printf(L_INFO, "tuntox built from git commit %s", gitversion);
8 log_printf(L_INFO, "Tuntox built from git commit %s", gitversion);
9 9 } }
File log.c changed (mode: 100644) (index c7627d9..7f72ec5)
2 2 #include <stdio.h> #include <stdio.h>
3 3 #include <stdlib.h> #include <stdlib.h>
4 4 #include <string.h> #include <string.h>
5 #include <syslog.h>
5 6 #include <time.h> #include <time.h>
6 7
7 8 #include "log.h" #include "log.h"
8 9
10 /*
11 * The minimum log level; set to one of L_* constants from log.h
12 */
9 13 int min_log_level = 666; int min_log_level = 666;
10 14
15 /*
16 * 0: send output to stderr
17 * 1: send output to syslog LOG_LOCAL1 facility
18 */
19 int use_syslog = 0;
20
11 21 /* Turn log level number to a printable string */ /* Turn log level number to a printable string */
12 22 char *log_printable_level(int level) char *log_printable_level(int level)
13 23 { {
 
... ... char *log_printable_level(int level)
27 37 return "UNKNOWN"; return "UNKNOWN";
28 38 } }
29 39
40 void log_init(void)
41 {
42 if(use_syslog)
43 {
44 openlog("tuntox", LOG_PID, LOG_LOCAL1);
45 }
46 }
47
48 void log_close(void)
49 {
50 if(use_syslog)
51 {
52 closelog();
53 }
54 }
55
30 56 /* Output the log to the console */ /* Output the log to the console */
31 57 void log_printf(int level, const char *fmt, ...) void log_printf(int level, const char *fmt, ...)
32 58 { {
 
... ... void log_printf(int level, const char *fmt, ...)
42 68 return; return;
43 69 } }
44 70
45 time(&rawtime);
46 timeinfo = localtime(&rawtime);
47 strftime(logtime, 100, "%F %X", timeinfo);
71 if(!use_syslog)
72 {
73 time(&rawtime);
74 timeinfo = localtime(&rawtime);
75 strftime(logtime, 100, "%F %X", timeinfo);
48 76
49 level_str = log_printable_level(level);
77 level_str = log_printable_level(level);
50 78
51 if(fmt[strlen(fmt)-1] == '\n')
52 {
53 snprintf(logfmt, 2048, "%s: [%s]\t%s", logtime, level_str, fmt);
79 if(fmt[strlen(fmt)-1] == '\n')
80 {
81 snprintf(logfmt, 2048, "%s: [%s]\t%s", logtime, level_str, fmt);
82 }
83 else
84 {
85 snprintf(logfmt, 2048, "%s: [%s]\t%s\n", logtime, level_str, fmt);
86 }
87
88 va_start(args, fmt);
89 vfprintf(stderr, logfmt, args);
90 va_end(args);
54 91 } }
55 92 else else
56 93 { {
57 snprintf(logfmt, 2048, "%s: [%s]\t%s\n", logtime, level_str, fmt);
94 vsyslog(LOG_MAKEPRI(LOG_LOCAL1, level), fmt, args);
58 95 } }
59
60 va_start(args, fmt);
61 vfprintf(stderr, logfmt, args);
62 va_end(args);
63 96 } }
64 97
65 98
File log.h changed (mode: 100644) (index 25b19f7..ed48364)
7 7 #define L_UNSET 0x29a #define L_UNSET 0x29a
8 8
9 9 void log_printf(int level, const char *fmt, ...); void log_printf(int level, const char *fmt, ...);
10 void log_init(void);
11 void log_close(void);
10 12
11 13 extern int min_log_level; extern int min_log_level;
14 extern int use_syslog;
12 15
13 16 #define d(x) log_printf(L_DEBUG, "%s:%d %s", __FILE__, __LINE__, #x); #define d(x) log_printf(L_DEBUG, "%s:%d %s", __FILE__, __LINE__, #x);
14 17
File main.c changed (mode: 100644) (index 9ee98ba..dae2d34)
... ... void cleanup(int status, void *tmp)
679 679 { {
680 680 close(client_socket); close(client_socket);
681 681 } }
682 log_close();
682 683 } }
683 684
684 685
 
... ... void help()
778 779 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");
779 780 fprintf(stderr, "-d - debug mode\n"); fprintf(stderr, "-d - debug mode\n");
780 781 fprintf(stderr, "-q - quiet mode\n"); fprintf(stderr, "-q - quiet mode\n");
782 fprintf(stderr, "-S - send output to syslog instead of stderr\n");
781 783 fprintf(stderr, "-h - this help message\n"); fprintf(stderr, "-h - this help message\n");
782 784 } }
783 785
 
... ... int main(int argc, char *argv[])
787 789 unsigned char tox_printable_id[TOX_FRIEND_ADDRESS_SIZE * 2 + 1]; unsigned char tox_printable_id[TOX_FRIEND_ADDRESS_SIZE * 2 + 1];
788 790 int oc; int oc;
789 791
790 while ((oc = getopt(argc, argv, "L:pi:C:P:dq")) != -1)
792 log_init();
793
794 while ((oc = getopt(argc, argv, "L:pi:C:P:dqhS")) != -1)
791 795 { {
792 796 switch(oc) switch(oc)
793 797 { {
 
... ... int main(int argc, char *argv[])
851 855 case 'q': case 'q':
852 856 min_log_level = L_ERROR; min_log_level = L_ERROR;
853 857 break; break;
858 case 'S':
859 use_syslog = 1;
860 break;
854 861 case '?': case '?':
862 case 'h':
855 863 default: default:
856 864 print_version(); print_version();
857 865 help(); help();
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