comparison cli-tcpfwd.c @ 258:306499676384

* add -g (dbclient) and -a (dropbear) options for allowing non-local hosts to connect to forwarded ports. Rearranged various some of the tcp listening code. * changed to /* */ style brackets in svr-authpam.c
author Matt Johnston <matt@ucc.asn.au>
date Sun, 04 Dec 2005 16:13:11 +0000
parents 84925eceeb13
children c049490e43fe
comparison
equal deleted inserted replaced
257:63601217f5ab 258:306499676384
93 93
94 TRACE(("enter cli_localtcp: %d %s %d", listenport, remoteaddr, 94 TRACE(("enter cli_localtcp: %d %s %d", listenport, remoteaddr,
95 remoteport)); 95 remoteport));
96 96
97 tcpinfo = (struct TCPListener*)m_malloc(sizeof(struct TCPListener)); 97 tcpinfo = (struct TCPListener*)m_malloc(sizeof(struct TCPListener));
98
98 tcpinfo->sendaddr = m_strdup(remoteaddr); 99 tcpinfo->sendaddr = m_strdup(remoteaddr);
99 tcpinfo->sendport = remoteport; 100 tcpinfo->sendport = remoteport;
101
102 if (opts.listen_fwd_all) {
103 tcpinfo->listenaddr = m_strdup("");
104 } else {
105 tcpinfo->listenaddr = m_strdup("localhost");
106 }
100 tcpinfo->listenport = listenport; 107 tcpinfo->listenport = listenport;
108
101 tcpinfo->chantype = &cli_chan_tcplocal; 109 tcpinfo->chantype = &cli_chan_tcplocal;
102 110
103 ret = listen_tcpfwd(tcpinfo); 111 ret = listen_tcpfwd(tcpinfo);
104 112
105 if (ret == DROPBEAR_FAILURE) { 113 if (ret == DROPBEAR_FAILURE) {
111 #endif /* ENABLE_CLI_LOCALTCPFWD */ 119 #endif /* ENABLE_CLI_LOCALTCPFWD */
112 120
113 #ifdef ENABLE_CLI_REMOTETCPFWD 121 #ifdef ENABLE_CLI_REMOTETCPFWD
114 static void send_msg_global_request_remotetcp(int port) { 122 static void send_msg_global_request_remotetcp(int port) {
115 123
124 char* listenspec = NULL;
116 TRACE(("enter send_msg_global_request_remotetcp")) 125 TRACE(("enter send_msg_global_request_remotetcp"))
117 126
118 CHECKCLEARTOWRITE(); 127 CHECKCLEARTOWRITE();
119 buf_putbyte(ses.writepayload, SSH_MSG_GLOBAL_REQUEST); 128 buf_putbyte(ses.writepayload, SSH_MSG_GLOBAL_REQUEST);
120 buf_putstring(ses.writepayload, "tcpip-forward", 13); 129 buf_putstring(ses.writepayload, "tcpip-forward", 13);
121 buf_putbyte(ses.writepayload, 0); 130 buf_putbyte(ses.writepayload, 0);
122 buf_putstring(ses.writepayload, "0.0.0.0", 7); /* TODO: IPv6? */ 131 if (opts.listen_fwd_all) {
132 listenspec = "";
133 } else {
134 listenspec = "localhost";
135 }
136 /* TODO: IPv6? */;
137 buf_putstring(ses.writepayload, listenspec, strlen(listenspec));
123 buf_putint(ses.writepayload, port); 138 buf_putint(ses.writepayload, port);
124 139
125 encrypt_packet(); 140 encrypt_packet();
126 141
127 TRACE(("leave send_msg_global_request_remotetcp")) 142 TRACE(("leave send_msg_global_request_remotetcp"))