summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.def.h4
-rw-r--r--ratox.c19
2 files changed, 19 insertions, 4 deletions
diff --git a/config.def.h b/config.def.h
index ba3eaf3..31adfc8 100644
--- a/config.def.h
+++ b/config.def.h
@@ -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[] = {
{
diff --git a/ratox.c b/ratox.c
index aa4773a..6c85e14 100644
--- a/ratox.c
+++ b/ratox.c
@@ -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();