0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-07-07 11:08:34 +02:00

ircd::net::dns: Improve the SRV -> A callback chain.

This commit is contained in:
Jason Volk 2018-04-28 16:46:42 -07:00
parent 4e796c896a
commit 2b41672259

View file

@ -2402,34 +2402,38 @@ ircd::net::dns::operator()(const hostport &hp,
callback(std::move(eptr), ipport); callback(std::move(eptr), ipport);
}}; }};
if(!hostport.service) if(!hp.service)
return operator()(hostport, opts, [hostport, calluser(std::move(calluser))] return operator()(hp, opts, [hp, calluser(std::move(calluser))]
(std::exception_ptr eptr, const rfc1035::record::A &record) (std::exception_ptr eptr, const rfc1035::record::A &record)
{ {
calluser(std::move(eptr), record.ip4, port(hostport)); calluser(std::move(eptr), record.ip4, port(hp));
}); });
operator()(hostport, opts, [this, hostport(hostport), opts(opts), calluser(std::move(calluser))] auto srv_opts{opts};
srv_opts.nxdomain_exceptions = false;
operator()(hp, srv_opts, [this, hp(hp), opts(opts), calluser(std::move(calluser))]
(std::exception_ptr eptr, const rfc1035::record::SRV &record) (std::exception_ptr eptr, const rfc1035::record::SRV &record)
mutable mutable
{ {
//TODO: we get NXDOMAIN and it kills the chain.. if(eptr)
//if(eptr) return calluser(std::move(eptr), 0, 0);
// return callback(std::move(eptr), {});
if(!record.tgt.empty())
host(hostport) = record.tgt;
if(record.port != 0) if(record.port != 0)
port(hostport) = record.port; port(hp) = record.port;
// Have to kill the service name to not run another SRV query now. // The host reference in hp has become invalid by the time of this cb.
hostport.service = {}; assert(!record.tgt.empty());
host(hp) = record.tgt;
// Have to kill the service name to not run another SRV query now, and
// these are also invalid references too.
hp.service = {};
opts.srv = {}; opts.srv = {};
this->operator()(hostport, opts, [hostport, calluser(std::move(calluser))]
this->operator()(hp, opts, [hp, calluser(std::move(calluser))]
(std::exception_ptr eptr, const rfc1035::record::A &record) (std::exception_ptr eptr, const rfc1035::record::A &record)
{ {
calluser(std::move(eptr), record.ip4, port(hostport)); calluser(std::move(eptr), record.ip4, port(hp));
}); });
}); });
} }