diff svr-tcpfwd.c @ 577:69e98c45db7c

- Progress for allowing specifying a listenaddr for tcp forwards
author Matt Johnston <matt@ucc.asn.au>
date Wed, 24 Feb 2010 16:13:15 +0000
parents 52a644e7b8e1
children 35d27c1d0ee7
line wrap: on
line diff
--- a/svr-tcpfwd.c	Wed Nov 12 13:13:00 2008 +0000
+++ b/svr-tcpfwd.c	Wed Feb 24 16:13:15 2010 +0000
@@ -206,11 +206,20 @@
 	tcpinfo = (struct TCPListener*)m_malloc(sizeof(struct TCPListener));
 	tcpinfo->sendaddr = NULL;
 	tcpinfo->sendport = 0;
-	tcpinfo->listenaddr = bindaddr;
 	tcpinfo->listenport = port;
 	tcpinfo->chantype = &svr_chan_tcpremote;
 	tcpinfo->tcp_type = forwarded;
 
+	if (!opts.listen_fwd_all 
+			|| (strcmp(tcpinfo->listenaddr, "localhost") == 0) ) {
+        // NULL means "localhost only"
+        tcpinfo->listenaddr = NULL;
+	}
+    else
+    {
+        tcpinfo->listenaddr = bindaddr;
+    }
+
 	ret = listen_tcpfwd(tcpinfo);
 
 out: