Browse Source

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>
travis-debug
Saibato 5 years ago
committed by Christian Decker
parent
commit
0f9ba53581
  1. 1
      connectd/connect_wire.csv
  2. 12
      connectd/connectd.c
  3. 6
      connectd/tor_autoservice.c
  4. 3
      connectd/tor_autoservice.h
  5. 3
      lightningd/connect_control.c
  6. 4
      lightningd/lightningd.h
  7. 7
      lightningd/options.c
  8. 1
      wallet/test/test_utils.c

1
connectd/connect_wire.csv

@ -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

Can't render this file because it has a wrong number of fields in line 6.

12
connectd/connectd.c

@ -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);

6
connectd/tor_autoservice.c

@ -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);

3
connectd/tor_autoservice.h

@ -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 */

3
lightningd/connect_control.c

@ -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);

4
lightningd/lightningd.h

@ -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 {

7
lightningd/options.c

@ -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();

1
wallet/test/test_utils.c

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

Loading…
Cancel
Save