From 2694e86bd921fba870cde2cabd29cd917ee84644 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Wed, 28 Dec 2016 18:02:08 +0800 Subject: [PATCH] Fix #1016 --- src/manager.c | 14 +++++++++++++- src/manager.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/manager.c b/src/manager.c index 3a9aa9d6..9f7142e1 100644 --- a/src/manager.c +++ b/src/manager.c @@ -168,6 +168,10 @@ construct_command_line(struct manager_ctx *manager, struct server *server) int len = strlen(cmd); snprintf(cmd + len, BUF_SIZE - len, " --fast-open"); } + if (manager->ipv6first) { + int len = strlen(cmd); + snprintf(cmd + len, BUF_SIZE - len, " -6"); + } if (manager->mtu) { int len = strlen(cmd); snprintf(cmd + len, BUF_SIZE - len, " --mtu %d", manager->mtu); @@ -621,6 +625,7 @@ main(int argc, char **argv) int fast_open = 0; int mode = TCP_ONLY; int mtu = 0; + int ipv6first = 0; #ifdef HAVE_SETRLIMIT static int nofile = 0; @@ -650,7 +655,7 @@ main(int argc, char **argv) USE_TTY(); - while ((c = getopt_long(argc, argv, "f:s:l:k:t:m:c:i:d:a:n:huUvA", + while ((c = getopt_long(argc, argv, "f:s:l:k:t:m:c:i:d:a:n:6huUvA", long_options, &option_index)) != -1) switch (c) { case 0: @@ -709,6 +714,9 @@ main(int argc, char **argv) case 'U': mode = UDP_ONLY; break; + case '6': + ipv6first = 1; + break; case 'v': verbose = 1; break; @@ -774,6 +782,9 @@ main(int argc, char **argv) if (obfs == 0) { obfs = conf->obfs; } + if (ipv6first == 0) { + ipv6first = conf->ipv6_first; + } #ifdef HAVE_SETRLIMIT if (nofile == 0) { nofile = conf->nofile; @@ -851,6 +862,7 @@ main(int argc, char **argv) manager.nameserver_num = nameserver_num; manager.mtu = mtu; manager.obfs = obfs; + manager.ipv6first = ipv6first; #ifdef HAVE_SETRLIMIT manager.nofile = nofile; #endif diff --git a/src/manager.h b/src/manager.h index 9f93da85..c667ae5f 100644 --- a/src/manager.h +++ b/src/manager.h @@ -51,6 +51,7 @@ struct manager_ctx { char **nameservers; int nameserver_num; int mtu; + int ipv6first; #ifdef HAVE_SETRLIMIT int nofile; #endif