mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
dns: expose multiaddress connect code.
Internally the dns code has the ability to try connecting to multiple addresses in a sequence. Expose this, as we'll want it for reconnection. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
f4722e93a0
commit
58bf67c310
23
daemon/dns.c
23
daemon/dns.c
@ -154,6 +154,29 @@ static struct io_plan *start_connecting(struct io_conn *conn,
|
||||
return io_close(conn);
|
||||
}
|
||||
|
||||
struct dns_async *multiaddress_connect_(struct lightningd_state *dstate,
|
||||
const struct netaddr *addresses,
|
||||
struct io_plan *(*init)(struct io_conn *,
|
||||
struct lightningd_state *,
|
||||
const struct netaddr *,
|
||||
void *arg),
|
||||
void (*fail)(struct lightningd_state *, void *arg),
|
||||
void *arg)
|
||||
{
|
||||
struct dns_async *d = tal(dstate, struct dns_async);
|
||||
|
||||
d->dstate = dstate;
|
||||
d->init = init;
|
||||
d->fail = fail;
|
||||
d->arg = arg;
|
||||
d->name = "names from address list";
|
||||
d->num_addresses = tal_count(addresses);
|
||||
d->addresses = tal_dup_arr(d, struct netaddr, addresses,
|
||||
d->num_addresses, 0);
|
||||
try_connect_one(d);
|
||||
return d;
|
||||
}
|
||||
|
||||
static struct io_plan *read_addresses(struct io_conn *conn, struct dns_async *d)
|
||||
{
|
||||
d->addresses = tal_arr(d, struct netaddr, d->num_addresses);
|
||||
|
21
daemon/dns.h
21
daemon/dns.h
@ -29,4 +29,25 @@ struct dns_async *dns_resolve_and_connect_(struct lightningd_state *dstate,
|
||||
void (*fail)(struct lightningd_state *, void *arg),
|
||||
void *arg);
|
||||
|
||||
/* Don't do lookup, just try to connect to these addresses. */
|
||||
#define multiaddress_connect(dstate, addresses, initfn, failfn, arg) \
|
||||
multiaddress_connect_((dstate), (addresses), \
|
||||
typesafe_cb_preargs(struct io_plan *, void *, \
|
||||
(initfn), (arg), \
|
||||
struct io_conn *, \
|
||||
struct lightningd_state *, \
|
||||
const struct netaddr *), \
|
||||
typesafe_cb_preargs(void, void *, (failfn), (arg), \
|
||||
struct lightningd_state *), \
|
||||
(arg))
|
||||
|
||||
struct dns_async *multiaddress_connect_(struct lightningd_state *dstate,
|
||||
const struct netaddr *addresses,
|
||||
struct io_plan *(*init)(struct io_conn *,
|
||||
struct lightningd_state *,
|
||||
const struct netaddr *,
|
||||
void *arg),
|
||||
void (*fail)(struct lightningd_state *, void *arg),
|
||||
void *arg);
|
||||
|
||||
#endif /* PETTYCOIN_DNS_H */
|
||||
|
Loading…
Reference in New Issue
Block a user