# HG changeset patch # User Matt Johnston # Date 1320505935 -28800 # Node ID af304deacb4ca920dc8cd9b6088c04a947285015 # Parent d79863572f49ad0a135be45c78d8ae03ad1db1be Print the server allocated port when using dbclient -R 0:.... Patch from Ali Onur Uyar diff -r d79863572f49 -r af304deacb4c cli-tcpfwd.c --- a/cli-tcpfwd.c Thu Nov 03 07:18:37 2011 +0000 +++ b/cli-tcpfwd.c Sat Nov 05 23:12:15 2011 +0800 @@ -148,15 +148,26 @@ /* 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; } }