Skip to content

Commit

Permalink
merge remote forward fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mkj committed Sep 7, 2018
2 parents 892c5fc + d2e71ad commit 6f6ef48
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cli-tcpfwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static int cli_localtcp(const char* listenaddr,
tcpinfo->chantype = &cli_chan_tcplocal;
tcpinfo->tcp_type = direct;

ret = listen_tcpfwd(tcpinfo);
ret = listen_tcpfwd(tcpinfo, NULL);

if (ret == DROPBEAR_FAILURE) {
m_free(tcpinfo);
Expand Down
5 changes: 3 additions & 2 deletions svr-tcpfwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ static int svr_remotetcpreq(int *allocated_listen_port) {
unsigned int addrlen;
struct TCPListener *tcpinfo = NULL;
unsigned int port;
struct Listener *listener = NULL;

TRACE(("enter remotetcpreq"))

Expand Down Expand Up @@ -208,9 +209,9 @@ static int svr_remotetcpreq(int *allocated_listen_port) {
tcpinfo->listenaddr = m_strdup(request_addr);
}

ret = listen_tcpfwd(tcpinfo);
ret = listen_tcpfwd(tcpinfo, &listener);
if (DROPBEAR_SUCCESS == ret) {
tcpinfo->listenport = get_sock_port(ses.listeners[0]->socks[0]);
tcpinfo->listenport = get_sock_port(listener->socks[0]);
*allocated_listen_port = tcpinfo->listenport;
}

Expand Down
8 changes: 6 additions & 2 deletions tcp-accept.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ static void tcp_acceptor(const struct Listener *listener, int sock) {
}
}

int listen_tcpfwd(struct TCPListener* tcpinfo) {
int listen_tcpfwd(struct TCPListener* tcpinfo, struct Listener **ret_listener) {

char portstring[NI_MAXSERV];
int socks[DROPBEAR_MAX_SOCKS];
struct Listener *listener = NULL;
int nsocks;
struct Listener *listener;
char* errstring = NULL;

TRACE(("enter listen_tcpfwd"))
Expand All @@ -142,6 +142,10 @@ int listen_tcpfwd(struct TCPListener* tcpinfo) {
return DROPBEAR_FAILURE;
}

if (ret_listener) {
*ret_listener = listener;
}

TRACE(("leave listen_tcpfwd: success"))
return DROPBEAR_SUCCESS;
}
Expand Down
3 changes: 2 additions & 1 deletion tcpfwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "channel.h"
#include "list.h"
#include "listener.h"

struct TCPListener {

Expand Down Expand Up @@ -69,7 +70,7 @@ void cli_recv_msg_request_success(void);
void cli_recv_msg_request_failure(void);

/* Common */
int listen_tcpfwd(struct TCPListener* tcpinfo);
int listen_tcpfwd(struct TCPListener* tcpinfo, struct Listener **ret_listener);
int tcp_prio_inithandler(struct Channel* chan);

/* A random identifier */
Expand Down

0 comments on commit 6f6ef48

Please sign in to comment.