|
|
@ -110,7 +110,9 @@ static void resolv_free_cb(void *data); |
|
|
|
int verbose = 0; |
|
|
|
int reuse_port = 0; |
|
|
|
int tcp_incoming_sndbuf = 0; |
|
|
|
int tcp_incoming_rcvbuf = 0; |
|
|
|
int tcp_outgoing_sndbuf = 0; |
|
|
|
int tcp_outgoing_rcvbuf = 0; |
|
|
|
|
|
|
|
int is_bind_local_addr = 0; |
|
|
|
struct sockaddr_storage local_addr_v4; |
|
|
@ -477,6 +479,10 @@ connect_to_remote(EV_P_ struct addrinfo *res, |
|
|
|
setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, &tcp_outgoing_sndbuf, sizeof(int)); |
|
|
|
} |
|
|
|
|
|
|
|
if (tcp_outgoing_rcvbuf > 0) { |
|
|
|
setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, &tcp_outgoing_rcvbuf, sizeof(int)); |
|
|
|
} |
|
|
|
|
|
|
|
// setup remote socks |
|
|
|
|
|
|
|
if (setnonblocking(sockfd) == -1) |
|
|
@ -1549,6 +1555,10 @@ accept_cb(EV_P_ ev_io *w, int revents) |
|
|
|
setsockopt(serverfd, SOL_SOCKET, SO_SNDBUF, &tcp_incoming_sndbuf, sizeof(int)); |
|
|
|
} |
|
|
|
|
|
|
|
if (tcp_incoming_rcvbuf > 0) { |
|
|
|
setsockopt(serverfd, SOL_SOCKET, SO_RCVBUF, &tcp_incoming_rcvbuf, sizeof(int)); |
|
|
|
} |
|
|
|
|
|
|
|
setnonblocking(serverfd); |
|
|
|
|
|
|
|
server_t *server = new_server(serverfd, listener); |
|
|
@ -1589,7 +1599,9 @@ main(int argc, char **argv) |
|
|
|
{ "fast-open", no_argument, NULL, GETOPT_VAL_FAST_OPEN }, |
|
|
|
{ "reuse-port", no_argument, NULL, GETOPT_VAL_REUSE_PORT }, |
|
|
|
{ "tcp-incoming-sndbuf", required_argument, NULL, GETOPT_VAL_TCP_INCOMING_SNDBUF }, |
|
|
|
{ "tcp-incoming-rcvbuf", required_argument, NULL, GETOPT_VAL_TCP_INCOMING_RCVBUF }, |
|
|
|
{ "tcp-outgoing-sndbuf", required_argument, NULL, GETOPT_VAL_TCP_OUTGOING_SNDBUF }, |
|
|
|
{ "tcp-outgoing-rcvbuf", required_argument, NULL, GETOPT_VAL_TCP_OUTGOING_RCVBUF }, |
|
|
|
{ "no-delay", no_argument, NULL, GETOPT_VAL_NODELAY }, |
|
|
|
{ "acl", required_argument, NULL, GETOPT_VAL_ACL }, |
|
|
|
{ "manager-address", required_argument, NULL, |
|
|
@ -1650,9 +1662,15 @@ main(int argc, char **argv) |
|
|
|
case GETOPT_VAL_TCP_INCOMING_SNDBUF: |
|
|
|
tcp_incoming_sndbuf = atoi(optarg); |
|
|
|
break; |
|
|
|
case GETOPT_VAL_TCP_INCOMING_RCVBUF: |
|
|
|
tcp_incoming_rcvbuf = atoi(optarg); |
|
|
|
break; |
|
|
|
case GETOPT_VAL_TCP_OUTGOING_SNDBUF: |
|
|
|
tcp_outgoing_sndbuf = atoi(optarg); |
|
|
|
break; |
|
|
|
case GETOPT_VAL_TCP_OUTGOING_RCVBUF: |
|
|
|
tcp_outgoing_rcvbuf = atoi(optarg); |
|
|
|
break; |
|
|
|
case 's': |
|
|
|
if (server_num < MAX_REMOTE_NUM) { |
|
|
|
parse_addr(optarg, &server_addr[server_num++]); |
|
|
@ -1782,9 +1800,15 @@ main(int argc, char **argv) |
|
|
|
if (tcp_incoming_sndbuf == 0) { |
|
|
|
tcp_incoming_sndbuf = conf->tcp_incoming_sndbuf; |
|
|
|
} |
|
|
|
if (tcp_incoming_rcvbuf == 0) { |
|
|
|
tcp_incoming_rcvbuf = conf->tcp_incoming_rcvbuf; |
|
|
|
} |
|
|
|
if (tcp_outgoing_sndbuf == 0) { |
|
|
|
tcp_outgoing_sndbuf = conf->tcp_outgoing_sndbuf; |
|
|
|
} |
|
|
|
if (tcp_outgoing_rcvbuf == 0) { |
|
|
|
tcp_outgoing_rcvbuf = conf->tcp_outgoing_rcvbuf; |
|
|
|
} |
|
|
|
if (fast_open == 0) { |
|
|
|
fast_open = conf->fast_open; |
|
|
|
} |
|
|
@ -1820,6 +1844,14 @@ main(int argc, char **argv) |
|
|
|
LOGI("set TCP incoming connection send buffer size to %d", tcp_incoming_sndbuf); |
|
|
|
} |
|
|
|
|
|
|
|
if (tcp_incoming_rcvbuf != 0 && tcp_incoming_rcvbuf < SOCKET_BUF_SIZE) { |
|
|
|
tcp_incoming_rcvbuf = 0; |
|
|
|
} |
|
|
|
|
|
|
|
if (tcp_incoming_rcvbuf != 0) { |
|
|
|
LOGI("set TCP incoming connection receive buffer size to %d", tcp_incoming_rcvbuf); |
|
|
|
} |
|
|
|
|
|
|
|
if (tcp_outgoing_sndbuf != 0 && tcp_outgoing_sndbuf < SOCKET_BUF_SIZE) { |
|
|
|
tcp_outgoing_sndbuf = 0; |
|
|
|
} |
|
|
@ -1828,6 +1860,14 @@ main(int argc, char **argv) |
|
|
|
LOGI("set TCP outgoing connection send buffer size to %d", tcp_outgoing_sndbuf); |
|
|
|
} |
|
|
|
|
|
|
|
if (tcp_outgoing_rcvbuf != 0 && tcp_outgoing_rcvbuf < SOCKET_BUF_SIZE) { |
|
|
|
tcp_outgoing_rcvbuf = 0; |
|
|
|
} |
|
|
|
|
|
|
|
if (tcp_outgoing_rcvbuf != 0) { |
|
|
|
LOGI("set TCP outgoing connection receive buffer size to %d", tcp_outgoing_recvbuf); |
|
|
|
} |
|
|
|
|
|
|
|
if (server_num == 0) { |
|
|
|
server_addr[server_num++].host = "0.0.0.0"; |
|
|
|
} |
|
|
|