summaryrefslogtreecommitdiffhomepage
path: root/cli-tcpfwd.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2011-11-05 23:12:15 +0800
committerMatt Johnston <matt@ucc.asn.au>2011-11-05 23:12:15 +0800
commitd4e7654ed04785324fb80b15bb613957475e5b80 (patch)
tree675b79e25756ef8852e441b31f1579e81a9e4d49 /cli-tcpfwd.c
parent68b458ece987b8a9bce6929c9f043aba2e50f087 (diff)
Print the server allocated port when using dbclient -R 0:....
Patch from Ali Onur Uyar
Diffstat (limited to 'cli-tcpfwd.c')
-rw-r--r--cli-tcpfwd.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/cli-tcpfwd.c b/cli-tcpfwd.c
index 6e451c4..0f47dcc 100644
--- a/cli-tcpfwd.c
+++ b/cli-tcpfwd.c
@@ -148,15 +148,26 @@ static void send_msg_global_request_remotetcp(const char *addr, int port) {
/* The only global success/failure messages are for remotetcp.
* Since there isn't any identifier in these messages, we have to rely on them
* being in the same order as we sent the requests. This is the ordering
- * of the cli_opts.remotefwds list */
+ * of the cli_opts.remotefwds list.
+ * If the requested remote port is 0 the listen port will be
+ * dynamically allocated by the server and the port number will be returned
+ * to client and the port number reported to the user. */
void cli_recv_msg_request_success() {
- /* Nothing in the packet. We just mark off that we have received the reply,
+ /* We just mark off that we have received the reply,
* so that we can report failure for later ones. */
m_list_elem * iter = NULL;
for (iter = cli_opts.remotefwds->first; iter; iter = iter->next) {
struct TCPFwdEntry *fwd = (struct TCPFwdEntry*)iter->item;
if (!fwd->have_reply) {
fwd->have_reply = 1;
+ if (fwd->listenport == 0) {
+ /* The server should let us know which port was allocated if we requestd port 0 */
+ int allocport = buf_getint(ses.payload);
+ if (allocport > 0) {
+ dropbear_log(LOG_INFO, "Allocated port %d for remote forward to %s:%d",
+ allocport, fwd->connectaddr, fwd->connectport);
+ }
+ }
return;
}
}