comparison svr-runopts.c @ 454:7e43f5e473b9

- Add -K keepalive flag for dropbear and dbclient - Try to reduce the frequency of select() timeouts - Add a max receive window size of 1MB
author Matt Johnston <matt@ucc.asn.au>
date Wed, 08 Aug 2007 15:12:06 +0000
parents 3e6c536bc023
children b956d6151600
comparison
equal deleted inserted replaced
453:29953de278ae 454:7e43f5e473b9
78 "-P PidFile Create pid file PidFile\n" 78 "-P PidFile Create pid file PidFile\n"
79 " (default %s)\n" 79 " (default %s)\n"
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)\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 #ifdef DEBUG_TRACE 85 #ifdef DEBUG_TRACE
85 "-v verbose\n" 86 "-v verbose\n"
86 #endif 87 #endif
87 ,DROPBEAR_VERSION, progname, 88 ,DROPBEAR_VERSION, progname,
88 #ifdef DROPBEAR_DSS 89 #ifdef DROPBEAR_DSS
89 DSS_PRIV_FILENAME, 90 DSS_PRIV_FILENAME,
90 #endif 91 #endif
91 #ifdef DROPBEAR_RSA 92 #ifdef DROPBEAR_RSA
92 RSA_PRIV_FILENAME, 93 RSA_PRIV_FILENAME,
93 #endif 94 #endif
94 DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT, DROPBEAR_PIDFILE, DEFAULT_RECV_WINDOW); 95 DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT, DROPBEAR_PIDFILE,
96 DEFAULT_RECV_WINDOW, DEFAULT_KEEPALIVE);
95 } 97 }
96 98
97 void svr_getopts(int argc, char ** argv) { 99 void svr_getopts(int argc, char ** argv) {
98 100
99 unsigned int i; 101 unsigned int i;
100 char ** next = 0; 102 char ** next = 0;
101 int nextisport = 0; 103 int nextisport = 0;
104 char* recv_window_arg = NULL;
105 char* keepalive_arg = NULL;
102 106
103 /* see printhelp() for options */ 107 /* see printhelp() for options */
104 svr_opts.rsakeyfile = NULL; 108 svr_opts.rsakeyfile = NULL;
105 svr_opts.dsskeyfile = NULL; 109 svr_opts.dsskeyfile = NULL;
106 svr_opts.bannerfile = NULL; 110 svr_opts.bannerfile = NULL;
128 #endif 132 #endif
129 #ifndef DISABLE_SYSLOG 133 #ifndef DISABLE_SYSLOG
130 svr_opts.usingsyslog = 1; 134 svr_opts.usingsyslog = 1;
131 #endif 135 #endif
132 opts.recv_window = DEFAULT_RECV_WINDOW; 136 opts.recv_window = DEFAULT_RECV_WINDOW;
133 char* recv_window_arg = NULL; 137 opts.keepalive_secs = DEFAULT_KEEPALIVE;
138
134 #ifdef ENABLE_SVR_REMOTETCPFWD 139 #ifdef ENABLE_SVR_REMOTETCPFWD
135 opts.listen_fwd_all = 0; 140 opts.listen_fwd_all = 0;
136 #endif 141 #endif
137 142
138 for (i = 1; i < (unsigned int)argc; i++) { 143 for (i = 1; i < (unsigned int)argc; i++) {
208 svr_opts.norootlogin = 1; 213 svr_opts.norootlogin = 1;
209 break; 214 break;
210 case 'W': 215 case 'W':
211 next = &recv_window_arg; 216 next = &recv_window_arg;
212 break; 217 break;
218 case 'K':
219 next = &keepalive_arg;
220 break;
213 #if defined(ENABLE_SVR_PASSWORD_AUTH) || defined(ENABLE_SVR_PAM_AUTH) 221 #if defined(ENABLE_SVR_PASSWORD_AUTH) || defined(ENABLE_SVR_PAM_AUTH)
214 case 's': 222 case 's':
215 svr_opts.noauthpass = 1; 223 svr_opts.noauthpass = 1;
216 break; 224 break;
217 case 'g': 225 case 'g':
272 } 280 }
273 buf_setpos(svr_opts.banner, 0); 281 buf_setpos(svr_opts.banner, 0);
274 282
275 } 283 }
276 284
277 if (recv_window_arg) 285 if (recv_window_arg) {
278 {
279 opts.recv_window = atol(recv_window_arg); 286 opts.recv_window = atol(recv_window_arg);
280 if (opts.recv_window == 0) 287 if (opts.recv_window == 0 || opts.recv_window > MAX_RECV_WINDOW)
281 { 288 {
282 dropbear_exit("Bad recv window '%s'", recv_window_arg); 289 dropbear_exit("Bad recv window '%s'", recv_window_arg);
290 }
291 }
292
293 if (keepalive_arg) {
294 opts.keepalive_secs = strtoul(keepalive_arg, NULL, 10);
295 if (opts.keepalive_secs == 0 && errno == EINVAL)
296 {
297 dropbear_exit("Bad keepalive '%s'", keepalive_arg);
283 } 298 }
284 } 299 }
285 } 300 }
286 301
287 static void addportandaddress(char* spec) { 302 static void addportandaddress(char* spec) {