diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index c2907cd..1d7b51e 100644
a
|
b
|
init_proxy_dowork (struct context *c) |
493 | 493 | c->c1.socks_proxy = socks_proxy_new (c->options.ce.socks_proxy_server, |
494 | 494 | c->options.ce.socks_proxy_port, |
495 | 495 | c->options.ce.socks_proxy_authfile, |
496 | | c->options.ce.socks_proxy_retry); |
| 496 | c->options.ce.socks_proxy_retry, |
| 497 | c->options.ce.socks_proxy_timeout); |
497 | 498 | if (c->c1.socks_proxy) |
498 | 499 | { |
499 | 500 | c->c1.socks_proxy_owned = true; |
diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index 18cb354..f6cad1b 100644
a
|
b
|
static const char usage_message[] = |
163 | 163 | " up is a file containing username/password on 2 lines, or\n" |
164 | 164 | " 'stdin' to prompt for console.\n" |
165 | 165 | "--socks-proxy-retry : Retry indefinitely on Socks proxy errors.\n" |
| 166 | "--socks-proxy-timeout n : Proxy timeout in seconds, default=5.\n" |
166 | 167 | #endif |
167 | 168 | "--resolv-retry n: If hostname resolve fails for --remote, retry\n" |
168 | 169 | " resolve for n seconds before failing (disabled by default).\n" |
… |
… |
add_option (struct options *options, |
5126 | 5127 | VERIFY_PERMISSION (OPT_P_GENERAL|OPT_P_CONNECTION); |
5127 | 5128 | options->ce.socks_proxy_retry = true; |
5128 | 5129 | } |
| 5130 | else if (streq (p[0], "socks-proxy-timeout") && p[1]) |
| 5131 | { |
| 5132 | VERIFY_PERMISSION (OPT_P_GENERAL|OPT_P_CONNECTION); |
| 5133 | options->ce.socks_proxy_timeout = positive_atoi (p[1]); |
| 5134 | } |
5129 | 5135 | #endif |
5130 | 5136 | else if (streq (p[0], "keepalive") && p[1] && p[2]) |
5131 | 5137 | { |
diff --git a/src/openvpn/options.h b/src/openvpn/options.h
index ec1d091..8371764 100644
a
|
b
|
struct connection_entry |
108 | 108 | const char *socks_proxy_port; |
109 | 109 | const char *socks_proxy_authfile; |
110 | 110 | bool socks_proxy_retry; |
| 111 | int socks_proxy_timeout; |
111 | 112 | #endif |
112 | 113 | |
113 | 114 | int tun_mtu; /* MTU of tun device */ |
diff --git a/src/openvpn/socks.c b/src/openvpn/socks.c
index 6e29e7a..d0bda39 100644
a
|
b
|
struct socks_proxy_info * |
63 | 63 | socks_proxy_new (const char *server, |
64 | 64 | const char *port, |
65 | 65 | const char *authfile, |
66 | | bool retry) |
| 66 | bool retry, |
| 67 | int timeout) |
67 | 68 | { |
68 | 69 | struct socks_proxy_info *p; |
69 | 70 | |
… |
… |
socks_proxy_new (const char *server, |
82 | 83 | |
83 | 84 | p->retry = retry; |
84 | 85 | p->defined = true; |
| 86 | if (timeout) |
| 87 | p->timeout = timeout; |
| 88 | else |
| 89 | p->timeout = 5; // default value |
85 | 90 | |
86 | 91 | return p; |
87 | 92 | } |
… |
… |
socks_handshake (struct socks_proxy_info *p, |
294 | 299 | static bool |
295 | 300 | recv_socks_reply (socket_descriptor_t sd, |
296 | 301 | struct openvpn_sockaddr *addr, |
297 | | volatile int *signal_received) |
| 302 | volatile int *signal_received, |
| 303 | int timeout_sec) |
298 | 304 | { |
299 | 305 | char atyp = '\0'; |
300 | 306 | int alen = 0; |
301 | 307 | int len = 0; |
302 | 308 | char buf[22]; |
303 | | const int timeout_sec = 5; |
304 | 309 | |
305 | 310 | if (addr != NULL) |
306 | 311 | { |
… |
… |
establish_socks_proxy_passthru (struct socks_proxy_info *p, |
463 | 468 | |
464 | 469 | |
465 | 470 | /* receive reply from Socks proxy and discard */ |
466 | | if (!recv_socks_reply (sd, NULL, signal_received)) |
| 471 | if (!recv_socks_reply (sd, NULL, signal_received, p->timeout)) |
467 | 472 | goto error; |
468 | 473 | |
469 | 474 | return; |
… |
… |
establish_socks_proxy_udpassoc (struct socks_proxy_info *p, |
501 | 506 | |
502 | 507 | /* receive reply from Socks proxy */ |
503 | 508 | CLEAR (*relay_addr); |
504 | | if (!recv_socks_reply (ctrl_sd, relay_addr, signal_received)) |
| 509 | if (!recv_socks_reply (ctrl_sd, relay_addr, signal_received, p->timeout)) |
505 | 510 | goto error; |
506 | 511 | |
507 | 512 | return; |
diff --git a/src/openvpn/socks.h b/src/openvpn/socks.h
index 30b957d..c4c96c4 100644
a
|
b
|
struct link_socket_actual; |
40 | 40 | struct socks_proxy_info { |
41 | 41 | bool defined; |
42 | 42 | bool retry; |
| 43 | int timeout; |
43 | 44 | |
44 | 45 | char server[128]; |
45 | 46 | const char *port; |
… |
… |
void socks_adjust_frame_parameters (struct frame *frame, int proto); |
51 | 52 | struct socks_proxy_info *socks_proxy_new (const char *server, |
52 | 53 | const char *port, |
53 | 54 | const char *authfile, |
54 | | bool retry); |
| 55 | bool retry, |
| 56 | int timeout); |
55 | 57 | |
56 | 58 | void socks_proxy_close (struct socks_proxy_info *sp); |
57 | 59 | |