mirror of
https://github.com/clearml/dropbear
synced 2025-03-09 21:41:07 +00:00
FIx remote forward listeners
This commit is contained in:
parent
e7504b3311
commit
d2e71ade72
@ -135,7 +135,7 @@ static int cli_localtcp(const char* listenaddr,
|
|||||||
tcpinfo->chantype = &cli_chan_tcplocal;
|
tcpinfo->chantype = &cli_chan_tcplocal;
|
||||||
tcpinfo->tcp_type = direct;
|
tcpinfo->tcp_type = direct;
|
||||||
|
|
||||||
ret = listen_tcpfwd(tcpinfo);
|
ret = listen_tcpfwd(tcpinfo, NULL);
|
||||||
|
|
||||||
if (ret == DROPBEAR_FAILURE) {
|
if (ret == DROPBEAR_FAILURE) {
|
||||||
m_free(tcpinfo);
|
m_free(tcpinfo);
|
||||||
|
@ -168,6 +168,7 @@ static int svr_remotetcpreq(int *allocated_listen_port) {
|
|||||||
unsigned int addrlen;
|
unsigned int addrlen;
|
||||||
struct TCPListener *tcpinfo = NULL;
|
struct TCPListener *tcpinfo = NULL;
|
||||||
unsigned int port;
|
unsigned int port;
|
||||||
|
struct Listener *listener = NULL;
|
||||||
|
|
||||||
TRACE(("enter remotetcpreq"))
|
TRACE(("enter remotetcpreq"))
|
||||||
|
|
||||||
@ -208,9 +209,9 @@ static int svr_remotetcpreq(int *allocated_listen_port) {
|
|||||||
tcpinfo->listenaddr = m_strdup(request_addr);
|
tcpinfo->listenaddr = m_strdup(request_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = listen_tcpfwd(tcpinfo);
|
ret = listen_tcpfwd(tcpinfo, &listener);
|
||||||
if (DROPBEAR_SUCCESS == ret) {
|
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;
|
*allocated_listen_port = tcpinfo->listenport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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];
|
char portstring[NI_MAXSERV];
|
||||||
int socks[DROPBEAR_MAX_SOCKS];
|
int socks[DROPBEAR_MAX_SOCKS];
|
||||||
struct Listener *listener = NULL;
|
|
||||||
int nsocks;
|
int nsocks;
|
||||||
|
struct Listener *listener;
|
||||||
char* errstring = NULL;
|
char* errstring = NULL;
|
||||||
|
|
||||||
TRACE(("enter listen_tcpfwd"))
|
TRACE(("enter listen_tcpfwd"))
|
||||||
@ -142,6 +142,10 @@ int listen_tcpfwd(struct TCPListener* tcpinfo) {
|
|||||||
return DROPBEAR_FAILURE;
|
return DROPBEAR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret_listener) {
|
||||||
|
*ret_listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
TRACE(("leave listen_tcpfwd: success"))
|
TRACE(("leave listen_tcpfwd: success"))
|
||||||
return DROPBEAR_SUCCESS;
|
return DROPBEAR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
3
tcpfwd.h
3
tcpfwd.h
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
#include "listener.h"
|
||||||
|
|
||||||
struct TCPListener {
|
struct TCPListener {
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ void cli_recv_msg_request_success(void);
|
|||||||
void cli_recv_msg_request_failure(void);
|
void cli_recv_msg_request_failure(void);
|
||||||
|
|
||||||
/* Common */
|
/* Common */
|
||||||
int listen_tcpfwd(struct TCPListener* tcpinfo);
|
int listen_tcpfwd(struct TCPListener* tcpinfo, struct Listener **ret_listener);
|
||||||
int tcp_prio_inithandler(struct Channel* chan);
|
int tcp_prio_inithandler(struct Channel* chan);
|
||||||
|
|
||||||
/* A random identifier */
|
/* A random identifier */
|
||||||
|
Loading…
Reference in New Issue
Block a user