diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2015-08-27 14:56:33 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2015-08-27 14:56:33 +0200 |
commit | 9e16baf4b3fd458da53ec00b2d97be24c795aea7 (patch) | |
tree | 8dd8cd50707a1b088f3fa73676ddfd17baaf8810 | |
parent | aae3a5a9180fe2917d14b437931bd9fe14e933e1 (diff) | |
download | cssh-9e16baf4b3fd458da53ec00b2d97be24c795aea7.tar.gz cssh-9e16baf4b3fd458da53ec00b2d97be24c795aea7.tar.bz2 |
parsing ports in the hosts file now too
-rw-r--r-- | src/cssh.c | 12 | ||||
-rw-r--r-- | src/options.ggo.in | 5 |
2 files changed, 13 insertions, 4 deletions
@@ -248,10 +248,16 @@ static int read_hosts_file( const char *hosts_file, unsigned short default_port, if( strlen( buf ) > 0 && buf[strlen( buf )-1] == '\n' ) { buf[strlen(buf)-1] = '\0'; } + // the user can be part of the hostname, libssh allows this, + // but we must parse the port separately + char *p = strchr( buf, ':' ); + if( p != NULL ) { + (*port)[*nof_hosts] = atoi( p+1 ); + *p = '\0'; + } else { + (*port)[*nof_hosts] = default_port; + } (*host)[*nof_hosts] = strdup( buf ); - // TODO: parse port from file - // TODO: parse user from file (but actually we can use the user@host hack in libssh) - (*port)[*nof_hosts] = default_port; (*nof_hosts)++; if( *nof_hosts > size_hosts ) { size_hosts *= 2; diff --git a/src/options.ggo.in b/src/options.ggo.in index 9f70ca4..c667572 100644 --- a/src/options.ggo.in +++ b/src/options.ggo.in @@ -23,7 +23,10 @@ section "Main Options" optional option "hosts-file" H - "List of hosts to use in parallel (listed one per line in a file), optional second parameter separated with a tab can be the port" + "List of hosts to use in parallel \ +(listed one per line in a file), optionally \ +you can specify a port immediatelly after a colon \ +after the hostname. Example 'user@host:port'" string typestr="hosts-file" optional |