mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-29 04:03:45 +00:00
Fix #615
This commit is contained in:
@@ -105,6 +105,9 @@ Enable UDP relay and disable TCP relay.
|
||||
.B \-A
|
||||
Enable onetime authentication.
|
||||
.TP
|
||||
.B \-6
|
||||
Resovle hostname to IPv6 address first.
|
||||
.TP
|
||||
.B \-w
|
||||
Enable white list mode (when ACL enabled).
|
||||
.TP
|
||||
|
||||
+3
-3
@@ -1007,7 +1007,7 @@ int main(int argc, char **argv)
|
||||
if (option_index == 0) {
|
||||
fast_open = 1;
|
||||
} else if (option_index == 1) {
|
||||
LOGI("initialize acl...");
|
||||
LOGI("initializing acl...");
|
||||
acl = !init_acl(optarg, BLACK_LIST);
|
||||
} else if (option_index == 2) {
|
||||
usage();
|
||||
@@ -1188,7 +1188,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);
|
||||
|
||||
// Setup proxy context
|
||||
@@ -1326,7 +1326,7 @@ int start_ss_local_server(profile_t profile)
|
||||
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);
|
||||
|
||||
struct sockaddr_storage *storage = ss_malloc(sizeof(struct sockaddr_storage));
|
||||
|
||||
+1
-1
@@ -834,7 +834,7 @@ int main(int argc, char **argv)
|
||||
signal(SIGABRT, SIG_IGN);
|
||||
|
||||
// Setup keys
|
||||
LOGI("initialize ciphers... %s", method);
|
||||
LOGI("initializing ciphers... %s", method);
|
||||
int m = enc_init(password, method);
|
||||
|
||||
// Setup proxy context
|
||||
|
||||
+5
-2
@@ -82,9 +82,12 @@ static struct sockaddr *choose_ipv4_first(struct ResolvQuery *);
|
||||
static struct sockaddr *choose_ipv6_first(struct ResolvQuery *);
|
||||
static struct sockaddr *choose_any(struct ResolvQuery *);
|
||||
|
||||
int resolv_init(struct ev_loop *loop, char **nameservers, int nameserver_num)
|
||||
int resolv_init(struct ev_loop *loop, char **nameservers, int nameserver_num, int ipv6first)
|
||||
{
|
||||
resolv_mode = MODE_IPV4_FIRST;
|
||||
if (ipv6first)
|
||||
resolv_mode = MODE_IPV6_FIRST;
|
||||
else
|
||||
resolv_mode = MODE_IPV4_FIRST;
|
||||
|
||||
struct dns_ctx *ctx = &dns_defctx;
|
||||
if (nameservers == NULL) {
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@
|
||||
|
||||
struct ResolvQuery;
|
||||
|
||||
int resolv_init(struct ev_loop *, char **, int);
|
||||
int resolv_init(struct ev_loop *, char **, int, int);
|
||||
struct ResolvQuery *resolv_query(const char *, void (*)(struct sockaddr *,
|
||||
void *), void (*)(
|
||||
void *), void *, uint16_t);
|
||||
|
||||
+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);
|
||||
|
||||
+1
-1
@@ -891,7 +891,7 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
// Setup keys
|
||||
LOGI("initialize ciphers... %s", method);
|
||||
LOGI("initializing ciphers... %s", method);
|
||||
int m = enc_init(password, method);
|
||||
|
||||
// Setup proxy context
|
||||
|
||||
@@ -261,6 +261,8 @@ void usage()
|
||||
printf(
|
||||
" [-A] Enable onetime authentication.\n");
|
||||
#ifdef MODULE_REMOTE
|
||||
printf(
|
||||
" [-6] Resovle hostname to IPv6 address first.\n");
|
||||
printf(
|
||||
" [-w] Enable white list mode (when ACL enabled).\n");
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user