diff options
author | sin <sin@2f30.org> | 2014-09-23 13:35:44 +0100 |
---|---|---|
committer | sin <sin@2f30.org> | 2014-09-23 13:35:44 +0100 |
commit | ab8e59fcb9749f90207c959fffd3e3263b520019 (patch) | |
tree | 9124b126593de6e12f857eaca82335a6caa436ce /ratox.c | |
parent | 9290ff8baa69f9afe77503a2c3694b1059b9d9aa (diff) |
Add proxy support
(Remove tcpenabled from config.def.h as it can easily be flipped
at runtime via the cmdline switch).
Diffstat (limited to 'ratox.c')
-rw-r--r-- | ratox.c | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -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 *, ...); @@ -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(); @@ -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); } @@ -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(); |