mirror of
https://github.com/clearml/dropbear
synced 2025-06-26 18:17:32 +00:00
- Fix dbclient with port 0 for server-allocated
- Fix port forwards with a bind address of 127.0.0.1 vs "localhost" etc
This commit is contained in:
parent
29062e629f
commit
3e4433f715
22
cli-tcpfwd.c
22
cli-tcpfwd.c
@ -161,9 +161,10 @@ void cli_recv_msg_request_success() {
|
|||||||
if (!fwd->have_reply) {
|
if (!fwd->have_reply) {
|
||||||
fwd->have_reply = 1;
|
fwd->have_reply = 1;
|
||||||
if (fwd->listenport == 0) {
|
if (fwd->listenport == 0) {
|
||||||
/* The server should let us know which port was allocated if we requestd port 0 */
|
/* The server should let us know which port was allocated if we requested port 0 */
|
||||||
int allocport = buf_getint(ses.payload);
|
int allocport = buf_getint(ses.payload);
|
||||||
if (allocport > 0) {
|
if (allocport > 0) {
|
||||||
|
fwd->listenport = allocport;
|
||||||
dropbear_log(LOG_INFO, "Allocated port %d for remote forward to %s:%d",
|
dropbear_log(LOG_INFO, "Allocated port %d for remote forward to %s:%d",
|
||||||
allocport, fwd->connectaddr, fwd->connectport);
|
allocport, fwd->connectaddr, fwd->connectport);
|
||||||
}
|
}
|
||||||
@ -220,15 +221,30 @@ static int newtcpforwarded(struct Channel * channel) {
|
|||||||
origaddr = buf_getstring(ses.payload, NULL);
|
origaddr = buf_getstring(ses.payload, NULL);
|
||||||
origport = buf_getint(ses.payload);
|
origport = buf_getint(ses.payload);
|
||||||
|
|
||||||
/* Find which port corresponds */
|
/* Find which port corresponds. First try and match address as well as port,
|
||||||
|
in case they want to forward different ports separately ... */
|
||||||
for (iter = cli_opts.remotefwds->first; iter; iter = iter->next) {
|
for (iter = cli_opts.remotefwds->first; iter; iter = iter->next) {
|
||||||
fwd = (struct TCPFwdEntry*)iter->item;
|
fwd = (struct TCPFwdEntry*)iter->item;
|
||||||
if (origport == fwd->listenport
|
if (origport == fwd->listenport
|
||||||
&& (strcmp(origaddr, fwd->listenaddr) == 0)) {
|
&& strcmp(origaddr, fwd->listenaddr) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!iter)
|
||||||
|
{
|
||||||
|
/* ... otherwise try to generically match the only forwarded port
|
||||||
|
without address (also handles ::1 vs 127.0.0.1 vs localhost case).
|
||||||
|
rfc4254 is vague about the definition of "address that was connected" */
|
||||||
|
for (iter = cli_opts.remotefwds->first; iter; iter = iter->next) {
|
||||||
|
fwd = (struct TCPFwdEntry*)iter->item;
|
||||||
|
if (origport == fwd->listenport) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (iter == NULL) {
|
if (iter == NULL) {
|
||||||
/* We didn't request forwarding on that port */
|
/* We didn't request forwarding on that port */
|
||||||
cleantext(origaddr);
|
cleantext(origaddr);
|
||||||
|
Loading…
Reference in New Issue
Block a user