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'
This commit is contained in:
Michael Schmoock 2021-08-18 12:52:21 +02:00 committed by Rusty Russell
parent 0550ffa9db
commit 24ea498350
7 changed files with 19 additions and 16 deletions

View File

@ -145,7 +145,7 @@ struct daemon {
struct addrinfo *proxyaddr; struct addrinfo *proxyaddr;
/* They can tell us we must use proxy even for non-Tor addresses. */ /* 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 /* 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. */ * 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 /* 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 */ * 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; daemon->broken_resolver_response = NULL;
return false; 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) static void try_connect_one_addr(struct connecting *connect)
{ {
int fd, af; 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]; const struct wireaddr_internal *addr = &connect->addrs[connect->addrnum];
struct io_conn *conn; struct io_conn *conn;
@ -1312,7 +1312,7 @@ static struct io_plan *connect_init(struct io_conn *conn,
&daemon->id, &daemon->id,
&proposed_wireaddr, &proposed_wireaddr,
&proposed_listen_announce, &proposed_listen_announce,
&proxyaddr, &daemon->use_proxy_always, &proxyaddr, &daemon->always_use_proxy,
&daemon->dev_allow_localhost, &daemon->use_dns, &daemon->dev_allow_localhost, &daemon->use_dns,
&tor_password, &tor_password,
&daemon->use_v3_autotor, &daemon->use_v3_autotor,
@ -1528,7 +1528,7 @@ static void try_connect_peer(struct daemon *daemon,
struct wireaddr_internal *addrhint) struct wireaddr_internal *addrhint)
{ {
struct wireaddr_internal *addrs; struct wireaddr_internal *addrs;
bool use_proxy = daemon->use_proxy_always; bool use_proxy = daemon->always_use_proxy;
struct connecting *connect; struct connecting *connect;
/* Already done? May happen with timer. */ /* Already done? May happen with timer. */

View File

@ -302,7 +302,7 @@ simple JSON object containing the options:
"port": 9050 "port": 9050
}, },
"torv3-enabled": true, "torv3-enabled": true,
"use_proxy_always": false "always_use_proxy": false
} }
} }
``` ```

View File

@ -165,7 +165,7 @@ static struct command_result *json_connect(struct command *cmd,
} }
addr = tal(cmd, struct wireaddr_internal); addr = tal(cmd, struct wireaddr_internal);
if (!parse_wireaddr_internal(name, addr, *port, false, if (!parse_wireaddr_internal(name, addr, *port, false,
!cmd->ld->use_proxy_always !cmd->ld->always_use_proxy
&& !cmd->ld->pure_tor_setup, && !cmd->ld->pure_tor_setup,
true, deprecated_apis, true, deprecated_apis,
&err_msg)) { &err_msg)) {
@ -390,7 +390,7 @@ int connectd_init(struct lightningd *ld)
&ld->id, &ld->id,
wireaddrs, wireaddrs,
listen_announce, 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, 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, ld->config.use_v3_autotor,

View File

@ -225,7 +225,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
ld->topology = new_topology(ld, ld->log); ld->topology = new_topology(ld, ld->log);
ld->daemon_parent_fd = -1; ld->daemon_parent_fd = -1;
ld->proxyaddr = NULL; ld->proxyaddr = NULL;
ld->use_proxy_always = false; ld->always_use_proxy = false;
ld->pure_tor_setup = false; ld->pure_tor_setup = false;
ld->tor_service_password = NULL; ld->tor_service_password = NULL;

View File

@ -251,7 +251,7 @@ struct lightningd {
/* tor support */ /* tor support */
struct wireaddr *proxyaddr; struct wireaddr *proxyaddr;
bool use_proxy_always; bool always_use_proxy;
char *tor_service_password; char *tor_service_password;
bool pure_tor_setup; bool pure_tor_setup;

View File

@ -213,7 +213,7 @@ static char *opt_add_addr_withtype(const char *arg,
tal_arr_expand(&ld->proposed_listen_announce, ala); tal_arr_expand(&ld->proposed_listen_announce, ala);
if (!parse_wireaddr_internal(arg, &wi, if (!parse_wireaddr_internal(arg, &wi,
ld->portnum, ld->portnum,
wildcard_ok, !ld->use_proxy_always, false, wildcard_ok, !ld->always_use_proxy, false,
deprecated_apis, &err_msg)) { deprecated_apis, &err_msg)) {
return tal_fmt(NULL, "Unable to parse address '%s': %s", arg, 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); ld->proxyaddr = tal_arr(ld, struct wireaddr, 1);
if (!parse_wireaddr(arg, ld->proxyaddr, 9050, if (!parse_wireaddr(arg, ld->proxyaddr, 9050,
ld->use_proxy_always ? &needed_dns : NULL, ld->always_use_proxy ? &needed_dns : NULL,
NULL)) { NULL)) {
return tal_fmt(NULL, "Unable to parse Tor proxy address '%s' %s", return tal_fmt(NULL, "Unable to parse Tor proxy address '%s' %s",
arg, needed_dns ? " (needed dns)" : ""); arg, needed_dns ? " (needed dns)" : "");
@ -787,7 +787,7 @@ static void check_config(struct lightningd *ld)
if (ld->config.anchor_confirms == 0) if (ld->config.anchor_confirms == 0)
fatal("anchor-confirms must be greater than zero"); 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"); fatal("--always-use-proxy needs --proxy");
if (ld->daemon_parent_fd != -1 && !ld->logfile) 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. */ /* Early, as it suppresses DNS lookups from cmdline too. */
opt_register_early_arg("--always-use-proxy", opt_register_early_arg("--always-use-proxy",
opt_set_bool_arg, opt_show_bool, 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. */ /* This immediately makes is a daemon. */
opt_register_early_noarg("--daemon", opt_start_daemon, ld, 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) if (argc != 1)
errx(1, "no arguments accepted"); 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. */ * so listconfigs shows the correct thing. */
if (tal_count(ld->proposed_wireaddr) != 0 if (tal_count(ld->proposed_wireaddr) != 0
&& all_tor_addresses(ld->proposed_wireaddr)) { && all_tor_addresses(ld->proposed_wireaddr)) {

View File

@ -1821,7 +1821,10 @@ plugin_populate_init_request(struct plugin *plugin, struct jsonrpc_request *req)
if (ld->proxyaddr) { if (ld->proxyaddr) {
json_add_address(req->stream, "proxy", 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, "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"); json_object_start(req->stream, "feature_set");
for (enum feature_place fp = 0; fp < NUM_FEATURE_PLACE; fp++) { for (enum feature_place fp = 0; fp < NUM_FEATURE_PLACE; fp++) {