comparison cli-runopts.c @ 1466:f787f60f8e45

bind to port as well with -b
author Matt Johnston <matt@ucc.asn.au>
date Fri, 26 Jan 2018 00:27:48 +0800
parents f7a53832501d
children 2d450c1056e3
comparison
equal deleted inserted replaced
1465:f7a53832501d 1466:f787f60f8e45
90 #endif 90 #endif
91 #if DROPBEAR_USER_ALGO_LIST 91 #if DROPBEAR_USER_ALGO_LIST
92 "-c <cipher list> Specify preferred ciphers ('-c help' to list options)\n" 92 "-c <cipher list> Specify preferred ciphers ('-c help' to list options)\n"
93 "-m <MAC list> Specify preferred MACs for packet verification (or '-m help')\n" 93 "-m <MAC list> Specify preferred MACs for packet verification (or '-m help')\n"
94 #endif 94 #endif
95 "-b bind_address\n" 95 "-b [bind_address][:bind_port]\n"
96 "-V Version\n" 96 "-V Version\n"
97 #if DEBUG_TRACE 97 #if DEBUG_TRACE
98 "-v verbose (compiled with DEBUG_TRACE)\n" 98 "-v verbose (compiled with DEBUG_TRACE)\n"
99 #endif 99 #endif
100 ,DROPBEAR_VERSION, cli_opts.progname, 100 ,DROPBEAR_VERSION, cli_opts.progname,
129 129
130 char* recv_window_arg = NULL; 130 char* recv_window_arg = NULL;
131 char* keepalive_arg = NULL; 131 char* keepalive_arg = NULL;
132 char* idle_timeout_arg = NULL; 132 char* idle_timeout_arg = NULL;
133 char *host_arg = NULL; 133 char *host_arg = NULL;
134 char *bind_arg = NULL;
134 char c; 135 char c;
135 136
136 /* see printhelp() for options */ 137 /* see printhelp() for options */
137 cli_opts.progname = argv[0]; 138 cli_opts.progname = argv[0];
138 cli_opts.remotehost = NULL; 139 cli_opts.remotehost = NULL;
165 #endif 166 #endif
166 #if DROPBEAR_CLI_PROXYCMD 167 #if DROPBEAR_CLI_PROXYCMD
167 cli_opts.proxycmd = NULL; 168 cli_opts.proxycmd = NULL;
168 #endif 169 #endif
169 cli_opts.bind_address = NULL; 170 cli_opts.bind_address = NULL;
171 cli_opts.bind_port = NULL;
170 #ifndef DISABLE_ZLIB 172 #ifndef DISABLE_ZLIB
171 opts.compress_mode = DROPBEAR_COMPRESS_ON; 173 opts.compress_mode = DROPBEAR_COMPRESS_ON;
172 #endif 174 #endif
173 #if DROPBEAR_USER_ALGO_LIST 175 #if DROPBEAR_USER_ALGO_LIST
174 opts.cipher_list = NULL; 176 opts.cipher_list = NULL;
313 case 'V': 315 case 'V':
314 print_version(); 316 print_version();
315 exit(EXIT_SUCCESS); 317 exit(EXIT_SUCCESS);
316 break; 318 break;
317 case 'b': 319 case 'b':
318 next = &cli_opts.bind_address; 320 next = &bind_arg;
319 break; 321 break;
320 default: 322 default:
321 fprintf(stderr, 323 fprintf(stderr,
322 "WARNING: Ignoring unknown option -%c\n", c); 324 "WARNING: Ignoring unknown option -%c\n", c);
323 break; 325 break;
417 } 419 }
418 #endif 420 #endif
419 421
420 if (cli_opts.remoteport == NULL) { 422 if (cli_opts.remoteport == NULL) {
421 cli_opts.remoteport = "22"; 423 cli_opts.remoteport = "22";
424 }
425
426 if (bind_arg) {
427 /* split [host][:port] */
428 char *port = strrchr(bind_arg, ':');
429 if (port) {
430 cli_opts.bind_port = m_strdup(port+1);
431 *port = '\0';
432 }
433 if (strlen(bind_arg) > 0) {
434 cli_opts.bind_address = m_strdup(bind_arg);
435 }
422 } 436 }
423 437
424 /* If not explicitly specified with -t or -T, we don't want a pty if 438 /* If not explicitly specified with -t or -T, we don't want a pty if
425 * there's a command, but we do otherwise */ 439 * there's a command, but we do otherwise */
426 if (cli_opts.wantpty == 9) { 440 if (cli_opts.wantpty == 9) {