The unified diff between revisions [f452aa06..] and [a4cab2b4..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'cli-tcpfwd.c'
#
#
# patch "cli-tcpfwd.c"
# from [d8d52da1d269d157d91e9731508a3b8beba444c2]
# to [3c2b139864eb87c901783d9d9398f3f584674533]
#
============================================================
--- cli-tcpfwd.c d8d52da1d269d157d91e9731508a3b8beba444c2
+++ cli-tcpfwd.c 3c2b139864eb87c901783d9d9398f3f584674533
@@ -95,10 +95,19 @@ static int cli_localtcp(unsigned int lis
remoteport));
tcpinfo = (struct TCPListener*)m_malloc(sizeof(struct TCPListener));
+
tcpinfo->sendaddr = m_strdup(remoteaddr);
tcpinfo->sendport = remoteport;
+
+ if (opts.listen_fwd_all) {
+ tcpinfo->listenaddr = m_strdup("");
+ } else {
+ tcpinfo->listenaddr = m_strdup("localhost");
+ }
tcpinfo->listenport = listenport;
+
tcpinfo->chantype = &cli_chan_tcplocal;
+ tcpinfo->tcp_type = direct;
ret = listen_tcpfwd(tcpinfo);
@@ -113,13 +122,20 @@ static void send_msg_global_request_remo
#ifdef ENABLE_CLI_REMOTETCPFWD
static void send_msg_global_request_remotetcp(int port) {
+ char* listenspec = NULL;
TRACE(("enter send_msg_global_request_remotetcp"))
CHECKCLEARTOWRITE();
buf_putbyte(ses.writepayload, SSH_MSG_GLOBAL_REQUEST);
buf_putstring(ses.writepayload, "tcpip-forward", 13);
buf_putbyte(ses.writepayload, 0);
- buf_putstring(ses.writepayload, "0.0.0.0", 7); /* TODO: IPv6? */
+ if (opts.listen_fwd_all) {
+ listenspec = "";
+ } else {
+ listenspec = "localhost";
+ }
+ /* TODO: IPv6? */;
+ buf_putstring(ses.writepayload, listenspec, strlen(listenspec));
buf_putint(ses.writepayload, port);
encrypt_packet();
@@ -186,11 +202,9 @@ static int newtcpforwarded(struct Channe
ses.maxfd = MAX(ses.maxfd, sock);
- /* Note that infd is actually the "outgoing" direction on the
- * tcp connection, vice versa for outfd.
- * We don't set outfd, that will get set after the connection's
+ /* We don't set readfd, that will get set after the connection's
* progress succeeds */
- channel->infd = sock;
+ channel->writefd = sock;
channel->initconn = 1;
err = SSH_OPEN_IN_PROGRESS;