Skip to content

Commit

Permalink
cleanup: rename use_proxy_always to always_use_proxy to match cfg
Browse files Browse the repository at this point in the history
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'
  • Loading branch information
m-schmoock committed Aug 21, 2021
1 parent 2ca7fd7 commit da0440e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 16 deletions.
10 changes: 5 additions & 5 deletions connectd/connectd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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. */
Expand Down
2 changes: 1 addition & 1 deletion doc/PLUGINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ simple JSON object containing the options:
"port": 9050
},
"torv3-enabled": true,
"use_proxy_always": false
"always_use_proxy": false
}
}
```
Expand Down
4 changes: 2 additions & 2 deletions lightningd/connect_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lightningd/lightningd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion lightningd/lightningd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 5 additions & 5 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)" : "");
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)) {
Expand Down
5 changes: 4 additions & 1 deletion lightningd/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down

0 comments on commit da0440e

Please sign in to comment.