Mercurial > dropbear
comparison cli-runopts.c @ 1467:7279a633cc50
Merge branch 'houseofkodai-cli_bind_address_connect'
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 26 Jan 2018 00:32:39 +0800 |
parents | f787f60f8e45 |
children | 2d450c1056e3 |
comparison
equal
deleted
inserted
replaced
1464:ad637c9e0f6f | 1467:7279a633cc50 |
---|---|
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][:bind_port]\n" | |
95 "-V Version\n" | 96 "-V Version\n" |
96 #if DEBUG_TRACE | 97 #if DEBUG_TRACE |
97 "-v verbose (compiled with DEBUG_TRACE)\n" | 98 "-v verbose (compiled with DEBUG_TRACE)\n" |
98 #endif | 99 #endif |
99 ,DROPBEAR_VERSION, cli_opts.progname, | 100 ,DROPBEAR_VERSION, cli_opts.progname, |
123 #endif | 124 #endif |
124 /* a flag (no arg) if 'next' is NULL, a string-valued option otherwise */ | 125 /* a flag (no arg) if 'next' is NULL, a string-valued option otherwise */ |
125 OPT_OTHER | 126 OPT_OTHER |
126 } opt; | 127 } opt; |
127 unsigned int cmdlen; | 128 unsigned int cmdlen; |
128 char* dummy = NULL; /* Not used for anything real */ | |
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; |
164 cli_opts.agent_keys_loaded = 0; | 165 cli_opts.agent_keys_loaded = 0; |
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 |
170 cli_opts.bind_address = NULL; | |
171 cli_opts.bind_port = NULL; | |
169 #ifndef DISABLE_ZLIB | 172 #ifndef DISABLE_ZLIB |
170 opts.compress_mode = DROPBEAR_COMPRESS_ON; | 173 opts.compress_mode = DROPBEAR_COMPRESS_ON; |
171 #endif | 174 #endif |
172 #if DROPBEAR_USER_ALGO_LIST | 175 #if DROPBEAR_USER_ALGO_LIST |
173 opts.cipher_list = NULL; | 176 opts.cipher_list = NULL; |
312 case 'V': | 315 case 'V': |
313 print_version(); | 316 print_version(); |
314 exit(EXIT_SUCCESS); | 317 exit(EXIT_SUCCESS); |
315 break; | 318 break; |
316 case 'b': | 319 case 'b': |
317 next = &dummy; | 320 next = &bind_arg; |
318 /* FALLTHROUGH */ | 321 break; |
319 default: | 322 default: |
320 fprintf(stderr, | 323 fprintf(stderr, |
321 "WARNING: Ignoring unknown option -%c\n", c); | 324 "WARNING: Ignoring unknown option -%c\n", c); |
322 break; | 325 break; |
323 } /* Switch */ | 326 } /* Switch */ |
416 } | 419 } |
417 #endif | 420 #endif |
418 | 421 |
419 if (cli_opts.remoteport == NULL) { | 422 if (cli_opts.remoteport == NULL) { |
420 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 } | |
421 } | 436 } |
422 | 437 |
423 /* 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 |
424 * there's a command, but we do otherwise */ | 439 * there's a command, but we do otherwise */ |
425 if (cli_opts.wantpty == 9) { | 440 if (cli_opts.wantpty == 9) { |