mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
Change default behavior of autotor onions to Version 3 onions.
This commit is contained in:
parent
4bf0bc1f28
commit
e638224092
@ -73,17 +73,42 @@ static void discard_remaining_response(struct rbuf *rbuf)
|
|||||||
|
|
||||||
static struct wireaddr *make_onion(const tal_t *ctx,
|
static struct wireaddr *make_onion(const tal_t *ctx,
|
||||||
struct rbuf *rbuf,
|
struct rbuf *rbuf,
|
||||||
const struct wireaddr *local)
|
const struct wireaddr *local,
|
||||||
|
bool use_v3_autotor)
|
||||||
{
|
{
|
||||||
char *line;
|
char *line;
|
||||||
struct wireaddr *onion;
|
struct wireaddr *onion;
|
||||||
|
|
||||||
//V3 tor after 3.3.3.aplha FIXME: TODO SAIBATO
|
/* Now that V3 is out of Beta default to V3 autoservice onions if version is above 0.4
|
||||||
//sprintf((char *)reach->buffer,"ADD_ONION NEW:ED25519-V3 Port=9735,127.0.0.1:9735\r\n");
|
*/
|
||||||
|
tor_send_cmd(rbuf, "PROTOCOLINFO 1");
|
||||||
|
|
||||||
|
while ((line = tor_response_line(rbuf)) != NULL) {
|
||||||
|
|
||||||
|
if (!strstarts(line, "VERSION Tor="))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (use_v3_autotor)
|
||||||
|
if(strstr(line, "\"0.0") ||
|
||||||
|
strstr(line, "\"0.1") ||
|
||||||
|
strstr(line, "\"0.2") ||
|
||||||
|
strstr(line, "\"0.3")) {
|
||||||
|
use_v3_autotor = false;
|
||||||
|
status_unusual("Autotor: fallback to try a V2 onion service, your Tor version is smaller than 0.4.x.x");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!use_v3_autotor) {
|
||||||
tor_send_cmd(rbuf,
|
tor_send_cmd(rbuf,
|
||||||
tal_fmt(tmpctx, "ADD_ONION NEW:RSA1024 Port=%d,%s Flags=DiscardPK,Detach",
|
tal_fmt(tmpctx, "ADD_ONION NEW:RSA1024 Port=%d,%s Flags=DiscardPK,Detach",
|
||||||
/* FIXME: We *could* allow user to set Tor port */
|
/* FIXME: We *could* allow user to set Tor port */
|
||||||
DEFAULT_PORT, fmt_wireaddr(tmpctx, local)));
|
DEFAULT_PORT, fmt_wireaddr(tmpctx, local)));
|
||||||
|
} else {
|
||||||
|
tor_send_cmd(rbuf,
|
||||||
|
tal_fmt(tmpctx, "ADD_ONION NEW:ED25519-V3 Port=%d,%s Flags=DiscardPK,Detach",
|
||||||
|
/* FIXME: We *could* allow user to set Tor port */
|
||||||
|
DEFAULT_PORT, fmt_wireaddr(tmpctx, local)));
|
||||||
|
}
|
||||||
|
|
||||||
while ((line = tor_response_line(rbuf)) != NULL) {
|
while ((line = tor_response_line(rbuf)) != NULL) {
|
||||||
const char *name;
|
const char *name;
|
||||||
@ -211,6 +236,7 @@ struct wireaddr *tor_autoservice(const tal_t *ctx,
|
|||||||
struct addrinfo *ai_tor;
|
struct addrinfo *ai_tor;
|
||||||
struct rbuf rbuf;
|
struct rbuf rbuf;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
bool use_v3_autotor;
|
||||||
|
|
||||||
laddr = find_local_address(bindings);
|
laddr = find_local_address(bindings);
|
||||||
ai_tor = wireaddr_to_addrinfo(tmpctx, tor_serviceaddr);
|
ai_tor = wireaddr_to_addrinfo(tmpctx, tor_serviceaddr);
|
||||||
@ -225,8 +251,10 @@ struct wireaddr *tor_autoservice(const tal_t *ctx,
|
|||||||
buffer = tal_arr(tmpctx, char, rbuf_good_size(fd));
|
buffer = tal_arr(tmpctx, char, rbuf_good_size(fd));
|
||||||
rbuf_init(&rbuf, fd, buffer, tal_count(buffer), buf_resize);
|
rbuf_init(&rbuf, fd, buffer, tal_count(buffer), buf_resize);
|
||||||
|
|
||||||
|
use_v3_autotor = true;
|
||||||
|
|
||||||
negotiate_auth(&rbuf, tor_password);
|
negotiate_auth(&rbuf, tor_password);
|
||||||
onion = make_onion(ctx, &rbuf, laddr);
|
onion = make_onion(ctx, &rbuf, laddr, use_v3_autotor);
|
||||||
|
|
||||||
/*on the other hand we can stay connected until ln finish to keep onion alive and then vanish */
|
/*on the other hand we can stay connected until ln finish to keep onion alive and then vanish */
|
||||||
//because when we run with Detach flag as we now do every start of LN creates a new addr while the old
|
//because when we run with Detach flag as we now do every start of LN creates a new addr while the old
|
||||||
|
Loading…
Reference in New Issue
Block a user