mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 17:47:30 +01:00
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:
parent
e638224092
commit
0f9ba53581
8 changed files with 28 additions and 9 deletions
|
@ -13,6 +13,7 @@ msgdata,connectctl_init,use_tor_proxy_always,bool,
|
||||||
msgdata,connectctl_init,dev_allow_localhost,bool,
|
msgdata,connectctl_init,dev_allow_localhost,bool,
|
||||||
msgdata,connectctl_init,use_dns,bool,
|
msgdata,connectctl_init,use_dns,bool,
|
||||||
msgdata,connectctl_init,tor_password,wirestring,
|
msgdata,connectctl_init,tor_password,wirestring,
|
||||||
|
msgdata,connectctl_init,use_v3_autotor,bool,
|
||||||
|
|
||||||
# Connectd->master, here are the addresses I bound, can announce.
|
# Connectd->master, here are the addresses I bound, can announce.
|
||||||
msgtype,connectctl_init_reply,2100
|
msgtype,connectctl_init_reply,2100
|
||||||
|
|
|
|
@ -148,6 +148,9 @@ struct daemon {
|
||||||
|
|
||||||
/* File descriptors to listen on once we're activated. */
|
/* File descriptors to listen on once we're activated. */
|
||||||
struct listen_fd *listen_fds;
|
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
|
/* 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,
|
tor_autoservice(tmpctx,
|
||||||
&proposed_wireaddr[i].u.torservice,
|
&proposed_wireaddr[i].u.torservice,
|
||||||
tor_password,
|
tor_password,
|
||||||
binding);
|
binding,
|
||||||
|
daemon->use_v3_autotor);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
add_announcable(announcable,
|
add_announcable(announcable,
|
||||||
tor_autoservice(tmpctx,
|
tor_autoservice(tmpctx,
|
||||||
&proposed_wireaddr[i].u.torservice,
|
&proposed_wireaddr[i].u.torservice,
|
||||||
tor_password,
|
tor_password,
|
||||||
binding));
|
binding,
|
||||||
|
daemon->use_v3_autotor));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sort and uniquify. */
|
/* Sort and uniquify. */
|
||||||
|
@ -1153,7 +1158,8 @@ static struct io_plan *connect_init(struct io_conn *conn,
|
||||||
&proposed_listen_announce,
|
&proposed_listen_announce,
|
||||||
&proxyaddr, &daemon->use_proxy_always,
|
&proxyaddr, &daemon->use_proxy_always,
|
||||||
&daemon->dev_allow_localhost, &daemon->use_dns,
|
&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
|
/* This is a helper which prints the type expected and the actual
|
||||||
* message, then exits (it should never be called!). */
|
* message, then exits (it should never be called!). */
|
||||||
master_badmsg(WIRE_CONNECTCTL_INIT, msg);
|
master_badmsg(WIRE_CONNECTCTL_INIT, msg);
|
||||||
|
|
|
@ -228,7 +228,8 @@ find_local_address(const struct wireaddr_internal *bindings)
|
||||||
struct wireaddr *tor_autoservice(const tal_t *ctx,
|
struct wireaddr *tor_autoservice(const tal_t *ctx,
|
||||||
const struct wireaddr *tor_serviceaddr,
|
const struct wireaddr *tor_serviceaddr,
|
||||||
const char *tor_password,
|
const char *tor_password,
|
||||||
const struct wireaddr_internal *bindings)
|
const struct wireaddr_internal *bindings,
|
||||||
|
const bool use_v3_autotor)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
const struct wireaddr *laddr;
|
const struct wireaddr *laddr;
|
||||||
|
@ -236,7 +237,6 @@ 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);
|
||||||
|
@ -251,8 +251,6 @@ 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, use_v3_autotor);
|
onion = make_onion(ctx, &rbuf, laddr, use_v3_autotor);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
struct wireaddr *tor_autoservice(const tal_t *ctx,
|
struct wireaddr *tor_autoservice(const tal_t *ctx,
|
||||||
const struct wireaddr *tor_serviceaddr,
|
const struct wireaddr *tor_serviceaddr,
|
||||||
const char *tor_password,
|
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 */
|
#endif /* LIGHTNING_CONNECTD_TOR_AUTOSERVICE_H */
|
||||||
|
|
|
@ -366,7 +366,8 @@ int connectd_init(struct lightningd *ld)
|
||||||
listen_announce,
|
listen_announce,
|
||||||
ld->proxyaddr, ld->use_proxy_always || ld->pure_tor_setup,
|
ld->proxyaddr, ld->use_proxy_always || ld->pure_tor_setup,
|
||||||
IFDEV(ld->dev_allow_localhost, false), ld->config.use_dns,
|
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,
|
subd_req(ld->connectd, ld->connectd, take(msg), -1, 0,
|
||||||
connect_init_done, NULL);
|
connect_init_done, NULL);
|
||||||
|
|
|
@ -67,6 +67,10 @@ struct config {
|
||||||
|
|
||||||
/* Minimal amount of effective funding_satoshis for accepting channels */
|
/* Minimal amount of effective funding_satoshis for accepting channels */
|
||||||
u64 min_capacity_sat;
|
u64 min_capacity_sat;
|
||||||
|
|
||||||
|
/* Allow to define the default behavior of tot services calls*/
|
||||||
|
bool use_v3_autotor;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lightningd {
|
struct lightningd {
|
||||||
|
|
|
@ -485,6 +485,8 @@ static const struct config testnet_config = {
|
||||||
|
|
||||||
/* Sets min_effective_htlc_capacity - at 1000$/BTC this is 10ct */
|
/* Sets min_effective_htlc_capacity - at 1000$/BTC this is 10ct */
|
||||||
.min_capacity_sat = 10000,
|
.min_capacity_sat = 10000,
|
||||||
|
|
||||||
|
.use_v3_autotor = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* aka. "Dude, where's my coins?" */
|
/* 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 */
|
/* Sets min_effective_htlc_capacity - at 1000$/BTC this is 10ct */
|
||||||
.min_capacity_sat = 10000,
|
.min_capacity_sat = 10000,
|
||||||
|
|
||||||
|
.use_v3_autotor = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void check_config(struct lightningd *ld)
|
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,
|
opt_register_noarg("--disable-dns", opt_set_invbool, &ld->config.use_dns,
|
||||||
"Disable DNS lookups of peers");
|
"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_logging(ld);
|
||||||
opt_register_version();
|
opt_register_version();
|
||||||
|
|
||||||
|
|
|
@ -23,4 +23,5 @@ const struct config test_config = {
|
||||||
.max_fee_multiplier = 10,
|
.max_fee_multiplier = 10,
|
||||||
.use_dns = true,
|
.use_dns = true,
|
||||||
.min_capacity_sat = 10000,
|
.min_capacity_sat = 10000,
|
||||||
|
.use_v3_autotor = true,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue