comparison svr-runopts.c @ 493:6cd2152aae0b idle-timeout

Idle-timeout patch from Farrell Aultman, need to figure whether to only account DATA packets and whether server->client data makes sense too.
author Matt Johnston <matt@ucc.asn.au>
date Mon, 22 Sep 2008 15:28:52 +0000
parents b956d6151600
children
comparison
equal deleted inserted replaced
492:b956d6151600 493:6cd2152aae0b
80 #ifdef INETD_MODE 80 #ifdef INETD_MODE
81 "-i Start for inetd\n" 81 "-i Start for inetd\n"
82 #endif 82 #endif
83 "-W <receive_window_buffer> (default %d, larger may be faster, max 1MB)\n" 83 "-W <receive_window_buffer> (default %d, larger may be faster, max 1MB)\n"
84 "-K <keepalive> (0 is never, default %d)\n" 84 "-K <keepalive> (0 is never, default %d)\n"
85 "-I <idle_timeout> (0 is never, default %d)\n"
85 #ifdef DEBUG_TRACE 86 #ifdef DEBUG_TRACE
86 "-v verbose\n" 87 "-v verbose\n"
87 #endif 88 #endif
88 ,DROPBEAR_VERSION, progname, 89 ,DROPBEAR_VERSION, progname,
89 #ifdef DROPBEAR_DSS 90 #ifdef DROPBEAR_DSS
91 #endif 92 #endif
92 #ifdef DROPBEAR_RSA 93 #ifdef DROPBEAR_RSA
93 RSA_PRIV_FILENAME, 94 RSA_PRIV_FILENAME,
94 #endif 95 #endif
95 DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT, DROPBEAR_PIDFILE, 96 DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT, DROPBEAR_PIDFILE,
96 DEFAULT_RECV_WINDOW, DEFAULT_KEEPALIVE); 97 DEFAULT_RECV_WINDOW, DEFAULT_KEEPALIVE, DEFAULT_IDLE_TIMEOUT);
97 } 98 }
98 99
99 void svr_getopts(int argc, char ** argv) { 100 void svr_getopts(int argc, char ** argv) {
100 101
101 unsigned int i; 102 unsigned int i;
102 char ** next = 0; 103 char ** next = 0;
103 int nextisport = 0; 104 int nextisport = 0;
104 char* recv_window_arg = NULL; 105 char* recv_window_arg = NULL;
105 char* keepalive_arg = NULL; 106 char* keepalive_arg = NULL;
107 char* idle_timeout_arg = NULL;
106 108
107 /* see printhelp() for options */ 109 /* see printhelp() for options */
108 svr_opts.rsakeyfile = NULL; 110 svr_opts.rsakeyfile = NULL;
109 svr_opts.dsskeyfile = NULL; 111 svr_opts.dsskeyfile = NULL;
110 svr_opts.bannerfile = NULL; 112 svr_opts.bannerfile = NULL;
132 #endif 134 #endif
133 #ifndef DISABLE_SYSLOG 135 #ifndef DISABLE_SYSLOG
134 svr_opts.usingsyslog = 1; 136 svr_opts.usingsyslog = 1;
135 #endif 137 #endif
136 opts.recv_window = DEFAULT_RECV_WINDOW; 138 opts.recv_window = DEFAULT_RECV_WINDOW;
137 opts.keepalive_secs = DEFAULT_KEEPALIVE; 139 opts.keepalive_secs = DEFAULT_KEEPALIVE;
140 opts.idle_timeout_secs = DEFAULT_IDLE_TIMEOUT;
138 141
139 #ifdef ENABLE_SVR_REMOTETCPFWD 142 #ifdef ENABLE_SVR_REMOTETCPFWD
140 opts.listen_fwd_all = 0; 143 opts.listen_fwd_all = 0;
141 #endif 144 #endif
142 145
216 next = &recv_window_arg; 219 next = &recv_window_arg;
217 break; 220 break;
218 case 'K': 221 case 'K':
219 next = &keepalive_arg; 222 next = &keepalive_arg;
220 break; 223 break;
224 case 'I':
225 next = &idle_timeout_arg;
226 break;
221 #if defined(ENABLE_SVR_PASSWORD_AUTH) || defined(ENABLE_SVR_PAM_AUTH) 227 #if defined(ENABLE_SVR_PASSWORD_AUTH) || defined(ENABLE_SVR_PAM_AUTH)
222 case 's': 228 case 's':
223 svr_opts.noauthpass = 1; 229 svr_opts.noauthpass = 1;
224 break; 230 break;
225 case 'g': 231 case 'g':
251 if (svr_opts.portcount == 0) { 257 if (svr_opts.portcount == 0) {
252 svr_opts.ports[0] = m_strdup(DROPBEAR_DEFPORT); 258 svr_opts.ports[0] = m_strdup(DROPBEAR_DEFPORT);
253 svr_opts.addresses[0] = m_strdup(DROPBEAR_DEFADDRESS); 259 svr_opts.addresses[0] = m_strdup(DROPBEAR_DEFADDRESS);
254 svr_opts.portcount = 1; 260 svr_opts.portcount = 1;
255 } 261 }
256 262
257 if (svr_opts.dsskeyfile == NULL) { 263 if (svr_opts.dsskeyfile == NULL) {
258 svr_opts.dsskeyfile = DSS_PRIV_FILENAME; 264 svr_opts.dsskeyfile = DSS_PRIV_FILENAME;
259 } 265 }
260 if (svr_opts.rsakeyfile == NULL) { 266 if (svr_opts.rsakeyfile == NULL) {
261 svr_opts.rsakeyfile = RSA_PRIV_FILENAME; 267 svr_opts.rsakeyfile = RSA_PRIV_FILENAME;
290 } 296 }
291 297
292 if (keepalive_arg) { 298 if (keepalive_arg) {
293 if (m_str_to_uint(keepalive_arg, &opts.keepalive_secs) == DROPBEAR_FAILURE) { 299 if (m_str_to_uint(keepalive_arg, &opts.keepalive_secs) == DROPBEAR_FAILURE) {
294 dropbear_exit("Bad keepalive '%s'", keepalive_arg); 300 dropbear_exit("Bad keepalive '%s'", keepalive_arg);
301 }
302 }
303
304 if (idle_timeout_arg) {
305 opts.idle_timeout_secs = strtoul(idle_timeout_arg, NULL, 10);
306 if (opts.idle_timeout_secs == 0 && errno == EINVAL) {
307 dropbear_exit("Bad idle_timeout '%s'", idle_timeout_arg);
295 } 308 }
296 } 309 }
297 } 310 }
298 311
299 static void addportandaddress(char* spec) { 312 static void addportandaddress(char* spec) {