mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-11-22 05:33:45 +00:00
Fix #615
This commit is contained in:
+22
-14
@@ -112,6 +112,7 @@ static int white_list = 0;
|
||||
static int acl = 0;
|
||||
static int mode = TCP_ONLY;
|
||||
static int auth = 0;
|
||||
static int ipv6first = 0;
|
||||
|
||||
static int fast_open = 0;
|
||||
#ifdef HAVE_SETRLIMIT
|
||||
@@ -1327,14 +1328,14 @@ int main(int argc, char **argv)
|
||||
|
||||
USE_TTY();
|
||||
|
||||
while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:c:i:d:a:n:huUvAw",
|
||||
while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:c:i:d:a:n:huUvAw6",
|
||||
long_options, &option_index)) != -1) {
|
||||
switch (c) {
|
||||
case 0:
|
||||
if (option_index == 0) {
|
||||
fast_open = 1;
|
||||
} else if (option_index == 1) {
|
||||
LOGI("initialize acl...");
|
||||
LOGI("initializing acl...");
|
||||
acl = 1;
|
||||
acl_path = optarg;
|
||||
} else if (option_index == 2) {
|
||||
@@ -1402,6 +1403,9 @@ int main(int argc, char **argv)
|
||||
case 'w':
|
||||
white_list = 1;
|
||||
break;
|
||||
case '6':
|
||||
ipv6first = 1;
|
||||
break;
|
||||
case '?':
|
||||
// The option character is not recognized.
|
||||
opterr = 1;
|
||||
@@ -1491,6 +1495,10 @@ int main(int argc, char **argv)
|
||||
daemonize(pid_path);
|
||||
}
|
||||
|
||||
if (ipv6first) {
|
||||
LOGI("resolving hostname to IPv6 address first");
|
||||
}
|
||||
|
||||
if (fast_open == 1) {
|
||||
#ifdef TCP_FASTOPEN
|
||||
LOGI("using tcp fast open");
|
||||
@@ -1503,6 +1511,14 @@ int main(int argc, char **argv)
|
||||
LOGI("onetime authentication enabled");
|
||||
}
|
||||
|
||||
if (mode != TCP_ONLY) {
|
||||
LOGI("UDP relay enabled");
|
||||
}
|
||||
|
||||
if (mode == UDP_ONLY) {
|
||||
LOGI("TCP relay disabled");
|
||||
}
|
||||
|
||||
#ifdef __MINGW32__
|
||||
winsock_init();
|
||||
#else
|
||||
@@ -1520,7 +1536,7 @@ int main(int argc, char **argv)
|
||||
ev_signal_start(EV_DEFAULT, &sigterm_watcher);
|
||||
|
||||
// setup keys
|
||||
LOGI("initialize ciphers... %s", method);
|
||||
LOGI("initializing ciphers... %s", method);
|
||||
int m = enc_init(password, method);
|
||||
|
||||
// inilitialize ev loop
|
||||
@@ -1530,12 +1546,12 @@ int main(int argc, char **argv)
|
||||
if (nameserver_num == 0) {
|
||||
#ifdef __MINGW32__
|
||||
nameservers[nameserver_num++] = "8.8.8.8";
|
||||
resolv_init(loop, nameservers, nameserver_num);
|
||||
resolv_init(loop, nameservers, nameserver_num, ipv6first);
|
||||
#else
|
||||
resolv_init(loop, NULL, 0);
|
||||
resolv_init(loop, NULL, 0, ipv6first);
|
||||
#endif
|
||||
} else {
|
||||
resolv_init(loop, nameservers, nameserver_num);
|
||||
resolv_init(loop, nameservers, nameserver_num, ipv6first);
|
||||
}
|
||||
|
||||
for (int i = 0; i < nameserver_num; i++)
|
||||
@@ -1588,14 +1604,6 @@ int main(int argc, char **argv)
|
||||
ev_timer_start(EV_DEFAULT, &stat_update_watcher);
|
||||
}
|
||||
|
||||
if (mode != TCP_ONLY) {
|
||||
LOGI("UDP relay enabled");
|
||||
}
|
||||
|
||||
if (mode == UDP_ONLY) {
|
||||
LOGI("TCP relay disabled");
|
||||
}
|
||||
|
||||
// setuid
|
||||
if (user != NULL) {
|
||||
run_as(user);
|
||||
|
||||
Reference in New Issue
Block a user