diff options
Diffstat (limited to 'cli-tcpfwd.c')
-rw-r--r-- | cli-tcpfwd.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/cli-tcpfwd.c b/cli-tcpfwd.c index 300a2fa..c3bfd4d 100644 --- a/cli-tcpfwd.c +++ b/cli-tcpfwd.c @@ -95,10 +95,19 @@ static int cli_localtcp(unsigned int listenport, const char* remoteaddr, 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 int cli_localtcp(unsigned int listenport, const char* remoteaddr, #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 Channel * channel) { 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; |