mirror of
https://github.com/matrix-construct/construct
synced 2024-10-05 15:18:52 +02:00
ircd::net::dns: Improve the SRV -> A callback chain.
This commit is contained in:
parent
4e796c896a
commit
2b41672259
1 changed files with 19 additions and 15 deletions
34
ircd/net.cc
34
ircd/net.cc
|
@ -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));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue