summaryrefslogtreecommitdiffhomepage
path: root/cli-runopts.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2018-01-26 00:27:48 +0800
committerMatt Johnston <matt@ucc.asn.au>2018-01-26 00:28:25 +0800
commite4ac7ea1ca910e0d245232a8ab16415f252b006b (patch)
treeffad8dc3321a7f3b60bef90a7d27ff504222711f /cli-runopts.c
parent9c7ecf6d14a82c1b1a97e1b4a328460ba8762299 (diff)
bind to port as well with -b
Diffstat (limited to 'cli-runopts.c')
-rw-r--r--cli-runopts.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/cli-runopts.c b/cli-runopts.c
index 4057824..d69a719 100644
--- a/cli-runopts.c
+++ b/cli-runopts.c
@@ -92,7 +92,7 @@ static void printhelp() {
"-c <cipher list> Specify preferred ciphers ('-c help' to list options)\n"
"-m <MAC list> Specify preferred MACs for packet verification (or '-m help')\n"
#endif
- "-b bind_address\n"
+ "-b [bind_address][:bind_port]\n"
"-V Version\n"
#if DEBUG_TRACE
"-v verbose (compiled with DEBUG_TRACE)\n"
@@ -131,6 +131,7 @@ void cli_getopts(int argc, char ** argv) {
char* keepalive_arg = NULL;
char* idle_timeout_arg = NULL;
char *host_arg = NULL;
+ char *bind_arg = NULL;
char c;
/* see printhelp() for options */
@@ -167,6 +168,7 @@ void cli_getopts(int argc, char ** argv) {
cli_opts.proxycmd = NULL;
#endif
cli_opts.bind_address = NULL;
+ cli_opts.bind_port = NULL;
#ifndef DISABLE_ZLIB
opts.compress_mode = DROPBEAR_COMPRESS_ON;
#endif
@@ -315,7 +317,7 @@ void cli_getopts(int argc, char ** argv) {
exit(EXIT_SUCCESS);
break;
case 'b':
- next = &cli_opts.bind_address;
+ next = &bind_arg;
break;
default:
fprintf(stderr,
@@ -421,6 +423,18 @@ void cli_getopts(int argc, char ** argv) {
cli_opts.remoteport = "22";
}
+ if (bind_arg) {
+ /* split [host][:port] */
+ char *port = strrchr(bind_arg, ':');
+ if (port) {
+ cli_opts.bind_port = m_strdup(port+1);
+ *port = '\0';
+ }
+ if (strlen(bind_arg) > 0) {
+ cli_opts.bind_address = m_strdup(bind_arg);
+ }
+ }
+
/* If not explicitly specified with -t or -T, we don't want a pty if
* there's a command, but we do otherwise */
if (cli_opts.wantpty == 9) {