URI: 
       tAdd proxy support - ratox - FIFO based tox client
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit ab8e59fcb9749f90207c959fffd3e3263b520019
   DIR parent 9290ff8baa69f9afe77503a2c3694b1059b9d9aa
  HTML Author: sin <sin@2f30.org>
       Date:   Tue, 23 Sep 2014 13:35:44 +0100
       
       Add proxy support
       
       (Remove tcpenabled from config.def.h as it can easily be flipped
       at runtime via the cmdline switch).
       
       Diffstat:
         M config.def.h                        |       4 +++-
         M ratox.c                             |      19 ++++++++++++++++---
       
       2 files changed, 19 insertions(+), 4 deletions(-)
       ---
   DIR diff --git a/config.def.h b/config.def.h
       t@@ -1,7 +1,9 @@
        /* See LICENSE file for copyright and license details. */
        
        static int encryptdatafile = 0;
       -static int tcpenabled = 0;
       +
       +static char proxyaddr[] = "localhost";
       +static uint16_t proxyport = 8080;
        
        static struct node nodes[] = {
                {
   DIR diff --git a/ratox.c b/ratox.c
       t@@ -169,6 +169,8 @@ static uint32_t pplen;
        static uint8_t toilet[BUFSIZ];
        static int running = 1;
        static int ipv6;
       +static int tcpflag;
       +static int proxyflag;
        
        static void printrat(void);
        static void printout(const char *, ...);
       t@@ -757,7 +759,14 @@ static int
        toxinit(void)
        {
                toxopt.ipv6enabled = ipv6;
       -        toxopt.udp_disabled = tcpenabled;
       +        toxopt.udp_disabled = tcpflag;
       +        if (proxyflag == 1) {
       +                snprintf(toxopt.proxy_address, sizeof(toxopt.proxy_address),
       +                         "%s", proxyaddr);
       +                toxopt.proxy_port = proxyport;
       +                toxopt.proxy_enabled = 1;
       +                printout("Using proxy %s:%hu\n", proxyaddr, proxyport);
       +        }
                tox = tox_new(&toxopt);
                dataload();
                datasave();
       t@@ -1247,10 +1256,11 @@ shutdown(void)
        static void
        usage(void)
        {
       -        fprintf(stderr, "usage: %s [-4|-6] [-t]\n", argv0);
       +        fprintf(stderr, "usage: %s [-4|-6] [-t] [-p]\n", argv0);
                fprintf(stderr, " -4\tIPv4 only\n");
                fprintf(stderr, " -6\tIPv6 only\n");
                fprintf(stderr, " -t\tEnable TCP mode (UDP by default)\n");
       +        fprintf(stderr, " -p\tEnable TCP socks5 proxy\n");
                exit(EXIT_FAILURE);
        }
        
       t@@ -1264,7 +1274,10 @@ main(int argc, char *argv[])
                        ipv6 = 1;
                        break;
                case 't':
       -                tcpenabled = 1;
       +                tcpflag = 1;
       +                break;
       +        case 'p':
       +                proxyflag = 1;
                        break;
                default:
                        usage();