From da0440e574804fbeca053c75d4354800a4e4c527 Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Wed, 18 Aug 2021 12:52:21 +0200 Subject: [PATCH] cleanup: rename use_proxy_always to always_use_proxy to match cfg This renames all occurences of use_proxy_always to always_use_proxy to keep it inline with config values. This was a bit confusing. Only significant change is that the payload in the plugins init requests also contained the old name. No plugin currently seems to make use of this variable yet. The old name 'use_proxy_always' is added when deprecated APIs is enabled. Changelog-Deprecated: Plugins: Renames plugin init 'use_proxy_always' to 'always_use_proxy' --- connectd/connectd.c | 10 +++++----- doc/PLUGINS.md | 2 +- lightningd/connect_control.c | 4 ++-- lightningd/lightningd.c | 2 +- lightningd/lightningd.h | 2 +- lightningd/options.c | 10 +++++----- lightningd/plugin.c | 5 ++++- 7 files changed, 19 insertions(+), 16 deletions(-) diff --git a/connectd/connectd.c b/connectd/connectd.c index 748aedab7d5e..7d45169ce62f 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -145,7 +145,7 @@ struct daemon { struct addrinfo *proxyaddr; /* They can tell us we must use proxy even for non-Tor addresses. */ - bool use_proxy_always; + bool always_use_proxy; /* There are DNS seeds we can use to look up node addresses as a last * resort, but doing so leaks our address so can be disabled. */ @@ -216,7 +216,7 @@ static bool broken_resolver(struct daemon *daemon) /* If they told us to never do DNS queries, don't even do this one and * also not if we just say that we don't */ - if (!daemon->use_dns || daemon->use_proxy_always) { + if (!daemon->use_dns || daemon->always_use_proxy) { daemon->broken_resolver_response = NULL; return false; } @@ -821,7 +821,7 @@ static struct io_plan *conn_proxy_init(struct io_conn *conn, static void try_connect_one_addr(struct connecting *connect) { int fd, af; - bool use_proxy = connect->daemon->use_proxy_always; + bool use_proxy = connect->daemon->always_use_proxy; const struct wireaddr_internal *addr = &connect->addrs[connect->addrnum]; struct io_conn *conn; @@ -1312,7 +1312,7 @@ static struct io_plan *connect_init(struct io_conn *conn, &daemon->id, &proposed_wireaddr, &proposed_listen_announce, - &proxyaddr, &daemon->use_proxy_always, + &proxyaddr, &daemon->always_use_proxy, &daemon->dev_allow_localhost, &daemon->use_dns, &tor_password, &daemon->use_v3_autotor, @@ -1528,7 +1528,7 @@ static void try_connect_peer(struct daemon *daemon, struct wireaddr_internal *addrhint) { struct wireaddr_internal *addrs; - bool use_proxy = daemon->use_proxy_always; + bool use_proxy = daemon->always_use_proxy; struct connecting *connect; /* Already done? May happen with timer. */ diff --git a/doc/PLUGINS.md b/doc/PLUGINS.md index feb715484c35..40d316b457e3 100644 --- a/doc/PLUGINS.md +++ b/doc/PLUGINS.md @@ -302,7 +302,7 @@ simple JSON object containing the options: "port": 9050 }, "torv3-enabled": true, - "use_proxy_always": false + "always_use_proxy": false } } ``` diff --git a/lightningd/connect_control.c b/lightningd/connect_control.c index 9d143c96891b..b5981da61c1d 100644 --- a/lightningd/connect_control.c +++ b/lightningd/connect_control.c @@ -165,7 +165,7 @@ static struct command_result *json_connect(struct command *cmd, } addr = tal(cmd, struct wireaddr_internal); if (!parse_wireaddr_internal(name, addr, *port, false, - !cmd->ld->use_proxy_always + !cmd->ld->always_use_proxy && !cmd->ld->pure_tor_setup, true, deprecated_apis, &err_msg)) { @@ -390,7 +390,7 @@ int connectd_init(struct lightningd *ld) &ld->id, wireaddrs, listen_announce, - ld->proxyaddr, ld->use_proxy_always || ld->pure_tor_setup, + ld->proxyaddr, ld->always_use_proxy || ld->pure_tor_setup, IFDEV(ld->dev_allow_localhost, false), ld->config.use_dns, ld->tor_service_password ? ld->tor_service_password : "", ld->config.use_v3_autotor, diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index d68598d8ced5..38ce1f574b02 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -225,7 +225,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx) ld->topology = new_topology(ld, ld->log); ld->daemon_parent_fd = -1; ld->proxyaddr = NULL; - ld->use_proxy_always = false; + ld->always_use_proxy = false; ld->pure_tor_setup = false; ld->tor_service_password = NULL; diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 10aa39a41803..32927957643f 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -251,7 +251,7 @@ struct lightningd { /* tor support */ struct wireaddr *proxyaddr; - bool use_proxy_always; + bool always_use_proxy; char *tor_service_password; bool pure_tor_setup; diff --git a/lightningd/options.c b/lightningd/options.c index ac43ece55066..aff8b090b414 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -213,7 +213,7 @@ static char *opt_add_addr_withtype(const char *arg, tal_arr_expand(&ld->proposed_listen_announce, ala); if (!parse_wireaddr_internal(arg, &wi, ld->portnum, - wildcard_ok, !ld->use_proxy_always, false, + wildcard_ok, !ld->always_use_proxy, false, deprecated_apis, &err_msg)) { return tal_fmt(NULL, "Unable to parse address '%s': %s", arg, err_msg); } @@ -406,7 +406,7 @@ static char *opt_add_proxy_addr(const char *arg, struct lightningd *ld) ld->proxyaddr = tal_arr(ld, struct wireaddr, 1); if (!parse_wireaddr(arg, ld->proxyaddr, 9050, - ld->use_proxy_always ? &needed_dns : NULL, + ld->always_use_proxy ? &needed_dns : NULL, NULL)) { return tal_fmt(NULL, "Unable to parse Tor proxy address '%s' %s", arg, needed_dns ? " (needed dns)" : ""); @@ -787,7 +787,7 @@ static void check_config(struct lightningd *ld) if (ld->config.anchor_confirms == 0) fatal("anchor-confirms must be greater than zero"); - if (ld->use_proxy_always && !ld->proxyaddr) + if (ld->always_use_proxy && !ld->proxyaddr) fatal("--always-use-proxy needs --proxy"); if (ld->daemon_parent_fd != -1 && !ld->logfile) @@ -922,7 +922,7 @@ static void register_opts(struct lightningd *ld) /* Early, as it suppresses DNS lookups from cmdline too. */ opt_register_early_arg("--always-use-proxy", opt_set_bool_arg, opt_show_bool, - &ld->use_proxy_always, "Use the proxy always"); + &ld->always_use_proxy, "Use the proxy always"); /* This immediately makes is a daemon. */ opt_register_early_noarg("--daemon", opt_start_daemon, ld, @@ -1267,7 +1267,7 @@ void handle_opts(struct lightningd *ld, int argc, char *argv[]) if (argc != 1) errx(1, "no arguments accepted"); - /* We keep a separate variable rather than overriding use_proxy_always, + /* We keep a separate variable rather than overriding always_use_proxy, * so listconfigs shows the correct thing. */ if (tal_count(ld->proposed_wireaddr) != 0 && all_tor_addresses(ld->proposed_wireaddr)) { diff --git a/lightningd/plugin.c b/lightningd/plugin.c index e7ea47e9ed5a..fa1dfcf5e727 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -1821,7 +1821,10 @@ plugin_populate_init_request(struct plugin *plugin, struct jsonrpc_request *req) if (ld->proxyaddr) { json_add_address(req->stream, "proxy", ld->proxyaddr); json_add_bool(req->stream, "torv3-enabled", ld->config.use_v3_autotor); - json_add_bool(req->stream, "use_proxy_always", ld->use_proxy_always); + json_add_bool(req->stream, "always_use_proxy", ld->always_use_proxy); + if (deprecated_apis) + json_add_bool(req->stream, "use_proxy_always", + ld->always_use_proxy); } json_object_start(req->stream, "feature_set"); for (enum feature_place fp = 0; fp < NUM_FEATURE_PLACE; fp++) {