Add enable-autotor-v2 config variable

With enable-autotor-v2 defined in cmdline the default behavior to create
v3 onions with the tor service call, is set to v2 onions.

Signed-off-by: Saibato <saibato.naga@pm.me>
This commit is contained in:
Saibato 2019-09-25 11:05:14 +00:00 committed by Christian Decker
parent e638224092
commit 0f9ba53581
8 changed files with 28 additions and 9 deletions

View file

@ -13,6 +13,7 @@ msgdata,connectctl_init,use_tor_proxy_always,bool,
msgdata,connectctl_init,dev_allow_localhost,bool,
msgdata,connectctl_init,use_dns,bool,
msgdata,connectctl_init,tor_password,wirestring,
msgdata,connectctl_init,use_v3_autotor,bool,
# Connectd->master, here are the addresses I bound, can announce.
msgtype,connectctl_init_reply,2100

1 #include <common/cryptomsg.h>
13 msgdata,connectctl_init,use_dns,bool,
14 msgdata,connectctl_init,tor_password,wirestring,
15 # Connectd->master, here are the addresses I bound, can announce. msgdata,connectctl_init,use_v3_autotor,bool,
16 # Connectd->master, here are the addresses I bound, can announce.
17 msgtype,connectctl_init_reply,2100
18 msgdata,connectctl_init_reply,num_bindings,u16,
19 msgdata,connectctl_init_reply,bindings,wireaddr_internal,num_bindings

View file

@ -148,6 +148,9 @@ struct daemon {
/* File descriptors to listen on once we're activated. */
struct listen_fd *listen_fds;
/* Allow to define the default behavior of tot services calls*/
bool use_v3_autotor;
};
/* Peers we're trying to reach: we iterate through addrs until we succeed
@ -1114,14 +1117,16 @@ static struct wireaddr_internal *setup_listeners(const tal_t *ctx,
tor_autoservice(tmpctx,
&proposed_wireaddr[i].u.torservice,
tor_password,
binding);
binding,
daemon->use_v3_autotor);
continue;
};
add_announcable(announcable,
tor_autoservice(tmpctx,
&proposed_wireaddr[i].u.torservice,
tor_password,
binding));
binding,
daemon->use_v3_autotor));
}
/* Sort and uniquify. */
@ -1153,7 +1158,8 @@ static struct io_plan *connect_init(struct io_conn *conn,
&proposed_listen_announce,
&proxyaddr, &daemon->use_proxy_always,
&daemon->dev_allow_localhost, &daemon->use_dns,
&tor_password)) {
&tor_password,
&daemon->use_v3_autotor)) {
/* This is a helper which prints the type expected and the actual
* message, then exits (it should never be called!). */
master_badmsg(WIRE_CONNECTCTL_INIT, msg);

View file

@ -228,7 +228,8 @@ find_local_address(const struct wireaddr_internal *bindings)
struct wireaddr *tor_autoservice(const tal_t *ctx,
const struct wireaddr *tor_serviceaddr,
const char *tor_password,
const struct wireaddr_internal *bindings)
const struct wireaddr_internal *bindings,
const bool use_v3_autotor)
{
int fd;
const struct wireaddr *laddr;
@ -236,7 +237,6 @@ struct wireaddr *tor_autoservice(const tal_t *ctx,
struct addrinfo *ai_tor;
struct rbuf rbuf;
char *buffer;
bool use_v3_autotor;
laddr = find_local_address(bindings);
ai_tor = wireaddr_to_addrinfo(tmpctx, tor_serviceaddr);
@ -251,8 +251,6 @@ struct wireaddr *tor_autoservice(const tal_t *ctx,
buffer = tal_arr(tmpctx, char, rbuf_good_size(fd));
rbuf_init(&rbuf, fd, buffer, tal_count(buffer), buf_resize);
use_v3_autotor = true;
negotiate_auth(&rbuf, tor_password);
onion = make_onion(ctx, &rbuf, laddr, use_v3_autotor);

View file

@ -9,6 +9,7 @@
struct wireaddr *tor_autoservice(const tal_t *ctx,
const struct wireaddr *tor_serviceaddr,
const char *tor_password,
const struct wireaddr_internal *bindings);
const struct wireaddr_internal *bindings,
const bool use_v3_autotor);
#endif /* LIGHTNING_CONNECTD_TOR_AUTOSERVICE_H */

View file

@ -366,7 +366,8 @@ int connectd_init(struct lightningd *ld)
listen_announce,
ld->proxyaddr, ld->use_proxy_always || ld->pure_tor_setup,
IFDEV(ld->dev_allow_localhost, false), ld->config.use_dns,
ld->tor_service_password ? ld->tor_service_password : "");
ld->tor_service_password ? ld->tor_service_password : "",
ld->config.use_v3_autotor);
subd_req(ld->connectd, ld->connectd, take(msg), -1, 0,
connect_init_done, NULL);

View file

@ -67,6 +67,10 @@ struct config {
/* Minimal amount of effective funding_satoshis for accepting channels */
u64 min_capacity_sat;
/* Allow to define the default behavior of tot services calls*/
bool use_v3_autotor;
};
struct lightningd {

View file

@ -485,6 +485,8 @@ static const struct config testnet_config = {
/* Sets min_effective_htlc_capacity - at 1000$/BTC this is 10ct */
.min_capacity_sat = 10000,
.use_v3_autotor = true,
};
/* aka. "Dude, where's my coins?" */
@ -544,6 +546,8 @@ static const struct config mainnet_config = {
/* Sets min_effective_htlc_capacity - at 1000$/BTC this is 10ct */
.min_capacity_sat = 10000,
.use_v3_autotor = true,
};
static void check_config(struct lightningd *ld)
@ -976,6 +980,9 @@ static void register_opts(struct lightningd *ld)
opt_register_noarg("--disable-dns", opt_set_invbool, &ld->config.use_dns,
"Disable DNS lookups of peers");
opt_register_noarg("--enable-autotor-v2-mode", opt_set_invbool, &ld->config.use_v3_autotor,
"Try to get a v2 onion address from the Tor service call, default is v3");
opt_register_logging(ld);
opt_register_version();

View file

@ -23,4 +23,5 @@ const struct config test_config = {
.max_fee_multiplier = 10,
.use_dns = true,
.min_capacity_sat = 10000,
.use_v3_autotor = true,
};