summaryrefslogtreecommitdiffhomepage
path: root/cli-tcpfwd.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2015-12-15 21:30:59 +0800
committerMatt Johnston <matt@ucc.asn.au>2015-12-15 21:30:59 +0800
commited21e7523580e5139bd5cedd6dea3cd5cb3f3d98 (patch)
tree85896c40cae38cb90420b0d7f75d0ca20abb5618 /cli-tcpfwd.c
parent87d2c9c05ce03bd8dd549218f4a67b6569a34fa5 (diff)
parent4dc1388ac76eee5af402eb751bcae4e38465a9ed (diff)
Merge pull request #16 from annulen/openssh_options
Implemented ExitOnForwardFailure option for local and remote forwarding.
Diffstat (limited to 'cli-tcpfwd.c')
-rw-r--r--cli-tcpfwd.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/cli-tcpfwd.c b/cli-tcpfwd.c
index ec65f41..4d46b94 100644
--- a/cli-tcpfwd.c
+++ b/cli-tcpfwd.c
@@ -60,6 +60,22 @@ static const struct ChanType cli_chan_tcplocal = {
};
#endif
+#ifdef ENABLE_CLI_ANYTCPFWD
+static void fwd_failed(const char* format, ...) ATTRIB_PRINTF(1,2);
+void fwd_failed(const char* format, ...)
+{
+ va_list param;
+ va_start(param, format);
+
+ if (cli_opts.exit_on_fwd_failure)
+ _dropbear_exit(EXIT_FAILURE, format, param);
+ else
+ _dropbear_log(LOG_WARNING, format, param);
+
+ va_end(param);
+}
+#endif
+
#ifdef ENABLE_CLI_LOCALTCPFWD
void setup_localtcp() {
m_list_elem *iter;
@@ -75,7 +91,7 @@ void setup_localtcp() {
fwd->connectaddr,
fwd->connectport);
if (ret == DROPBEAR_FAILURE) {
- dropbear_log(LOG_WARNING, "Failed local port forward %s:%d:%s:%d",
+ fwd_failed("Failed local port forward %s:%d:%s:%d",
fwd->listenaddr,
fwd->listenport,
fwd->connectaddr,
@@ -181,7 +197,10 @@ void cli_recv_msg_request_failure() {
struct TCPFwdEntry *fwd = (struct TCPFwdEntry*)iter->item;
if (!fwd->have_reply) {
fwd->have_reply = 1;
- dropbear_log(LOG_WARNING, "Remote TCP forward request failed (port %d -> %s:%d)", fwd->listenport, fwd->connectaddr, fwd->connectport);
+ fwd_failed("Remote TCP forward request failed (port %d -> %s:%d)",
+ fwd->listenport,
+ fwd->connectaddr,
+ fwd->connectport);
return;
}
}