mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
Fix an edge case where the connect answer is not zero and not error.
The tor proxy might want auth 0x2 or answer what ever not defined in https://tools.ietf.org/html/rfc1928. Changelog-Fixed: TOR: We don't send any further request if the return code of connect is not zero or error. Signed-off-by: Saibato <saibato.naga@pm.me>
This commit is contained in:
parent
68271f7c6b
commit
291fc48cd3
1 changed files with 22 additions and 15 deletions
|
@ -140,23 +140,30 @@ static struct io_plan *io_tor_connect_after_resp_to_connect(struct io_conn
|
|||
connect->host);
|
||||
return io_close(conn);
|
||||
}
|
||||
/* make the V5 request */
|
||||
connect->hlen = strlen(connect->host);
|
||||
connect->buffer[0] = SOCKS_V5;
|
||||
connect->buffer[1] = SOCKS_CONNECT;
|
||||
connect->buffer[2] = 0;
|
||||
connect->buffer[3] = SOCKS_DOMAIN;
|
||||
connect->buffer[4] = connect->hlen;
|
||||
if (connect->buffer[1] == '\0') {
|
||||
/* make the V5 request */
|
||||
connect->hlen = strlen(connect->host);
|
||||
connect->buffer[0] = SOCKS_V5;
|
||||
connect->buffer[1] = SOCKS_CONNECT;
|
||||
connect->buffer[2] = 0;
|
||||
connect->buffer[3] = SOCKS_DOMAIN;
|
||||
connect->buffer[4] = connect->hlen;
|
||||
|
||||
memcpy(connect->buffer + SOCK_REQ_V5_LEN, connect->host, connect->hlen);
|
||||
memcpy(connect->buffer + SOCK_REQ_V5_LEN + strlen(connect->host),
|
||||
&(connect->port), sizeof connect->port);
|
||||
memcpy(connect->buffer + SOCK_REQ_V5_LEN, connect->host, connect->hlen);
|
||||
memcpy(connect->buffer + SOCK_REQ_V5_LEN + strlen(connect->host),
|
||||
&(connect->port), sizeof connect->port);
|
||||
|
||||
status_io(LOG_IO_OUT, NULL, "proxy", connect->buffer,
|
||||
SOCK_REQ_V5_HEADER_LEN + connect->hlen);
|
||||
return io_write(conn, connect->buffer,
|
||||
SOCK_REQ_V5_HEADER_LEN + connect->hlen,
|
||||
connect_out, connect);
|
||||
status_io(LOG_IO_OUT, NULL, "proxy", connect->buffer,
|
||||
SOCK_REQ_V5_HEADER_LEN + connect->hlen);
|
||||
return io_write(conn, connect->buffer,
|
||||
SOCK_REQ_V5_HEADER_LEN + connect->hlen,
|
||||
connect_out, connect);
|
||||
} else {
|
||||
status_debug("Connected out for %s error: unexpected connect answer %0x from the tor socks5 proxy",
|
||||
connect->host,
|
||||
connect->buffer[1]);
|
||||
return io_close(conn);
|
||||
}
|
||||
}
|
||||
|
||||
static struct io_plan *io_tor_connect_after_req_to_connect(struct io_conn *conn,
|
||||
|
|
Loading…
Add table
Reference in a new issue