comparison cli-tcpfwd.c @ 631:af304deacb4c

Print the server allocated port when using dbclient -R 0:.... Patch from Ali Onur Uyar
author Matt Johnston <matt@ucc.asn.au>
date Sat, 05 Nov 2011 23:12:15 +0800
parents 345aaed42ef4
children c19acba28590
comparison
equal deleted inserted replaced
630:d79863572f49 631:af304deacb4c
146 } 146 }
147 147
148 /* The only global success/failure messages are for remotetcp. 148 /* The only global success/failure messages are for remotetcp.
149 * Since there isn't any identifier in these messages, we have to rely on them 149 * Since there isn't any identifier in these messages, we have to rely on them
150 * being in the same order as we sent the requests. This is the ordering 150 * being in the same order as we sent the requests. This is the ordering
151 * of the cli_opts.remotefwds list */ 151 * of the cli_opts.remotefwds list.
152 * If the requested remote port is 0 the listen port will be
153 * dynamically allocated by the server and the port number will be returned
154 * to client and the port number reported to the user. */
152 void cli_recv_msg_request_success() { 155 void cli_recv_msg_request_success() {
153 /* Nothing in the packet. We just mark off that we have received the reply, 156 /* We just mark off that we have received the reply,
154 * so that we can report failure for later ones. */ 157 * so that we can report failure for later ones. */
155 m_list_elem * iter = NULL; 158 m_list_elem * iter = NULL;
156 for (iter = cli_opts.remotefwds->first; iter; iter = iter->next) { 159 for (iter = cli_opts.remotefwds->first; iter; iter = iter->next) {
157 struct TCPFwdEntry *fwd = (struct TCPFwdEntry*)iter->item; 160 struct TCPFwdEntry *fwd = (struct TCPFwdEntry*)iter->item;
158 if (!fwd->have_reply) { 161 if (!fwd->have_reply) {
159 fwd->have_reply = 1; 162 fwd->have_reply = 1;
163 if (fwd->listenport == 0) {
164 /* The server should let us know which port was allocated if we requestd port 0 */
165 int allocport = buf_getint(ses.payload);
166 if (allocport > 0) {
167 dropbear_log(LOG_INFO, "Allocated port %d for remote forward to %s:%d",
168 allocport, fwd->connectaddr, fwd->connectport);
169 }
170 }
160 return; 171 return;
161 } 172 }
162 } 173 }
163 } 174 }
164 175