comparison cli-tcpfwd.c @ 1206:2907c658fa76

Implemented ExitOnForwardFailure option for local and remote forwarding.
author Konstantin Tokarev <ktokarev@smartlabs.tv>
date Mon, 30 Nov 2015 20:30:58 +0300
parents d7b752525b91
children d058e15ea213
comparison
equal deleted inserted replaced
1205:978887222d29 1206:2907c658fa76
58 NULL, 58 NULL,
59 NULL 59 NULL
60 }; 60 };
61 #endif 61 #endif
62 62
63 #ifdef ENABLE_CLI_ANYTCPFWD
64 static void fwd_failed(const char* format, ...) ATTRIB_PRINTF(1,2);
65 void fwd_failed(const char* format, ...)
66 {
67 va_list param;
68 va_start(param, format);
69
70 if (cli_opts.exit_on_fwd_failure)
71 _dropbear_exit(EXIT_FAILURE, format, param);
72 else
73 _dropbear_log(LOG_WARNING, format, param);
74
75 va_end(param);
76 }
77 #endif
78
63 #ifdef ENABLE_CLI_LOCALTCPFWD 79 #ifdef ENABLE_CLI_LOCALTCPFWD
64 void setup_localtcp() { 80 void setup_localtcp() {
65 m_list_elem *iter; 81 m_list_elem *iter;
66 int ret; 82 int ret;
67 83
73 fwd->listenaddr, 89 fwd->listenaddr,
74 fwd->listenport, 90 fwd->listenport,
75 fwd->connectaddr, 91 fwd->connectaddr,
76 fwd->connectport); 92 fwd->connectport);
77 if (ret == DROPBEAR_FAILURE) { 93 if (ret == DROPBEAR_FAILURE) {
78 dropbear_log(LOG_WARNING, "Failed local port forward %s:%d:%s:%d", 94 fwd_failed("Failed local port forward %s:%d:%s:%d",
79 fwd->listenaddr, 95 fwd->listenaddr,
80 fwd->listenport, 96 fwd->listenport,
81 fwd->connectaddr, 97 fwd->connectaddr,
82 fwd->connectport); 98 fwd->connectport);
83 } 99 }
179 m_list_elem *iter; 195 m_list_elem *iter;
180 for (iter = cli_opts.remotefwds->first; iter; iter = iter->next) { 196 for (iter = cli_opts.remotefwds->first; iter; iter = iter->next) {
181 struct TCPFwdEntry *fwd = (struct TCPFwdEntry*)iter->item; 197 struct TCPFwdEntry *fwd = (struct TCPFwdEntry*)iter->item;
182 if (!fwd->have_reply) { 198 if (!fwd->have_reply) {
183 fwd->have_reply = 1; 199 fwd->have_reply = 1;
184 dropbear_log(LOG_WARNING, "Remote TCP forward request failed (port %d -> %s:%d)", fwd->listenport, fwd->connectaddr, fwd->connectport); 200 fwd_failed("Remote TCP forward request failed (port %d -> %s:%d)",
201 fwd->listenport,
202 fwd->connectaddr,
203 fwd->connectport);
185 return; 204 return;
186 } 205 }
187 } 206 }
188 } 207 }
189 208