diff --git a/src/jconf.h b/src/jconf.h index 6b8a38b9..a3cf6dec 100644 --- a/src/jconf.h +++ b/src/jconf.h @@ -25,6 +25,7 @@ #define MAX_REMOTE_NUM 10 #define MAX_CONF_SIZE 16 * 1024 #define DNS_THREAD_NUM 4 +#define MAX_CONNECT_TIMEOUT 10 typedef struct { char *host; diff --git a/src/local.c b/src/local.c index 6bba2e80..213bd55a 100644 --- a/src/local.c +++ b/src/local.c @@ -688,9 +688,9 @@ static struct remote * new_remote(int fd, int timeout) remote->fd = fd; ev_io_init(&remote->recv_ctx->io, remote_recv_cb, fd, EV_READ); ev_io_init(&remote->send_ctx->io, remote_send_cb, fd, EV_WRITE); - ev_timer_init(&remote->send_ctx->watcher, remote_timeout_cb, min(5, + ev_timer_init(&remote->send_ctx->watcher, remote_timeout_cb, min(MAX_CONNECT_TIMEOUT, timeout), 0); - ev_timer_init(&remote->recv_ctx->watcher, remote_timeout_cb, min(10, + ev_timer_init(&remote->recv_ctx->watcher, remote_timeout_cb, min(MAX_CONNECT_TIMEOUT, timeout), timeout); remote->recv_ctx->remote = remote; remote->send_ctx->remote = remote; diff --git a/src/redir.c b/src/redir.c index 6209b242..4cd84145 100644 --- a/src/redir.c +++ b/src/redir.c @@ -471,7 +471,7 @@ static struct remote * new_remote(int fd, int timeout) remote->fd = fd; ev_io_init(&remote->recv_ctx->io, remote_recv_cb, fd, EV_READ); ev_io_init(&remote->send_ctx->io, remote_send_cb, fd, EV_WRITE); - ev_timer_init(&remote->send_ctx->watcher, remote_timeout_cb, min(5, timeout), 0); + ev_timer_init(&remote->send_ctx->watcher, remote_timeout_cb, min(MAX_CONNECT_TIMEOUT, timeout), 0); remote->recv_ctx->remote = remote; remote->recv_ctx->connected = 0; remote->send_ctx->remote = remote; diff --git a/src/server.c b/src/server.c index e4ad2190..5ce6b4df 100644 --- a/src/server.c +++ b/src/server.c @@ -803,7 +803,7 @@ static struct server * new_server(int fd, struct listen_ctx *listener) ev_io_init(&server->recv_ctx->io, server_recv_cb, fd, EV_READ); ev_io_init(&server->send_ctx->io, server_send_cb, fd, EV_WRITE); ev_timer_init(&server->recv_ctx->watcher, server_timeout_cb, - min(10, listener->timeout), listener->timeout); + min(MAX_CONNECT_TIMEOUT, listener->timeout), listener->timeout); server->recv_ctx->server = server; server->recv_ctx->connected = 0; server->send_ctx->server = server; diff --git a/src/tunnel.c b/src/tunnel.c index 7a612d40..2dfc2823 100644 --- a/src/tunnel.c +++ b/src/tunnel.c @@ -466,7 +466,7 @@ static struct remote * new_remote(int fd, int timeout) remote->fd = fd; ev_io_init(&remote->recv_ctx->io, remote_recv_cb, fd, EV_READ); ev_io_init(&remote->send_ctx->io, remote_send_cb, fd, EV_WRITE); - ev_timer_init(&remote->send_ctx->watcher, remote_timeout_cb, min(5, + ev_timer_init(&remote->send_ctx->watcher, remote_timeout_cb, min(MAX_CONNECT_TIMEOUT, timeout), 0); remote->recv_ctx->remote = remote; remote->recv_ctx->connected = 0; diff --git a/src/udprelay.c b/src/udprelay.c index 4940ba52..6983f03f 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -914,7 +914,7 @@ int init_udprelay(const char *server_host, const char *server_port, setnonblocking(serverfd); server_ctx = new_server_ctx(serverfd); - server_ctx->timeout = min(timeout, 5); + server_ctx->timeout = min(timeout, MAX_CONNECT_TIMEOUT); server_ctx->method = method; server_ctx->iface = iface; server_ctx->conn_cache = conn_cache;