common: remove unused parameter "allow_deprecated" from parse_wireaddr_internal.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-09-10 11:27:31 +09:30
parent a56b17c759
commit 6c33f7db65
9 changed files with 31 additions and 36 deletions

View File

@@ -214,11 +214,8 @@ int main(int argc, char *argv[])
assert(!parse_wireaddr("odpzvneidqdf5hdq.onion:49150", &addr, 1, false, NULL));
assert(!parse_wireaddr("odpzvneidqdf5hdq.onion", &addr, 1, false, NULL));
/* Neither allow_deprecated = true nor false will parse it now */
assert(!parse_wireaddr_internal("odpzvneidqdf5hdq.onion", &addr_int, 1,
false, false, false, false, NULL));
assert(!parse_wireaddr_internal("odpzvneidqdf5hdq.onion", &addr_int, 1,
false, false, false, true, NULL));
false, false, false, NULL));
assert(wireaddr_from_hostname(tmpctx, "odpzvneidqdf5hdq.onion", 1, NULL, NULL, NULL) == NULL);
assert(wireaddr_from_hostname(tmpctx, "aaa.onion", 1, NULL, NULL, NULL) == NULL);

View File

@@ -127,59 +127,59 @@ int main(int argc, char *argv[])
common_setup(argv[0]);
/* Simple IPv4 address. */
assert(parse_wireaddr_internal("127.0.0.1", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("127.0.0.1", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_WIREADDR;
assert(parse_wireaddr("127.0.0.1:9735", &expect->u.wireaddr, 0, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));
/* IPv4 address with port. */
assert(parse_wireaddr_internal("127.0.0.1:1", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("127.0.0.1:1", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_WIREADDR;
assert(parse_wireaddr("127.0.0.1:1", &expect->u.wireaddr, 0, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));
/* Simple IPv6 address. */
assert(parse_wireaddr_internal("::1", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("::1", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_WIREADDR;
assert(parse_wireaddr("::1", &expect->u.wireaddr, DEFAULT_PORT, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));
/* IPv6 address with port. */
assert(parse_wireaddr_internal("[::1]:1", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("[::1]:1", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_WIREADDR;
assert(parse_wireaddr("::1", &expect->u.wireaddr, 1, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));
/* autotor address */
assert(parse_wireaddr_internal("autotor:127.0.0.1", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("autotor:127.0.0.1", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_AUTOTOR;
expect->u.torservice.port = DEFAULT_PORT;
assert(parse_wireaddr("127.0.0.1", &expect->u.torservice.address, 9051, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));
/* autotor address with port */
assert(parse_wireaddr_internal("autotor:127.0.0.1:9055", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("autotor:127.0.0.1:9055", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_AUTOTOR;
expect->u.torservice.port = DEFAULT_PORT;
assert(parse_wireaddr("127.0.0.1", &expect->u.torservice.address, 9055, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));
/* autotor address with torport */
assert(parse_wireaddr_internal("autotor:127.0.0.1/torport=9055", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("autotor:127.0.0.1/torport=9055", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_AUTOTOR;
expect->u.torservice.port = 9055;
assert(parse_wireaddr("127.0.0.1", &expect->u.torservice.address, 9051, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));
/* autotor address with port and torport */
assert(parse_wireaddr_internal("autotor:127.0.0.1:9055/torport=10055", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("autotor:127.0.0.1:9055/torport=10055", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_AUTOTOR;
expect->u.torservice.port = 10055;
assert(parse_wireaddr("127.0.0.1", &expect->u.torservice.address, 9055, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));
/* statictor address */
assert(parse_wireaddr_internal("statictor:127.0.0.1", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("statictor:127.0.0.1", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_STATICTOR;
expect->u.torservice.port = DEFAULT_PORT;
memset(expect->u.torservice.blob, 0, sizeof(expect->u.torservice.blob));
@@ -188,28 +188,28 @@ int main(int argc, char *argv[])
assert(wireaddr_internal_eq(&addr, expect));
/* statictor address with port */
assert(parse_wireaddr_internal("statictor:127.0.0.1:9055", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("statictor:127.0.0.1:9055", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_STATICTOR;
expect->u.torservice.port = DEFAULT_PORT;
assert(parse_wireaddr("127.0.0.1", &expect->u.torservice.address, 9055, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));
/* statictor address with torport */
assert(parse_wireaddr_internal("statictor:127.0.0.1/torport=9055", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("statictor:127.0.0.1/torport=9055", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_STATICTOR;
expect->u.torservice.port = 9055;
assert(parse_wireaddr("127.0.0.1", &expect->u.torservice.address, 9051, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));
/* statictor address with port and torport */
assert(parse_wireaddr_internal("statictor:127.0.0.1:9055/torport=10055", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("statictor:127.0.0.1:9055/torport=10055", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_STATICTOR;
expect->u.torservice.port = 10055;
assert(parse_wireaddr("127.0.0.1", &expect->u.torservice.address, 9055, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));
/* statictor address with port and torport and torblob */
assert(parse_wireaddr_internal("statictor:127.0.0.1:9055/torport=10055/torblob=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("statictor:127.0.0.1:9055/torport=10055/torblob=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_STATICTOR;
expect->u.torservice.port = 10055;
/* This is actually nul terminated */
@@ -218,24 +218,24 @@ int main(int argc, char *argv[])
assert(wireaddr_internal_eq(&addr, expect));
/* local socket path */
assert(parse_wireaddr_internal("/tmp/foo.sock", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("/tmp/foo.sock", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_SOCKNAME;
strcpy(expect->u.sockname, "/tmp/foo.sock");
assert(wireaddr_internal_eq(&addr, expect));
/* Unresolved */
assert(!parse_wireaddr_internal("ozlabs.org", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(!parse_wireaddr_internal("ozlabs.org", &addr, DEFAULT_PORT, false, false, false, &err));
assert(streq(err, "Needed DNS, but lookups suppressed"));
assert(parse_wireaddr_internal("ozlabs.org", &addr, DEFAULT_PORT, false, false, true, false, &err));
assert(parse_wireaddr_internal("ozlabs.org", &addr, DEFAULT_PORT, false, false, true, &err));
expect->itype = ADDR_INTERNAL_FORPROXY;
strcpy(expect->u.unresolved.name, "ozlabs.org");
expect->u.unresolved.port = DEFAULT_PORT;
assert(wireaddr_internal_eq(&addr, expect));
/* Unresolved with port */
assert(!parse_wireaddr_internal("ozlabs.org:1234", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(!parse_wireaddr_internal("ozlabs.org:1234", &addr, DEFAULT_PORT, false, false, false, &err));
assert(streq(err, "Needed DNS, but lookups suppressed"));
assert(parse_wireaddr_internal("ozlabs.org:1234", &addr, DEFAULT_PORT, false, false, true, false, &err));
assert(parse_wireaddr_internal("ozlabs.org:1234", &addr, DEFAULT_PORT, false, false, true, &err));
expect->itype = ADDR_INTERNAL_FORPROXY;
strcpy(expect->u.unresolved.name, "ozlabs.org");
expect->u.unresolved.port = 1234;

View File

@@ -586,7 +586,7 @@ bool wireaddr_internal_eq(const struct wireaddr_internal *a,
bool parse_wireaddr_internal(const char *arg, struct wireaddr_internal *addr,
u16 port, bool wildcard_ok, bool dns_ok,
bool unresolved_ok, bool allow_deprecated,
bool unresolved_ok,
const char **err_msg)
{
u16 splitport;

View File

@@ -158,7 +158,7 @@ bool is_dnsaddr(const char *arg);
bool parse_wireaddr_internal(const char *arg, struct wireaddr_internal *addr,
u16 port, bool wildcard_ok, bool dns_ok,
bool unresolved_ok, bool allow_deprecated,
bool unresolved_ok,
const char **err_msg);
void towire_wireaddr_internal(u8 **pptr,

View File

@@ -326,7 +326,7 @@ int main(int argc, char *argv[])
(int)(at - argv[1]), argv[1]);
if (!parse_wireaddr_internal(at+1, &addr, chainparams_get_ln_port(chainparams), NULL,
true, false, true, &err_msg))
true, false, &err_msg))
opt_usage_exit_fail("%s '%s'", err_msg, argv[1]);
switch (addr.itype) {

View File

@@ -201,7 +201,7 @@ static struct command_result *json_connect(struct command *cmd,
if (!parse_wireaddr_internal(id_addr.host, addr, port, false,
!cmd->ld->always_use_proxy
&& !cmd->ld->pure_tor_setup,
true, deprecated_apis,
true,
&err_msg)) {
return command_fail(cmd, LIGHTNINGD,
"Host %s:%u not valid: %s",

View File

@@ -237,7 +237,7 @@ static char *opt_add_addr_withtype(const char *arg,
|| ala != ADDR_ANNOUNCE) {
if (!parse_wireaddr_internal(arg, &wi, ld->portnum,
wildcard_ok, dns_ok, false,
deprecated_apis, &err_msg)) {
&err_msg)) {
return tal_fmt(NULL, "Unable to parse address '%s': %s", arg, err_msg);
}
@@ -318,8 +318,7 @@ static char *opt_add_addr(const char *arg, struct lightningd *ld)
struct wireaddr_internal addr;
/* handle in case you used the addr option with an .onion */
if (parse_wireaddr_internal(arg, &addr, 0, true, false, true,
deprecated_apis, NULL)) {
if (parse_wireaddr_internal(arg, &addr, 0, true, false, true, NULL)) {
if (addr.itype == ADDR_INTERNAL_WIREADDR &&
addr.u.wireaddr.type == ADDR_TYPE_TOR_V3) {
log_unusual(ld->log, "You used `--addr=%s` option with an .onion address, please use"
@@ -365,8 +364,7 @@ static char *opt_add_bind_addr(const char *arg, struct lightningd *ld)
struct wireaddr_internal addr;
/* handle in case you used the bind option with an .onion */
if (parse_wireaddr_internal(arg, &addr, 0, true, false, true,
deprecated_apis, NULL)) {
if (parse_wireaddr_internal(arg, &addr, 0, true, false, true, NULL)) {
if (addr.itype == ADDR_INTERNAL_WIREADDR &&
addr.u.wireaddr.type == ADDR_TYPE_TOR_V3) {
log_unusual(ld->log, "You used `--bind-addr=%s` option with an .onion address,"

View File

@@ -1098,7 +1098,7 @@ static bool test_wallet_outputs(struct lightningd *ld, const tal_t *ctx)
/* Add another utxo that's CSV-locked for 5 blocks */
parse_wireaddr_internal("localhost:1234", &addr, 0, false, false, false,
true, NULL);
NULL);
channel.peer = new_peer(ld, 0, &id, &addr, false);
channel.dbid = 1;
channel.type = channel_type_anchor_outputs(tmpctx);
@@ -1395,7 +1395,7 @@ static bool test_channel_crud(struct lightningd *ld, const tal_t *ctx)
mempat(scriptpubkey, tal_count(scriptpubkey));
c1.first_blocknum = 1;
parse_wireaddr_internal("localhost:1234", &addr, 0, false, false, false,
true, NULL);
NULL);
c1.final_key_idx = 1337;
p = new_peer(ld, 0, &id, &addr, false);
c1.peer = p;
@@ -1558,7 +1558,7 @@ static bool test_channel_inflight_crud(struct lightningd *ld, const tal_t *ctx)
pubkey_from_der(tal_hexdata(w, "02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc", 66), 33, &pk);
node_id_from_pubkey(&id, &pk);
parse_wireaddr_internal("localhost:1234", &addr, 0, false, false, false,
true, NULL);
NULL);
/* new channel! */
p = new_peer(ld, 0, &id, &addr, false);

View File

@@ -839,11 +839,11 @@ static struct peer *wallet_peer_load(struct wallet *w, const u64 dbid)
/* This can happen for peers last seen on Torv2! */
addrstr = db_col_strdup(tmpctx, stmt, "address");
if (!parse_wireaddr_internal(addrstr, &addr, chainparams_get_ln_port(chainparams),
false, false, true, true, NULL)) {
false, false, true, NULL)) {
log_unusual(w->log, "Unparsable peer address %s: replacing",
addrstr);
parse_wireaddr_internal("127.0.0.1:1", &addr, chainparams_get_ln_port(chainparams),
false, false, true, true, NULL);
false, false, true, NULL);
}
/* FIXME: save incoming in db! */