|
@ -478,10 +478,12 @@ connect_to_remote(EV_P_ struct addrinfo *res, |
|
|
if (is_bind_local_addr) { |
|
|
if (is_bind_local_addr) { |
|
|
struct sockaddr_storage *local_addr = |
|
|
struct sockaddr_storage *local_addr = |
|
|
res->ai_family == AF_INET ? &local_addr_v4 : &local_addr_v6; |
|
|
res->ai_family == AF_INET ? &local_addr_v4 : &local_addr_v6; |
|
|
if (bind_to_addr(local_addr, sockfd) == -1) { |
|
|
|
|
|
ERROR("bind_to_addr"); |
|
|
|
|
|
close(sockfd); |
|
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
if (res->ai_family == local_addr->ss_family) { |
|
|
|
|
|
if (bind_to_addr(local_addr, sockfd) == -1) { |
|
|
|
|
|
ERROR("bind_to_addr"); |
|
|
|
|
|
FATAL("cannot bind socket"); |
|
|
|
|
|
return NULL; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1568,6 +1570,8 @@ main(int argc, char **argv) |
|
|
int server_num = 0; |
|
|
int server_num = 0; |
|
|
ss_addr_t server_addr[MAX_REMOTE_NUM]; |
|
|
ss_addr_t server_addr[MAX_REMOTE_NUM]; |
|
|
memset(server_addr, 0, sizeof(ss_addr_t) * MAX_REMOTE_NUM); |
|
|
memset(server_addr, 0, sizeof(ss_addr_t) * MAX_REMOTE_NUM); |
|
|
|
|
|
memset(&local_addr_v4, 0, sizeof(struct sockaddr_storage)); |
|
|
|
|
|
memset(&local_addr_v6, 0, sizeof(struct sockaddr_storage)); |
|
|
|
|
|
|
|
|
static struct option long_options[] = { |
|
|
static struct option long_options[] = { |
|
|
{ "fast-open", no_argument, NULL, GETOPT_VAL_FAST_OPEN }, |
|
|
{ "fast-open", no_argument, NULL, GETOPT_VAL_FAST_OPEN }, |
|
@ -1635,8 +1639,7 @@ main(int argc, char **argv) |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case 'b': |
|
|
case 'b': |
|
|
if (parse_local_addr(&local_addr_v4, &local_addr_v6, optarg) == 0) |
|
|
|
|
|
is_bind_local_addr = 1; |
|
|
|
|
|
|
|
|
is_bind_local_addr += parse_local_addr(&local_addr_v4, &local_addr_v6, optarg); |
|
|
break; |
|
|
break; |
|
|
case 'p': |
|
|
case 'p': |
|
|
server_port = optarg; |
|
|
server_port = optarg; |
|
@ -1760,12 +1763,13 @@ main(int argc, char **argv) |
|
|
fast_open = conf->fast_open; |
|
|
fast_open = conf->fast_open; |
|
|
} |
|
|
} |
|
|
if (is_bind_local_addr == 0) { |
|
|
if (is_bind_local_addr == 0) { |
|
|
if (parse_local_addr(&local_addr_v4, &local_addr_v6, conf->local_addr) == 0) |
|
|
|
|
|
is_bind_local_addr = 1; |
|
|
|
|
|
if (parse_local_addr(&local_addr_v4, &local_addr_v6, conf->local_addr_v4) == 0) |
|
|
|
|
|
is_bind_local_addr = 1; |
|
|
|
|
|
if (parse_local_addr(&local_addr_v4, &local_addr_v6, conf->local_addr_v6) == 0) |
|
|
|
|
|
is_bind_local_addr = 1; |
|
|
|
|
|
|
|
|
is_bind_local_addr += parse_local_addr(&local_addr_v4, &local_addr_v6, conf->local_addr); |
|
|
|
|
|
} |
|
|
|
|
|
if (is_bind_local_addr == 0) { |
|
|
|
|
|
is_bind_local_addr += parse_local_addr(&local_addr_v4, &local_addr_v6, conf->local_addr_v4); |
|
|
|
|
|
} |
|
|
|
|
|
if (is_bind_local_addr == 0) { |
|
|
|
|
|
is_bind_local_addr += parse_local_addr(&local_addr_v4, &local_addr_v6, conf->local_addr_v6); |
|
|
} |
|
|
} |
|
|
#ifdef HAVE_SETRLIMIT |
|
|
#ifdef HAVE_SETRLIMIT |
|
|
if (nofile == 0) { |
|
|
if (nofile == 0) { |
|
|